From 0375f5fd37e575ae3122d2b2337f1949c3efff7b Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 4 Sep 2020 15:24:45 +0200 Subject: [PATCH 01/26] 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 02/26] 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 03/26] 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 04/26] 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 05/26] 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 06/26] 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 912999a6b6b82c6d18db32416aae4ccc0eda9921 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 27 Aug 2020 11:11:53 +0200 Subject: [PATCH 07/26] Creation box --- htdocs/core/boxes/box_validated_projects.php | 205 +++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 htdocs/core/boxes/box_validated_projects.php diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php new file mode 100644 index 00000000000..9fffc92963f --- /dev/null +++ b/htdocs/core/boxes/box_validated_projects.php @@ -0,0 +1,205 @@ + + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Juan José Menent + * Copyright (C) 2020 Pierre Ardoin + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_project.php + * \ingroup projet + * \brief Module to show Projet activity of the current Year + */ +include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; + +/** + * Class to manage the box to show last projet + */ +class box_project extends ModeleBoxes +{ + public $boxcode="project"; + public $boximg="object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $user, $langs; + + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); + + $this->db = $db; + $this->boxlabel = "OpenedProjects"; + + $this->hidden = ! ($user->rights->projet->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + + $this->max=$max; + + $totalMnt = 0; + $totalnb = 0; + $totalnbTask=0; + + $textHead = $langs->trans("OpenedProjects"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); + + $socid=0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId=''; + if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql.= " AND p.fk_statut = 1"; // Only open projects + if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + + $sql.= " ORDER BY p.datec DESC"; + //$sql.= $this->db->plimit($max, 0); + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < min($num, $max)) { + $objp = $this->db->fetch_object($result); + + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; + $projectstatic->title = $objp->title; + $projectstatic->public = $objp->public; + $projectstatic->statut = $objp->status; + + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $objp->title, + ); + + $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; + $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; + $sql.= " WHERE p.entity IN (".getEntity('project').')'; + $sql.=" AND p.rowid = ".$objp->rowid; + $resultTask = $this->db->query($sql); + if ($resultTask) { + $objTask = $this->db->fetch_object($resultTask); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objTask->nb." ".$langs->trans("Tasks"), + ); + if ($objTask->nb > 0) + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => round($objTask->totprogress/$objTask->nb, 0)."%", + ); + else + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + $totalnbTask += $objTask->nb; + } else { + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + } + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); + + $i++; + } + if ($max < $num) + { + $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $i++; + } + } + } + + + // Add the sum à the bottom of the boxes + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total")." ".$textHead, + 'text' => " ", + ); + $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' => " ", + ); + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} From c9833c501d38dab811c61320de0de6f8621765db Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 27 Aug 2020 17:23:53 +0200 Subject: [PATCH 08/26] SQL + insertion champs dans box --- htdocs/core/boxes/box_validated_projects.php | 105 ++++++------------- htdocs/core/modules/modProjet.class.php | 2 + 2 files changed, 35 insertions(+), 72 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index 9fffc92963f..02121612aea 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -20,18 +20,18 @@ */ /** - * \file htdocs/core/boxes/box_project.php + * \file htdocs/core/boxes/box_validated_projects.php * \ingroup projet - * \brief Module to show Projet activity of the current Year + * \brief Module to show validated projects whose tasks are assigned to the connected person, without any time entered by the connected person */ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box to show last projet */ -class box_project extends ModeleBoxes +class box_validated_projects extends ModeleBoxes { - public $boxcode="project"; + public $boxcode="validated_project"; public $boximg="object_projectpub"; public $boxlabel; //var $depends = array("projet"); @@ -60,7 +60,7 @@ class box_project extends ModeleBoxes $langs->loadLangs(array('boxes', 'projects')); $this->db = $db; - $this->boxlabel = "OpenedProjects"; + $this->boxlabel = "ValidatedProjects"; $this->hidden = ! ($user->rights->projet->lire); } @@ -81,11 +81,12 @@ class box_project extends ModeleBoxes $totalnb = 0; $totalnbTask=0; - $textHead = $langs->trans("OpenedProjects"); + $textHead = $langs->trans("ValidatedProjects"); $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); // list the summary of the orders if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($this->db); @@ -96,17 +97,20 @@ class box_project extends ModeleBoxes $projectsListId=''; if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok - $sql.= " AND p.fk_statut = 1"; // Only open projects - if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users - - $sql.= " ORDER BY p.datec DESC"; - //$sql.= $this->db->plimit($max, 0); - + $sql = "SELECT p.rowid, p.ref as Ref, p.fk_soc as Client, p.dateo as startDate,"; + $sql.= " (SELECT COUNT(t.rowid) FROM ".MAIN_DB_PREFIX."projet_task AS t"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; + $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)) AS 'taskNumber'"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; + $sql.= " WHERE p.fk_statut = 1"; // Only open projects + $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)"; + $sql.= " AND c.fk_socpeople = ".$user->id; + $sql.= " GROUP BY p.ref"; + $sql.= " ORDER BY p.dateo ASC"; +var_dump($user->id); $result = $this->db->query($sql); - if ($result) { $num = $this->db->num_rows($result); $i = 0; @@ -114,10 +118,10 @@ class box_project extends ModeleBoxes $objp = $this->db->fetch_object($result); $projectstatic->id = $objp->rowid; - $projectstatic->ref = $objp->ref; - $projectstatic->title = $objp->title; - $projectstatic->public = $objp->public; - $projectstatic->statut = $objp->status; + $projectstatic->ref = $objp->Ref; + $projectstatic->customer = $objp->Client; + $projectstatic->startDate = $objp->startDate; + $projectstatic->taskNumber = $objp->taskNumber; $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', @@ -127,67 +131,24 @@ class box_project extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $objp->title, + 'text' => $objp->Client, ); - $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; - $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql.= " WHERE p.entity IN (".getEntity('project').')'; - $sql.=" AND p.rowid = ".$objp->rowid; - $resultTask = $this->db->query($sql); - if ($resultTask) { - $objTask = $this->db->fetch_object($resultTask); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objTask->nb." ".$langs->trans("Tasks"), - ); - if ($objTask->nb > 0) - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => round($objTask->totprogress/$objTask->nb, 0)."%", - ); - else - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - $totalnbTask += $objTask->nb; - } else { - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - } - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $objp->startDate, + ); - $i++; - } - if ($max < $num) - { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), + ); $i++; } } } - // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => $langs->trans("Total")." ".$textHead, - 'text' => " ", - ); - $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' => " ", - ); } /** diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 77d339da035..ad77f85dfb5 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -144,6 +144,8 @@ class modProjet extends DolibarrModules $r++; $this->boxes[$r][1] = "box_task.php"; $r++; + $this->boxes[$r][1] = "box_validated_projects.php"; + $r++; // Permissions $this->rights = array(); From 76d5ce18caa83f375561ead51f1300ac178c04f6 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 28 Aug 2020 14:07:35 +0200 Subject: [PATCH 09/26] Titres + lien cliquable client + traductions --- htdocs/core/boxes/box_validated_projects.php | 54 ++++++++++++++++---- htdocs/langs/fr_FR/boxes.lang | 1 + 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index 02121612aea..e06da942b8a 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -100,7 +100,7 @@ class box_validated_projects extends ModeleBoxes $sql = "SELECT p.rowid, p.ref as Ref, p.fk_soc as Client, p.dateo as startDate,"; $sql.= " (SELECT COUNT(t.rowid) FROM ".MAIN_DB_PREFIX."projet_task AS t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; - $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)) AS 'taskNumber'"; + $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_c_type_contact != 160 AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)) AS 'taskNumber'"; $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; @@ -109,12 +109,30 @@ class box_validated_projects extends ModeleBoxes $sql.= " AND c.fk_socpeople = ".$user->id; $sql.= " GROUP BY p.ref"; $sql.= " ORDER BY p.dateo ASC"; -var_dump($user->id); + $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < min($num, $max)) { + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => "Reference projet", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => 'Client', + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => 'Date debut de projet', + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => 'Nombre de mes tâches sans temps saisi', + ); + $i++; + + while ($i < min($num+1, $max+1)) { $objp = $this->db->fetch_object($result); $projectstatic->id = $objp->rowid; @@ -122,30 +140,44 @@ var_dump($user->id); $projectstatic->customer = $objp->Client; $projectstatic->startDate = $objp->startDate; $projectstatic->taskNumber = $objp->taskNumber; - +//var_dump($projectstatic->getNomUrl(1)); $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', 'text' => $projectstatic->getNomUrl(1), 'asis' => 1 ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $objp->Client, - ); + $sql = 'SELECT nom FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->Client; + $resql = $this->db->query($sql); + if ($resql){ + $socstatic = new Societe($this->db); + $obj = $this->db->fetch_object($resql); + $socstatic->nom = $obj->nom; + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $socstatic->getNomUrl(1), + 'asis' => 1 + ); + } + else { + dol_print_error($this->db); + } $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'td' => 'class="center"', 'text' => $objp->startDate, ); $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', + 'td' => 'class="center"', 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), + 'asis' => 1 ); $i++; } - } + }else { + dol_print_error($this->db); + } } diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index e2964afd6a3..7b633336c34 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -104,3 +104,4 @@ BoxTitleLastCustomerShipments=Les %s dernières expéditions clients NoRecordedShipments=Aucune expédition client # Pages AccountancyHome=Comptabilité +ValidatedProjects = Projets ouverts dont les tâches me sont affectées et n'ont pas de temps saisi From 281b52db752fc9664cc68043192754b66d3fbbd3 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 28 Aug 2020 15:45:10 +0200 Subject: [PATCH 10/26] =?UTF-8?q?lien=20cliquable=20nbTache=20vers=20liste?= =?UTF-8?q?=20tache=20filtr=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/boxes/box_validated_projects.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index e06da942b8a..bd76fc9c4c9 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -140,7 +140,7 @@ class box_validated_projects extends ModeleBoxes $projectstatic->customer = $objp->Client; $projectstatic->startDate = $objp->startDate; $projectstatic->taskNumber = $objp->taskNumber; -//var_dump($projectstatic->getNomUrl(1)); + $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', 'text' => $projectstatic->getNomUrl(1), @@ -171,7 +171,8 @@ class box_validated_projects extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="center"', 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), - 'asis' => 1 + 'asis' => 1, + 'url' => DOL_URL_ROOT.'/custom/cligp/tasks/projettasks.php?id='.$objp->rowid.'&search_progresscalc=0%&search_user_id='.$user->id, ); $i++; } From 343b39e31ff8868a5b6e1a906858242240b16850 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 28 Aug 2020 16:59:50 +0200 Subject: [PATCH 11/26] FIX : lien cliquable tiers --- htdocs/core/boxes/box_validated_projects.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index bd76fc9c4c9..0683b771a9b 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -147,16 +147,16 @@ class box_validated_projects extends ModeleBoxes 'asis' => 1 ); - $sql = 'SELECT nom FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->Client; + $sql = 'SELECT rowid, nom FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->Client; $resql = $this->db->query($sql); if ($resql){ $socstatic = new Societe($this->db); $obj = $this->db->fetch_object($resql); - $socstatic->nom = $obj->nom; $this->info_box_contents[$i][] = array( 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $socstatic->getNomUrl(1), - 'asis' => 1 + 'text' => $obj->nom, + 'asis' => 1, + 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj->rowid ); } else { From 5a3016594752b80422597a24b2b8d81f9b13a5ff Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 31 Aug 2020 10:21:10 +0200 Subject: [PATCH 12/26] FIX : correction redirection pour nbTache --- htdocs/core/boxes/box_validated_projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index 0683b771a9b..f1e7fda8a2e 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -172,7 +172,7 @@ class box_validated_projects extends ModeleBoxes 'td' => 'class="center"', 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), 'asis' => 1, - 'url' => DOL_URL_ROOT.'/custom/cligp/tasks/projettasks.php?id='.$objp->rowid.'&search_progresscalc=0%&search_user_id='.$user->id, + 'url' => DOL_URL_ROOT.'/custom/cligp/tasks/projettasks.php?id='.$objp->rowid.'&search_timespend==0&search_user_id='.$user->id, ); $i++; } From acfae190c381170499ce2fa9dbdf0b46e4860e93 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 2 Sep 2020 09:15:15 +0200 Subject: [PATCH 13/26] =?UTF-8?q?FIX=20:=20suppression=20lien=20nbT=C3=A2c?= =?UTF-8?q?he?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/boxes/box_validated_projects.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index f1e7fda8a2e..fc190b9d5d3 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -172,7 +172,6 @@ class box_validated_projects extends ModeleBoxes 'td' => 'class="center"', 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), 'asis' => 1, - 'url' => DOL_URL_ROOT.'/custom/cligp/tasks/projettasks.php?id='.$objp->rowid.'&search_timespend==0&search_user_id='.$user->id, ); $i++; } From 419b2b71a924142de3053b3950cae35468617ee2 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 2 Sep 2020 10:52:30 +0200 Subject: [PATCH 14/26] =?UTF-8?q?FIX=20:=20modif=20requete=20SQL,=20prise?= =?UTF-8?q?=20en=20compte=20user=20connect=C3=A9=20pour=20saisie=20des=20t?= =?UTF-8?q?emps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/boxes/box_validated_projects.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index fc190b9d5d3..2bf303d9254 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -100,12 +100,12 @@ class box_validated_projects extends ModeleBoxes $sql = "SELECT p.rowid, p.ref as Ref, p.fk_soc as Client, p.dateo as startDate,"; $sql.= " (SELECT COUNT(t.rowid) FROM ".MAIN_DB_PREFIX."projet_task AS t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; - $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_c_type_contact != 160 AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)) AS 'taskNumber'"; + $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_c_type_contact != 160 AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")) AS 'taskNumber'"; $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; $sql.= " WHERE p.fk_statut = 1"; // Only open projects - $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)"; + $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")"; $sql.= " AND c.fk_socpeople = ".$user->id; $sql.= " GROUP BY p.ref"; $sql.= " ORDER BY p.dateo ASC"; From b4942707bbb4cc719df7f22ac29a0523d0a67059 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 10 Sep 2020 11:23:45 +0200 Subject: [PATCH 15/26] EN_US Traductions --- htdocs/langs/en_US/boxes.lang | 1 + htdocs/langs/fr_FR/boxes.lang | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index ab89bc10c4b..14db79809bc 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -104,3 +104,4 @@ BoxTitleLastCustomerShipments=Latest %s customer shipments NoRecordedShipments=No recorded customer shipment # Pages AccountancyHome=Accountancy +ValidatedProjects=Validated projects diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index 7b633336c34..e2964afd6a3 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -104,4 +104,3 @@ BoxTitleLastCustomerShipments=Les %s dernières expéditions clients NoRecordedShipments=Aucune expédition client # Pages AccountancyHome=Comptabilité -ValidatedProjects = Projets ouverts dont les tâches me sont affectées et n'ont pas de temps saisi From 3f8b2153ea18b34e41b792a9f52eab4179460d4c Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 11:25:35 +0200 Subject: [PATCH 16/26] 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 17/26] 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 0fc24366e12bcd97354f52bf582ddca60d3d8579 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 10 Sep 2020 09:28:05 +0000 Subject: [PATCH 18/26] Fixing style errors. --- htdocs/core/boxes/box_validated_projects.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index 2bf303d9254..378aea61df5 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -86,7 +86,6 @@ class box_validated_projects extends ModeleBoxes // list the summary of the orders if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($this->db); @@ -179,8 +178,6 @@ class box_validated_projects extends ModeleBoxes dol_print_error($this->db); } } - - } /** From 747d8c32e2aa8012f0678f749d8d63ee3bd3ae55 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 12:29:01 +0200 Subject: [PATCH 19/26] 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; } From 9f475a3f93ae9d8cfaa64a899443c8b7ba5fb3df Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 10 Sep 2020 14:01:00 +0200 Subject: [PATCH 20/26] FIX API variable error return Some modules, when there is no value, delete the variables so don't find variable can be normal. Error 404 is better than 500 with error servor (same as other object when not found) ie thirdparties, contacts invoices...) --- htdocs/api/class/api_setup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 5dade088fd0..58b8954762c 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1413,7 +1413,7 @@ class Setup extends DolibarrApi * @url GET conf/{constantname} * * @throws RestException 403 Forbidden - * @throws RestException 500 Error Bad or unknown value for constantname + * @throws RestException 404 Error Bad or unknown value for constantname */ public function getConf($constantname) { @@ -1425,7 +1425,7 @@ class Setup extends DolibarrApi } if (!preg_match('/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) { - throw new RestException(500, 'Error Bad or unknown value for constantname'); + throw new RestException(404, 'Error Bad or unknown value for constantname'); } if (preg_match('/(_pass|_pw|password|secret|_key|key$)/i', $constantname)) { throw new RestException(403, 'Forbidden'); From 25d6af2b862b8ebec03cefa2439c60c00d07d786 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 11 Sep 2020 09:55:34 +0200 Subject: [PATCH 21/26] Add global search for misc payments +TODO --- .../bank/class/paymentvarious.class.php | 31 +++++++++++ htdocs/compta/bank/various_payment/list.php | 53 ++++++++++++++++++- htdocs/core/ajax/selectsearchbox.php | 12 +++++ htdocs/langs/en_US/main.lang | 3 +- 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index d33523863a3..bfb522b6e3a 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -95,6 +95,37 @@ class PaymentVarious extends CommonObject public $fk_user_modif; + /** + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + public $fields = array( + // TODO: fill this array + ); + // END MODULEBUILDER PROPERTIES + /** * Constructor * diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 9241608db8b..70963e29f6d 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -101,6 +101,37 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $typeid = ''; } +$search_all = GETPOSTISSET("search_all") ? trim(GETPOSTISSET("search_all", 'alpha')) : trim(GETPOST('sall')); + +/* +* TODO: fill array "$fields" in "/compta/bank/class/paymentvarious.class.php" and use +* +* +* $object = new PaymentVarious($db); +* +* $search = array(); +* foreach ($object->fields as $key => $val) +* { +* if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +* } + +* $fieldstosearchall = array(); +* foreach ($object->fields as $key => $val) +* { +* if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +* } +* +*/ + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'v.rowid'=>"Ref", + 'v.label'=>"Label", + 'v.datep'=>"DatePayment", + 'v.datev'=>"DateValue", + 'v.amount'=>$langs->trans("Debit").", ".$langs->trans("Credit"), +); + // Definition of fields for lists $arrayfields = array( 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), @@ -136,8 +167,6 @@ if (empty($reshook)) { * View */ -llxHeader(); - $form = new Form($db); if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db); if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db); @@ -174,6 +203,7 @@ if ($filtre) { $filtre = str_replace(":", "=", $filtre); $sql .= " AND ".$filtre; } +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); $sql .= $db->order($sortfield, $sortorder); @@ -189,6 +219,19 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); + + // Direct jump if only one record found + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) + { + $obj = $db->fetch_object($result); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id); + exit; + } + + // must be place behind the last "header(...)" call + llxHeader(); + $i = 0; $total = 0; @@ -226,6 +269,12 @@ if ($result) print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); + if ($search_all) + { + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + } + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index bdd4eacc976..160a613bf7c 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -119,6 +119,17 @@ if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFOR $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } +// Miscellaneous payments +if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire) +{ + $arrayresult['searchintomiscpayments'] = array( + 'position'=>180, + 'img'=>'object_payment', + 'label'=>$langs->trans("SearchIntoMiscPayments", $search_boxvalue), + 'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoMiscPayments", $search_boxvalue), + 'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); +} + if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) { $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); @@ -132,6 +143,7 @@ if (!empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKE $arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } + // HR if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) { diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 2bdb3d2b6f6..911f0b3464c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1010,6 +1010,7 @@ SearchIntoCustomerShipments=Customer shipments SearchIntoExpenseReports=Expense reports SearchIntoLeaves=Leave SearchIntoTickets=Tickets +SearchIntoMiscPayments=Miscellaneous payments CommentLink=Comments NbComments=Number of comments CommentPage=Comments space @@ -1085,4 +1086,4 @@ MODIFYInDolibarr=Record %s modified DELETEInDolibarr=Record %s deleted VALIDATEInDolibarr=Record %s validated APPROVEDInDolibarr=Record %s approved -DefaultMailModel=Default Mail Model \ No newline at end of file +DefaultMailModel=Default Mail Model From 8a6c6c933303eac1762ddd6779b6a15250401297 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 11 Sep 2020 10:01:25 +0200 Subject: [PATCH 22/26] removeempty line --- htdocs/core/ajax/selectsearchbox.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 160a613bf7c..00b66ced374 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -143,7 +143,6 @@ if (!empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKE $arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } - // HR if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) { From 0a0eed289eab96541347cf89da96b11b84850d7f Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 11 Sep 2020 14:15:10 +0200 Subject: [PATCH 23/26] cleanup workflow page + bugfixes --- htdocs/admin/workflow.php | 304 ++++++++++++++++++++++---------------- 1 file changed, 173 insertions(+), 131 deletions(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 311531a52de..8d3b9576b29 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2016 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -19,19 +19,20 @@ */ /** - * \file htdocs/admin/workflow.php - * \ingroup company - * \brief Workflows setup page + * \file htdocs/admin/workflow.php + * \ingroup company + * \brief Workflows setup page */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -// Load translation files required by the page -$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions")); - +// security check if (!$user->admin) accessforbidden(); +// Load translation files required by the page +$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions", "errors")); + $action = GETPOST('action', 'alpha'); @@ -39,157 +40,198 @@ $action = GETPOST('action', 'alpha'); * Actions */ -if (preg_match('/set(.*)/', $action, $reg)) -{ - if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) - { - dol_print_error($db); - } +if (preg_match('/set(.*)/', $action, $reg)) { + if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) { + dol_print_error($db); + } } -if (preg_match('/del(.*)/', $action, $reg)) -{ - if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) - { - dol_print_error($db); - } +if (preg_match('/del(.*)/', $action, $reg)) { + if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) { + dol_print_error($db); + } } +// List of workflow we can enable +clearstatcache(); + +$workflowcodes = array( + // Automatic creation + 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array( + 'family'=>'create', + 'position'=>10, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order' + ), + 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array( + 'family'=>'create', + 'position'=>20, + 'enabled'=>(!empty($conf->commande->enabled) && !empty($conf->facture->enabled)), + 'picto'=>'bill' + ), + + 'separator1'=>array('family'=>'separator', 'position'=>25), + + // Automatic classification of proposal + 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array( + 'family'=>'classify_proposal', + 'position'=>30, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'propal', + 'warning'=>'' + ), + 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array( + 'family'=>'classify_proposal', + 'position'=>31, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->facture->enabled)), + 'picto'=>'propal', + 'warning'=>'' + ), + + // Automatic classification of order + 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array( + 'family'=>'classify_order', + 'position'=>40, + 'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order' + ), + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array( + 'family'=>'classify_order', + 'position'=>41, + 'enabled'=>(!empty($conf->facture->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order', + 'warning'=>'' + ), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. + + 'separator2'=>array('family'=>'separator', 'position'=>50), + + // Automatic classification supplier proposal + 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array( + 'family'=>'classify_supplier_proposal', + 'position'=>60, + 'enabled'=>(!empty($conf->supplier_proposal->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), + 'picto'=>'propal', + 'warning'=>'' + ), + + // Automatic classification supplier order + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array( + 'family'=>'classify_supplier_order', + 'position'=>62, + 'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)), + 'picto'=>'order', + 'warning'=>'' + ), + + // Automatic classification reception + 'WORKFLOW_BILL_ON_RECEPTION'=>array( + 'family'=>'classify_reception', + 'position'=>64, + 'enabled'=>(!empty($conf->reception->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), + 'picto'=>'bill' + ), +); + +if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) { + foreach ($conf->modules_parts['workflow'] as $workflow) { + $workflowcodes = array_merge($workflowcodes, $workflow); + } +} + +// remove not available workflows (based on activated modules and global defined keys) +$workflowcodes = array_filter($workflowcodes, function ($var) { return $var['enabled']; }); /* - * View + * View */ -llxHeader('', $langs->trans("WorkflowSetup"), ''); +llxHeader('', $langs->trans("WorkflowSetup"), "EN:Module_Workflow_En|FR:Module_Workflow|ES:Módulo_Workflow"); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("WorkflowSetup"), $linkback, 'title_setup'); -print ''.$langs->trans("WorkflowDesc").'
'; -print "
"; +print ''.$langs->trans("WorkflowDesc").''; +print '
'; +print '
'; -// List of workflow we can enable +// current module setup don't support any automatic workflow of this module +if (count($workflowcodes) < 1) { + print $langs->trans("ThereIsNoWorkflowToModify"); -clearstatcache(); - -$workflowcodes = array( - // Automatic creation - 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), - 'separator1'=>array('family'=>'separator', 'position'=>25), - // Automatic classification of proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal', 'warning'=>''), - 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal', 'warning'=>''), - 'separator2'=>array('family'=>'separator', 'position'=>35), - // Automatic classification of order - 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order', 'warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. - 'separator3'=>array('family'=>'separator', 'position'=>50), - // Automatic classification supplier proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', 'picto'=>'propal', 'warning'=>''), - 'separator4'=>array('family'=>'separator', 'position'=>61), - // Automatic classification supplier order - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)', 'picto'=>'order', 'warning'=>''), - 'separator5'=>array('family'=>'separator', 'position'=>63), - // Automatic classification reception - 'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify_reception', 'position'=>64, 'enabled'=>'! empty($conf->reception->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', 'picto'=>'bill'), - 'separator6'=>array('family'=>'separator', 'position'=>90), - // Automatic classification of intervention - 'WORKFLOW_TICKET_CLOSE_INTERVENTION'=>array('family'=>'classify_intervention', 'position'=>100, 'enabled'=>'! empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)', 'picto'=>'intervention'), -); - -if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) -{ - foreach ($conf->modules_parts['workflow'] as $workflow) - { - $workflowcodes = array_merge($workflowcodes, $workflow); - } + llxFooter(); + $db->close(); + return; } // Sort on position $workflowcodes = dol_sort_array($workflowcodes, 'position'); -$nbqualified = 0; +print ''; + $oldfamily = ''; -print '
'."\n"; - -foreach ($workflowcodes as $key => $params) -{ - $picto = $params['picto']; - $enabled = $params['enabled']; - $family = $params['family']; - - if ($family == 'separator') - { - print '

'; - print ''."\n"; +foreach ($workflowcodes as $key => $params) { + if ($params['family'] == 'separator') { + print '
'; + print '
'; + print ''; continue; } - if (!verifCond($enabled)) continue; - - $nbqualified++; - - - if ($oldfamily != $family) - { - print ''."\n"; - print ' '; - print ' '; - print "\n"; - $oldfamily = $family; - } - print "\n"; - print "\n"; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + + $oldfamily = $params['family']; + } + + print ''; + print ''; + + print ''; + print ''; } -if ($nbqualified == 0) -{ - print '
'; - $reg = array(); - if ($family == 'create') { - print $langs->trans("AutomaticCreation"); - } elseif (preg_match('/classify_(.*)/', $family, $reg)) - { - print $langs->trans("AutomaticClassification"); - if ($reg[1] == 'proposal') print ' - '.$langs->trans('Proposal'); - if ($reg[1] == 'order') print ' - '.$langs->trans('Order'); - if ($reg[1] == 'supplier_proposal') print ' - '.$langs->trans('SupplierProposal'); - if ($reg[1] == 'supplier_order') print ' - '.$langs->trans('SupplierOrder'); - if ($reg[1] == 'reception') print ' - '.$langs->trans('Reception'); - if ($reg[1] == 'intervention') print ' - '.$langs->trans('Intervention'); + if ($oldfamily != $params['family']) { + if ($params['family'] == 'create') { + $header = $langs->trans("AutomaticCreation"); + } elseif (preg_match('/classify_(.*)/', $params['family'], $reg)) { + $header = $langs->trans("AutomaticClassification"); + if ($reg[1] == 'proposal') $header .= ' - '.$langs->trans('Proposal'); + if ($reg[1] == 'order') $header .= ' - '.$langs->trans('Order'); + if ($reg[1] == 'supplier_proposal') $header .= ' - '.$langs->trans('SupplierProposal'); + if ($reg[1] == 'supplier_order') $header .= ' - '.$langs->trans('SupplierOrder'); + if ($reg[1] == 'reception') $header .= ' - '.$langs->trans('Reception'); } else { - print $langs->trans("Description"); + $header = $langs->trans("Description"); } - print ''.$langs->trans("Status").'
".img_object('', $picto, 'class="paddingright"').$langs->trans('desc'.$key); - if (!empty($params['warning'])) - { - $langs->load("errors"); - print ' '.img_warning($langs->transnoentitiesnoconv($params['warning'])); - } - print "'; - if (!empty($conf->use_javascript_ajax)) - { - print ajax_constantonoff($key); - } else { - if (!empty($conf->global->$key)) - { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - } - print '
'.$header.''.$langs->trans("Status").'
'; + print img_object('', $params['picto']); + print ' '.$langs->trans('desc'.$key); + + if (!empty($params['warning'])) { + print ' '.img_warning($langs->transnoentitiesnoconv($params['warning'])); + } + + print ''; + + if (!empty($conf->use_javascript_ajax)) { + print ajax_constantonoff($key); + } else { + if (!empty($conf->global->$key)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + } + + print '
'.$langs->trans("ThereIsNoWorkflowToModify"); -} print '
'; // End of page From 97e74642ce7427408619f264bafcd0aa739f72af Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 11 Sep 2020 12:26:14 +0000 Subject: [PATCH 24/26] Fixing style errors. --- htdocs/admin/workflow.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 8d3b9576b29..671bacee080 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -139,7 +139,8 @@ if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['w } // remove not available workflows (based on activated modules and global defined keys) -$workflowcodes = array_filter($workflowcodes, function ($var) { return $var['enabled']; }); +$workflowcodes = array_filter($workflowcodes, function ($var) { + return $var['enabled']; }); /* * View From 5118f1c8212b96123fda93fe694c8c765072841d Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 11 Sep 2020 15:47:46 +0200 Subject: [PATCH 25/26] NEW ticket classification on create from email collector --- htdocs/emailcollector/class/emailcollector.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 9e666033d83..be53ebefaeb 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1879,9 +1879,9 @@ class EmailCollector extends CommonObject $tickettocreate->subject = $subject; $tickettocreate->message = $description; - $tickettocreate->type_code = 0; - $tickettocreate->category_code = null; - $tickettocreate->severity_code = null; + $tickettocreate->type_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_TYPE_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_TYPE_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_type', 'use_default', 'code', 1)); + $tickettocreate->category_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_CATEGORY_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_CATEGORY_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_category', 'use_default', 'code', 1)); + $tickettocreate->severity_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_SEVERITY_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_SEVERITY_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_severity', 'use_default', 'code', 1)); $tickettocreate->origin_email = $from; $tickettocreate->fk_user_create = $user->id; $tickettocreate->datec = $date; From e89bfe5ac1185bcd33c8a5d6c770ddb2bc098840 Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Fri, 11 Sep 2020 22:31:48 +0100 Subject: [PATCH 26/26] fix: unuseful truncations in extrafield select lists --- htdocs/core/class/extrafields.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 1ed6056404e..f08516812be 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1218,13 +1218,13 @@ class ExtraFields } else { $labeltoshow = $obj->{$InfoFieldList[1]}; } - $labeltoshow = dol_trunc($labeltoshow, 45); + $labeltoshow = $labeltoshow; if ($value == $obj->rowid) { if (!$notrans) { foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); - $labeltoshow = dol_trunc($translabel, 18).' '; + $labeltoshow = $translabel.' '; } } $out .= '';