From 39e021feba384189c27c048ff8221c239e98498d Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Mon, 14 Oct 2024 11:56:59 +0200 Subject: [PATCH] NEW Share msg "not found" for widgets and add a button to add new record when none exists (#31309) * New msg displayed on widghet * update msg * comment code on box_fediverse * comment code on box_fediverse and delete code langs * fix errors * remove underscore before comparing files * update boxes for get messages and buttons * continue adding button for widgets --------- Co-authored-by: Laurent Destailleur --- htdocs/core/boxes/box_actions.php | 15 +++-- htdocs/core/boxes/box_boms.php | 14 +++-- htdocs/core/boxes/box_bookmarks.php | 24 ++++---- htdocs/core/boxes/box_clients.php | 9 +-- htdocs/core/boxes/box_commandes.php | 10 ++-- htdocs/core/boxes/box_comptes.php | 8 +-- htdocs/core/boxes/box_contacts.php | 17 +++--- htdocs/core/boxes/box_contracts.php | 14 +++-- htdocs/core/boxes/box_external_rss.php | 1 + htdocs/core/boxes/box_factures.php | 14 +++-- htdocs/core/boxes/box_factures_fourn.php | 14 +++-- htdocs/core/boxes/box_factures_imp.php | 10 ++-- htdocs/core/boxes/box_fediverse.php | 14 +++-- htdocs/core/boxes/box_ficheinter.php | 14 +++-- htdocs/core/boxes/box_fournisseurs.php | 16 +++--- .../boxes/box_members_last_subscriptions.php | 9 +-- htdocs/core/boxes/box_mos.php | 9 +-- htdocs/core/boxes/box_produits.php | 14 +++-- .../core/boxes/box_produits_alerte_stock.php | 14 +++-- htdocs/core/boxes/box_project.php | 57 ++++++++++--------- .../core/boxes/box_project_opportunities.php | 57 ++++++++++--------- htdocs/core/boxes/box_propales.php | 9 +-- htdocs/core/boxes/box_prospect.php | 10 +--- htdocs/core/boxes/box_scheduled_jobs.php | 42 +++++++------- htdocs/core/boxes/box_services_contracts.php | 9 +-- htdocs/core/boxes/box_services_expired.php | 10 +--- htdocs/core/boxes/box_shipments.php | 15 +++-- htdocs/core/boxes/box_supplier_orders.php | 10 +--- htdocs/core/boxes/modules_boxes.php | 19 +++++++ htdocs/langs/en_US/boxes.lang | 3 + htdocs/langs/fr_FR/boxes.lang | 2 + 31 files changed, 258 insertions(+), 225 deletions(-) diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index dff2d54a91c..4d9954669eb 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -55,6 +55,9 @@ class box_actions extends ModeleBoxes $this->enabled = isModEnabled('agenda'); $this->hidden = !($user->hasRight('agenda', 'myactions', 'read')); + + $this->urltoaddentry = DOL_URL_ROOT.'/comm/action/card.php?action=create'; + $this->msgNoRecords = 'NoActionsToDo'; } /** @@ -173,12 +176,12 @@ class box_actions extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoActionsToDo").'' - ); - } + // if ($num == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoActionsToDo").'' + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index e5c8a0ca6e6..99ca90917e2 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -51,6 +51,8 @@ class box_boms extends ModeleBoxes $this->db = $db; $this->hidden = !$user->hasRight('bom', 'read'); + $this->urltoaddentry = DOL_URL_ROOT.'/bom/bom_card.php?action=create'; + $this->msgNoRecords = 'NoRecordedOrders'; } /** @@ -149,12 +151,12 @@ class box_boms extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedOrders").'' - ); - } + // if ($num == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoRecordedOrders").'' + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 9c025931400..ddaf6749dfd 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -47,6 +47,8 @@ class box_bookmarks extends ModeleBoxes $this->db = $db; $this->hidden = !$user->hasRight('bookmark', 'lire'); + $this->urltoaddentry = DOL_URL_ROOT.'/bookmarks/card.php?action=create'; + $this->msgNoRecords = 'NoRecordedBookmarks'; } /** @@ -109,17 +111,17 @@ class box_bookmarks extends ModeleBoxes $line++; } - if ($num == 0) { - $mytxt = $langs->trans("NoRecordedBookmarks"); - if ($user->hasRight("bookmark", "creer")) { - $mytxt .= ' '.$langs->trans("ClickToAdd"); - } - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center" colspan="2"', - 'tooltip' => $mytxt, - 'url' => DOL_URL_ROOT.'/bookmarks/list.php', 'text' => $mytxt, - ); - } + // if ($num == 0) { + // $mytxt = $langs->trans("NoRecordedBookmarks"); + // if ($user->hasRight("bookmark", "creer")) { + // $mytxt .= ' '.$langs->trans("ClickToAdd"); + // } + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center" colspan="2"', + // 'tooltip' => $mytxt, + // 'url' => DOL_URL_ROOT.'/bookmarks/list.php', 'text' => $mytxt, + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 0b18e3ca48f..8d30c4f3505 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -58,6 +58,9 @@ class box_clients extends ModeleBoxes } $this->hidden = !($user->hasRight('societe', 'read') && empty($user->socid)); + + $this->urltoaddentry = DOL_URL_ROOT.'/societe/card.php?action=create&type=c'; + $this->msgNoRecords = 'NoRecordedCustomers'; } /** @@ -147,12 +150,6 @@ class box_clients extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedCustomers").'' - ); - } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index de80645db7d..288492c9601 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -51,6 +51,10 @@ class box_commandes extends ModeleBoxes $this->db = $db; $this->hidden = !$user->hasRight('commande', 'lire'); + + $this->urltoaddentry = DOL_URL_ROOT.'/commande/card.php?action=create'; + + $this->msgNoRecords = 'NoRecordedOrders'; } /** @@ -186,12 +190,6 @@ class box_commandes extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedOrders").'' - ); - } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index dc0a9e29354..f67bf006148 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -60,6 +60,8 @@ class box_comptes extends ModeleBoxes } $this->hidden = !$user->hasRight('banque', 'lire'); + $this->urltoaddentry = DOL_URL_ROOT.'/compta/bank/card.php?action=create'; + $this->msgNoRecords = 'NoRecordedBankAccounts'; } /** @@ -164,12 +166,6 @@ class box_comptes extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedBankAccounts").'' - ); - } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 06a5db32149..5b95234e478 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -54,6 +54,9 @@ class box_contacts extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('societe', 'lire') && $user->hasRight('societe', 'contact', 'lire')); + + $this->urltoaddentry = DOL_URL_ROOT.'/contact/card.php?action=create'; + $this->msgNoRecords = 'NoRecordedContacts'; } /** @@ -183,13 +186,13 @@ class box_contacts extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedContacts").'', - 'asis' => 1 - ); - } + // if ($num == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoRecordedContacts").'', + // 'asis' => 1 + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index d3c66fce04b..e7700692e3e 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -50,6 +50,8 @@ class box_contracts extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('contrat', 'lire')); + $this->urltoaddentry = DOL_URL_ROOT.'/contrat/card.php?action=create'; + $this->msgNoRecords = 'NoRecordedContracts'; } /** @@ -162,12 +164,12 @@ class box_contracts extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedContracts").'' - ); - } + // if ($num == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoRecordedContracts").'' + // ); + // } $this->db->free($resql); } else { diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 73f69b2d723..07829e463c4 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -52,6 +52,7 @@ class box_external_rss extends ModeleBoxes { $this->db = $db; $this->paramdef = $param; + $this->urltoaddentry = DOL_URL_ROOT.'/admin/external_rss.php'; } /** diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 408fcb1fa49..ee333e1eec5 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -49,6 +49,8 @@ class box_factures extends ModeleBoxes $this->db = $db; $this->hidden = !$user->hasRight('facture', 'lire'); + $this->urltoaddentry = DOL_URL_ROOT.'/compta/facture/card.php?action=create'; + $this->msgNoRecords = 'NoRecordedInvoices'; } /** @@ -197,12 +199,12 @@ class box_factures extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedInvoices").'', - ); - } + // if ($num == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoRecordedInvoices").'', + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index dceb3d6843c..511a041a035 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -50,6 +50,8 @@ class box_factures_fourn extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('fournisseur', 'facture', 'lire')); + $this->urltoaddentry = DOL_URL_ROOT.'/fourn/facture/card.php?action=create'; + $this->msgNoRecords = 'NoModifiedSupplierBills'; } /** @@ -193,12 +195,12 @@ class box_factures_fourn extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoModifiedSupplierBills").'', - ); - } + // if ($num == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoModifiedSupplierBills").'', + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index d6a24e31576..cf4d4967a16 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -53,6 +53,8 @@ class box_factures_imp extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('facture', 'lire')); + $this->urltoaddentry = DOL_URL_ROOT.'/compta/facture/card.php?action=create'; + $this->msgNoRecords = 'NoUnpaidCustomerBills'; } /** @@ -220,10 +222,10 @@ class box_factures_imp extends ModeleBoxes } if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center" colspan="3"', - 'text' => ''.$langs->trans("NoUnpaidCustomerBills").'' - ); + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center" colspan="3"', + // 'text' => ''.$langs->trans("NoUnpaidCustomerBills").'' + // ); } else { $sql = "SELECT SUM(f.total_ht) as total_ht ".$sql2; diff --git a/htdocs/core/boxes/box_fediverse.php b/htdocs/core/boxes/box_fediverse.php index 7ce725e741a..b4cd84fc642 100644 --- a/htdocs/core/boxes/box_fediverse.php +++ b/htdocs/core/boxes/box_fediverse.php @@ -50,6 +50,8 @@ class box_fediverse extends ModeleBoxes { $this->db = $db; $this->paramdef = $param; + $this->urltoaddentry = DOL_URL_ROOT.'/admin/fediverse.php'; + $this->msgNoRecords = 'NoRecordFound'; } /** @@ -150,12 +152,12 @@ class box_fediverse extends ModeleBoxes } - if ($nbitems == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordFound").'' - ); - } + // if ($nbitems == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoRecordFound").'' + // ); + // } } diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index dfa059d4bf6..ff12319eebe 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -50,6 +50,8 @@ class box_ficheinter extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('ficheinter', 'lire')); + $this->urltoaddentry = DOL_URL_ROOT.'/fichinter/card.php?action=create'; + $this->msgNoRecords = 'NoRecordedInterventions'; } /** @@ -151,12 +153,12 @@ class box_ficheinter extends ModeleBoxes $i++; } - if ($num == 0) { - $this->info_box_contents[$i][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedInterventions").'' - ); - } + // if ($num == 0) { + // $this->info_box_contents[$i][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoRecordedInterventions").'' + // ); + // } $this->db->free($resql); } else { diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 4917492036b..6cd7b8c3bab 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -51,6 +51,8 @@ class box_fournisseurs extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('societe', 'read') && empty($user->socid)); + $this->urltoaddentry = DOL_URL_ROOT.'/societe/card.php?action=create&type=f'; + $this->msgNoRecords = 'NoRecordedSuppliers'; } /** @@ -138,13 +140,13 @@ class box_fournisseurs extends ModeleBoxes $line++; } - if ($num == 0) { - $langs->load("suppliers"); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedSuppliers").'' - ); - } + // if ($num == 0) { + // $langs->load("suppliers"); + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoRecordedSuppliers").'' + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index 03c77b0500e..f6323dd7af9 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -59,6 +59,9 @@ class box_members_last_subscriptions extends ModeleBoxes } $this->hidden = !(isModEnabled('member') && $user->hasRight('adherent', 'lire')); + + $this->urltoaddentry = DOL_URL_ROOT.'/adherents/card.php?leftmenu=members&action=create'; + $this->msgNoRecords = 'NoRecordedMembers'; } /** @@ -156,12 +159,6 @@ class box_members_last_subscriptions extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedMembers").'', - ); - } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index 214c38ced17..be80c7d4536 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -51,6 +51,9 @@ class box_mos extends ModeleBoxes $this->db = $db; $this->hidden = !$user->hasRight('bom', 'read'); + + $this->urltoaddentry = DOL_URL_ROOT.'/mrp/mo_card.php?action=create'; + $this->msgNoRecords = 'NoRecordedOrders'; } /** @@ -146,12 +149,6 @@ class box_mos extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedOrders").'' - ); - } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 52a27b151cb..db7710e960b 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -55,6 +55,8 @@ class box_produits extends ModeleBoxes $tmpentry = array('enabled' => (isModEnabled("product") || isModEnabled("service")), 'perms' => ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire')), 'module' => 'product|service'); $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); + $this->urltoaddentry = DOL_URL_ROOT.'/product/card.php?action=create'; + $this->msgNoRecords = 'NoRecordedProducts'; } /** @@ -210,12 +212,12 @@ class box_produits extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoRecordedProducts"), - ); - } + // if ($num == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => $langs->trans("NoRecordedProducts"), + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index da714ede7ab..f2a18d04ccc 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -57,6 +57,8 @@ class box_produits_alerte_stock extends ModeleBoxes $tmpentry = array('enabled' => ((isModEnabled("product") || isModEnabled("service")) && isModEnabled('stock')), 'perms' => $user->hasRight('stock', 'lire'), 'module' => 'product|service|stock'); $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); + $this->urltoaddentry = DOL_URL_ROOT.'/product/card.php?action=create'; + $this->msgNoRecords = 'NoTooLowStockProducts'; } /** @@ -202,12 +204,12 @@ class box_produits_alerte_stock extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoTooLowStockProducts"), - ); - } + // if ($num == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => $langs->trans("NoTooLowStockProducts"), + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index e713b654997..e58fa7047dc 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -54,6 +54,8 @@ class box_project extends ModeleBoxes $this->boxlabel = "OpenedProjects"; $this->hidden = !$user->hasRight('projet', 'lire'); + $this->urltoaddentry = DOL_URL_ROOT.'/projet/card.php?action=create'; + $this->msgNoRecords = 'NoOpenedProjects'; } /** @@ -175,33 +177,34 @@ class box_project extends ModeleBoxes } } - - // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][] = array( - 'tr' => 'class="liste_total_wrap"', - 'td' => 'class="liste_total"', - 'text' => $langs->trans("Total")." ".$textHead, - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => round($num, 0)." ".$langs->trans("Projects"), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); + if ($num > 0) { + // Add the sum à the bottom of the boxes + $this->info_box_contents[$i][] = array( + 'tr' => 'class="liste_total_wrap"', + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total")." ".$textHead, + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => round($num, 0)." ".$langs->trans("Projects"), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + } } diff --git a/htdocs/core/boxes/box_project_opportunities.php b/htdocs/core/boxes/box_project_opportunities.php index 43e35640e7e..9781657ccdd 100644 --- a/htdocs/core/boxes/box_project_opportunities.php +++ b/htdocs/core/boxes/box_project_opportunities.php @@ -55,6 +55,8 @@ class box_project_opportunities extends ModeleBoxes $this->enabled = getDolGlobalInt('PROJECT_USE_OPPORTUNITIES'); $this->hidden = !$user->hasRight('projet', 'lire'); + $this->urltoaddentry = DOL_URL_ROOT.'/projet/card.php?action=create'; + $this->msgNoRecords = 'NoOpenedProjectsOpportunities'; } /** @@ -160,33 +162,34 @@ class box_project_opportunities extends ModeleBoxes } } - - // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][] = array( - 'tr' => 'class="liste_total_wrap"', - 'td' => 'class="liste_total"', - 'text' => $langs->trans("Total")." ".$textHead, - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => round($num, 0)." ".$langs->trans("Projects"), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); + if ($num > 0) { + // Add the sum à the bottom of the boxes + $this->info_box_contents[$i][] = array( + 'tr' => 'class="liste_total_wrap"', + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total")." ".$textHead, + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => round($num, 0)." ".$langs->trans("Projects"), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + } } diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 59daa109ef1..09b12577f48 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -52,6 +52,9 @@ class box_propales extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('propal', 'read')); + + $this->urltoaddentry = DOL_URL_ROOT.'/comm/propal/card.php?action=create'; + $this->msgNoRecords = 'NoRecordedProposals'; } /** @@ -171,12 +174,6 @@ class box_propales extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoRecordedProposals"), - ); - } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 0052c28a331..dd90e6f1910 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -60,6 +60,9 @@ class box_prospect extends ModeleBoxes } $this->hidden = !($user->hasRight('societe', 'read') && empty($user->socid)); + + $this->urltoaddentry = DOL_URL_ROOT.'/societe/card.php?action=create&type=p'; + $this->msgNoRecords = 'NoRecordedProspects'; } /** @@ -153,13 +156,6 @@ class box_prospect extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedProspects").'' - ); - } - $this->db->free($resql); } else { $this->info_box_contents[0][0] = array( diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 1b621155ee2..cf1d6f683fe 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -51,6 +51,9 @@ class box_scheduled_jobs extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('cron', 'read')); + + $this->urltoaddentry = DOL_URL_ROOT.'/cron/card.php?action=create'; + $this->msgNoRecords = 'NoScheduledJobs'; } /** @@ -159,26 +162,27 @@ class box_scheduled_jobs extends ModeleBoxes ); $line++; } - - // Line nb job in error - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax300" colspan="3"', - 'text' => $langs->trans("NumberScheduledJobError") - ); - $textnoformat = ''; - if ($nbjobsnotfinished) { - $textnoformat .= '
'.$nbjobsnotfinished.'
'; + if ($num > 0) { + // Line nb job in error + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax300" colspan="3"', + 'text' => $langs->trans("NumberScheduledJobError") + ); + $textnoformat = ''; + if ($nbjobsnotfinished) { + $textnoformat .= '
'.$nbjobsnotfinished.'
'; + } + if ($nbjobsinerror) { + $textnoformat .= '
'.$nbjobsinerror.'
'; + } + if (empty($nbjobsnotfinished) && empty($nbjobsinerror)) { + $textnoformat .= '
0
'; + } + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'textnoformat' => $textnoformat + ); } - if ($nbjobsinerror) { - $textnoformat .= '
'.$nbjobsinerror.'
'; - } - if (empty($nbjobsnotfinished) && empty($nbjobsinerror)) { - $textnoformat .= '
0
'; - } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'textnoformat' => $textnoformat - ); } else { $this->info_box_contents[0][0] = array( 'td' => '', diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index ccdf6b9fce1..87acbc6c000 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -51,6 +51,9 @@ class box_services_contracts extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('service', 'lire') && $user->hasRight('contrat', 'lire')); + + $this->urltoaddentry = DOL_URL_ROOT.'/contrat/card.php?action=create'; + $this->msgNoRecords = 'NoContractedProducts'; } /** @@ -200,12 +203,6 @@ class box_services_contracts extends ModeleBoxes $i++; } - if ($num == 0) { - $this->info_box_contents[$i][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoContractedProducts").'' - ); - } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index f5c7ee6211a..13ed4b8d54d 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -48,6 +48,9 @@ class box_services_expired extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('contrat', 'lire')); + + $this->urltoaddentry = DOL_URL_ROOT.'/contrat/card.php?action=create'; + $this->msgNoRecords = 'NoExpiredServices'; } /** @@ -155,13 +158,6 @@ class box_services_expired extends ModeleBoxes $i++; } - if ($num == 0) { - $langs->load("contracts"); - $this->info_box_contents[$i][] = array( - 'td' => 'class="nohover center"', - 'text' => ''.$langs->trans("NoExpiredServices").'' - ); - } $this->db->free($resql); } else { diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 9dbf5448c07..a2d54f3e948 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -51,6 +51,9 @@ class box_shipments extends ModeleBoxes $this->db = $db; $this->hidden = !$user->hasRight('expedition', 'lire'); + + $this->urltoaddentry = DOL_URL_ROOT.'/expedition/card.php?action=create2'; + $this->msgNoRecords = 'NoRecordedShipments'; } /** @@ -163,12 +166,12 @@ class box_shipments extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoRecordedShipments").'' - ); - } + // if ($num == 0) { + // $this->info_box_contents[$line][0] = array( + // 'td' => 'class="center"', + // 'text' => ''.$langs->trans("NoRecordedShipments").'' + // ); + // } $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 168d5f6fc9b..1c6c9475c09 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -49,6 +49,9 @@ class box_supplier_orders extends ModeleBoxes $this->db = $db; $this->hidden = !($user->hasRight('fournisseur', 'commande', 'lire')); + + $this->urltoaddentry = DOL_URL_ROOT.'/fourn/commande/card.php?action=create'; + $this->msgNoRecords = 'NoSupplierOrder'; } /** @@ -160,13 +163,6 @@ class box_supplier_orders extends ModeleBoxes $line++; } - if ($num == 0) { - $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => ''.$langs->trans("NoSupplierOrder").'', - ); - } - $this->db->free($result); } else { $this->info_box_contents[0][] = array( diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index d7d237d6961..355d087e83a 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -158,6 +158,14 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo * @var string[] Example array("accounting") */ public $depends; + /** + * @var string urltoaddentry + */ + public $urltoaddentry; + /** + * @var string msg when no records exist + */ + public $msgNoRecords = 'NoRecordFound'; @@ -429,6 +437,17 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo $out .= "\n"; } } + } else { + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) { + $out .= ''.$langs->trans($this->msgNoRecords).' '; + + // Check if $urltoaddentry is defined for the widget + if (!empty($this->urltoaddentry)) { + $out .= ''.img_picto($langs->trans("New"), 'add', 'pictofixedwidth').''; + } + + $out .= ''; + } } if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) { diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 19e38c96890..5cef15e6404 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -119,6 +119,9 @@ NoRecordedShipments=No recorded customer shipment BoxCustomersOutstandingBillReached=Customers with outstanding limit reached BoxTitleLastFediverseInfos=Last %s posts from %s BoxLastFediverseInfos=Latest Fediverse Updates: News and Trends +NoOpenedProjectsOpportunities=No open opportunities +NoOpenedProjects=No open projects +NoScheduledJobs=No Scheduled jobs # Pages UsersHome=Home users and groups MembersHome=Home Membership diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index d4c0c4d6e86..f30449960da 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -118,6 +118,8 @@ NoRecordedShipments=Aucune expédition client BoxCustomersOutstandingBillReached=Clients dont l'en-cours de facturation est dépassé BoxTitleLastFediverseInfos=Les %s derniers messages de %s BoxLastFediverseInfos=Dernières mises à jour de Fediverse : Actualités et Tendances +NoOpenedProjectsOpportunities=Aucune opportunités ouvertes +NoOpenedProjects=Aucun projet ouvert # Pages UsersHome=Accueil des utilisateurs et groupes MembersHome=Accueil des adhérents