From 0375f5fd37e575ae3122d2b2337f1949c3efff7b Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 4 Sep 2020 15:24:45 +0200 Subject: [PATCH 1/9] Add helper function for table headers with numbers --- htdocs/comm/index.php | 28 +++----------- htdocs/core/lib/functions.lib.php | 62 +++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 602cde69163..56e5071a250 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -168,10 +168,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $total = 0; $num = $db->num_rows($resql); - print '
'; - print ''; - print ''; - print ''; + StartSimpleTableHeader(["ProposalsDraft"], 2, $num, "comm/propal/list.php","search_status=0"); if ($num > 0) { @@ -253,10 +250,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $total = 0; $num = $db->num_rows($resql); - print '
'; - print '
'.$langs->trans("ProposalsDraft").' '.$num.'
'; - print ''; - print ''; + StartSimpleTableHeader(["SupplierProposalsDraft"], 2, $num, "supplier_proposal/list.php","search_status=0"); if ($num > 0) { @@ -335,10 +329,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $total = 0; $num = $db->num_rows($resql); - print '
'; - print '
'.$langs->trans("SupplierProposalsDraft").' '.$num.'
'; - print ''; - print ''; + StartSimpleTableHeader(["DraftOrders"], 2, $num, "commande/list.php","search_status=0"); if ($num > 0) { @@ -422,10 +413,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $total = 0; $num = $db->num_rows($resql); - print '
'; - print '
'.$langs->trans("DraftOrders").' '.$num.'
'; - print ''; - print ''; + StartSimpleTableHeader(["DraftSuppliersOrders"], 2, $num, "fourn/commande/list.php","search_status=0"); if ($num > 0) { @@ -727,9 +715,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $i = 0; if ($num > 0) { - print '
'; - print '
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'; - print ''; + StartSimpleTableHeader(["ProposalsOpened"], 4, $num, "comm/propal/list.php","search_status=1"); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) @@ -831,9 +817,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $i = 0; if ($num > 0) { - print '
'; - print '
'.$langs->trans("ProposalsOpened").' '.$num.'
'; - print ''; + StartSimpleTableHeader(["OrdersOpened"], 4, $num, "commande/list.php","search_status=1"); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 74916ec62e1..7feb9aa8655 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8670,3 +8670,65 @@ function currentToken() { return $_SESSION['token']; } + +/** + * Start a table with headers and a optinal clickable number + * (don't forget to close the table with a HTML TABLE and a HTML DIV element) + * + * @param string|array $headers The header(s) of the table (headers inside a array are automatic translated) + * @param integer $emptyRows (optional) The count of empty rows after the first header (use this instead of empty headers) + * @param integer $number (optional) The number that is shown right after the first header + * @param string $internalLink (optional) The link to a internal dolibarr page, when click on the number (without the first "/") + * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") + * @return void + */ +function StartSimpleTableHeader($headers, $emptyRows = 0, $number = -1, $internalLink = "", $arguments = "") +{ + global $langs; + + print '
'; + print '
'.$langs->trans("OrdersOpened").' '.$num.'
'; + print ''; + + print $emptyRows < 1 ? ''; + + if(!is_array($headers) || count($headers) < 2) + { + print ''; + return; + } + + foreach(array_slice($headers, 1) as $header) + { + print ''; + } + + print ''; +} From bd96e0fe421c5db7cc27383ecda20c1a4a79c245 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Tue, 8 Sep 2020 11:15:33 +0200 Subject: [PATCH 2/9] finished helper method and usage of it --- htdocs/comm/index.php | 51 ++++++++++++++--------------- htdocs/core/lib/functions.lib.php | 54 +++++++++++++++++++------------ 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 56e5071a250..511fb606a4e 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Pierre Ardoin + * Copyright (C) 2020 Tobias Sekan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -168,7 +169,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["ProposalsDraft"], 2, $num, "comm/propal/list.php","search_status=0"); + StartSimpleTableHeader("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -250,7 +251,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["SupplierProposalsDraft"], 2, $num, "supplier_proposal/list.php","search_status=0"); + StartSimpleTableHeader("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -329,7 +330,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["DraftOrders"], 2, $num, "commande/list.php","search_status=0"); + StartSimpleTableHeader("DraftOrders", "commande/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -413,7 +414,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["DraftSuppliersOrders"], 2, $num, "fourn/commande/list.php","search_status=0"); + StartSimpleTableHeader("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -503,16 +504,19 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) $num = $db->num_rows($resql); $i = 0; - print '
'; - print '
' : ''; + + print is_array($headers) ? $langs->trans($headers[0]) : $headers; + + if($number > -1) + { + // extra space between the first header and the number + print ' '; + } + + if(!empty($internalLink)) + { + print ''; + } + + if($number > -1) + { + print ''.$number.''; + } + + if(!empty($internalLink)) + { + print ''; + } + + print '
'; + print print $langs->trans($header); + print '
'; - print ''; - print ''; - print ''; - print ''; + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + StartSimpleTableHeader($langs->trans("BoxTitleLastCustomersOrProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + } + elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + } + else + { + StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedCustomers", min($max, $num)), "societe/list.php", "type=p,c", 1); + } + if ($num) { while ($i < $num) @@ -570,12 +574,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $num = $db->num_rows($result); $i = 0; - print '
'; - print '
'; - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects", $max); - elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max); - else print $langs->trans("BoxTitleLastModifiedCustomers", $max); - print ''.$langs->trans("FullList").'
'; - print ''; - print ''; - print ''; - print ''; + StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f"); + if ($num) { while ($i < $num && $i < $max) @@ -650,12 +650,11 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD if ($resql) { $num = $db->num_rows($resql); - + if ($num > 0) { - print '
'; - print '
'.$langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)).''.$langs->trans("FullList").'
'; - print ''; + StartSimpleTableHeader($langs->trans("LastContracts", 5), "", "", 2); + $i = 0; $staticcontrat = new Contrat($db); @@ -715,7 +714,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $i = 0; if ($num > 0) { - StartSimpleTableHeader(["ProposalsOpened"], 4, $num, "comm/propal/list.php","search_status=1"); + StartSimpleTableHeader("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) @@ -817,7 +816,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $i = 0; if ($num > 0) { - StartSimpleTableHeader(["OrdersOpened"], 4, $num, "commande/list.php","search_status=1"); + StartSimpleTableHeader("OrdersOpened", "commande/list.php", "search_status=1", 4, $num); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7feb9aa8655..2bc5d8eea53 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8675,58 +8675,70 @@ function currentToken() * Start a table with headers and a optinal clickable number * (don't forget to close the table with a HTML TABLE and a HTML DIV element) * - * @param string|array $headers The header(s) of the table (headers inside a array are automatic translated) - * @param integer $emptyRows (optional) The count of empty rows after the first header (use this instead of empty headers) - * @param integer $number (optional) The number that is shown right after the first header - * @param string $internalLink (optional) The link to a internal dolibarr page, when click on the number (without the first "/") - * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") + * @param string $header The first left header of the table (automatic translated) + * @param string $link (optional) The link to a internal dolibarr page, when click on the number (without the first "/") + * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") + * @param integer $emptyRows (optional) The count of empty rows after the first header + * @param integer $number (optional) The number that is shown right after the first header, when not set the link is shown on the right side of the header as "FullList" * @return void */ -function StartSimpleTableHeader($headers, $emptyRows = 0, $number = -1, $internalLink = "", $arguments = "") +function StartSimpleTableHeader($header, $link = "", $arguments = "", $emptyRows = 0, $number = -1) { global $langs; print '
'; print '
'.$langs->trans("LastContracts", 5).'
'; print ''; - + print $emptyRows < 1 ? ''; - if(!is_array($headers) || count($headers) < 2) + if ($number < 0 && !empty($link)) { - print ''; - return; - } + print ''; } From 413bb10913385262755795efae418e8041844330 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 8 Sep 2020 09:22:02 +0000 Subject: [PATCH 3/9] Fixing style errors. --- htdocs/comm/index.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 511fb606a4e..e28f0c397e7 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -512,8 +512,7 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); } - else - { + else { StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedCustomers", min($max, $num)), "societe/list.php", "type=p,c", 1); } @@ -650,7 +649,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD if ($resql) { $num = $db->num_rows($resql); - + if ($num > 0) { StartSimpleTableHeader($langs->trans("LastContracts", 5), "", "", 2); From 49d009502c0749f8fec26e04bf23dc19b5672996 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Wed, 9 Sep 2020 08:16:26 +0200 Subject: [PATCH 4/9] fix sticker CI --- htdocs/core/lib/functions.lib.php | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2bc5d8eea53..144a420a542 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8694,46 +8694,35 @@ function StartSimpleTableHeader($header, $link = "", $arguments = "", $emptyRows print $langs->trans($header); - if ($number > -1) - { - // extra space between the first header and the number + // extra space between the first header and the number + if ($number > -1) { print ' '; } - if (!empty($link)) - { - if (!empty($arguments)) - { + if (!empty($link)) { + if (!empty($arguments)) { print ''; - } - else - { + } else { print ''; } } - if ($number > -1) - { + if ($number > -1) { print ''.$number.''; } - if (!empty($link)) - { + if (!empty($link)) { print ''; } print ''; - if ($number < 0 && !empty($link)) - { + if ($number < 0 && !empty($link)) { print ''; - print ''; - print ''; + $companystatic->email = $obj->email; + $companystatic->code_compta = $obj->code_compta; + + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; $total += $obj->total_ht; } - if ($num > $nbofloop) - { - print '"; - } elseif ($total > 0) - { - print '"; - } - } else { - print ''; } - print "
' : ''; - print is_array($headers) ? $langs->trans($headers[0]) : $headers; + print $langs->trans($header); - if($number > -1) + if ($number > -1) { // extra space between the first header and the number print ' '; } - if(!empty($internalLink)) + if (!empty($link)) { - print ''; + if (!empty($arguments)) + { + print ''; + } + else + { + print ''; + } } - if($number > -1) + if ($number > -1) { print ''.$number.''; } - if(!empty($internalLink)) + if (!empty($link)) { print ''; } print '
'; - foreach(array_slice($headers, 1) as $header) - { - print ''; - print print $langs->trans($header); + if (!empty($arguments)) + { + print ''; + } + else + { + print ''; + } + + print $langs->trans("FullList"); + print ''; print ''; - if (!empty($arguments)) - { + if (!empty($arguments)) { print ''; - } - else - { + } else { print ''; } From d2903c5de6a48868b7f7ff814725809b2885b392 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 11:04:41 +0200 Subject: [PATCH 5/9] adress feedback + massive cleanup --- htdocs/comm/index.php | 868 +++++++++++++----------------- htdocs/core/lib/functions.lib.php | 74 ++- 2 files changed, 455 insertions(+), 487 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index e28f0c397e7..dcb6b3b92b5 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -53,8 +53,7 @@ $bid = GETPOST('bid', 'int'); // Securite acces client $socid = GETPOST('socid', 'int'); -if (isset($user->socid) && $user->socid > 0) -{ +if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -85,75 +84,65 @@ print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial'); print '
'; -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo -{ - // Search proposal - if (!empty($conf->propal->enabled) && $user->rights->propal->lire) - { - $listofsearchfields['search_proposal'] = array('text'=>'Proposal'); - } - // Search customer order - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) - { - $listofsearchfields['search_customer_order'] = array('text'=>'CustomerOrder'); - } - // Search supplier proposal - if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) - { - $listofsearchfields['search_supplier_proposal'] = array('text'=>'SupplierProposalShort'); - } - // Search supplier order - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) - { - $listofsearchfields['search_supplier_order'] = array('text'=>'SupplierOrder'); - } - // Search intervention - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) - { - $listofsearchfields['search_intervention'] = array('text'=>'Intervention'); - } - // Search contract - if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) - { - $listofsearchfields['search_contract'] = array('text'=>'Contract'); - } +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo + // Search proposal + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { + $listofsearchfields['search_proposal'] = array('text'=>'Proposal'); + } + // Search customer order + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { + $listofsearchfields['search_customer_order'] = array('text'=>'CustomerOrder'); + } + // Search supplier proposal + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { + $listofsearchfields['search_supplier_proposal'] = array('text'=>'SupplierProposalShort'); + } + // Search supplier order + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { + $listofsearchfields['search_supplier_order'] = array('text'=>'SupplierOrder'); + } + // Search intervention + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { + $listofsearchfields['search_intervention'] = array('text'=>'Intervention'); + } + // Search contract + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { + $listofsearchfields['search_contract'] = array('text'=>'Contract'); + } - if (count($listofsearchfields)) - { - print '
'; - print ''; - print '
'; - print ''; - $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print ''; - print ''; - print ''; - if ($i == 0) print ''; - print ''; - $i++; - } - print '
'.$langs->trans("Search").'
'; - print '
'; - print '
'; - print '
'; - } + if (count($listofsearchfields)) { + print '
'; + print ''; + print '
'; + print ''; + $i = 0; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
'; + print '
'; + print '
'; + print '
'; + } } /* * Draft customer proposals */ -if (!empty($conf->propal->enabled) && $user->rights->propal->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.email"; - $sql .= ", s.entity"; - $sql .= ", s.code_compta"; + $sql .= ", s.entity"; + $sql .= ", s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -164,58 +153,48 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) if ($socid) $sql .= " AND s.rowid = ".$socid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); - - StartSimpleTableHeader("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); - - if ($num > 0) - { + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); + + if ($num > 0) { $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { + + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); - print '
'; $propalstatic->id = $obj->rowid; $propalstatic->ref = $obj->ref; - $propalstatic->ref_client = $obj->ref_client; - $propalstatic->total_ht = $obj->total_ht; - $propalstatic->total_tva = $obj->total_tva; - $propalstatic->total_ttc = $obj->total_ttc; - print $propalstatic->getNomUrl(1); - print ''; + $propalstatic->ref_client = $obj->ref_client; + $propalstatic->total_ht = $obj->total_ht; + $propalstatic->total_tva = $obj->total_tva; + $propalstatic->total_ttc = $obj->total_ttc; + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - $companystatic->code_compta = $obj->code_compta; - print $companystatic->getNomUrl(1, 'customer', 16); - print ''.price($obj->total_ht).'
'.$propalstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 16).''.price($obj->total_ht).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoProposal").'

"; + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); $db->free($resql); } else { dol_print_error($db); @@ -223,98 +202,85 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) } - /* * Draft supplier proposals */ -if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) -{ - $langs->load("supplier_proposal"); +if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { + $langs->load("supplier_proposal"); - $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.code_fournisseur"; + $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql .= ", s.code_client"; + $sql .= ", s.code_fournisseur"; $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.fk_statut = 0"; - $sql .= " AND p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= ", s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_statut = 0"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; - $resql = $db->query($sql); - if ($resql) - { - $total = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) { + $total = 0; + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num); - StartSimpleTableHeader("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num); + if ($num > 0) { + $i = 0; - if ($num > 0) - { - $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($resql); + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); - print ''; - $supplierproposalstatic->id = $obj->rowid; - $supplierproposalstatic->ref = $obj->ref; - $supplierproposalstatic->total_ht = $obj->total_ht; - $supplierproposalstatic->total_tva = $obj->total_tva; - $supplierproposalstatic->total_ttc = $obj->total_ttc; - print $supplierproposalstatic->getNomUrl(1); - print ''; - print ''; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; + $supplierproposalstatic->id = $obj->rowid; + $supplierproposalstatic->ref = $obj->ref; + $supplierproposalstatic->total_ht = $obj->total_ht; + $supplierproposalstatic->total_tva = $obj->total_tva; + $supplierproposalstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'supplier', 16); - print ''; - print ''.price($obj->total_ht).''; - $i++; - $total += $obj->total_ht; - } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total").''.price($total).""; - } - } else { - print ''.$langs->trans("NoProposal").''; - } - print "
"; + $companystatic->email = $obj->email; - $db->free($resql); - } else { - dol_print_error($db); - } + print ''; + print ''.$supplierproposalstatic->getNomUrl(1).''; + print ''.$companystatic->getNomUrl(1, 'supplier', 16).''; + print ''.price($obj->total_ht).''; + print ''; + + $i++; + $total += $obj->total_ht; + } + } + + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); + } } /* * Draft customer orders */ -if (!empty($conf->commande->enabled) && $user->rights->commande->lire) -{ +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.email"; - $sql .= ", s.entity"; - $sql .= ", s.code_compta"; + $sql .= ", s.entity"; + $sql .= ", s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -325,61 +291,47 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if ($socid) $sql .= " AND c.fk_soc = ".$socid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("DraftOrders", "commande/list.php", "search_status=0", 2, $num); - StartSimpleTableHeader("DraftOrders", "commande/list.php", "search_status=0", 2, $num); - - if ($num > 0) - { + if ($num > 0) { $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { + + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); - print ''; - $orderstatic->id = $obj->rowid; - $orderstatic->ref = $obj->ref; - $orderstatic->ref_client = $obj->ref_client; - $orderstatic->total_ht = $obj->total_ht; - $orderstatic->total_tva = $obj->total_tva; - $orderstatic->total_ttc = $obj->total_ttc; - print $orderstatic->getNomUrl(1); - print ''; - print ''; + + $orderstatic->id = $obj->rowid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; + $orderstatic->total_ht = $obj->total_ht; + $orderstatic->total_tva = $obj->total_tva; + $orderstatic->total_ttc = $obj->total_ttc; + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; - $companystatic->email = $obj->email; - $companystatic->entity = $obj->entity; - print $companystatic->getNomUrl(1, 'customer', 16); - print ''; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; - } else { - print ''.price($obj->total_ttc).''; - } + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; + $companystatic->email = $obj->email; + $companystatic->entity = $obj->entity; + + print ''; + print ''.$orderstatic->getNomUrl(1).''; + print ''.$companystatic->getNomUrl(1, 'customer', 16).''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; + print ''; + $i++; $total += $obj->total_ttc; } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total").''.price($total).""; - } - } else { - print ''.$langs->trans("NoOrder").''; } - print ""; - print "
"; + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); $db->free($resql); } else { dol_print_error($db); @@ -390,105 +342,86 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) /* * Draft suppliers orders */ -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) -{ - $langs->load("orders"); +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { + $langs->load("orders"); - $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.code_fournisseur"; + $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql .= ", s.code_client"; + $sql .= ", s.code_fournisseur"; $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE cf.fk_soc = s.rowid"; - $sql .= " AND cf.fk_statut = 0"; - $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND cf.fk_soc = ".$socid; + $sql .= ", s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cf.fk_soc = s.rowid"; + $sql .= " AND cf.fk_statut = 0"; + $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND cf.fk_soc = ".$socid; - $resql = $db->query($sql); - if ($resql) - { - $total = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) { + $total = 0; + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num); - StartSimpleTableHeader("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num); + if ($num > 0) { + $i = 0; - if ($num > 0) - { - $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($resql); - print ''; - $supplierorderstatic->id = $obj->rowid; - $supplierorderstatic->ref = $obj->ref; - $supplierorderstatic->ref_supplier = $obj->ref_suppliert; - $supplierorderstatic->total_ht = $obj->total_ht; - $supplierorderstatic->total_tva = $obj->total_tva; - $supplierorderstatic->total_ttc = $obj->total_ttc; - print $supplierorderstatic->getNomUrl(1); - print ''; - print ''; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); + + $supplierorderstatic->id = $obj->rowid; + $supplierorderstatic->ref = $obj->ref; + $supplierorderstatic->ref_supplier = $obj->ref_suppliert; + $supplierorderstatic->total_ht = $obj->total_ht; + $supplierorderstatic->total_tva = $obj->total_tva; + $supplierorderstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'supplier', 16); - print ''; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; - } else { - print ''.price($obj->total_ttc).''; - } - $i++; - $total += $obj->total_ttc; - } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total").''.price($total).""; - } - } else { - print ''.$langs->trans("NoSupplierOrder").''; - } - print ""; - print "
"; + $companystatic->email = $obj->email; - $db->free($resql); - } else { - dol_print_error($db); - } + print ''; + print ''.$supplierorderstatic->getNomUrl(1).''; + print ''.$companystatic->getNomUrl(1, 'supplier', 16).''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; + print ''; + + $i++; + $total += $obj->total_ttc; + } + } + + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); + } } - print '
'; - $max = 3; - /* * Last modified customers or prospects */ -if (!empty($conf->societe->enabled) && $user->rights->societe->lire) -{ +if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.code_compta"; - $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.entity"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.client IN (1, 2, 3)"; @@ -499,65 +432,65 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) $sql .= $db->plimit($max, 0); $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - StartSimpleTableHeader($langs->trans("BoxTitleLastCustomersOrProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + if ($resql) { + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + $header = "BoxTitleLastCustomersOrProspects"; } - elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + $header = "BoxTitleLastModifiedProspects"; } else { - StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedCustomers", min($max, $num)), "societe/list.php", "type=p,c", 1); + $header = "BoxTitleLastModifiedCustomers"; } - if ($num) - { - while ($i < $num) - { + $num = $db->num_rows($resql); + startSimpleTable($langs->trans($header, min($max, $num)), "societe/list.php", "type=p,c", 1); + + if ($num) { + $i = 0; + + while ($i < $num && $i < $max) { $objp = $db->fetch_object($resql); + $companystatic->id = $objp->rowid; $companystatic->name = $objp->name; $companystatic->client = $objp->client; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas = $objp->canvas; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas = $objp->canvas; $companystatic->code_compta = $objp->code_compta; - $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; + print ''; print ''.$companystatic->getNomUrl(1, 'customer', 48).''; - print ''; - print $companystatic->getLibCustProspStatut(); - print ""; - print ''.dol_print_date($db->jdate($objp->tms), 'day').""; + print ''.$companystatic->getLibCustProspStatut().''; + print ''.dol_print_date($db->jdate($objp->tms), 'day').''; print ''; + $i++; } - - $db->free($resql); - } else { - print ''.$langs->trans("None").''; } - print ""; - print "

"; + + addSummaryTableLine(3, $num); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); } } -// Last suppliers -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) -{ + +/* + * Last suppliers + */ +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; - $sql .= ", s.code_fournisseur"; + $sql .= ", s.code_fournisseur"; $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.fournisseur = 1"; @@ -567,38 +500,38 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= " ORDER BY s.datec DESC"; $sql .= $db->plimit($max, 0); - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f"); - StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f"); + if ($num) { + $i = 0; + while ($i < $num && $i < $max) { + $objp = $db->fetch_object($resql); - if ($num) - { - while ($i < $num && $i < $max) - { - $objp = $db->fetch_object($result); $companystatic->id = $objp->rowid; - $companystatic->name = $objp->name; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas = $objp->canvas; + $companystatic->name = $objp->name; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas = $objp->canvas; $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; - print ''; + $companystatic->email = $objp->email; + + print ''; print ''.$companystatic->getNomUrl(1, 'supplier', 44).''; print ''.dol_print_date($db->jdate($objp->dm), 'day').''; print ''; $i++; } - } else { - print ''.$langs->trans("None").''; } - print ''; - print '

'; + + addSummaryTableLine(2, $num); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); } } @@ -606,8 +539,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU /* * Last actions */ -if ($user->rights->agenda->myactions->read) -{ +if ($user->rights->agenda->myactions->read) { show_array_last_actions_done($max); } @@ -615,8 +547,7 @@ if ($user->rights->agenda->myactions->read) /* * Actions to do */ -if ($user->rights->agenda->myactions->read) -{ +if ($user->rights->agenda->myactions->read) { show_array_actions_to_do(10); } @@ -624,15 +555,14 @@ if ($user->rights->agenda->myactions->read) /* * Latest contracts */ -if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT -{ +if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT $langs->load("contracts"); $sql = "SELECT s.nom as name, s.rowid, s.canvas, "; - $sql .= ", s.code_client"; - $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo"; + $sql .= ", s.code_client"; + $sql .= ", s.entity"; + $sql .= ", s.email"; + $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."product as p"; @@ -646,54 +576,53 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD $sql .= $db->plimit(5, 0); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); + startSimpleTable($langs->trans("LastContracts", 5), "", "", 2); - if ($num > 0) - { - StartSimpleTableHeader($langs->trans("LastContracts", 5), "", "", 2); - + if ($num > 0) { $i = 0; - $staticcontrat = new Contrat($db); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - print 'contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'; - print ''; - $companystatic->id = $objp->rowid; - $companystatic->name = $objp->name; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas = $objp->canvas; + + $companystatic->id = $objp->rowid; + $companystatic->name = $objp->name; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas = $objp->canvas; $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; - print $companystatic->getNomUrl(1, 'customer', 44); - print ''."\n"; - print "".$staticcontrat->LibStatut($obj->statut, 3)."\n"; + $companystatic->email = $objp->email; + + print ''; + print 'contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'; + print ''.$companystatic->getNomUrl(1, 'customer', 44).''; + print ''.$staticcontrat->LibStatut($obj->statut, 3).''; + print ''; $i++; } - print ""; - print "
"; } + + addSummaryTableLine(2, $num); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } } + /* * Opened proposals */ -if (!empty($conf->propal->enabled) && $user->rights->propal->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT s.nom as name, s.rowid, s.code_client"; $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.email"; $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; @@ -705,33 +634,39 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY p.rowid DESC"; - $result = $db->query($sql); - if ($result) - { + $resql = $db->query($sql); + if ($resql) { $total = 0; - $num = $db->num_rows($result); - $i = 0; - if ($num > 0) - { - StartSimpleTableHeader("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num); + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num); - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($result); + if ($num > 0) { + $i = 0; + + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); + + $propalstatic->id = $obj->propalid; + $propalstatic->ref = $obj->ref; + $propalstatic->ref_client = $obj->ref_client; + $propalstatic->total_ht = $obj->total_ht; + $propalstatic->total_tva = $obj->total_tva; + $propalstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print ''; // Ref print ''; - - $propalstatic->id = $obj->propalid; - $propalstatic->ref = $obj->ref; - $propalstatic->ref_client = $obj->ref_client; - $propalstatic->total_ht = $obj->total_ht; - $propalstatic->total_tva = $obj->total_tva; - $propalstatic->total_ttc = $obj->total_ttc; - print ''; print '
'; print $propalstatic->getNomUrl(1); @@ -745,58 +680,39 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
'; - print ""; - print ''; - $companystatic->id = $obj->rowid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; - $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'customer', 44); - print ''; - print ''; - print dol_print_date($db->jdate($obj->dp), 'day').''."\n"; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; - } else { - print ''.price($obj->total_ttc).''; - } - print ''.$propalstatic->LibStatut($obj->fk_statut, 3).''."\n"; - print ''."\n"; + print ''.$companystatic->getNomUrl(1, 'customer', 44).''; + print ''.dol_print_date($db->jdate($obj->dp), 'day').''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; + print ''.$propalstatic->LibStatut($obj->fk_statut, 3).''; + + print ''; + $i++; $total += $obj->total_ttc; } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total")."".price($total)." "; - } - print ""; - print "
"; } + + addSummaryTableLine(5, $num, $nbofloop, $total, "NoProposal", true); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } } + /* * Opened Order */ -if (!empty($conf->commande->enabled) && $user->rights->commande->lire) -{ +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -807,33 +723,39 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY c.rowid DESC"; - $result = $db->query($sql); - if ($result) - { + $resql = $db->query($sql); + if ($resql) { $total = 0; - $num = $db->num_rows($result); - $i = 0; - if ($num > 0) - { - StartSimpleTableHeader("OrdersOpened", "commande/list.php", "search_status=1", 4, $num); + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("OrdersOpened", "commande/list.php", "search_status=1", 4, $num); - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($result); + if ($num > 0) { + $i = 0; + + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); + + $orderstatic->id = $obj->commandeid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; + $orderstatic->total_ht = $obj->total_ht; + $orderstatic->total_tva = $obj->total_tva; + $orderstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print ''; // Ref print ''; - - $orderstatic->id = $obj->commandeid; - $orderstatic->ref = $obj->ref; - $orderstatic->ref_client = $obj->ref_client; - $orderstatic->total_ht = $obj->total_ht; - $orderstatic->total_tva = $obj->total_tva; - $orderstatic->total_ttc = $obj->total_ttc; - print ''; print '
'; print $orderstatic->getNomUrl(1); @@ -847,49 +769,27 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir); print '
'; - print ""; - print ''; - $companystatic->id = $obj->rowid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; - $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'customer', 44); - print ''; - print ''; - print dol_print_date($db->jdate($obj->dp), 'day').''."\n"; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; - } else { - print ''.price($obj->total_ttc).''; - } - print ''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).''."\n"; + print ''.$companystatic->getNomUrl(1, 'customer', 44).''; + print ''.dol_print_date($db->jdate($obj->dp), 'day').''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; + print ''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).''; print ''."\n"; + $i++; $total += $obj->total_ttc; } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total")."".price($total)." "; - } - print ""; - print "
"; } + + addSummaryTableLine(5, $num, $nbofloop, $num, $total, "None", true); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } } - - print ''; $parameters = array('user' => $user); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 144a420a542..d7bf227a304 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8673,8 +8673,10 @@ function currentToken() /** * Start a table with headers and a optinal clickable number - * (don't forget to close the table with a HTML TABLE and a HTML DIV element) - * + * (don't forget to use "finishSimpleTable()" after the last table row) + * + * @see finishSimpleTable + * * @param string $header The first left header of the table (automatic translated) * @param string $link (optional) The link to a internal dolibarr page, when click on the number (without the first "/") * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") @@ -8682,7 +8684,7 @@ function currentToken() * @param integer $number (optional) The number that is shown right after the first header, when not set the link is shown on the right side of the header as "FullList" * @return void */ -function StartSimpleTableHeader($header, $link = "", $arguments = "", $emptyRows = 0, $number = -1) +function startSimpleTable($header, $link = "", $arguments = "", $emptyRows = 0, $number = -1) { global $langs; @@ -8733,3 +8735,69 @@ function StartSimpleTableHeader($header, $link = "", $arguments = "", $emptyRows print ''; } + +/** + * Add the correct HTML close tags for "startSimpleTable(...)" + * (use after the last table line) + * + * @see startSimpleTable + * + * @param bool $addLineBreak (optional) Add a extra line break after the complete table (\) + * + * @return void + */ +function finishSimpleTable($addLineBreak = false) +{ + print ''; + print ''; + + if($addLineBreak) { + print '
'; + } +} + +function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false) +{ + global $langs; + + if($num === 0) { + print ''; + print ''.$langs->trans($noneWord ).''; + print ''; + return; + } + + if($nbofloop === 0) + { + // don't show a summary line + return; + } + + if ($num === 0) { + $colspan = $tableColumnCount; + } + elseif ($num > $nbofloop) { + $colspan = $tableColumnCount; + } else { + $colspan = $tableColumnCount - 1; + } + + if($extraRightColumn) { + $colspan--; + } + + print ''; + + if($nbofloop > 0 && $num > $nbofloop) { + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).''; + } else { + print ' '.$langs->trans("Total").''; + print ''.price($total).''; + } + + if($extraRightColumn) { + print ''; + } + + print ''; +} From be32a24eed2ac536376d88d8522ab73d72eb7c71 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 10 Sep 2020 09:07:10 +0000 Subject: [PATCH 6/9] Fixing style errors. --- htdocs/comm/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index dcb6b3b92b5..555b5895fac 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -158,7 +158,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $num = $db->num_rows($resql); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); - + if ($num > 0) { $i = 0; @@ -171,7 +171,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $propalstatic->total_ht = $obj->total_ht; $propalstatic->total_tva = $obj->total_tva; $propalstatic->total_ttc = $obj->total_ttc; - + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; @@ -309,7 +309,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; $orderstatic->total_ttc = $obj->total_ttc; - + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; @@ -653,7 +653,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $propalstatic->total_ht = $obj->total_ht; $propalstatic->total_tva = $obj->total_tva; $propalstatic->total_ttc = $obj->total_ttc; - + $companystatic->id = $obj->rowid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; From 3f8b2153ea18b34e41b792a9f52eab4179460d4c Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 11:25:35 +0200 Subject: [PATCH 7/9] fix sticker Ci and add missing doc --- htdocs/core/lib/functions.lib.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d7bf227a304..4b65f3eedf3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8751,23 +8751,34 @@ function finishSimpleTable($addLineBreak = false) print ''; print ''; - if($addLineBreak) { + if ($addLineBreak) { print '
'; } } +/** + * Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx") + * + * @param integer $tableColumnCount The complete count columns of the table + * @param integer $num The count of the rows of the table, when it is zero (0) the "$noneWord" is shown instead + * @param integer $nbofloop (optional) The maximum count of rows thaht the table show (when it is zero (0) no summary line will show, expect "$noneWord" when $num === 0) + * @param integer $total (optional) The total value thaht is shown after when the table has minimum of one entire + * @param string $noneWord (optional) The word that is shown when the table has no entires ($num === 0) + * @param boolean $extraRightColumn (optional) Add a addtional column after the summary word and total number + * @return void + */ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false) { global $langs; - if($num === 0) { + if ($num === 0) { print ''; print ''.$langs->trans($noneWord ).''; print ''; return; } - if($nbofloop === 0) + if ($nbofloop === 0) { // don't show a summary line return; @@ -8782,20 +8793,20 @@ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $colspan = $tableColumnCount - 1; } - if($extraRightColumn) { + if ($extraRightColumn) { $colspan--; } print ''; - if($nbofloop > 0 && $num > $nbofloop) { + if ($nbofloop > 0 && $num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).''; } else { print ' '.$langs->trans("Total").''; print ''.price($total).''; } - if($extraRightColumn) { + if ($extraRightColumn) { print ''; } From 2292f83258e91d41b867af7930734c77d2a8c1f9 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 11:26:17 +0200 Subject: [PATCH 8/9] fix sticker ci --- htdocs/core/lib/functions.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4b65f3eedf3..db261bcf8d2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8674,9 +8674,9 @@ function currentToken() /** * Start a table with headers and a optinal clickable number * (don't forget to use "finishSimpleTable()" after the last table row) - * + * * @see finishSimpleTable - * + * * @param string $header The first left header of the table (automatic translated) * @param string $link (optional) The link to a internal dolibarr page, when click on the number (without the first "/") * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") @@ -8739,11 +8739,11 @@ function startSimpleTable($header, $link = "", $arguments = "", $emptyRows = 0, /** * Add the correct HTML close tags for "startSimpleTable(...)" * (use after the last table line) - * + * * @see startSimpleTable * * @param bool $addLineBreak (optional) Add a extra line break after the complete table (\) - * + * * @return void */ function finishSimpleTable($addLineBreak = false) From 747d8c32e2aa8012f0678f749d8d63ee3bd3ae55 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 12:29:01 +0200 Subject: [PATCH 9/9] Fix Sticker CI (again :'-( ) --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index db261bcf8d2..430ca76ddb0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8759,7 +8759,7 @@ function finishSimpleTable($addLineBreak = false) /** * Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx") * - * @param integer $tableColumnCount The complete count columns of the table + * @param integer $tableColumnCount The complete count columns of the table * @param integer $num The count of the rows of the table, when it is zero (0) the "$noneWord" is shown instead * @param integer $nbofloop (optional) The maximum count of rows thaht the table show (when it is zero (0) no summary line will show, expect "$noneWord" when $num === 0) * @param integer $total (optional) The total value thaht is shown after when the table has minimum of one entire @@ -8773,7 +8773,7 @@ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, if ($num === 0) { print ''; - print ''.$langs->trans($noneWord ).''; + print ''.$langs->trans($noneWord).''; print ''; return; }