From 9957b8aed5a1a7863c4d9992d6190c870acaeea3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 15 Apr 2019 09:07:36 +0200 Subject: [PATCH 01/84] WIP - FEC - Validate --- htdocs/accountancy/closure/index.html | 0 htdocs/accountancy/closure/index.php | 416 ++++++++++++++++++++++++ htdocs/core/menus/standard/eldy.lib.php | 13 +- 3 files changed, 427 insertions(+), 2 deletions(-) create mode 100644 htdocs/accountancy/closure/index.html create mode 100644 htdocs/accountancy/closure/index.php diff --git a/htdocs/accountancy/closure/index.html b/htdocs/accountancy/closure/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php new file mode 100644 index 00000000000..9786734ab82 --- /dev/null +++ b/htdocs/accountancy/closure/index.php @@ -0,0 +1,416 @@ + + * + * 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/accountancy/customer/index.php + * \ingroup Accountancy + * \brief Home closure page + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("compta","bills","other","main","accountancy")); + +// Security check +if (empty($conf->accounting->enabled)) { + accessforbidden(); +} +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->closure->read) + accessforbidden(); + + +$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); +else +{ + $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year +} +$year_end = $year_start + 1; +$month_end = $month_start - 1; +if ($month_end < 1) +{ + $month_end = 12; + $year_end--; +} +$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); +$search_date_end = dol_get_last_day($year_end, $month_end); +$year_current = $year_start; + +// Validate History +$action = GETPOST('action', 'aZ09'); + + +/* + * Actions + */ + +if ($action == 'clean' || $action == 'validatehistory') +{ + // Clean database + $db->begin(); + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql1 .= " SET fk_code_ventilation = 0"; + $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN'; + $sql1 .= ' (SELECT accnt.rowid '; + $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; + $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture WHERE entity = '.$conf->entity.')'; + $sql1 .= ' AND fk_code_ventilation <> 0'; + + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $db->commit(); + } + // End clean database +} + +if ($action == 'validatehistory') { + + $error = 0; + $db->begin(); + + // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind + if ($db->type == 'pgsql') { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; + $sql1 .= " SET fk_code_ventilation = accnt.rowid"; + $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; + $sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0"; + } else { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 .= " SET fk_code_ventilation = accnt.rowid"; + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; + $sql1 .= " AND fd.fk_code_ventilation = 0"; + } + + dol_syslog('htdocs/accountancy/customer/index.php'); + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $db->commit(); + setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); + } +} + + +/* + * View + */ + +llxHeader('', $langs->trans("CustomersVentilation")); + +$textprevyear = '' . img_previous() . ''; +$textnextyear = ' ' . img_next() . ''; + + +print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); + +print $langs->trans("DescVentilCustomer") . '
'; +print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; +print '
'; + + +$y = $year_current; + +$buttonbind = '' . $langs->trans("ValidateHistory") . ''; + +print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); +//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); + +print '
'; +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + print ''; +} +print ''; + +$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " SUM(fd.total_ht) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; +$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; +$sql .= " AND f.fk_statut > 0"; +$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy +$sql .= " AND aa.account_number IS NULL"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} +$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; + +dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; +print '
'; + + +print '
'; + + +print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); +//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); + +print '
'; +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + print ''; +} +print ''; + +$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " SUM(fd.total_ht) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; +$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; +$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.fk_statut > 0"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} +$sql .= " AND aa.account_number IS NOT NULL"; +$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; + +dol_syslog('htdocs/accountancy/customer/index.php'); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + print ''; + + print ''; + + for($i = 2; $i <= 12; $i++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; +print '
'; + + +if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? +{ + print '
'; + print '
'; + + print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); + //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print '
'; + print ''; + print ''; + for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; + for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM(fd.total_ht) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; + $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; + $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy + $sql .= " AND f.fk_statut > 0"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } + + dol_syslog('htdocs/accountancy/customer/index.php'); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; + print '
'; + + + if (! empty($conf->margin->enabled)) { + print "
\n"; + print '
'; + print ''; + print ''; + for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; + for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; + $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; + $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy + $sql .= " AND f.fk_statut > 0"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } + + dol_syslog('htdocs/accountancy/customer/index.php'); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; + print '
'; + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7491556bebd..9382e3d4984 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1303,9 +1303,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report", $langs->trans("MenuReportInOut"), 2, $user->rights->accounting->comptarapport->lire); - $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire); + $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire); $newmenu->add("/compta/resultat/result.php?leftmenu=accountancy_report", $langs->trans("ByPersonalizedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire); } @@ -1335,6 +1335,15 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } } + // Closure + if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { + $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&leftmenu=accountancy_closure", $langs->trans("Closure"), 1, $user->rights->accounting->closure->read, '', $mainmenu, 'closure'); + + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_closure/', $leftmenu)) { + $newmenu->add("/accountancy/closure/validation.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->closure->read); + } + } + // Accountancy (simple) if (! empty($conf->comptabilite->enabled)) { From 4e16992796061f3c4a0f051dfd721934a93b6f00 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 5 May 2019 14:07:42 +0200 Subject: [PATCH 02/84] WIP --- htdocs/accountancy/closure/index.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- htdocs/core/modules/modAccounting.class.php | 8 ++++++++ htdocs/langs/en_US/accountancy.lang | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 9786734ab82..8d2b93ccb6f 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -36,7 +36,7 @@ if (empty($conf->accounting->enabled)) { } if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accounting->closure->read) +if (! $user->rights->accounting->fiscalyear->closure) accessforbidden(); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 6e935d4bc49..0ccd2b671a1 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1304,10 +1304,10 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Closure if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { - $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&leftmenu=accountancy_closure", $langs->trans("Closure"), 1, $user->rights->accounting->closure->read, '', $mainmenu, 'closure'); + $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->rights->accounting->fiscalyear->closure, '', $mainmenu, 'closure'); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_closure/', $leftmenu)) { - $newmenu->add("/accountancy/closure/validation.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->closure->read); + $newmenu->add("/accountancy/closure/validation.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->fiscalyear->closure); } } diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 8250549b9e1..54187b16d6c 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -228,6 +228,14 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = ''; $r++; + $this->rights[$r][0] = 50431; + $this->rights[$r][1] = 'Validate movements of a fiscal year'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'fiscalyear'; + $this->rights[$r][5] = 'closure'; + $r++; + // Menus //------- diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index a2195784bef..ffc097f23a0 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -97,6 +97,8 @@ MenuExpenseReportAccounts=Expense report accounts MenuLoanAccounts=Loan accounts MenuProductsAccounts=Product accounts MenuClosureAccounts=Closure accounts +MenuAccountancyClosure=Closure +MenuAccountancyValidationMovements=Validate movements ProductsBinding=Products accounts TransferInAccounting=Transfer in accounting RegistrationInAccounting=Registration in accounting From b30929af6d7d63344d9a003d11ce4b3f1247eef7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 6 May 2019 11:05:00 +0200 Subject: [PATCH 03/84] WIP --- htdocs/accountancy/closure/index.php | 217 +-------------------------- 1 file changed, 2 insertions(+), 215 deletions(-) diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 8d2b93ccb6f..25fdf013f9a 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/accountancy/customer/index.php + * \file htdocs/accountancy/closure/index.php * \ingroup Accountancy * \brief Home closure page */ @@ -140,7 +140,6 @@ $textnextyear = ' trans("DescVentilCustomer") . '
'; -print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; print '
'; @@ -149,12 +148,9 @@ $y = $year_current; $buttonbind = '
' . $langs->trans("ValidateHistory") . ''; print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); -//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print '
'; print ''; -print ''; -print ''; for($i = 1; $i <= 12; $i ++) { $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; if ($j > 12) $j-=12; @@ -178,11 +174,6 @@ $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; $sql .= " AND f.fk_statut > 0"; $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; -} else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; -} $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG); @@ -192,20 +183,7 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; + print ''; for($i = 2; $i <= 12; $i ++) { print ''; } @@ -220,197 +198,6 @@ if ($resql) { print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '
'; - if ($row[0] == 'tobind') - { - print $langs->trans("Unknown"); - } - else print length_accountg($row[0]); - print ''; - if ($row[0] == 'tobind') - { - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); - } - else print $row[1]; - print '
' . price($row[$i]) . '
\n"; print '
'; - -print '
'; - - -print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); -//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); - -print '
'; -print ''; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; -} -print ''; - -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; -} -$sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; -$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy -$sql .= " AND f.fk_statut > 0"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; -} else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; -} -$sql .= " AND aa.account_number IS NOT NULL"; -$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; - -dol_syslog('htdocs/accountancy/customer/index.php'); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - - while ( $row = $db->fetch_row($resql)) { - - print ''; - - print ''; - - for($i = 2; $i <= 12; $i++) { - print ''; - } - print ''; - print ''; - print ''; - } - $db->free($resql); -} else { - print $db->lasterror(); // Show last sql error -} -print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
'; - if ($row[0] == 'tobind') - { - print $langs->trans("Unknown"); - } - else print length_accountg($row[0]); - print ''; - if ($row[0] == 'tobind') - { - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); - } - else print $row[1]; - print '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; -print '
'; - - -if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? -{ - print '
'; - print '
'; - - print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); - //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); - - print '
'; - print ''; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; - } - print ''; - - $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; - } - $sql .= " SUM(fd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy - $sql .= " AND f.fk_statut > 0"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; - } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; - } - - dol_syslog('htdocs/accountancy/customer/index.php'); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; - print '
'; - - - if (! empty($conf->margin->enabled)) { - print "
\n"; - print '
'; - print ''; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; - } - print ''; - - $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; - } - $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy - $sql .= " AND f.fk_statut > 0"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; - } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; - } - - dol_syslog('htdocs/accountancy/customer/index.php'); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; - print '
'; - } -} - // End of page llxFooter(); $db->close(); From 876e1147d134386d87aff4ad74e096f29aa0558e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 18 May 2019 09:41:29 +0200 Subject: [PATCH 04/84] WIP Correct right on fiscal year --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0ccd2b671a1..d0962f454be 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1317,8 +1317,8 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10); // Fiscal year - Not really yet used. In a future will lock some periods. - if ($conf->global->MAIN_FEATURES_LEVEL > 1) { - $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear', 20); + if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { + $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'fiscalyear', 20); } $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 30); From 65070afce447d2ad7d728d1f6063b2759347bc91 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 22 May 2019 17:22:49 +0200 Subject: [PATCH 05/84] WIP --- htdocs/accountancy/closure/index.php | 103 +++----------------- htdocs/core/menus/standard/eldy.lib.php | 4 +- htdocs/core/modules/modAccounting.class.php | 2 +- htdocs/langs/en_US/accountancy.lang | 4 + 4 files changed, 23 insertions(+), 90 deletions(-) diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 25fdf013f9a..f060be19440 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2019 Open-DSI * * 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 @@ -58,96 +58,32 @@ $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); $search_date_end = dol_get_last_day($year_end, $month_end); $year_current = $year_start; -// Validate History -$action = GETPOST('action', 'aZ09'); - - /* * Actions */ -if ($action == 'clean' || $action == 'validatehistory') -{ - // Clean database - $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql1 .= " SET fk_code_ventilation = 0"; - $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN'; - $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture WHERE entity = '.$conf->entity.')'; - $sql1 .= ' AND fk_code_ventilation <> 0'; - - dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } else { - $db->commit(); - } - // End clean database -} - -if ($action == 'validatehistory') { - - $error = 0; - $db->begin(); - - // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - if ($db->type == 'pgsql') { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; - $sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0"; - } else { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; - $sql1 .= " AND fd.fk_code_ventilation = 0"; - } - - dol_syslog('htdocs/accountancy/customer/index.php'); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } else { - $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); - } -} - /* * View */ -llxHeader('', $langs->trans("CustomersVentilation")); +llxHeader('', $langs->trans("Closure")); $textprevyear = '' . img_previous() . ''; $textnextyear = ' ' . img_next() . ''; -print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("Closure") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); -print $langs->trans("DescVentilCustomer") . '
'; +print $langs->trans("DescClosure") . '
'; print '
'; $y = $year_current; -$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonbind = '' . $langs->trans("ValidateMovements") . ''; -print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); +print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); print '
'; print ''; @@ -158,25 +94,19 @@ for($i = 1; $i <= 12; $i ++) { } print ''; -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; +$sql = "SELECT COUNT(b.rowid) as detail,"; for($i = 1; $i <= 12; $i ++) { $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + $sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; } -$sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; -$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; -$sql .= " AND f.fk_statut > 0"; -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy -$sql .= " AND aa.account_number IS NULL"; -$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; +$sql .= " COUNT(b.rowid) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; +$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'"; +$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'"; +$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy -dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -184,11 +114,10 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i ++) { + for($i = 1; $i <= 12; $i ++) { print ''; } - print ''; - print ''; + print ''; print ''; } $db->free($resql); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 47ff76d6b56..a432069c9fa 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1298,7 +1298,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->rights->accounting->fiscalyear->closure, '', $mainmenu, 'closure'); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_closure/', $leftmenu)) { - $newmenu->add("/accountancy/closure/validation.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->fiscalyear->closure); + $newmenu->add("/accountancy/closure/validate.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->fiscalyear->closure); } } @@ -1309,7 +1309,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Fiscal year - Not really yet used. In a future will lock some periods. if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { - $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'fiscalyear', 20); + $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->fiscalyear->write, '', $mainmenu, 'fiscalyear', 20); } $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 30); diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 956f7ea24fc..d1a9de7bef4 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -225,7 +225,7 @@ class modAccounting extends DolibarrModules $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'fiscalyear'; - $this->rights[$r][5] = ''; + $this->rights[$r][5] = 'write'; $r++; $this->rights[$r][0] = 50431; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 17bbfc41f66..01c5752f4b5 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -242,6 +242,10 @@ DescVentilExpenseReport=Consult here the list of expense report lines bound (or DescVentilExpenseReportMore=If you setup accounting account on type of expense report lines, the application will be able to make all the binding between your expense report lines and the accounting account of your chart of accounts, just in one click with the button "%s". If account was not set on fees dictionary or if you still have some lines not bound to any account, you will have to make a manual binding from the menu "%s". DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account +DescClosure=Consult here the number of movements by month who are not validated & fiscal years already open +OverviewOfMovementsNotValidated=Step 1/ Overview of movements not validated. (Necessary to close a fiscal year) +ValidateMovements=Validate movements + ValidateHistory=Bind Automatically AutomaticBindingDone=Automatic binding done From d4384f507d48c6f92d276de930d0110d86a419e1 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 23 May 2019 09:25:09 +0200 Subject: [PATCH 06/84] WIP --- htdocs/accountancy/closure/index.php | 4 +- htdocs/accountancy/closure/validate.php | 158 ++++++++++++++++++++++++ htdocs/langs/en_US/accountancy.lang | 2 + 3 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 htdocs/accountancy/closure/validate.php diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index f060be19440..1c9fa255fed 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -115,9 +115,9 @@ if ($resql) { print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } - print ''; + print ''; print ''; } $db->free($resql); diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php new file mode 100644 index 00000000000..7271ef4d98e --- /dev/null +++ b/htdocs/accountancy/closure/validate.php @@ -0,0 +1,158 @@ + + * + * 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/accountancy/closure/validate.php + * \ingroup Accountancy + * \brief Validate entries page + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("compta","bills","other","main","accountancy")); + +// Security check +if (empty($conf->accounting->enabled)) { + accessforbidden(); +} +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->fiscalyear->closure) + accessforbidden(); + + +$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); +else +{ + $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year +} +$year_end = $year_start + 1; +$month_end = $month_start - 1; +if ($month_end < 1) +{ + $month_end = 12; + $year_end--; +} +$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); +$search_date_end = dol_get_last_day($year_end, $month_end); +$year_current = $year_start; + +/* + * Actions + */ + +if ($action == 'validate') +{ + $now = dol_now(); + + // Update database + $db->begin(); + $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; + $sql .= " SET b.date_validated = '" . $db->idate($now) . "'"; + $sql .= ' WHERE b.date_validated IS NULL'; + + dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); + $resql = $db->query($sql); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $db->commit(); + } + // End clean database +} + + +/* + * View + */ + +llxHeader('', $langs->trans("ValidateMovements")); + +$textprevyear = '' . img_previous() . ''; +$textnextyear = ' ' . img_next() . ''; + + +print load_fiche_titre($langs->trans("ValidateMovements") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); + +print $langs->trans("DescValidateMovements") . '
'; +print '
'; + + +$y = $year_current; + +print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', '', -1, '', '', 0, '', 'class="right"', 0, 1, 1); + +print '
'; +print '
' . $langs->trans("Total") . '
' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '' . price($row[13]) . '
' . price($row[$i]) . '' . $row[$i] . '' . price($row[13]) . '' . $row[13] . '
'; +print ''; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + print ''; +} +print ''; + +print ''; +$sql = "SELECT COUNT(b.rowid) as detail,"; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + $sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " COUNT(b.rowid) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; +$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'"; +$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'"; +$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy + +dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + for($i = 1; $i <= 12; $i ++) { + print '' ; + } + print ''; + } + print + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print ''; +print "
' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[$i] . '

'; + print ''; + print '
' . $row[13] . '
\n"; + +print '
'; +print '
'; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 01c5752f4b5..2819ff372ec 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -245,6 +245,8 @@ DescVentilDoneExpenseReport=Consult here the list of the lines of expenses repor DescClosure=Consult here the number of movements by month who are not validated & fiscal years already open OverviewOfMovementsNotValidated=Step 1/ Overview of movements not validated. (Necessary to close a fiscal year) ValidateMovements=Validate movements +DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible +SelectMonthAndValidate=Select month and validate movements ValidateHistory=Bind Automatically AutomaticBindingDone=Automatic binding done From 2aee62ea28726d0247147fd3e145a936222cfdb5 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Mon, 7 Oct 2019 17:32:52 +0200 Subject: [PATCH 07/84] FIX: $from and $sendto variables are unescaped in the sending error message This causes addresses like Tom not to be shown in the message. --- htdocs/core/actions_sendmails.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 17f1a70d555..088c30aaf31 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -460,7 +460,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $mesg='
'; if ($mailfile->error) { - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.=$langs->transnoentities('ErrorFailedToSendMail',dol_escape_htmltag($from),dol_escape_htmltag($sendto)); $mesg.='
'.$mailfile->error; } else From 44476afdac8d09cae7b3e12d2f3794101d707d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Mon, 14 Oct 2019 15:35:04 +0200 Subject: [PATCH 08/84] FIX: No pricing rule on new clean installation There is no pricing rule on new fresh installation of Dolibarr. I think the pricing rule "PRODUCT_PRICE_UNIQ" should be set by default because it is needed to update a product through API REST. --- htdocs/core/modules/modProduct.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index da2ac06dcea..a3e3e539468 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -85,6 +85,13 @@ class modProduct extends DolibarrModules $this->const[$r][3] = 'Module to control product codes'; $this->const[$r][4] = 0; $r++; + + $this->const[$r][0] = "PRODUCT_PRICE_UNIQ"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "1"; + $this->const[$r][3] = 'pricing rule by default'; + $this->const[$r][4] = 0; + $r++; /*$this->const[$r][0] = "PRODUCT_ADDON_PDF"; $this->const[$r][1] = "chaine"; From 7ce5ddbf025a2bb6e7f895929348105d20fbdafc Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 14 Oct 2019 21:25:43 +0200 Subject: [PATCH 09/84] Internationalization --- htdocs/core/modules/contract/doc/pdf_strato.modules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index d2dd1f56218..badf7343295 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -269,7 +269,7 @@ class pdf_strato extends ModelePDFContract $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); - // Affiche notes + // Display notes if (! empty($object->note_public)) { $tab_top -= 2; @@ -411,7 +411,7 @@ class pdf_strato extends ModelePDFContract $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -613,7 +613,7 @@ class pdf_strato extends ModelePDFContract pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->CONTRACT_DRAFT_WATERMARK); } - //Prepare la suite + //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -727,7 +727,7 @@ class pdf_strato extends ModelePDFContract $this->recipient = $object->thirdparty; //Recipient name - // On peut utiliser le nom de la societe du contact + // You can use the name of the contact company if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { From b88059433c18706f26bd1f9d0ed5a878c4bc1cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 14 Oct 2019 21:36:38 +0200 Subject: [PATCH 10/84] Update list.php --- htdocs/fourn/commande/list.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 6410f2c9e57..5f0ca9f9be1 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -349,7 +349,7 @@ if (empty($reshook)) { $fk_parent_line = 0; } - $result = $object->addline( + $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, @@ -492,7 +492,9 @@ $sql.= ' cf.date_creation as date_creation, cf.tms as date_update,'; $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; $sql.= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook From 6761e1ef3334dcddf425d81076dc4f5bbfa5cbed Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 14 Oct 2019 21:38:21 +0200 Subject: [PATCH 11/84] Internationalization --- .../expedition/doc/pdf_espadon.modules.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 8d29edec7d8..40ae16aff59 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -218,7 +218,7 @@ class pdf_espadon extends ModelePdfExpedition if ($conf->expedition->dir_output) { - // Definition de $dir et $file + // Definition of $dir and $file if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; @@ -390,10 +390,10 @@ class pdf_espadon extends ModelePdfExpedition } - // Use new auto collum system + // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); - // Simulation de tableau pour connaitre la hauteur de la ligne de titre + // Table simulation to know the height of the title line $pdf->startTransaction(); $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); @@ -606,10 +606,10 @@ class pdf_espadon extends ModelePdfExpedition $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - // Affiche zone totaux + // Display total area $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); - // Pied de page + // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -653,12 +653,12 @@ class pdf_espadon extends ModelePdfExpedition /** * Show total to pay * - * @param PDF $pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice - * @param int $deja_regle Montant deja regle - * @param int $posy Position depart + * @param int $deja_regle Amount already paid + * @param int $posy Start Position * @param Translate $outputlangs Objet langs - * @return int Position pour suite + * @return int Position for suite */ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { @@ -673,7 +673,7 @@ class pdf_espadon extends ModelePdfExpedition $tab2_hl = 4; $pdf->SetFont('', 'B', $default_font_size - 1); - // Tableau total + // Total table $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; /*if ($this->page_largeur < 210) // To work with US executive format { @@ -824,7 +824,7 @@ class pdf_espadon extends ModelePdfExpedition pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); } - //Prepare la suite + //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1006,7 +1006,7 @@ class pdf_espadon extends ModelePdfExpedition } //Recipient name - // On peut utiliser le nom de la societe du contact + // You can use the name of the contact company if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { From 30099a821b471cbbcc91ef587fea43c46a43d212 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 14 Oct 2019 19:39:00 +0000 Subject: [PATCH 12/84] Fixing style errors. --- htdocs/core/modules/expedition/doc/pdf_espadon.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 40ae16aff59..ddc07db0380 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -656,7 +656,7 @@ class pdf_espadon extends ModelePdfExpedition * @param PDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Amount already paid - * @param int $posy Start Position + * @param int $posy Start Position * @param Translate $outputlangs Objet langs * @return int Position for suite */ From 234dfec351344e7234175d54274edc4cc8fcda0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 14 Oct 2019 21:53:25 +0200 Subject: [PATCH 13/84] add missing td --- htdocs/product/stock/product.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index b91c5d9c5ec..345151138e0 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -1073,6 +1073,7 @@ if (! $variants) { print ''; print ''.$langs->trans("Total").''; print ''.$stock_total.''; + print ''; print ''; } else From 2257706a3026edc8908941bbb87d2ce6d6868e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Mon, 14 Oct 2019 22:22:20 +0200 Subject: [PATCH 14/84] New: Update product type with update method --- htdocs/product/class/api_products.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 2a9f407bf54..81e2659d918 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -246,8 +246,13 @@ class Products extends DolibarrApi } $this->product->$field = $value; } + + $updatetype = false; + if ($this->product->type != $oldproduct->type && ($this->product->isProduct() || $this->product->isService())) { + $updatetype = true; + } - $result = $this->product->update($id, DolibarrApiAccess::$user, 1, 'update'); + $result = $this->product->update($id, DolibarrApiAccess::$user, 1, 'update', $updatetype); // If price mode is 1 price per product if ($result > 0 && ! empty($conf->global->PRODUCT_PRICE_UNIQ)) { From 3429cb7c1d8dc4d4a43b4372b077a1e998ea6ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Mon, 14 Oct 2019 22:42:38 +0200 Subject: [PATCH 15/84] New: Update product type with update method --- htdocs/product/class/product.class.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1b46a656511..aa0c575d8d7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -787,13 +787,14 @@ class Product extends CommonObject * Update a record into database. * If batch flag is set to on, we create records into llx_product_batch * - * @param int $id Id of product - * @param User $user Object user making update - * @param int $notrigger Disable triggers - * @param string $action Current action for hookmanager ('add' or 'update') + * @param int $id Id of product + * @param User $user Object user making update + * @param int $notrigger Disable triggers + * @param string $action Current action for hookmanager ('add' or 'update') + * @param int $updatetype Update product type * @return int 1 if OK, -1 if ref already exists, -2 if other error */ - public function update($id, $user, $notrigger = false, $action = 'update') + public function update($id, $user, $notrigger = false, $action = 'update', $updatetype = false) { global $langs, $conf, $hookmanager; @@ -939,6 +940,11 @@ class Product extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."product"; $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; + + if ($updatetype && ($this->isProduct() || $this->isService())) { + $sql.= ", fk_product_type = " . $this->type; + } + $sql.= ", ref = '" . $this->db->escape($this->ref) ."'"; $sql.= ", ref_ext = ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); From b77d2f2ff2d71ac8c1948ee25db8e2b63804f78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 14 Oct 2019 23:27:37 +0200 Subject: [PATCH 16/84] Update box_task.php --- htdocs/core/boxes/box_task.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 59b31086db5..dbe1757d55d 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -134,7 +134,13 @@ class box_task extends ModeleBoxes }); }); '; - + // set cookie by js + $boxcontent.=''; + $this->info_box_contents[0][] = array( + 'tr'=>'class="nohover"', + 'td' => 'class="nohover"', + 'textnoformat' => $boxcontent, + ); $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; @@ -163,7 +169,7 @@ class box_task extends ModeleBoxes $sql.= $this->db->plimit($max, 0); $result = $this->db->query($sql); - $i = 0; + $i = 1; if ($result) { $num = $this->db->num_rows($result); while ($objp = $this->db->fetch_object($result)) { @@ -183,8 +189,12 @@ class box_task extends ModeleBoxes $label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); - $boxcontent.= getTaskProgressView($taskstatic, $label, true, false, true); + $boxcontent = getTaskProgressView($taskstatic, $label, true, false, true); + $this->info_box_contents[$i][] = array( + 'td' => '', + 'text' => $boxcontent, + ); $i++; } } else { @@ -192,15 +202,6 @@ class box_task extends ModeleBoxes } } - // set cookie by js - if(empty($i)){ - $boxcontent.=''; - } - - $this->info_box_contents[0][] = array( - 'td' => '', - 'text' => $boxcontent, - ); } /** From a53c7cfca8d9887e566b21717f59c153072c5f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Oct 2019 00:13:52 +0200 Subject: [PATCH 17/84] Update box_last_modified_ticket.php --- htdocs/core/boxes/box_last_modified_ticket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 8f86be5a115..56299c60429 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -166,7 +166,7 @@ class box_last_modified_ticket extends ModeleBoxes // Date creation $this->info_box_contents[$i][$r] = array( 'td' => 'class="right"', - 'text' => dol_print_date($this->db->idate($objp->datec), 'dayhour') + 'text' => dol_print_date($datec, 'dayhour') ); $r++; From 194072fc60ec7728877f51bacbf54407644211bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Oct 2019 00:14:43 +0200 Subject: [PATCH 18/84] Update box_last_ticket.php --- htdocs/core/boxes/box_last_ticket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 18990cd8bb6..cf4b7f305f7 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -166,7 +166,7 @@ class box_last_ticket extends ModeleBoxes // Date creation $this->info_box_contents[$i][$r] = array( 'td' => 'class="right"', - 'text' => dol_print_date($this->db->idate($objp->datec), 'dayhour'), + 'text' => dol_print_date($datec, 'dayhour'), ); $r++; From 568faef7f4c2f77087fd9005b9a0b37dd0bffc85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Oct 2019 04:08:34 +0200 Subject: [PATCH 19/84] Fix encoding of message --- htdocs/takepos/takepos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index bd14e227876..311bcd00d8b 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -396,7 +396,7 @@ function Refresh() { function New() { // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined console.log("New with place = , js place="+place); - var r = confirm(' 0 ? $langs->trans("ConfirmDeletionOfThisPOSSale") : $langs->trans("ConfirmDiscardOfThisPOSSale")); ?>'); + var r = confirm(' 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>'); if (r == true) { $("#poslines").load("invoice.php?action=delete&place="+place, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); From 00bac9e98911fea926babb7806a35e5accd264d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Oct 2019 08:02:59 +0200 Subject: [PATCH 20/84] Update interface_50_modAgenda_ActionsAuto.class.php Update agenda.lang Update agenda.lang Update interface_50_modAgenda_ActionsAuto.class.php --- htdocs/langs/en_US/agenda.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 8ad19e06695..465846a43db 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -76,6 +76,7 @@ ContractSentByEMail=Contract %s sent by email OrderSentByEMail=Sales order %s sent by email InvoiceSentByEMail=Customer invoice %s sent by email SupplierOrderSentByEMail=Purchase order %s sent by email +ORDER_SUPPLIER_DELETEInDolibarr=Purchase order %s deleted SupplierInvoiceSentByEMail=Vendor invoice %s sent by email ShippingSentByEMail=Shipment %s sent by email ShippingValidated= Shipment %s validated From 0d69ae9e8c0a6a8f6b025b546c65c0c70fccce84 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 15 Oct 2019 09:52:14 +0200 Subject: [PATCH 21/84] NEW mode for list thirdparty API (add supplier) add new mode for more universel use of the api and easy switch between customer's and supplier's modes --- htdocs/societe/class/api_thirdparties.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index ed3b26e04ac..b5ae7d94c03 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -117,6 +117,7 @@ class Thirdparties extends DolibarrApi * @param int $mode Set to 1 to show only customers * Set to 2 to show only prospects * Set to 3 to show only those are not customer neither prospect + * Set to 4 to show only suppliers * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.nom:like:'TheCompany%') and (t.date_creation:<:'20160101')" * @return array Array of thirdparty objects */ @@ -143,6 +144,7 @@ class Thirdparties extends DolibarrApi if ($mode == 1) $sql.= " AND t.client IN (1, 3)"; if ($mode == 2) $sql.= " AND t.client IN (2, 3)"; if ($mode == 3) $sql.= " AND t.client IN (0)"; + if ($mode == 4) $sql.= " AND t.fournisseur IN (1)"; $sql.= ' AND t.entity IN ('.getEntity('societe').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; From 63a60c7811465eb5e46d53c1a16d6ef5483cac64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Oct 2019 11:13:14 +0200 Subject: [PATCH 22/84] NEW Add option MAIN_PDF_FORCE_FONT_SIZE --- htdocs/core/lib/pdf.lib.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d16fc569961..b233b937be7 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -240,14 +240,18 @@ function pdf_getPDFFont($outputlangs) */ function pdf_getPDFFontSize($outputlangs) { + global $conf; + $size=10; // By default, for FPDI or ISO language on TCPDF - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) + if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 font like DejaVuSans if required (slower) { - if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF') + if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') { $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); } } + if (! empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE; + return $size; } From a45ad29e71e6b6cfd83d544bb3c0a4f2186fa5b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Oct 2019 11:32:53 +0200 Subject: [PATCH 23/84] Doc --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3583c10385b..d4e1356b493 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ English Dolibarr ChangeLog -------------------------------------------------------------- ***** ChangeLog for 10.0.3 compared to 10.0.2 ***** +IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card. +The unit were not saved correctly in database making calculation on shipments wrong. +Update to this version must be done if you use them and have installed version 10.0.0, 10.0.1 or 10.0.2 and set some products after installing or upgrading to this version. +Once update is done you must then edit (manually) the product that has bad unit to set the correct unit to have features restored. + FIX: #11702 FIX: #11861 No consistent code to manage measuring units FIX: #11942 From 9ce71c26aa7b7f673a1319cf45a5ebf82b17205b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Oct 2019 11:41:22 +0200 Subject: [PATCH 24/84] Use alpha logo by default --- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 5 +++-- htdocs/theme/dolibarr_logo_squarred_alpha.png | Bin 0 -> 8921 bytes 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 htdocs/theme/dolibarr_logo_squarred_alpha.png diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 39e2150280e..5f27a68d63a 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -137,7 +137,7 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout } else { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred.png'; + $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred_alpha.png'; } $title=$langs->trans("GoIntoSetupToChangeLogo"); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5d6bf501d82..cf95da29568 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -482,7 +482,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $mysoc->logo_squarred_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI); $logoContainerAdditionalClass = 'backgroundforcompanylogo'; - if(!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND)){ + if(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND)){ $logoContainerAdditionalClass = ''; } @@ -496,7 +496,8 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = }*/ else { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred.png'; + $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred_alpha.png'; + $logoContainerAdditionalClass = ''; } $title=$langs->trans("GoIntoSetupToChangeLogo"); diff --git a/htdocs/theme/dolibarr_logo_squarred_alpha.png b/htdocs/theme/dolibarr_logo_squarred_alpha.png new file mode 100644 index 0000000000000000000000000000000000000000..06e69ad8b7b66c0fb6b464644290dd3bcc66064e GIT binary patch literal 8921 zcmZ`<1z40%w||MH6;x7?PH9oP6cGU_kuDV!lm_Wq1^!ASDUGy%AV{|~C?KtLH!RH( zyL)Hx|Hb{jdmo;ChJD}JGiOfz&Y20)R9Ct{a+L&vpbN_P?>>YeT<|Y0L_`3FefOag zFc3UdRk{mduz%_GxzXSWvBP}>X9$uW#eQ&J#MVfFhlH<`)f5TmNyv%WaNgxr;z1BI zqR{gMm+yvkUv<3$XOHw@qmOc;2S(a_p>1=ffowLK#}#hGe~mi_dFv6X###> z|2cFT=;Go-R{-DiS0KQ?5Do<05W*1xbHPJ-@Qw1H1G9!cF$MJC4;k+JakvEkHYZ)k zosI(f0A2#QYDN~~6G5C11P7Ak{xdA_Ai$S@5d}Y>fgp<#2urlIgX6zA)Beu|{$3sa z-~p73!GjY+Q2L+cu)}fJ!zSqQpXKClmtJQ62QPomiOj7dBl<7qvAbsbv+IBD^Y2|V zD|rA0|G6U-R+mfAKM4GvvIGy|Y&q-~cyX3$czcs66i)O=-dG_v!i!R;rjcLcDtcE? zi@~Wf^)Jd?Unv?XxxI2dx~uA?SLWubsHA6KR^~=RflLDmOFJ!Um}wP%GDKk%-13lF zveql3`m@OI(Sb{+Mp94xtSvX}SKpbT5M~%l1#P378}=core<>7b-0klJw*fMM=`Oj zaNot%&W|YamFZQrL91WWu4<@;5s8CSLvuZI)ggp+*yQQ>Q%iHzjj7SAQuIa{r+#Xj zz&bk36_qcy5FFN8|7!AeoI@a`0Jj@9HtH3K7vY;;iF2cvYLAYom6f$i?A(z2M;-x{ zrwc#Pjmg)C&U7X6tgX~d$EpQIZR|rYjMJN=4*&X9Q_JINVhBicPdEvA>SJE*e?dEL zb!D0z?*X~|Dl@k)^))iL$@8kFEgT=4d9J7l!SCpr8Zv0Nld0u~(w)%zHTY;~mwIda z6i$|M#o3Ng3EJ7ZFY*uqHIWPz3vd|AntR{93#8ZH9q-CjAc_c&6&&s;4Xe#4&s5a} z>JKc;&)|Em&X~}fEPaEO)zfRx-O)&))XKz!&rpv>RctG`$WDyz4K74kmXX2E89|q* z&M0!TsMg{o&`d{g&p|OIZamoxoD_Zy)@erdj6>M`p_-)mz;_L%4eQl+mb&(8OT`mc zNp)?*4twobUK2x_D+Ic+9g8BIS@C@zD6W~vl(?Ii-0)kBbAQK_P*-s3~k95mNwU#-y48EBEtK+mdk#0}VPI=3$N;uWz zYmd|gV4bDug=OLbk_X8B4DE=B_N7A)a=tP5-x^EBVV@691O0KKNSJ>CuYk|`M)W{s zuPjfT{aEb80dmdV$>Z}U;MnrIXKR;lx1cMG5JpwA?M!`U^io$7VG7^4FXJ>JL@neO zYq4TGX^Cj$L2ab z5ohNb0ZAA`ka%G@y{r&wU&^xMug$QoN=E&w5dy#YD4mKS?p(;nyt(t+YVNdz6m@Zd zYQyeeV2Pczzh)<$z$2Xf5)sbftV&FySQciRYq_H-pX4>LG>fGUQRTUEOZEGRGo;Sy zEt*tHMa3XZtmvQ0H}1MmCq2)>pgxWo=}^ERW^2v}#zbEf$}a{zS^hPnrt|?bgQG6) z57LTDlnZqFQLXfrYASt6l1pru-ImmJ1(XCnq$#tU4@3YHx5aOwSagXlqXLOm|b_GhKc>d)HD3^xxhF>9o_%;oLNO=D{E z=pOQ8cf&_#227w`&HjN#ibJ6gR;m_{bv(R}W#V)7ek60B&*9M;WrE!wC=xN_3Y zzLI8U{pynjKh81sJgM3TqQ1JA-PQ~uPG^*}I%A6Os!Va%nu_4%IkDI*J6wp{D)#~H zd+;=#3xVqP=^vQlpuk%FTvka(R%PAkZXTZ?)j2Z{=*3u3%@^YDC3xXtH?a7li*2y4 zZttlEA=Z9+jt9e4?-1AnwocGS}HUQ405 z!1&07g$#yO9M%b={X9P|zM%rsmy)B~vk+A_HOwTD+3>yBw)hN+Vhz6cYCupcwc2!j zLOFup^puDi7Z)i*7@Wb5-syX8CX-h)fhY-t0~I{MJDof@8Z}{l*PIAJO-!!e_Dfbd zawBL0a6uTHc(qwgPjFOBiTxHwmS04R`Bu<(>HM9sYkL3)ejUVjaDe~Go>lCL>T?M7 zk-`aCq=|?ez7Xi>h5Ah=_3fM{cQApSUF^bIL~fcU+dJic676?W1Js#mTpLj(4;R0^hsAno3}Bz1c~<-Um#+zUHNk*$T8CtrG-ry=U?| z9%si?xuoZ-7bW;ONj5zH!VHi{X;xJpx2(ef-?;#Le(+=tBxv9J!=;@&ii`y-*Pi_y zwg))a*()YFkjKZ?8xX{xKG+^{-!fHP(!=#Y_sN12&X;Zm=&cXQc8$o~?_neS_btY_ zP`XAAWSJsvNFgDEg?8!W6WcX(I~&*Iae$R}#;ndOWodU@_#-}J5wCm-r$<3VGfh~S zfsn3Z?~28w&SkLYU;oa^no(EA-mMbC#+p%+!517H#m&nTetVcoIIo8FFS5J`1=qW6 z?uJ*Xs;5Qz9xL^+dmUDiDB!@)h9*W5yqCXm9G|46#l%szrLT3zlitR3>vew<_Rq&+ z2oS~nLK#G7K7JdfiXR(e5Xk0G+{xL~2p#t=(WfPW9B#gHIl70Mip!fG-#tZ-Jwshr zG2eK1Te#@CLufG_!+iKPhAT?sL5VD=$s0dds@Kk3ollg&n?VH1Zi^(W#Q#_!`hi{+B|No6_B*`-koVaXa;!1 zd+^r;BdM-k5RBK%bRwHuIckTEu;axQ>$!bpHuI&R%t3VQmdFgob#vp>M`*zqM`+j| z&(iNWcIsx>!T4e8iLKYu-g({(pyLElU-x9^T}MZB*}VB&9!v8a6;^?{3}QD8v}=uk z2g|dpu5N~Lth=>F9Z1cs%lQbjhttLwJDmhn?T79NI}T|+gCjG)a=yilRDd;^68BMU^_gr9qXq}J6mGgsp$KmoT^`8fXD3+yU5}A zji&?aDDJ=8H!tjbES_XSG%Q+ng^V9^RMiU%Zm6^2-K}1)m-o9H*a7s^lv|4UtC&T2~|xP=1)p$Pjm1b9^Iy0%N|AW{ioX z_oj*1w>;fK?W79!g&8eLr?|g=@Wi7ULWVQ-L=Z!fh z?Cmli7`Xg4JyROw1)l=z^?40BH#a_gg93a?cz$rH__I4t# zch0%tRLxrakbr*`434*a>OLe_FZ05CG1YQzsdkC$6N;@kMa;Gkv9EOoiYkVMowSK< z|F`jN4NHd$(W7QD)HHO@mon!guEm5i$_o81wN4WX@5YCiH6~9tYLIX3rIYs$^PeAg z&%=S%SUenNPmsCxa%)cVsfofKF%*C$g}o5Vk@g-pnZ@=d=~rv5i5E->K7nXbD#c{L zDChY!TR}OM?vaVGFL1Co;v^~)Blv_Z=&0}LgI=zAq&Xpn<%6rw6c$G*nMDy+lmWz0 z)5q1V)v$=ElgAq`Z5Ua@&K$b~%mYD6tCPH-X1lX9zI@B`26H1Pwi+xR+Y_{lkXqt* zl#@@T74d#7Y4cbP8~BQ+M*U7~YznO(;qJD+iU*+%-tw`aRt$aY6%lxVv+GZTcg=&t z?qx4t#e3UtEFMoxOwKk|hr42zQ?0%)R$aMAUha2o6_?pweA~Pc#ewlYRwA8?65+h7 zqnIG%R1Jk*J<+`Cn7|&+5D&rMR8&^WY`I%~^1^YNm_f(JUtBfgA%a0O+tu?QIr@JN zxfZZHd6Niv=23*(;A}r!I74FXWN&A1Y>IB$%c?7^p|RSwIgh2GSZUiFlwQrr9lCd& zjdGctezj_GLQ3wqkS5Y_OlrPE!_z=hz?m4phm|XCGBwhk{A7_|IYSwusHs-1fQp_} zfC`7t`0MZ`PNmrRxVt?+(Qg1axY$^|r$@^2c9={HxD{M>yOWeYv%FrFLgMAZ7o0od zclcmrSgjmMN_ow7Eha^O@00#E@?)47&JXzc$)yc%qYsEIfHlcrp}Sc^V}__?ttb9_ z|9jUVr3cC{N22y@J{pfvSKMQ<+FS|EreBK^$qlWz?fj!e;dHzYq=u7TXX^?Q7Q!%E zV_SYu!=)pnYhQ*?IB9|u&mfYgLILPbV`C~Plt@_#4M?$D6p^W~FUhHxDwH6+P?%2v z>Z+e^y0%js_%QHR6Y7M4D2ug>{gg153wMNYI{8#_TE2a0q>PDo-3YrGc7K96()+)&cUMtSQWiok=I&v!b7v$NaM z;;~HTCK^fwM4GDvUrPiz7RKy#1^UDB4Sh%@n7=m*u>5%>T!3X^fihj6$mhqyCI_Jn zL0E2WtsYUeyTkSC!M$Zl6h4N~S;lLE$R{R~lXp7Xh~<^F?!HBR7OcjHEWB`kn&U=B zTjp|H)BvJmTHADqO9%-LVMqn~ZIB+^?=(BxF<*Db>9+)f^Sh8B`jr>5@rV5k7up~g~U zB8m1ZkkVhV&}{lIGZHnOXP+pXetaLrY+C!6K^A1;7&_4`KRK3#54~Hd5x+)HQdI%= z1zP71U>F=4+kx=_@AP?Dg&P?HlP4kpZJo$lr$&@mi-;H|+Z4nHqJo%JgF}L!4t>F~ z6Z>9{`!fgY>ONLO!gzcz8{9|(Qv!U#Z|H~m;q=1yi6ji64QuQ^mIC@)0wVnnlOTo! zVz~3w<&bj6qfA3#8ZRgg|3J}SMR};cTH~`|Z{uK1rgLMElZZu+ z3$lYAfv=kag**TY#!|ds0G~6MDiG|47-)A$*8k9Q0Wf|uW%A8G9ecDW+2v^rr4*t|C&}&R zSO@UPi+d3!T9-#ny@NrR$*Cd00>ihX*_O!^nc;LRXE)-xAeXQ^*x*s@X6#!-;ZzT8 zV3RVu#cE`z#Id{eswGCEmjkG4=8NZ%&N2~8$L7?ilNxG@8XJM%cEEB&LsqXOqn2x8 zlU#e>H^0}JOCS}eJ&gB$X!wwU$#Wg{rW5bG*vRijEH@Ey9zCl7fxXLA@qGXVVB@`K z3!z>|ZISf%Z*m%iV}%gI3y#C^2}}Cl)C_eR#(pmz>BJDTlG_wa$KSkJPCR#?25PiQ z$DvFVGZW_*5Pw$pIhIS;X6(hZBnbenB;B1)@a8b}n|IzuOP6*Z_yN9$xdr)y{7#d^ z?z&|6`^kFDw%MLi!$I^~DF zAcpum1IyeQCO0krm{ItM)+6szIort4*5%gzBv9Zkf5TLeo26U?LGNCwVU?%q!1($G zaAk4%Tn)x+W*!)(T-0eSDO-e0rDq5>3*+r2CPdFUBWhUr1rPRO5vhg^z`(ykv<*$K zzcwse?4-JFA#Jfn|qJ$A+EIQC2S2{JOW-jf?c=DvZ?^vw4n zsgn3G1rT&5nE94Gv~Oa2?1QjJ*;h2~e&^mgy|$4k4GH`+MA(ZSh*wb!o*z?H4?1c% zJ}WZ|{EEJFu$@7(sR}$Pss;x}J$Z3;=j$;q?7cQjp5EUdNph3YnqGcefFna+Ps@` z5@JBXM8mPq9NS}rg`K-Ui0`!u3qRY~F01MsKSoXhNIL)8a+HMihy<=qKqyAo84h?9 zf3pAOgJ=V1j+(e=PIz(94%=JF8D~vj^nQNUr*abtPzDI34oA?*a)WRw&KY|3DkyD2 z0Kf?;VI#b2TSV=Mr84uek%Jn^v|;GMsL|Ktl(VQ_St5 zwEJcXCr4iKWhG=Cl z&`l1vpRE1qHiZv*1;?{>99>22&u=fB;ma$E;5HFK7w3Ot#1KBcM>0$#a5emk7>BBf zgU$hq+^?9rnadz*ZEj%b<@|I39DxjObo>UEAYTC>Nt>V4sU9eBbzM)HNJMlVODS1@JCu# zDyQw+m(=rz(p?$c3dcnyG`u zZhUmLG~d<3IO&zSyduVONqY6La>}!184)aVY7~f-5^VFD$rJBbIW=CM z^Y-@DTm~m|qEA4ovbb%Z*xq4ZFXrL2dhgGJ#CzT+N#vYz9#5-<+!dAAezS{jGY#mK zH2xYCHzdSp`0Tx2I3?$&CIAu7KmzHvG)^vw%*1xxdfa3aCw7`xZ(|9!VTJBAJ^_0( z<92RKsyNZ>X8kwkLgd`pj}g^{|7Bq?|} z8%Y8;igr%3eMCFn?7FaRP~q#fyCv8gbW-2b+ysh5(k-JelE*84XudJYnt*Q~X`p5H znX@$MV|4bVN|eoQr#*7UpdlI(knWmCNBXJ6d|d2yXPm7AUSp33r05f)8qssf`Xwdm zv<&UIk3;c6W@x@tVbv42;8Qs<|6C5>f*bv}2Hzp38ikI}+?EyHG>YZHZb?kcwb$#C z8g3kcV;ma_Y&(=%x-wt%c%~7N+m`{%_ zwrR`#s`jYdcrR#tD@DY9*6@kLJ}G=WYNn|g7OBvmlp}o9Mb%~5xc7L&)@cM(`|{t6 z%5p@HbH@=8x5{e+ZiiDrxg3E$V?mc7B}LTK5*_BGUWppB5cJG+G6YQjxW2j?hLEWe zuU_o!04H?{%m7IR+D$dPboBszkJwN0lkI+lKB#?r?R)_~eRwwZxr?R|o7IYm-b?oYZ&uq1}Ba4z@}A*DuO}+}&KUl%3LL>rB%sm}*KV zGxh5&C@_Cf7f(h_oJ8l&_b-onWRU|AMjqt6kVc=KEUe4}i$}w=5k;d1r615pmnb`X^fShd+Y&ErCWxH|(YE((bv3LZ`QM%5` z)@iwJ*&JP}hRb3OfWG<2$d<~MuZ8j%a_3p^VV4t*gCXucD9|3n0E?;Sa>u@TRrAGm z$=B(iWy<{sYcr>52G@@G^{GNeM?3?_DWP=D`m#(GkB#F4N6gm(^PM$A-UDD@lo_d0 zH{%M&6QxVtO@5eF2JZTts!aKLFJ`=m_$&Rm>HSMzXriGzzRpP>o;fmad?5B%sp;c1VHR}>Zf z`qQ?*YJe#V=-TCnRD=u6g7fNy+Fo!jX$Q%WNJM zq|v!h$0Sq3o@zWM_rA5iytukYQogZcDyJf>_G%I*fVMOniug+4N`WEvE2Oaw<6C@b29Ku#Rt z#DK$GN3y*9cclYSdEA0(1-#!gt5#NCHI9TAS-pIr0SeZPPvtUTc-q$xmuGJioD!y1 zQZVa>t}ZB%kgTb(wE$qMB^#W*t#$7L3Soc{t)|W;<-6cKvA@x*jn@w``n|ary=8xG zXk03@ww8;P6&yF4R*y_2<@65?FrFHYnMwSj?@@T-Ob#tn0qq>3c4x>Oswjj0{b~Sk zGEiik-xqMwQPxkr@{faZZg~y?a4ZgTABc;fT>bZ7H6Abw%5F~Hwg@H{@hs_^%kU|`np`1}4r!iV!K1;DXDmGfu%)Uoe6Gao6CSUxI(*mn7<6jQ-64cIc!51u%Al@|>Jd z9M}-ZW6Z$K{=eG?*hQTJ-EcsVB!#=cA;70R9t8j4NDlJLPYmI;Uj7!p8oRq-myoie L`rV>CkKg Date: Tue, 15 Oct 2019 14:29:27 +0200 Subject: [PATCH 25/84] Fix non-numeric value encountered on ical export --- htdocs/comm/action/class/actioncomm.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 5803c0afc20..1ce4dce01a0 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1543,6 +1543,19 @@ class ActionComm extends CommonObject $event['uid']='dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"]; $event['type']=$type; $datestart=$this->db->jdate($obj->datep)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600)); + + // fix for -> Warning: A non-numeric value encountered + if(is_numeric($this->db->jdate($obj->datep2))) + { + $dateend = $this->db->jdate($obj->datep2) + - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + } + else + { + // use start date as fall-back to avoid import erros on empty end date + $datestart = $dateend; + } + $dateend=$this->db->jdate($obj->datep2)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600)); $duration=($datestart && $dateend)?($dateend - $datestart):0; $event['summary']=$obj->label.($obj->socname?" (".$obj->socname.")":""); From 6a8e8907efc528598cec19f395a8f97e53399d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Oct 2019 17:55:07 +0200 Subject: [PATCH 26/84] Update list.php --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 893a3935cba..511166991bf 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -267,7 +267,7 @@ $sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.to $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; $sql.= ' u.login'; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user,"; +if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); From e94d47daf74ccb62122e236cb6599d1f980f1816 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Oct 2019 19:57:23 +0200 Subject: [PATCH 27/84] Work on MRP module --- htdocs/bom/bom_card.php | 91 ++++++++++++++++++- htdocs/bom/class/bom.class.php | 2 +- htdocs/commande/card.php | 2 +- .../install/mysql/migration/10.0.0-11.0.0.sql | 2 + .../install/mysql/tables/llx_bom_bomline.sql | 2 +- htdocs/mrp/index.php | 3 +- 6 files changed, 97 insertions(+), 5 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 5e24724b6f7..5f3ec89da61 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -42,6 +42,11 @@ $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bomcard $backtopage = GETPOST('backtopage', 'alpha'); $lineid = GETPOST('lineid', 'int'); +// PDF +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); + // Initialize technical objects $object=new BOM($db); $extrafields = new ExtraFields($db); @@ -173,6 +178,34 @@ if (empty($reshook)) $action = ''; } } + + if ($action == 'confirm_validate' && $confirm == 'yes' && $permissionedit) + { + $result = $object->valid($user); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } @@ -286,6 +319,52 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); + } + + // Confirmation of validation + if ($action == 'validate') + { + // We check that object has a temporary ref + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') { + $object->fetch_product(); + $numref = $object->getNextNumRef($object->product); + } else { + $numref = $object->ref; + } + + $text = $langs->trans('ConfirmValidateBom', $numref); + if (! empty($conf->notification->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('BOM_VALIDATE', $object->socid, $object); + } + + $formquestion=array(); + if (! empty($conf->bom->enabled)) + { + $langs->load("mrp"); + require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + } + // Clone confirmation if ($action == 'clone') { // Create an array for form @@ -467,10 +546,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Modify').''."\n"; } + if ($user->rights->bom->write && $object->status == BOM::STATUS_DRAFT) + { + print ''; + } + + if ($user->rights->bom->write && $object->status == BOM::STATUS_VALIDATED) + { + print ''; + } + // Clone if ($user->rights->bom->write) { - print ''; + print ''; } /* diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 73e26de8aea..c8855c9cc03 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1052,7 +1052,7 @@ class BOMLine extends CommonObject 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',), 'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), - 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'position'=>200, 'notnull'=>1,), + 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), ); public $rowid; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 968607ed660..0d13537037c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1924,7 +1924,7 @@ if ($action == 'create' && $usercancreate) // Confirmation of validation if ($action == 'validate') { - // on verifie si l'objet est en numerotation provisoire + // We check that object has a temporary ref $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 42097685f6f..1a8379d857a 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -50,6 +50,8 @@ UPDATE llx_c_units SET label = 'SurfaceUnitm2' WHERE code IN ('M2'); -- For v11 ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL; +ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0; +ALTER TABLE llx_bom_bomline DROP COLUMN rank; create table llx_categorie_warehouse ( diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.sql b/htdocs/install/mysql/tables/llx_bom_bomline.sql index cb7079cf16a..330f1bb18d6 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.sql @@ -23,6 +23,6 @@ CREATE TABLE llx_bom_bomline( import_key varchar(14), qty double(24,8) NOT NULL, efficiency double(8,4) NOT NULL DEFAULT 1, - position integer NOT NULL + position integer NOT NULL DEFAULT 0 -- END MODULEBUILDER FIELDS ) ENGINE=innodb; diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index f5f723a8fac..b6c20cde620 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -175,7 +175,7 @@ print '
'; */ $max=5; -$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem"; +$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status"; $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom as a"; $sql.= " WHERE a.entity IN (".getEntity('bom').")"; $sql.= $db->order("a.tms", "DESC"); @@ -200,6 +200,7 @@ if ($resql) $staticbom->id=$obj->rowid; $staticbom->ref=$obj->ref; $staticbom->date_modification=$obj->datem; + $staticbom->status=$obj->status; print ''; print ''.$staticbom->getNomUrl(1, 32).''; From d2eeb9e749711b5363af954ec7889fd501588ddc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Oct 2019 19:59:16 +0200 Subject: [PATCH 28/84] Wor kon BOM --- htdocs/mrp/ChangeLog.md | 5 + htdocs/mrp/README.md | 3 + htdocs/mrp/admin/setup.php | 151 ++++ htdocs/mrp/class/mo.class.php | 746 ++++++++++++++++++ htdocs/mrp/core/modules/modMrp.class.php | 349 ++++++++ htdocs/mrp/lib/mrp.lib.php | 54 ++ htdocs/mrp/lib/mrp_mo.lib.php | 83 ++ htdocs/mrp/mo_agenda.php | 262 ++++++ htdocs/mrp/mo_card.php | 550 +++++++++++++ htdocs/mrp/mo_document.php | 167 ++++ htdocs/mrp/mo_list.php | 602 ++++++++++++++ htdocs/mrp/mo_note.php | 165 ++++ htdocs/mrp/modulebuilder.txt | 3 + htdocs/mrp/sql/llx_mrp_mo.key.sql | 35 + htdocs/mrp/sql/llx_mrp_mo.sql | 39 + htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql | 19 + htdocs/mrp/sql/llx_mrp_mo_extrafields.sql | 23 + 17 files changed, 3256 insertions(+) create mode 100644 htdocs/mrp/ChangeLog.md create mode 100644 htdocs/mrp/README.md create mode 100644 htdocs/mrp/admin/setup.php create mode 100644 htdocs/mrp/class/mo.class.php create mode 100644 htdocs/mrp/core/modules/modMrp.class.php create mode 100644 htdocs/mrp/lib/mrp.lib.php create mode 100644 htdocs/mrp/lib/mrp_mo.lib.php create mode 100644 htdocs/mrp/mo_agenda.php create mode 100644 htdocs/mrp/mo_card.php create mode 100644 htdocs/mrp/mo_document.php create mode 100644 htdocs/mrp/mo_list.php create mode 100644 htdocs/mrp/mo_note.php create mode 100644 htdocs/mrp/modulebuilder.txt create mode 100644 htdocs/mrp/sql/llx_mrp_mo.key.sql create mode 100644 htdocs/mrp/sql/llx_mrp_mo.sql create mode 100644 htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql create mode 100644 htdocs/mrp/sql/llx_mrp_mo_extrafields.sql diff --git a/htdocs/mrp/ChangeLog.md b/htdocs/mrp/ChangeLog.md new file mode 100644 index 00000000000..416bad1d559 --- /dev/null +++ b/htdocs/mrp/ChangeLog.md @@ -0,0 +1,5 @@ +# CHANGELOG MRP FOR DOLIBARR ERP CRM + +## 1.0 +Initial version + diff --git a/htdocs/mrp/README.md b/htdocs/mrp/README.md new file mode 100644 index 00000000000..b23e31fb577 --- /dev/null +++ b/htdocs/mrp/README.md @@ -0,0 +1,3 @@ +# MRP Module + +Module to manage Manufacturing Orders (MO) \ No newline at end of file diff --git a/htdocs/mrp/admin/setup.php b/htdocs/mrp/admin/setup.php new file mode 100644 index 00000000000..8d7df29b383 --- /dev/null +++ b/htdocs/mrp/admin/setup.php @@ -0,0 +1,151 @@ + + * Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson + * + * 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 mrp/admin/setup.php + * \ingroup mrp + * \brief Mrp setup page. + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +global $langs, $user; + +// Libraries +require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once '../lib/mrp.lib.php'; +//require_once "../class/myclass.class.php"; + +// Translations +$langs->loadLangs(array("admin", "mrp")); + +// Access control +if (! $user->admin) accessforbidden(); + +// Parameters +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + +$arrayofparameters=array( + 'MRP_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), + 'MRP_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +); + + + +/* + * Actions + */ + +if ((float) DOL_VERSION >= 6) +{ + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; +} + + + +/* + * View + */ + +$page_name = "MrpSetup"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = ''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mrp'); + +// Configuration header +$head = mrpAdminPrepareHead(); +dol_fiche_head($head, 'settings', '', -1, "mrp"); + +// Setup page goes here +echo ''.$langs->trans("MrpSetupPage").'

'; + + +if ($action == 'edit') +{ + print '
'; + print ''; + print ''; + + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); + print '
'; + + print '
'; + print ''; + print '
'; + + print '
'; + print '
'; +} +else +{ + if (! empty($arrayofparameters)) + { + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); + print '' . $conf->global->$key . '
'; + + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; + } + else + { + print '
'.$langs->trans("NothingToSetup"); + } +} + + +// Page end +dol_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php new file mode 100644 index 00000000000..a459a582bba --- /dev/null +++ b/htdocs/mrp/class/mo.class.php @@ -0,0 +1,746 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 class/mo.class.php + * \ingroup mrp + * \brief This file is a CRUD class file for Mo (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for Mo + */ +class Mo extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'mo'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'mrp_mo'; + + /** + * @var int Does mo support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does mo support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for mo. Must be the part after the 'object_' into object_mo.png + */ + public $picto = 'mrp'; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; // To produce + const STATUS_INPROGRESS = 2; + const STATUS_DONE = 3; + const STATUS_CANCELED = -1; + + + + /** + * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * '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). 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) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * '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_...). + * 'position' is the sort order of field. + * '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 + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>-1, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), + 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'index'=>1, 'comment'=>"Qty to produce",), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>62, 'notnull'=>-1,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>-1,), + 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',), + 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), + 'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap'), + 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,), + 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'Done', '-1'=>'Canceled')), + ); + public $rowid; + public $ref; + public $entity; + public $label; + public $qty; + public $fk_soc; + public $note_public; + public $note_private; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $import_key; + public $status; + public $fk_product; + public $date_start_planned; + public $date_end_planned; + public $fk_bom; + public $fk_project; + // END MODULEBUILDER PROPERTIES + + + // If this object has a subtable with lines + + /** + * @var int Name of subtable line + */ + //public $table_element_line = 'mrp_moline'; + + /** + * @var int Field with ID of parent key if this field has a parent + */ + //public $fk_element = 'fk_mo'; + + /** + * @var int Name of subtable class that manage subtable lines + */ + //public $class_element_line = 'Moline'; + + /** + * @var array List of child tables. To test if we can delete object. + */ + //protected $childtables=array(); + + /** + * @var array List of child tables. To know object to delete on cascade. + */ + //protected $childtablesoncascade=array('mrp_modet'); + + /** + * @var MoLine[] Array of subtable lines + */ + //public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($val['arrayofkeyval'])) + { + foreach($val['arrayofkeyval'] as $key2 => $val2) + { + $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->table_element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + if (! $error) + { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) + { + $error++; + } + } + + if (! $error) + { + // copy external contacts if same company + if (property_exists($this, 'socid') && $this->socid == $object->socid) + { + if ($this->copy_linked_contact($object, 'external') < 0) + $error++; + } + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchLines() + { + $this->lines=array(); + + $result = $this->fetchLinesCommon(); + return $result; + } + + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records=array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList(); + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + else $sql .= ' WHERE 1 = 1'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key=='t.rowid') { + $sqlwhere[] = $key . '='. $value; + } + elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } + elseif ($key=='customsql') { + $sqlwhere[] = $value; + } + else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < min($limit, $num)) + { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Delete a line of object in database + * + * @param User $user User that delete + * @param int $idline Id of line to delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int >0 if OK, <0 if KO + */ + public function deleteLine(User $user, $idline, $notrigger = false) + { + if ($this->status < 0) + { + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; + return -2; + } + + return $this->deleteLineCommon($user, $idline, $notrigger); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + + $label = '' . $langs->trans("Mo") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = dol_buildpath('/mrp/mo_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowMo"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action,$hookmanager; + $hookmanager->initHooks(array('modao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + + /** + * Return label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("mrp"); + $this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + } + + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 3) + { + return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 4) + { + return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 5) + { + return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 6) + { + return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); + } + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + /** + * Create an array of lines + * + * @return array|int array of lines if OK, <0 if KO + */ + public function getLinesArray() + { + $this->lines=array(); + + $objectline = new MoLine($this->db); + $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_mo = '.$this->id)); + + if (is_numeric($result)) + { + $this->error = $this->error; + $this->errors = $this->errors; + return $result; + } + else + { + $this->lines = $result; + return $this->lines; + } + } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf,$langs; + + $langs->load("mrp"); + + if (! dol_strlen($modele)) { + + $modele = 'standard'; + + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->MO_ADDON_PDF)) { + $modele = $conf->global->MO_ADDON_PDF; + } + } + + $modelpath = "core/modules/mrp/doc/"; + + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + //public function doScheduledJob($param1, $param2, ...) + public function doScheduledJob() + { + global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error=''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} + +/** + * Class MoLine. You can also remove this and generate a CRUD class for lines objects. + */ +class MoLine +{ + // To complete with content of an object MoLine + // We should have a field rowid, fk_mo and position +} diff --git a/htdocs/mrp/core/modules/modMrp.class.php b/htdocs/mrp/core/modules/modMrp.class.php new file mode 100644 index 00000000000..7e57f70c6c8 --- /dev/null +++ b/htdocs/mrp/core/modules/modMrp.class.php @@ -0,0 +1,349 @@ + + * Copyright (C) 2018-2019 Nicolas ZABOURI + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson + * + * 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 . + */ + +/** + * \defgroup mrp Module Mrp + * \brief Mrp module descriptor. + * + * \file htdocs/mrp/core/modules/modMrp.class.php + * \ingroup mrp + * \brief Description and activation file for module Mrp + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + +/** + * Description and activation class for module Mrp + */ +class modMrp extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs,$conf; + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 660; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'mrp'; + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "products"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '62'; + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module). + $this->description = "MRPDescription"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "Module to Manage Manufacturing Orders (MO)"; + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'dolibarr'; + // Url to the file with your last numberversion of this module + //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; + + // Key used in llx_const table to save module status enabled/disabled (where MRP is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto='mrp'; + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 0, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 0, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + // '/mrp/css/mrp.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + // '/mrp/js/mrp.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all' + 'hooks' => array( + // 'data' => array( + // 'hookcontext1', + // 'hookcontext2', + // ), + // 'entity' => '0', + ), + // Set this to 1 if features of module are opened to external users + 'moduleforexternal' => 0, + ); + // Data directories to create when module is enabled. + // Example: this->dirs = array("/mrp/temp","/mrp/subdir"); + $this->dirs = array("/mrp/temp"); + // Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@mrp"); + // Dependencies + // A condition to hide module + $this->hidden = false; + // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->depends = array('modBom'); + $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->langfiles = array("mrp"); + $this->phpmin = array(5,5); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(8,0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled + + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(1 => array('MRP_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), + // 2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) + // ); + $this->const = array( + // 1 => array('MRP_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + ); + + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( + 'en_US:ParentCompany'=>'Parent company or reseller', + 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' + )*/ + + if (! isset($conf->mrp) || ! isset($conf->mrp->enabled)) { + $conf->mrp=new stdClass(); + $conf->mrp->enabled=0; + } + + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mrp:$user->rights->mrp->read:/mrp/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mrp:$user->rights->othermodule->read:/mrp/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // + // Where objecttype can be + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + + // Dictionaries + $this->dictionaries=array(); + /* Example: + $this->dictionaries=array( + 'langs'=>'mylangfile@mrp', + // List of tables we want to see into dictonnary editor + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), + // Label of tables + 'tablib'=>array("Table1","Table2","Table3"), + // Request to select fields + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + // Sort order + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), + // List of fields (result of select to show dictionary) + 'tabfield'=>array("code,label","code,label","code,label"), + // List of fields (list of fields to edit a record) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), + // List of fields (list of fields for insert) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), + // Name of columns with primary key (try to always name it 'rowid') + 'tabrowid'=>array("rowid","rowid","rowid"), + // Condition to show each dictionary + 'tabcond'=>array($conf->mrp->enabled,$conf->mrp->enabled,$conf->mrp->enabled) + ); + */ + + // Boxes/Widgets + // Add here list of php file(s) stored in mrp/core/boxes that contains a class to show a widget. + $this->boxes = array( + // 0 => array( + // 'file' => 'mrpwidget1.php@mrp', + // 'note' => 'Widget provided by Mrp', + // 'enabledbydefaulton' => 'Home', + // ), + // ... + ); + + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + // 0 => array( + // 'label' => 'MyJob label', + // 'jobtype' => 'method', + // 'class' => '/mrp/class/mo.class.php', + // 'objectname' => 'Mo', + // 'method' => 'doScheduledJob', + // 'parameters' => '', + // 'comment' => 'Comment', + // 'frequency' => 2, + // 'unitfrequency' => 3600, + // 'status' => 0, + // 'test' => '$conf->mrp->enabled', + // 'priority' => 50, + // ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50) + // ); + + // Permissions provided by this module + $this->rights = array(); + $r=0; + // Add here entries to declare new permissions + /* BEGIN MODULEBUILDER PERMISSIONS */ + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read objects of Mrp'; // Permission label + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update objects of Mrp'; // Permission label + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete objects of Mrp'; // Permission label + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $r++; + /* END MODULEBUILDER PERMISSIONS */ + + // Main menu entries to add + $this->menu = array(); + $r=0; + // Add here entries to declare new menus + /* BEGIN MODULEBUILDER TOPMENU */ + /* END MODULEBUILDER LEFTMENU MO */ + + // Exports profiles provided by this module + $r=1; + /* BEGIN MODULEBUILDER EXPORT MO */ + /* + $langs->load("mrp"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='mo@mrp'; + $keyforclass = 'Mo'; $keyforclassfile='/mymobule/class/mo.class.php'; $keyforelement='mo'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='mo'; $keyforaliasextra='extra'; $keyforelement='mo'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'mo as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')'; + $r++; */ + /* END MODULEBUILDER EXPORT MO */ + + // Imports profiles provided by this module + $r=1; + /* BEGIN MODULEBUILDER IMPORT MO */ + /* + $langs->load("mrp"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='mo@mrp'; + $keyforclass = 'Mo'; $keyforclassfile='/mymobule/class/mo.class.php'; $keyforelement='mo'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='mo'; $keyforaliasextra='extra'; $keyforelement='mo'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'mo as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')'; + $r++; */ + /* END MODULEBUILDER IMPORT MO */ + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $result=$this->_load_tables('/mrp/sql/'); + if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + + // Create extrafields during init + //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + //$extrafields = new ExtraFields($this->db); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + + $sql = array(); + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); + return $this->_remove($sql, $options); + } +} diff --git a/htdocs/mrp/lib/mrp.lib.php b/htdocs/mrp/lib/mrp.lib.php new file mode 100644 index 00000000000..7ee1fcd04c7 --- /dev/null +++ b/htdocs/mrp/lib/mrp.lib.php @@ -0,0 +1,54 @@ + + * + * 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 mrp/lib/mrp.lib.php + * \ingroup mrp + * \brief Library files with common functions for Mrp + */ + +/** + * Prepare admin pages header + * + * @return array + */ +function mrpAdminPrepareHead() +{ + global $langs, $conf; + + $langs->load("mrp"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/mrp/admin/setup.php", 1); + $head[$h][1] = $langs->trans("Settings"); + $head[$h][2] = 'settings'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@mrp:/mrp/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@mrp:/mrp/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, null, $head, $h, 'mrp'); + + return $head; +} diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php new file mode 100644 index 00000000000..6189761269e --- /dev/null +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -0,0 +1,83 @@ +. + */ + +/** + * \file lib/mrp_mo.lib.php + * \ingroup mrp + * \brief Library files with common functions for Mo + */ + +/** + * Prepare array of tabs for Mo + * + * @param Mo $object Mo + * @return array Array of tabs + */ +function moPrepareHead($object) +{ + global $db, $langs, $conf; + + $langs->load("mrp"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/mrp/mo_card.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) + { + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; + $head[$h][0] = dol_buildpath('/mrp/mo_note.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + $head[$h][2] = 'note'; + $h++; + } + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->mrp->dir_output . "/mo/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks=Link::count($db, $object->element, $object->id); + $head[$h][0] = dol_buildpath("/mrp/mo_document.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + $head[$h][2] = 'document'; + $h++; + + $head[$h][0] = dol_buildpath("/mrp/mo_agenda.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Events"); + $head[$h][2] = 'agenda'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@mrp:/mrp/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@mrp:/mrp/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'mo@mrp'); + + return $head; +} diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php new file mode 100644 index 00000000000..aab1ff10581 --- /dev/null +++ b/htdocs/mrp/mo_agenda.php @@ -0,0 +1,262 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 mo_agenda.php + * \ingroup mrp + * \brief Page of Mo events + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + + +// Load translation files required by the page +$langs->loadLangs(array("mrp","other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +if (GETPOST('actioncode', 'array')) +{ + $actioncode=GETPOST('actioncode', 'array', 3); + if (! count($actioncode)) $actioncode='0'; +} +else +{ + $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); +} +$search_agenda_label=GETPOST('search_agenda_label'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mrp', $id); + +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield='a.datep,a.id'; +if (! $sortorder) $sortorder='DESC'; + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('moagenda','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity] . "/" . $object->id; + + + +/* + * Actions + */ + +$parameters=array('id'=>$socid); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Cancel + if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $actioncode=''; + $search_agenda_label=''; + } +} + + + +/* + * View + */ + +$contactstatic = new Contact($db); + +$form = new Form($db); + +if ($object->id > 0) +{ + $title=$langs->trans("Agenda"); + //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; + $help_url = ''; + llxHeader('', $title, $help_url); + + if (! empty($conf->notification->enabled)) $langs->load("mails"); + $head = moPrepareHead($object); + + + dol_fiche_head($head, 'agenda', $langs->trans("Mo"), -1, $object->picto); + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mrp->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + + $object->info($object->id); + dol_print_object_info($object, 1); + + print '
'; + + dol_fiche_end(); + + + + // Actions buttons + + $objthirdparty=$object; + $objcon=new stdClass(); + + $out='&origin='.$object->element.'&originid='.$object->id; + $permok=$user->rights->agenda->myactions->create; + if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok) + { + //$out.='trans("AddAnAction"),'filenew'); + //$out.=""; + } + + + print '
'; + + if (! empty($conf->agenda->enabled)) + { + if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } + } + + print '
'; + + if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + { + $param='&id='.$object->id.'&socid='.$socid; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + + + //print load_fiche_titre($langs->trans("ActionsOnMo"), '', ''); + + // List of all actions + $filters=array(); + $filters['search_agenda_label']=$search_agenda_label; + + // TODO Replace this with same code than into list.php + //show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php new file mode 100644 index 00000000000..f15b45b96e5 --- /dev/null +++ b/htdocs/mrp/mo_card.php @@ -0,0 +1,550 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 mo_card.php + * \ingroup mrp + * \brief Page to create/edit/view mo + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies + + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'mocard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('mocard','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$isdraft = (($object->statut == Mo::STATUS_DRAFT) ? 1 : 0); +//$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + +$permissionnote=$user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php +$permissionedit=$user->rights->mrp->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php + + + +/* + * Actions + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error=0; + + $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); + $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); + if (empty($backtopage)) { + if (empty($id)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/mrp/mo_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } + $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, delete or clone + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $trigger_name='MO_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid='mo'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + * + * Put here all code to build page + */ + +$form=new Form($db); +$formfile=new FormFile($db); + +llxHeader('', $langs->trans('Mo'), ''); + +// Example : Adding jquery code +print ''; + + +// Part to create +if ($action == 'create') +{ + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Mo")), '', 'cubes'); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + dol_fiche_end(); + + print ' + + '; + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') +{ + print load_fiche_titre($langs->trans("Mo"), '', 'cubes'); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + dol_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals(); + + $head = moPrepareHead($object); + dol_fiche_head($head, 'card', $langs->trans("Mo"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mrp->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } + } + */ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); + + + /* + * Lines + */ + + if (! empty($object->table_element_line)) + { + // Show object lines + $result = $object->getLinesArray(); + + print '
+ + + + + '; + + if (! empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print ''; + } + + if (! empty($object->lines)) + { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') + { + if ($action != 'editline') + { + // Add products/services form + $object->formAddObjectLine(1, $mysoc, $soc); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + + if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print '
'; + } + print '
'; + + print "
\n"; + } + + + // Buttons for actions + + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + // Send + print '' . $langs->trans('SendMail') . ''."\n"; + + // Modify + if (! empty($user->rights->mrp->write)) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } + + // Clone + if (! empty($user->rights->mrp->write)) + { + print ''; + } + + /* + if ($user->rights->mrp->write) + { + if ($object->status == 1) + { + print ''.$langs->trans("Disable").''."\n"; + } + else + { + print ''.$langs->trans("Enable").''."\n"; + } + } + */ + + // Delete (need delete permission, or if draft, just need create/modify permission) + if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write))) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + // Documents + /*$objref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->mrp->dir_output . '/' . $objref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('mrp', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + */ + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright.= $langs->trans("SeeAll"); + $morehtmlright.= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'mo', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + + print '
'; + } + + //Select mail models is same action as presend + /* + if (GETPOST('modelselected')) $action = 'presend'; + + // Presend form + $modelmail='inventory'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->product->dir_output.'/inventory'; + $trackid = 'stockinv'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + */ +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php new file mode 100644 index 00000000000..09f34ae583e --- /dev/null +++ b/htdocs/mrp/mo_document.php @@ -0,0 +1,167 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 mo_document.php + * \ingroup mrp + * \brief Tab for documents linked to Mo + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp","companies","other","mails")); + + +$action=GETPOST('action', 'aZ09'); +$confirm=GETPOST('confirm'); +$id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$ref = GETPOST('ref', 'alpha'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mrp', $id); + +// Get parameters +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; +//if (! $sortfield) $sortfield="position_name"; + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('modocument','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity?$object->entity:$conf->entity] . "/mo/" . dol_sanitizeFileName($object->id); +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity?$object->entity:$conf->entity] . "/mo/" . dol_sanitizeFileName($object->ref); + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; + + +/* + * View + */ + +$form = new Form($db); + +$title=$langs->trans("Mo").' - '.$langs->trans("Files"); +$help_url=''; +//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('', $title, $help_url); + +if ($object->id) +{ + /* + * Show tabs + */ + $head = moPrepareHead($object); + + dol_fiche_head($head, 'document', $langs->trans("Mo"), -1, $object->picto); + + + // Build file list + $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + // Number of files + print ''; + + // Total size + print ''; + + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print '
'; + + dol_fiche_end(); + + $modulepart = 'mrp'; + //$permission = $user->rights->mrp->create; + $permission = 1; + //$permtoedit = $user->rights->mrp->create; + $permtoedit = 1; + $param = '&id=' . $object->id; + + //$relativepathwithnofile='mo/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile='mo/' . dol_sanitizeFileName($object->ref).'/'; + + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + accessforbidden('', 0, 1); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php new file mode 100644 index 00000000000..891ad76eaf8 --- /dev/null +++ b/htdocs/mrp/mo_list.php @@ -0,0 +1,602 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 mo_list.php + * \ingroup mrp + * \brief List page for mo + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL',1); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + +// load mrp libraries +require_once __DIR__ . '/class/mo.class.php'; + +// for other modules +//dol_include_once('/othermodule/class/otherobject.class.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp","other")); + +$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'molist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id', 'int'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +//if (! $sortfield) $sortfield="p.date_fin"; +//if (! $sortorder) $sortorder="DESC"; + +// Initialize technical objects +$object = new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('molist')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (! $sortorder) $sortorder="ASC"; + +// Security check +if (empty($conf->mrp->enabled)) accessforbidden('Module not enabled'); +$socid=0; +if ($user->societe_id > 0) // Protection if external user +{ + //$socid = $user->societe_id; + accessforbidden(); +} +//$result = restrictedArea($user, 'mrp', $id, ''); + + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +} + +// Definition of fields for list +$arrayfields=array(); +foreach($object->fields as $key => $val) +{ + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); +} +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='Mo'; + $objectlabel='Mo'; + $permtoread = $user->rights->mrp->read; + $permtodelete = $user->rights->mrp->delete; + $uploaddir = $conf->mrp->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + */ + +$form=new Form($db); + +$now=dol_now(); + +//$help_url="EN:Module_Mo|FR:Module_Mo_FR|ES:Módulo_Mo"; +$help_url=''; +$title = $langs->trans('ListOfManufacturingOrders'); + + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/', '', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql.=" WHERE 1 = 1"; +foreach($search as $key => $val) +{ + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); +} +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); +*/ + +$sql.=$db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { + $page = 0; + $offset = 0; + } +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; +} +else +{ + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// 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($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/mrp/mo_card.php', 1).'?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +foreach($search as $key => $val) +{ + if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); + else $param.= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>$langs->trans("Validate"), + //'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), +); +if ($user->rights->mrp->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/mrp/mo_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->mrp->write); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cubes', 0, $newcardbutton, '', $limit); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail="SendMoRef"; +$modelmail="mo"; +$objecttmp=new Mo($db); +$trackid='xxxx'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($search_all) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
';*/ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $cssforfield=(empty($val['css'])?'':$val['css']); + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $cssforfield=(empty($val['css'])?'':$val['css']); + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine=0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) + { + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + } +} + + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (property_exists($obj, $key)) $object->$key = $obj->$key; + } + + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { + $cssforfield=(empty($val['css'])?'':$val['css']); + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + else print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''; + + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + else print ''; + } + } + print ''; +} + +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; +} + + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; + if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 0, 0, 0, '', 'maxwidth75'); + else print ''; + print ''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&', '&', $param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mrp->read; + $delallowed=$user->rights->mrp->write; + + print $formfile->showdocuments('massfilesarea_mrp', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php new file mode 100644 index 00000000000..a006f79a609 --- /dev/null +++ b/htdocs/mrp/mo_note.php @@ -0,0 +1,165 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 mo_note.php + * \ingroup mrp + * \brief Car with notes on Mo + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp","companies")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('monote','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mrp', $id); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity] . "/" . $object->id; + +$permissionnote=1; +//$permissionnote=$user->rights->mrp->creer; // Used by the include of actions_setnotes.inc.php + + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + + +/* + * View + */ + +$form = new Form($db); + +//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; +$help_url=''; +llxHeader('', $langs->trans('Mo'), $help_url); + +if ($id > 0 || ! empty($ref)) +{ + $object->fetch_thirdparty(); + + $head = moPrepareHead($object); + + dol_fiche_head($head, 'note', $langs->trans("Mo"), -1, $object->picto); + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mrp->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + + + $cssclass="titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '
'; + + dol_fiche_end(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/modulebuilder.txt b/htdocs/mrp/modulebuilder.txt new file mode 100644 index 00000000000..24ea0d6eac5 --- /dev/null +++ b/htdocs/mrp/modulebuilder.txt @@ -0,0 +1,3 @@ +# DO NOT DELETE THIS FILE MANUALLY +# File to flag module built using official module template. +# When this file is present into a module directory, you can edit it with the module builder tool. Use ModuleBuilder if you want to delete module. \ No newline at end of file diff --git a/htdocs/mrp/sql/llx_mrp_mo.key.sql b/htdocs/mrp/sql/llx_mrp_mo.key.sql new file mode 100644 index 00000000000..071a663dd56 --- /dev/null +++ b/htdocs/mrp/sql/llx_mrp_mo.key.sql @@ -0,0 +1,35 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 http://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_rowid (rowid); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_ref (ref); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_entity (entity); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_qty (qty); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_soc (fk_soc); +ALTER TABLE llx_mrp_mo ADD CONSTRAINT llx_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES user(rowid); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_status (status); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_product (fk_product); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_start_planned (date_start_planned); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_end_planned (date_end_planned); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_bom (fk_bom); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_project (fk_project); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_mrp_mo ADD UNIQUE INDEX uk_mrp_mo_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_mrp_mo ADD CONSTRAINT llx_mrp_mo_fk_field FOREIGN KEY (fk_field) REFERENCES llx_mrp_myotherobject(rowid); + diff --git a/htdocs/mrp/sql/llx_mrp_mo.sql b/htdocs/mrp/sql/llx_mrp_mo.sql new file mode 100644 index 00000000000..dbb8b0faa01 --- /dev/null +++ b/htdocs/mrp/sql/llx_mrp_mo.sql @@ -0,0 +1,39 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 http://www.gnu.org/licenses/. + + +CREATE TABLE llx_mrp_mo( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + entity integer DEFAULT 1 NOT NULL, + label varchar(255), + qty real NOT NULL, + fk_soc integer, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer NOT NULL, + fk_product integer NOT NULL, + date_start_planned datetime, + date_end_planned datetime, + fk_bom integer, + fk_project integer + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql b/htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql new file mode 100644 index 00000000000..5b280acc41f --- /dev/null +++ b/htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql @@ -0,0 +1,19 @@ +-- Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson +-- +-- 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 http://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_mrp_myobject_extrafields ADD INDEX idx_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/mrp/sql/llx_mrp_mo_extrafields.sql b/htdocs/mrp/sql/llx_mrp_mo_extrafields.sql new file mode 100644 index 00000000000..9245ac1c341 --- /dev/null +++ b/htdocs/mrp/sql/llx_mrp_mo_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson +-- +-- 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 http://www.gnu.org/licenses/. + +create table llx_mrp_myobject_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + From ccd9da99f45dc9a15c6e2223c7f5d7ca32921d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Oct 2019 20:11:15 +0200 Subject: [PATCH 29/84] Update list.php --- htdocs/comm/action/list.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index efb11a7e22b..65f593e26a0 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -21,7 +21,7 @@ */ /** - * \file htdocs/comm/action/list.php + * \file htdocs/comm/action/list.php * \ingroup agenda * \brief Page to list actions */ @@ -239,7 +239,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $sql = "SELECT"; if ($usergroup > 0) $sql.=" DISTINCT"; $sql.= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; -$sql.= " a.id, a.label, a.note, a.datep as dp, a.datep2 as dp2,"; +$sql.= " a.id, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; $sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= " a.fk_contact, a.note, a.percent as percent,"; $sql.= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; @@ -286,14 +286,14 @@ if (! empty($actioncode)) elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; else { - if (is_array($actioncode)) - { - $sql.=" AND c.code IN ('".implode("','", $actioncode)."')"; - } - else - { - $sql.=" AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; - } + if (is_array($actioncode)) + { + $sql.=" AND c.code IN ('".implode("','", $actioncode)."')"; + } + else + { + $sql.=" AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; + } } } } @@ -460,7 +460,7 @@ if ($resql) print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0); print ''; } - if (! empty($arrayfields['a.datep2']['checked'])) { + if (! empty($arrayfields['a.datep2']['checked'])) { print ''; print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0); print ''; @@ -548,6 +548,7 @@ if ($resql) $actionstatic->type_label=$obj->type_label; $actionstatic->type_picto=$obj->type_picto; $actionstatic->label=$obj->label; + $actionstatic->location = $obj->location; $actionstatic->note=dol_htmlentitiesbr($obj->note); print ''; @@ -609,11 +610,11 @@ if ($resql) print $form->textwithtooltip(dol_trunc($text, 40), $actionstatic->note); print ''; } - + $formatToUse = $obj->fulldayevent?'day':'dayhour'; // Start date if (! empty($arrayfields['a.datep']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->dp), "dayhour"); + print dol_print_date($db->jdate($obj->dp), $formatToUse); $late=0; if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1; if ($obj->percent == 0 && ! $obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1; @@ -626,7 +627,7 @@ if ($resql) // End date if (! empty($arrayfields['a.datep2']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->dp2), "dayhour"); + print dol_print_date($db->jdate($obj->dp2), $formatToUse); print ''; } From 12f1962085501bd3f735ae56d0558fba3bc306ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 00:40:42 +0200 Subject: [PATCH 30/84] Better error message when module file is corrupted --- htdocs/admin/modules.php | 2 +- htdocs/langs/en_US/errors.lang | 1 + htdocs/mrp/class/mo.class.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 787f3ded291..f26e657679a 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -190,7 +190,7 @@ if ($action=='install') //var_dump($modulenamedir); if (! dol_is_dir($modulenamedir)) { - setEventMessages($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat").'
Dir not found: '.$conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename.'
'.$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename, null, 'errors'); + setEventMessages($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat").'
'.$langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat2", $modulename, 'htdocs/'.$modulename), null, 'errors'); $error++; } } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index f8c3c1a1aee..0b4b9b61746 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -196,6 +196,7 @@ ErrorPhpMailDelivery=Check that you don't use a too high number of recipients an ErrorUserNotAssignedToTask=User must be assigned to task to be able to enter time consumed. ErrorTaskAlreadyAssigned=Task already assigned to user ErrorModuleFileSeemsToHaveAWrongFormat=The module package seems to have a wrong format. +ErrorModuleFileSeemsToHaveAWrongFormat2=At least one mandatory directory must exists into zip of module: %s or %s ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package (%s) does not match expected name syntax: %s ErrorDuplicateTrigger=Error, duplicate trigger name %s. Already loaded from %s. ErrorNoWarehouseDefined=Error, no warehouses defined. diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index a459a582bba..d485ec0ef16 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1,3 +1,4 @@ + * Copyright (C) ---Put here your own copyright and developer email--- From b0355dd1498368d293cf1a61cb5ee1e380c06dbb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 01:20:58 +0200 Subject: [PATCH 31/84] Module BOM have now status DRAFT, VALIDATED, DISABLED --- htdocs/bom/bom_card.php | 143 ++++++++++++++++++++++- htdocs/bom/class/bom.class.php | 103 +++++++++------- htdocs/commande/class/commande.class.php | 2 +- htdocs/core/class/commonobject.class.php | 53 ++++++++- htdocs/langs/en_US/mrp.lang | 5 +- 5 files changed, 252 insertions(+), 54 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 5f3ec89da61..899fcdbe0e6 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -206,6 +206,62 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } + + if ($action == 'confirm_close' && $confirm == 'yes' && $permissionedit) + { + $result = $object->cancel($user); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissionedit) + { + $result = $object->reopen($user); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } @@ -339,13 +395,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } $text = $langs->trans('ConfirmValidateBom', $numref); - if (! empty($conf->notification->enabled)) + /*if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('BOM_VALIDATE', $object->socid, $object); - } + }*/ $formquestion=array(); if (! empty($conf->bom->enabled)) @@ -362,7 +418,67 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + } + + // Confirmation of closing + if ($action == 'close') + { + $text = $langs->trans('ConfirmCloseBom', $object->ref); + /*if (! empty($conf->notification->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); + }*/ + + $formquestion=array(); + if (! empty($conf->bom->enabled)) + { + $langs->load("mrp"); + require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Close'), $text, 'confirm_close', $formquestion, 0, 1, 220); + } + + // Confirmation of reopen + if ($action == 'reopen') + { + $text = $langs->trans('ConfirmReopenBom', $object->ref); + /*if (! empty($conf->notification->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); + }*/ + + $formquestion=array(); + if (! empty($conf->bom->enabled)) + { + $langs->load("mrp"); + require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpen'), $text, 'confirm_reopen', $formquestion, 0, 1, 220); } // Clone confirmation @@ -546,20 +662,35 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Modify').''."\n"; } + // Validate if ($user->rights->bom->write && $object->status == BOM::STATUS_DRAFT) { - print ''; + if (is_array($object->lines) && count($object->lines) > 0) + { + print '' . $langs->trans("Validate") . ''; + } + else + { + print '' . $langs->trans("Validate") . ''; + } } + // Close / Cancel if ($user->rights->bom->write && $object->status == BOM::STATUS_VALIDATED) { - print ''; + print '' . $langs->trans("Disable") . ''; + } + + // Re-open + if ($user->rights->bom->write && $object->status == BOM::STATUS_CANCELED) + { + print '' . $langs->trans("ReOpen") . ''; } // Clone if ($user->rights->bom->write) { - print ''; + print '' . $langs->trans("ToClone") . ''; } /* diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index c8855c9cc03..3968c6d2813 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -640,62 +640,75 @@ class BOM extends CommonObject * Set draft status * * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - public function setDraft($user) + public function setDraft($user, $notrigger = 0) { - global $conf, $langs; + // Protection + if ($this->status <= self::STATUS_DRAFT) + { + return 0; + } - $error=0; + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->bom_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ - // Protection - if ($this->status <= self::STATUS_DRAFT) - { - return 0; - } + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'BOM_UNVALIDATE'); + } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->bom_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) + { + return 0; + } - $this->db->begin(); + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->bom_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ - $sql = "UPDATE ".MAIN_DB_PREFIX."bom"; - $sql.= " SET status = ".self::STATUS_DRAFT; - $sql.= " WHERE rowid = ".$this->id; + return $this->setStatusCommon($user, self::STATUS_CANCELED, 'BOM_CLOSE'); + } - dol_syslog(get_class($this)."::setDraft", LOG_DEBUG); - if ($this->db->query($sql)) - { - if (! $error) - { - $this->oldcopy= clone $this; - } + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) + { + return 0; + } - if (!$error) { - // Call trigger - $result=$this->call_trigger('BOM_UNVALIDATE', $user); - if ($result < 0) $error++; - } + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->bom_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ - if (!$error) { - $this->status=self::STATUS_DRAFT; - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } + return $this->setStatusCommon($user, self::STATUS_VALIDATED, 'BOM_REOPEN'); } /** diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 16d9dcdc3d8..66a15857a04 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -647,7 +647,7 @@ class Commande extends CommonOrder $now=dol_now(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET fk_statut = '.self::STATUS_CLOSED.','; $sql.= ' fk_user_cloture = '.$user->id.','; $sql.= " date_cloture = '".$this->db->idate($now)."'"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 484bb5fa4d4..d17d49e326e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7399,7 +7399,7 @@ abstract class CommonObject if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref']=dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data - + $keys=array(); $values = array(); foreach ($fieldvalues as $k => $v) { @@ -7857,6 +7857,57 @@ abstract class CommonObject } } + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $status New status to set (often a constant like self::STATUS_XXX) + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $triggercode Trigger code to use + * @return int <0 if KO, >0 if OK + */ + public function setStatusCommon($user, $status, $notrigger = 0, $triggercode = '') + { + $error=0; + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " SET status = ".$status; + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + if (! $error) + { + $this->oldcopy= clone $this; + } + + if (! $error && ! $notrigger) { + // Call trigger + $result=$this->call_trigger($triggercode, $user); + if ($result < 0) $error++; + } + + if (!$error) { + $this->status = $status; + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** * Initialise object with example values * Id must be 0 if object instance is a specimen diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 9d8e85f889d..601fe792cd6 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -27,4 +27,7 @@ DateStartPlannedMo=Date start planned DateEndPlannedMo=Date end planned KeepEmptyForAsap=Empty means 'As Soon As Possible' EstimatedDuration=Estimated duration -EstimatedDurationDesc=Estimated duration to manufacture this product using this BOM \ No newline at end of file +EstimatedDurationDesc=Estimated duration to manufacture this product using this BOM +ConfirmValidateBom=Are you sure you want to validate this BOM (you will be able to use it to build new Manufacturing Orders) +ConfirmCloseBom=Are you sure you want to cancel this BOM (you won't be able to use it to build new Manufacturing Orders anymore) ? +ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders) \ No newline at end of file From d3df04c5aa4b9cd6ca856715e695c30eb1e51a86 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 01:36:07 +0200 Subject: [PATCH 32/84] Mutualize code --- htdocs/bom/bom_card.php | 84 ------------------ htdocs/bom/class/bom.class.php | 9 +- htdocs/core/actions_addupdatedelete.inc.php | 88 ++++++++++++++++++- .../template/class/myobject.class.php | 76 ++++++++++++++++ 4 files changed, 168 insertions(+), 89 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 899fcdbe0e6..15ae8f3c21f 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -178,90 +178,6 @@ if (empty($reshook)) $action = ''; } } - - if ($action == 'confirm_validate' && $confirm == 'yes' && $permissionedit) - { - $result = $object->valid($user); - if ($result >= 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - if ($action == 'confirm_close' && $confirm == 'yes' && $permissionedit) - { - $result = $object->cancel($user); - if ($result >= 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissionedit) - { - $result = $object->reopen($user); - if ($result >= 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 3968c6d2813..284191d0672 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -513,7 +513,7 @@ class BOM extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if OK, 0=Nothing done, >0 if KO */ - public function valid($user, $notrigger = 0) + public function validate($user, $notrigger = 0) { global $conf, $langs; @@ -553,7 +553,7 @@ class BOM extends CommonObject $this->newref = $num; // Validate - $sql = "UPDATE ".MAIN_DB_PREFIX."bom_bom"; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql.= " SET ref = '".$this->db->escape($num)."',"; $sql.= " status = ".self::STATUS_VALIDATED.","; $sql.= " date_valid='".$this->db->idate($now)."',"; @@ -683,7 +683,7 @@ class BOM extends CommonObject return -1; }*/ - return $this->setStatusCommon($user, self::STATUS_CANCELED, 'BOM_CLOSE'); + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'BOM_CLOSE'); } /** @@ -708,9 +708,10 @@ class BOM extends CommonObject return -1; }*/ - return $this->setStatusCommon($user, self::STATUS_VALIDATED, 'BOM_REOPEN'); + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOM_REOPEN'); } + /** * Return a link to the object card (with optionaly the picto) * diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 66428eea974..abe80b5a832 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -18,7 +18,7 @@ /** * \file htdocs/core/actions_addupdatedelete.inc.php - * \brief Code for common actions cancel / add / update / delete / clone + * \brief Code for common actions cancel / add / update / update_extras / delete / deleteline / validate / cancel / reopen / clone */ @@ -231,6 +231,92 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiont } } +// Action validate object +if ($action == 'confirm_validate' && $confirm == 'yes' && $permissionedit) +{ + $result = $object->valid($user); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +// Action close object +if ($action == 'confirm_close' && $confirm == 'yes' && $permissionedit) +{ + $result = $object->cancel($user); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +// Action reopen object +if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissionedit) +{ + $result = $object->reopen($user); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } +} // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd)) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 371c4498da8..5c17723e4dd 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -489,6 +489,82 @@ class MyObject extends CommonObject return $this->deleteLineCommon($user, $idline, $notrigger); } + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) + { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'BOM_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) + { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'BOM_CLOSE'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) + { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOM_REOPEN'); + } + /** * Return a link to the object card (with optionaly the picto) * From ffc48209702ed36c9effb9c30764ed925144cf0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 02:05:23 +0200 Subject: [PATCH 33/84] Fix counter of BOM --- htdocs/bom/bom_card.php | 4 ++-- htdocs/bom/class/bom.class.php | 6 +++--- htdocs/core/actions_addupdatedelete.inc.php | 2 +- htdocs/core/modules/bom/mod_bom_advanced.php | 6 +++--- htdocs/core/modules/bom/mod_bom_standard.php | 10 +++++----- htdocs/langs/en_US/mrp.lang | 2 +- htdocs/modulebuilder/template/myobject_card.php | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 15ae8f3c21f..8e6551e92ea 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -97,8 +97,8 @@ if (empty($reshook)) $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; if (empty($backtopage)) { - if (empty($id)) $backtopage = $backurlforlist; - else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.$id; + if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist; + else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 284191d0672..d8e5387f075 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -524,7 +524,7 @@ class BOM extends CommonObject // Protection if ($this->statut == self::STATUS_VALIDATED) { - dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING); + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); return 0; } @@ -560,7 +560,7 @@ class BOM extends CommonObject $sql.= " fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::valid()", LOG_DEBUG); + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { @@ -597,7 +597,7 @@ class BOM extends CommonObject $dirdest = $conf->bom->dir_output.'/'.$newref; if (! $error && file_exists($dirsource)) { - dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); + dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) { diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index abe80b5a832..7082bc5e882 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -234,7 +234,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiont // Action validate object if ($action == 'confirm_validate' && $confirm == 'yes' && $permissionedit) { - $result = $object->valid($user); + $result = $object->validate($user); if ($result >= 0) { // Define output language diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index be6bd9f095d..eed79c037fd 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -118,11 +118,11 @@ class mod_bom_advanced extends ModeleNumRefboms /** * Return next free value * - * @param Societe $objsoc Object thirdparty + * @param Product $objprod Object product * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - public function getNextValue($objsoc, $object) + public function getNextValue($objprod, $object) { global $db,$conf; @@ -139,7 +139,7 @@ class mod_bom_advanced extends ModeleNumRefboms $date = ($object->date_bom ? $object->date_bom : $object->date); - $numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', $objsoc, $date); + $numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', null, $date); return $numFinal; } diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index af7e173bbae..5eacb3289df 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -108,16 +108,16 @@ class mod_bom_standard extends ModeleNumRefboms /** * Return next free value * - * @param Societe $objsoc Object thirdparty + * @param Product $objprod Object product * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - public function getNextValue($objsoc, $object) + public function getNextValue($objprod, $object) { global $db,$conf; // D'abord on recupere la valeur max - $posindice=8; + $posindice=9; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom"; $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; @@ -137,9 +137,9 @@ class mod_bom_standard extends ModeleNumRefboms } //$date=time(); - $date=$object->date; + $date=$object->date_creation; $yymm = strftime("%y%m", $date); - +; if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is else $num = sprintf("%04s", $max+1); diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 601fe792cd6..9fbbe6a7161 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -28,6 +28,6 @@ DateEndPlannedMo=Date end planned KeepEmptyForAsap=Empty means 'As Soon As Possible' EstimatedDuration=Estimated duration EstimatedDurationDesc=Estimated duration to manufacture this product using this BOM -ConfirmValidateBom=Are you sure you want to validate this BOM (you will be able to use it to build new Manufacturing Orders) +ConfirmValidateBom=Are you sure you want to validate the BOM with the reference %s (you will be able to use it to build new Manufacturing Orders) ConfirmCloseBom=Are you sure you want to cancel this BOM (you won't be able to use it to build new Manufacturing Orders anymore) ? ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders) \ No newline at end of file diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 01d800f23c8..c443641ffd6 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -129,7 +129,7 @@ if (empty($reshook)) $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); if (empty($backtopage)) { - if (empty($id)) $backtopage = $backurlforlist; + if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist; else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record From b0de030f3e732aa8fb9b0244b4fd03688cd52981 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 02:05:47 +0200 Subject: [PATCH 34/84] phpcs --- htdocs/core/modules/bom/mod_bom_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index 5eacb3289df..eefbc7570c0 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -139,7 +139,7 @@ class mod_bom_standard extends ModeleNumRefboms //$date=time(); $date=$object->date_creation; $yymm = strftime("%y%m", $date); -; + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is else $num = sprintf("%04s", $max+1); From fc90916de944287e9327915ca7de3336c51be4b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 03:17:53 +0200 Subject: [PATCH 35/84] Look and feel v11 --- htdocs/bom/bom_list.php | 48 +- htdocs/mrp/mo_list.php | 21 +- htdocs/product/inventory/list.php | 92 ++- htdocs/product/stock/class/entrepot.class.php | 24 + htdocs/product/stock/list.php | 592 ++++++++++++------ 5 files changed, 479 insertions(+), 298 deletions(-) diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 635f0f9db65..46473d52ddb 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -21,6 +21,7 @@ * \ingroup bom * \brief List page for bom */ + // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -99,7 +100,7 @@ $arrayfields=array(); foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) @@ -179,8 +180,9 @@ foreach($object->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) +if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -213,6 +215,7 @@ foreach($object->fields as $key => $val) // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +} // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook @@ -258,7 +261,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && { $obj = $db->fetch_object($resql); $id = $obj->rowid; - header("Location: ".dol_buildpath('/bom/bom_card.php', 1).'?id='.$id); + header("Location: ".DOL_URL_ROOT.'/bom/bom_card.php?id='.$id); exit; } @@ -290,7 +293,8 @@ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&con if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); foreach($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); + else $param.= '&search_'.$key.'='.urlencode($search[$key]); } if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -315,19 +319,7 @@ print ''; print ''; print ''; -$newcardbutton=''; -//if ($user->rights->bom->creer) -//{ - $newcardbutton=''.$langs->trans('New').''; - $newcardbutton.= ''; - $newcardbutton.= ''; -//} -//else -//{ -// $newcardbutton=''.$langs->trans('New').''; -// $newcardbutton.= ''; -// $newcardbutton.= ''; -//} +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cubes', 0, $newcardbutton, '', $limit); @@ -338,10 +330,10 @@ $objecttmp=new BOM($db); $trackid='xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) +if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -424,7 +416,7 @@ $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sort $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print ''."\n"; @@ -460,12 +452,14 @@ while ($i < min($num, $limit)) foreach($object->fields as $key => $val) { $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; - + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (! empty($arrayfields['t.'.$key]['checked'])) { print ''; @@ -488,7 +482,7 @@ while ($i < min($num, $limit)) $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print ''; + print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 891ad76eaf8..2f32058a41f 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -42,20 +42,7 @@ //if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL',1); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -409,11 +396,11 @@ foreach($object->fields as $key => $val) if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; if (! empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 0, 0, 0, '', 'maxwidth75'); + if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print ''; print ''; } @@ -442,7 +429,7 @@ foreach($object->fields as $key => $val) if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; if (! empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index b81e989cbb9..59c81c83e29 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -21,6 +21,7 @@ * \brief List page for inventory */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -30,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; // Load translation files required by the page $langs->loadLangs(array("stocks","other")); -$action = GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation @@ -47,7 +48,7 @@ $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -67,7 +68,7 @@ if (! $sortorder) $sortorder="ASC"; // Security check $socid=0; -if ($user->societe_id > 0) +if ($user->societe_id > 0) // Protection if external user { //$socid = $user->societe_id; accessforbidden(); @@ -101,10 +102,10 @@ $arrayfields=array(); foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -119,8 +120,6 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); /* * Actions - * - * Put here all code to do according to value of "$action" parameter */ if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } @@ -164,8 +163,6 @@ if (empty($reshook)) /* * View - * - * Put here all code to render page */ $form=new Form($db); @@ -192,10 +189,10 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); +$sql=preg_replace('/,\s*$/', '', $sql); $sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('myobject').")"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; else $sql.=" WHERE 1 = 1"; foreach($search as $key => $val) { @@ -218,11 +215,14 @@ foreach($object->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +} // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); */ $sql.=$db->order($sortfield, $sortorder); @@ -231,18 +231,17 @@ $sql.=$db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { $page = 0; $offset = 0; } } -// if total resultset is smaller the limit, no need to do paging. +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { - $resql = $result; $num = $nbtotalofrecords; } else @@ -274,21 +273,6 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('', $title, $help_url); -// Example : Adding jquery code -print ''; - $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; @@ -296,7 +280,8 @@ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&con if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); foreach($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); + else $param.= '&search_'.$key.'='.urlencode($search[$key]); } if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -308,7 +293,7 @@ $arrayofmassactions = array( //'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); print '
'; @@ -321,7 +306,9 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, '', '', $limit); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) $topicmail="Information"; @@ -330,7 +317,7 @@ $objecttmp=new Inventory($db); $trackid='inve'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) +if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; @@ -415,13 +402,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine=0; -if (! empty($extrafields->attributes[$object->table_element]['computed'])) { +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object @@ -448,16 +437,21 @@ while ($i < min($num, $limit)) print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; + $cssforfield=(empty($val['css'])?'':$val['css']); + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (! empty($arrayfields['t.'.$key]['checked'])) { - print ''; - print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + else print $object->showOutputField($val, $key, $obj->$key, ''); print ''; if (! $i) $totalarray['nbfield']++; if (! empty($val['isameasure'])) @@ -474,7 +468,7 @@ while ($i < min($num, $limit)) $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print ''; + print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; @@ -484,7 +478,7 @@ while ($i < min($num, $limit)) print ''; if (! $i) $totalarray['nbfield']++; - print ''; + print ''."\n"; $i++; } diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 824934992bf..004ad49ce46 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -95,6 +95,30 @@ class Entrepot extends CommonObject // List of short language codes for status public $statuts = array(); + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10), + 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-2, 'showoncombobox'=>1, 'position'=>25), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30), + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35), + 'lieu' =>array('type'=>'varchar(64)', 'label'=>'LocationSummary', 'enabled'=>1, 'visible'=>-2, 'position'=>40), + 'fk_parent' =>array('type'=>'integer', 'label'=>'ParentWarehouse', 'enabled'=>1, 'visible'=>-2, 'position'=>41), + 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-2, 'position'=>45), + 'zip' =>array('type'=>'varchar(10)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-2, 'position'=>50), + 'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-2, 'position'=>55), + 'fk_departement' =>array('type'=>'integer', 'label'=>'State', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'fk_pays' =>array('type'=>'integer', 'label'=>'Country', 'enabled'=>1, 'visible'=>-2, 'position'=>65), + //'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-2, 'position'=>82), + //'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>-2, 'position'=>84), + //'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportKey', 'enabled'=>1, 'visible'=>-2, 'position'=>85), + 'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-2, 'position'=>200), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + ); + + /** * Constructor * diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index ae39ba63f3b..b38888be9bb 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -28,34 +28,50 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; // Load translation files required by the page -$langs->load("stocks"); +$langs->loadLangs(array("stocks","other")); -// Security check -$result=restrictedArea($user, 'stock'); +$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'stocklist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); $search_ref=GETPOST("sref", "alpha")?GETPOST("sref", "alpha"):GETPOST("search_ref", "alpha"); $search_label=GETPOST("snom", "alpha")?GETPOST("snom", "alpha"):GETPOST("search_label", "alpha"); $search_status=GETPOST("search_status", "int"); +// Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$sortfield = GETPOST("sortfield"); -$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortfield) $sortfield="e.ref"; if (! $sortorder) $sortorder="ASC"; -$page = GETPOST("page"); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page; + +// Security check +$result=restrictedArea($user, 'stock'); + $year = strftime("%Y", time()); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Entrepot($db); -$hookmanager->initHooks(array('stocklist')); $extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('stocklist')); -// fetch optionals attributes and labels +// Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); + $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -69,30 +85,69 @@ $fieldstosearchall = array( 'e.town'=>'Town', ); - -// Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +// Definition of fields for list +$arrayfields=array( + 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70), + 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71), + 'sellvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72), +); +foreach($object->fields as $key => $val) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - $search_ref=""; - $sall=""; - $search_label=""; - $search_status=""; - $search_array_options=array(); + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_ref=""; + $sall=""; + $search_label=""; + $search_status=""; + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='Entrepot'; + $objectlabel='Warehouse'; + $permtoread = $user->rights->stock->lire; + $permtodelete = $user->rights->stock->supprimer; + $uploaddir = $conf->stock->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -103,6 +158,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $form=new Form($db); $warehouse=new Entrepot($db); +$now=dol_now(); + +$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; +$title = $langs->trans("ListOfWarehouses"); + + +// Build and execute select +// -------------------------------------------------------------------- $sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; $sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; // Add fields from extrafields @@ -115,16 +178,16 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -//$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; +$sql=preg_replace('/,\s*$/', '', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; $sql.= " WHERE e.entity IN (".getEntity('stock').")"; if ($search_ref) $sql.= natural_search("e.ref", $search_ref); // ref if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -149,189 +212,308 @@ if ($result) } } $sql.= $db->order($sortfield, $sortorder); -$sql.= $db->plimit($limit+1, $offset); -$result = $db->query($sql); -if ($result) +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $num = $db->num_rows($result); - - $i = 0; - - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - llxHeader("", $langs->trans("ListOfWarehouses"), $help_url); - - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_label) $param.="&search_label=".urlencode($search_label); - if ($search_status) $param.="&search_status=".urlencode($search_status); - if ($sall) $param.="&sall=".urlencode($sall); - - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - - $newcardbutton=''; - if ($user->rights->stock->creer) + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { - $newcardbutton=''.$langs->trans('MenuNewWarehouse').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $page = 0; + $offset = 0; } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'generic', 0, $newcardbutton, '', $limit); - - if ($sall) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; - } - - $moreforfilter=''; - - print '
'; - print ''."\n"; - - // Fields title search - print ''; - - print ''; - - print ''; - - print ''; - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - - print ''; - - print ''; - - print ''; - - print ''; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); - print "\n"; - - if ($num) - { - $warehouse=new Entrepot($db); - $var=false; - $totalarray=array(); - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($result); - - $warehouse->id = $obj->rowid; - $warehouse->ref = $obj->ref; - $warehouse->label = $obj->ref; - $warehouse->lieu = $obj->lieu; - $warehouse->fk_parent = $obj->fk_parent; - $warehouse->statut = $obj->statut; - - print ''; - print ''; - if (! $i) $totalarray['nbfield']++; - // Location - print ''; - if (! $i) $totalarray['nbfield']++; - - // Stock qty - print ''; - if (! $i) $totalarray['nbfield']++; - - // PMP value - print ''; - if (! $i) $totalarray['nbfield']++; - - // Selling value - print ''; - if (! $i) $totalarray['nbfield']++; - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - - // Status - print ''; - if (! $i) $totalarray['nbfield']++; - - print ''; - if (! $i) $totalarray['nbfield']++; - - print "\n"; - - - $i++; - } - - if ($totalnboflines-$offset <= $limit) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - } - - $db->free($result); - - print "
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); - print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
' . $warehouse->getNomUrl(1) . ''.$obj->lieu.''.price2num($obj->stockqty, 5).''; - if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1); - else print ''; - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1); - else - { - $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); - print $form->textwithtooltip($langs->trans("Variable"), $htmltext); - } - print ''.$warehouse->LibStatut($obj->statut, 5).'
'.$langs->trans("Total").''.price2num($totalStock, 5).''.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency); - else - { - $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); - print $form->textwithtooltip($langs->trans("Variable"), $htmltext); - } - print '
"; - print ""; - - print ''; +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; } else { - dol_print_error($db); + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// 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($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/product/stock/card.php?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($search_ref) $param.="&search_ref=".urlencode($search_ref); +if ($search_label) $param.="&search_label=".urlencode($search_label); +if ($search_status) $param.="&search_status=".urlencode($search_status); +if ($search_all) $param.="&search_all=".urlencode($search_all); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// List of mass actions available +$arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), +); +//if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton = dolGetButtonTitle($langs->trans('MenuNewWarehouse'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->stock->creer); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail="Information"; +$modelmail="warehouse"; +$objecttmp=new Entrepot($db); +$trackid='ware'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + +if ($search_all) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; + $moreforfilter.= $langs->trans('MyFilter') . ': '; + $moreforfilter.= '
';*/ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print ''; + +print ''; + +print ''; + +print ''; +print ''; +print ''; + +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +// Status +print ''; + +// Action column +print ''; +print ''."\n"; + +// Fields title label +// -------------------------------------------------------------------- +print ''; +print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right '); +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +if ($num) +{ + $warehouse=new Entrepot($db); + + $totalarray=array(); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + $warehouse->id = $obj->rowid; + $warehouse->ref = $obj->ref; + $warehouse->label = $obj->ref; + $warehouse->lieu = $obj->lieu; + $warehouse->fk_parent = $obj->fk_parent; + $warehouse->statut = $obj->statut; + + // Show here line of result + print ''; + print ''; + if (! $i) $totalarray['nbfield']++; + // Location + print ''; + if (! $i) $totalarray['nbfield']++; + + // Stock qty + print ''; + if (! $i) $totalarray['nbfield']++; + + // PMP value + print ''; + if (! $i) $totalarray['nbfield']++; + + // Selling value + print ''; + if (! $i) $totalarray['nbfield']++; + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Status + print ''; + if (! $i) $totalarray['nbfield']++; + + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''."\n"; + + + $i++; + } + + if ($totalnboflines-$offset <= $limit) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } +} + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; +print ''; +print ''; +print ''; +print ''; +print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); +print ''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
' . $warehouse->getNomUrl(1) . ''.$obj->lieu.''.price2num($obj->stockqty, 5).''; + if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1); + else print ''; + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1); + else + { + $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); + print $form->textwithtooltip($langs->trans("Variable"), $htmltext); + } + print ''.$warehouse->LibStatut($obj->statut, 5).''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.$langs->trans("Total").''.price2num($totalStock, 5).''.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency); + else + { + $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); + print $form->textwithtooltip($langs->trans("Variable"), $htmltext); + } + print '
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&', '&', $param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page From e07e01580db7de0078259127ec3626ff881efa3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 03:34:32 +0200 Subject: [PATCH 36/84] Replace deprecated code with new one --- htdocs/comm/action/list.php | 4 +++- htdocs/compta/bank/bankentries_list.php | 4 +++- htdocs/compta/bank/card.php | 2 +- htdocs/compta/bank/list.php | 11 ++++++++--- htdocs/contact/list.php | 4 +++- htdocs/contrat/list.php | 4 +++- htdocs/contrat/services_list.php | 4 +++- .../modules/stock/doc/pdf_stdmovement.modules.php | 5 ++++- htdocs/expedition/list.php | 4 +++- htdocs/fichinter/list.php | 4 +++- htdocs/fourn/commande/list.php | 4 +++- htdocs/fourn/facture/list.php | 4 +++- htdocs/product/stock/movement_card.php | 4 +++- htdocs/product/stock/movement_list.php | 4 +++- htdocs/projet/list.php | 6 ++++-- htdocs/projet/tasks/list.php | 4 +++- htdocs/reception/list.php | 4 +++- htdocs/societe/list.php | 4 +++- htdocs/supplier_proposal/list.php | 4 +++- htdocs/user/list.php | 4 +++- 20 files changed, 65 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index efb11a7e22b..38ce916aeee 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -247,7 +247,9 @@ $sql.= " c.code as type_code, c.libelle as type_label,"; $sql.= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 1b0f7feffe4..7f43b24763a 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -473,7 +473,9 @@ $sql.= " ba.rowid as bankid, ba.ref as bankref,"; $sql.= " bu.url_id,"; $sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index fd5a2b42723..ac32ce98c30 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -627,7 +627,7 @@ else $conciliate=$object->canBeConciliated(); if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; - else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); + else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); print ''; print ''.$langs->trans("BalanceMinimalAllowed").''; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 8f87d6f7151..6a143d4a8d1 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -73,7 +73,7 @@ $hookmanager->initHooks(array('bankaccountlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label('bank_account'); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -144,7 +144,9 @@ $accounts = array(); $sql = "SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -514,7 +516,10 @@ foreach ($accounts as $key=>$type) } } } - else print $langs->trans("FeatureDisabled"); + else + { + print ''.$langs->trans("FeatureDisabled").''; + } print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 1eed9497619..9f3dc206447 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -276,7 +276,9 @@ $sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, $sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql.= " co.code as country_code"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index fc110d4a396..0fd27d29826 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -218,7 +218,9 @@ $sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND $sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,'; $sql.= ' SUM('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed'; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 3e5b9f55c98..fac71516e99 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -219,7 +219,9 @@ $sql.= " cd.subprice,"; //$sql.= " cd.date_c as date_creation,"; $sql.= " cd.tms as date_update"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 2a5f797147e..3ed4ff7e813 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -253,6 +253,7 @@ class pdf_stdmovement extends ModelePDFMovement $warehousestatic=new Entrepot($db); $movement=new MouvementStock($db); $userstatic=new User($db); + $element = 'movement'; $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; @@ -262,7 +263,9 @@ class pdf_stdmovement extends ModelePDFMovement $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields - foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); + if (! empty($extrafields->attributes[$element]['label'])) { + foreach ($extrafields->attributes[$element]['label'] as $key => $val) $sql.=($extrafields->attributes[$element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + } // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index ebe0bcfd8df..1840569fd0e 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -192,7 +192,9 @@ $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= ' e.date_creation as date_creation, e.tms as date_update'; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 7160eb8152c..7df7eac69b0 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -209,7 +209,9 @@ if (!empty($conf->contrat->enabled)) { $sql .= ", c.rowid as contrat_id, c.ref as contrat_ref, c.ref_customer as contrat_ref_supplier, c.ref_supplier as contrat_ref_supplier"; } // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 6410f2c9e57..1b1cf0c9b6d 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -492,7 +492,9 @@ $sql.= ' cf.date_creation as date_creation, cf.tms as date_update,'; $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; $sql.= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 862e4d6ece5..4bd6059df3e 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -277,7 +277,9 @@ $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. if (! $search_all) $sql.= ', SUM(pf.amount) as dynamount_payed'; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 0278e1572e6..c08fc8078a8 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -451,7 +451,9 @@ $sql.= " m.type_mouvement,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 73b783e09b9..a4831d46844 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -429,7 +429,9 @@ $sql.= " m.fk_projet,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 59d727c5027..9a5514ff1cc 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -293,8 +293,10 @@ $sql.= ", s.rowid as socid, s.nom as name, s.email"; $sql.= ", cls.code as opp_status_code"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; -// Add fields for extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 00ef201aa9f..e13b7092b26 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -271,7 +271,9 @@ if (! empty($arrayfields['t.tobill']['checked']) || ! empty($arrayfields['t.bill $sql.=" , SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 65fdf153dd4..7978f7eaab3 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -427,7 +427,9 @@ $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= ' e.date_creation as date_creation, e.tms as date_update'; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e29edb07717..7420c417aae 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -388,7 +388,9 @@ if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index f36013b289c..687d98911f2 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -250,7 +250,9 @@ $sql.= " p.rowid as project_id, p.ref as project_ref,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= " u.firstname, u.lastname, u.photo, u.login"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/user/list.php b/htdocs/user/list.php index d65d852294f..5520465a75d 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -198,7 +198,9 @@ $sql.= " u.tms as date_update, u.datec as date_creation,"; $sql.= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2, u2.admin as admin2, u2.fk_soc as fk_soc2, u2.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2,"; $sql.= " s.nom as name, s.canvas"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook From 42d8f276fca2425ea2873c52aa937964c25d58b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 16 Oct 2019 08:17:13 +0200 Subject: [PATCH 37/84] Update mo.class.php --- htdocs/mrp/class/mo.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index d485ec0ef16..a459a582bba 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1,4 +1,3 @@ - * Copyright (C) ---Put here your own copyright and developer email--- From 4bb16770796b07b197c8e1dcdd6fe5a44efd7340 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 16 Oct 2019 10:39:35 +0200 Subject: [PATCH 38/84] Fix - Accountancy - Various payment - Subledger is not recovered in bank journal --- htdocs/accountancy/journal/bankjournal.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 8003cf1c523..a532379c358 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -4,12 +4,12 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2019 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2017-2018 Frédéric France - * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018 Eric Seigne + * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2018 Eric Seigne * * 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 @@ -387,7 +387,9 @@ if ($result) { $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; $paymentvariousstatic->fetch($paymentvariousstatic->id); $account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word - $tabtp[$obj->rowid][$account_various] += $obj->amount; + $account_subledger = (! empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word + $tabpay[$obj->rowid]["account_various"] = $account_various; + $tabtp[$obj->rowid][$account_subledger] += $obj->amount; } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id']; @@ -660,11 +662,11 @@ if (! $error && $action == 'writebookkeeping') { $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'payment_various') { - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; + $bookkeeping->subledger_account = $k; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $tabpay[$obj->rowid]["account_various"]; - $accountingaccount->fetch(null, $k, true); + $accountingaccount->fetch(null, $bookkeeping->numero_compte, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'banktransfert') { $bookkeeping->subledger_account = ''; @@ -1123,6 +1125,7 @@ if (empty($action) || $action == 'view') { if ($tabtype[$key] == 'payment_salary') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; if ($tabtype[$key] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT; + if ($tabtype[$key] == 'payment_various') $account_ledger = $tabpay[$key]["account_various"]; $accounttoshow = length_accounta($account_ledger); if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { @@ -1156,7 +1159,7 @@ if (empty($action) || $action == 'view') { // Subledger account print ""; - if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary'))) // Type of payment with subledger + if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) // Type of payment with subledger { $accounttoshowsubledger = length_accounta($k); if ($accounttoshow != $accounttoshowsubledger) From 5a1682509beb97483b41431dde8f1873d85d4a29 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 16 Oct 2019 11:11:34 +0200 Subject: [PATCH 39/84] FIX It is not possible to create an expedition if there is no unit data --- htdocs/expedition/class/expedition.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 915177164ac..1a9a249effc 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -325,8 +325,8 @@ class Expedition extends CommonObject $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth $sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth $sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql.= ", ".$this->weight_units; - $sql.= ", ".$this->size_units; + $sql.= ", ".($this->weight_units>0?$this->weight_units:'NULL'); + $sql.= ", ".($this->size_units>0?$this->size_units:'NULL'); $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); From 517fcf45d144c6c3ce1639432fd04a6a46967ac3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 11:23:06 +0200 Subject: [PATCH 40/84] Look and feel v11 --- htdocs/modulebuilder/index.php | 39 +++++++++++++++++++++++++++++++++- htdocs/societe/card.php | 18 ++++++++-------- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 5cd32512713..0f5ab5e2c90 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -537,6 +537,26 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', } else { + /** + * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * '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). 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) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * '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_...). + * 'position' is the sort order of field. + * '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 + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ + /*public $fields=array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), @@ -562,14 +582,31 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', $i=10; while ($obj = $db->fetch_object($_results)) { + // fieldname $fieldname = $obj->Field; + // type $type = $obj->Type; if ($type == 'int(11)') $type='integer'; + // notnull $notnull = ($obj->Null == 'YES'?0:1); + // label $label = preg_replace('/_/', ' ', ucfirst($fieldname)); if ($fieldname == 'rowid') $label='ID'; + if ($fieldname == 'import_key') $label='ImportKey'; + // visible + $visible = -1; + if ($fieldname == 'entity') $visible = -2; + if ($fieldname == 'model_pdf') $visible = 0; + // enabled + $enabled = 1; + // default + $default = ''; + if ($fieldname == 'entity') $default=1; - $string.= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."', 'enabled'=>1, 'visible'=>-2"; + $string.= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."',"; + if ($default != '') $string.= " 'default'=>".$default.","; + $string.= " 'enabled'=>".$enabled.","; + $string.= " 'visible'=>".$visible; if ($notnull) $string.= ", 'notnull'=>".$notnull; if ($fieldname == 'ref') $string.= ", 'showoncombobox'=>1"; $string.= ", 'position'=>".$i."),\n"; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e2a8f731856..344fa76fa8d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1293,9 +1293,9 @@ else } // Email / Web - print ''.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', $conf->global->SOCIETE_EMAIL_MANDATORY).''; + print ''.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', $conf->global->SOCIETE_EMAIL_MANDATORY).''; print ''; - print ''.$form->editfieldkey('Web', 'url', '', $object, 0).''; + print ''.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', '', $object, 0).''; print ''; if (! empty($conf->socialnetworks->enabled)) @@ -1335,9 +1335,9 @@ else } // Phone / Fax - print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; + print ''.img_picto('', 'object_phoning').' '.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; print ''; - print ''.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; + print ''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; print ''; // Prof ids @@ -1916,9 +1916,9 @@ else } // EMail / Web - print ''.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; + print ''.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email','alpha'), $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; print ''; - print ''.$form->editfieldkey('Web', 'url', '', $object, 0).''; + print ''.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', GETPOST('url','alpha'), $object, 0).''; print ''; if (! empty($conf->socialnetworks->enabled)) @@ -1950,9 +1950,9 @@ else } // Phone / Fax - print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; + print ''.img_picto('', 'object_phoning').' '.$form->editfieldkey('Phone', 'phone', GETPOST('phone', 'alpha'), $object, 0).''; print ''; - print ''.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; + print ''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).''; print ''; // Prof ids @@ -2666,7 +2666,7 @@ else { print ''."\n"; } - + if (! empty($conf->adherent->enabled)) { $adh = new Adherent($db); From 6d05d42c50178f035e07c4342711c7773ca47cb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 11:26:20 +0200 Subject: [PATCH 41/84] Look and feel v11 --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7bda225978f..b3140c7e051 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2220,7 +2220,7 @@ function dol_print_socialnetworks($value, $cid, $socid, $type) if (! empty($type)) { $newskype ='
'; - $newskype.=img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright'); + $newskype.=img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0); $newskype.=$value; if ($type == 'skype') { From 8d4960954902e7997009d228abf9958ee674fc4d Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Wed, 16 Oct 2019 12:28:50 +0200 Subject: [PATCH 42/84] Fix user time instead of server time it seems that we want to use a user time by clicking on now button. IDEA : may i use client time ??? because if page is old, the now button insert an old time. --- htdocs/core/class/html.form.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d9442e43457..19c01f151cf 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5607,10 +5607,10 @@ class Form $reset_scripts = ""; // Generate the date part, depending on the use or not of the javascript calendar - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y','tzuser').'\');'; /*if ($usecalendar == "eldy") { $base=DOL_URL_ROOT.'/core/'; @@ -5627,7 +5627,7 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H','tzuser').'\');'; if ($fullday) $reset_scripts .= ' } '; } // Update the minute part @@ -5635,7 +5635,7 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M','tzuser').'\');'; if ($fullday) $reset_scripts .= ' } '; } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick From e1521b6c7d28efe5fa495197dcac79dfd7024584 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 12:31:44 +0200 Subject: [PATCH 43/84] Fix phpcs --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 344fa76fa8d..e855cb71b8c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1916,9 +1916,9 @@ else } // EMail / Web - print ''.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email','alpha'), $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; + print ''.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; print ''; - print ''.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', GETPOST('url','alpha'), $object, 0).''; + print ''.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).''; print ''; if (! empty($conf->socialnetworks->enabled)) From a9e57fa2b27a8820331885ff0f453d6efd66672e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 12:32:26 +0200 Subject: [PATCH 44/84] Clean page --- htdocs/modulebuilder/index.php | 46 ++++++++++++++++------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 0f5ab5e2c90..2e22e9fb23e 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1615,7 +1615,7 @@ elseif (! empty($module)) print ''; print '
'; - print load_fiche_titre($langs->trans("DescriptorFile")); + print load_fiche_titre($langs->trans("DescriptorFile"), '', ''); if (! empty($moduleobj)) { @@ -1675,35 +1675,33 @@ elseif (! empty($module)) print ''; print ''; - - print '

'; - - // Readme file - print load_fiche_titre($langs->trans("ReadmeFile")); - - print '
'; - print '
'; - if (dol_is_file($dirread.'/'.$pathtofilereadme)) print $moduleobj->getDescLong(); - else print $langs->trans("ErrorFileNotFound", $pathtofilereadme); - - print '

'; - - // ChangeLog - print load_fiche_titre($langs->trans("ChangeLog")); - - print '
'; - print '
'; - - if (dol_is_file($dirread.'/'.$pathtochangelog)) print $moduleobj->getChangeLog(); - else print $langs->trans("ErrorFileNotFound", $pathtochangelog); - - print '
'; } else { print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; } + if (! empty($moduleobj)) + { + print '

'; + + // Readme file + print load_fiche_titre($langs->trans("ReadmeFile"), '', ''); + + print ''; + if (dol_is_file($dirread.'/'.$pathtofilereadme)) print '
'.$moduleobj->getDescLong().'
'; + else print ''.$langs->trans("ErrorFileNotFound", $pathtofilereadme).''; + + print '

'; + + // ChangeLog + print load_fiche_titre($langs->trans("ChangeLog"), '', ''); + + print ''; + if (dol_is_file($dirread.'/'.$pathtochangelog)) print '
'.$moduleobj->getChangeLog().'
'; + else print ''.$langs->trans("ErrorFileNotFound", $pathtochangelog).''; + } + dol_fiche_end(); } else From bba042c0c31ee10b662bf908996d1dc8aa1dd0e6 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 16 Oct 2019 10:34:47 +0000 Subject: [PATCH 45/84] Fixing style errors. --- htdocs/core/class/html.form.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 19c01f151cf..2130a7d7e38 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5607,10 +5607,10 @@ class Form $reset_scripts = ""; // Generate the date part, depending on the use or not of the javascript calendar - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day','tzuser').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d','tzuser').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m','tzuser').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; /*if ($usecalendar == "eldy") { $base=DOL_URL_ROOT.'/core/'; @@ -5627,7 +5627,7 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; if ($fullday) $reset_scripts .= ' } '; } // Update the minute part @@ -5635,7 +5635,7 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; if ($fullday) $reset_scripts .= ' } '; } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick From 9663205601233fa6fe812ce7d0ec3ce1ad656437 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 13:55:29 +0200 Subject: [PATCH 46/84] FIX css (some buttons not aligned) --- htdocs/theme/eldy/btn.inc.php | 3 ++- htdocs/theme/md/btn.inc.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index a3a952925e3..a9b1a6708a3 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -11,7 +11,8 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> div.divButAction { margin-bottom: 1.4em; } -div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused { +div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused, div.tabsAction > a.butActionDelete, +div.tabsAction > span.butAction, div.tabsAction > span.butActionRefused, div.tabsAction > span.butActionDelete { margin-bottom: 1.4em !important; } div.tabsActionNoBottom > a.butAction, div.tabsActionNoBottom > a.butActionRefused { diff --git a/htdocs/theme/md/btn.inc.php b/htdocs/theme/md/btn.inc.php index be897e8f841..51cdd1ce11b 100644 --- a/htdocs/theme/md/btn.inc.php +++ b/htdocs/theme/md/btn.inc.php @@ -13,7 +13,8 @@ div.divButAction { margin-bottom: 1.4em; vertical-align: top; } -div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused { +div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused, div.tabsAction > a.butActionDelete, +div.tabsAction > span.butAction, div.tabsAction > span.butActionRefused, div.tabsAction > span.butActionDelete { margin-bottom: 1.4em !important; } From 741627897ee2ff709dd59d68787dc60159a27161 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Wed, 16 Oct 2019 13:56:11 +0200 Subject: [PATCH 47/84] fix interchanged allocation --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1ce4dce01a0..42e77c898c3 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1553,7 +1553,7 @@ class ActionComm extends CommonObject else { // use start date as fall-back to avoid import erros on empty end date - $datestart = $dateend; + $dateend = $datestart; } $dateend=$this->db->jdate($obj->datep2)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600)); From b9ec45fd49150c01951282b479e2a3b245ed947d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 14:02:13 +0200 Subject: [PATCH 48/84] Clean code --- htdocs/commande/card.php | 20 ++++---- htdocs/compta/facture/card.php | 84 +++++++++++++++++----------------- test/phpunit/FilesLibTest.php | 4 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0d13537037c..ea423a0a99c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2543,19 +2543,19 @@ if ($action == 'create' && $usercancreate) // Send if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { - print ''; + print '' . $langs->trans('SendMail') . ''; } else - print ''; + print '' . $langs->trans('SendMail') . ''; } // Valid if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && $usercanvalidate) { - print ''; + print '' . $langs->trans('Validate') . ''; } // Edit if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) { - print ''; + print '' . $langs->trans('Modify') . ''; } // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) @@ -2572,9 +2572,9 @@ if ($action == 'create' && $usercancreate) if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($user->rights->ficheinter->creer) { - print ''; + print '' . $langs->trans('AddIntervention') . ''; } else { - print ''; + print '' . $langs->trans('AddIntervention') . ''; } } } @@ -2584,7 +2584,7 @@ if ($action == 'create' && $usercancreate) $langs->load("contracts"); if ($user->rights->contrat->creer) { - print ''; + print '' . $langs->trans('AddContract') . ''; } } @@ -2596,13 +2596,13 @@ if ($action == 'create' && $usercancreate) if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { if ($user->rights->expedition->creer) { - print ''; + print '' . $langs->trans('CreateShipment') . ''; } else { - print ''; + print '' . $langs->trans('CreateShipment') . ''; } } else { $langs->load("errors"); - print ''; + print 'transnoentitiesnoconv("Shipment"))) . '">' . $langs->trans('CreateShipment') . ''; } } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9467cebde59..2a08c55eeba 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4845,20 +4845,20 @@ elseif ($id > 0 || ! empty($ref)) { if ($usercanunvalidate) { - print ''; + print '' . $langs->trans('Modify') . ''; } else { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } } elseif (!$object->is_last_in_cycle()) { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } else { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } } } else { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } } @@ -4874,9 +4874,9 @@ elseif ($id > 0 || ! empty($ref)) { if ($object->close_code != 'replaced' || (! $objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted { - print ''; + print '' . $langs->trans('ReOpen') . ''; } else { - print '
' . $langs->trans('ReOpen') . '
'; + print '' . $langs->trans('ReOpen') . ''; } } @@ -4884,19 +4884,19 @@ elseif ($id > 0 || ! empty($ref)) if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ($usercanvalidate) { - print ''; + print '' . $langs->trans('Validate') . ''; } } // Send by mail if (($object->statut == Facture::STATUS_VALIDATED || $object->statut == Facture::STATUS_CLOSED) || ! empty($conf->global->FACTURE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($objectidnext) { - print '
' . $langs->trans('SendMail') . '
'; + print '' . $langs->trans('SendMail') . ''; } else { if ($usercansend) { - print ''; + print '' . $langs->trans('SendMail') . ''; } else - print ''; + print '' . $langs->trans('SendMail') . ''; } } @@ -4911,7 +4911,7 @@ elseif ($id > 0 || ! empty($ref)) { print ''.$langs->trans("MakeWithdrawRequest").''; } else { - print '
' . $langs->trans('MakeWithdrawRequest') . '
'; + print '' . $langs->trans('MakeWithdrawRequest') . ''; } } else @@ -4930,18 +4930,18 @@ elseif ($id > 0 || ! empty($ref)) { $langs->load("cashdesk"); $receipt_url=DOL_URL_ROOT."/takepos/receipt.php"; - print ''; + print '' . $langs->trans('POSTicket') .''; } // Create payment if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercanissuepayment) { if ($objectidnext) { - print '
' . $langs->trans('DoPayment') . '
'; + print '' . $langs->trans('DoPayment') . ''; } else { //if ($resteapayer == 0) { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) // print '
' . $langs->trans('DoPayment') . '
'; //} else { - print ''; + print '' . $langs->trans('DoPayment') . ''; //} } } @@ -4953,27 +4953,27 @@ elseif ($id > 0 || ! empty($ref)) { if ($resteapayer == 0) { - print '
'.$langs->trans('DoPaymentBack').'
'; + print ''.$langs->trans('DoPaymentBack').''; } else { - print ''; + print ''.$langs->trans('DoPaymentBack').''; } } // For standard invoice with excess received if ($object->type == Facture::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id)) { - print ''; + print ''.$langs->trans('ConvertExcessReceivedToReduc').''; } // For credit note if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && $object->getSommePaiement() == 0) { - print ''; + print '' . $langs->trans('ConvertToReduc') . ''; } // For deposit invoice if ($object->type == Facture::TYPE_DEPOSIT && $usercancreate && $object->statut > 0 && empty($discount->id)) { - print ''; + print ''.$langs->trans('ConvertToReduc').''; } } @@ -4982,7 +4982,7 @@ elseif ($id > 0 || ! empty($ref)) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) ) { - print ''; + print ''.$langs->trans('ClassifyPaid').''; } // Classify 'closed not completely paid' (possible si validee et pas encore classee payee) @@ -4992,7 +4992,7 @@ elseif ($id > 0 || ! empty($ref)) if ($totalpaye > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice - print ''; + print '' . $langs->trans('ClassifyPaidPartially') . ''; } else { @@ -5000,11 +5000,11 @@ elseif ($id > 0 || ! empty($ref)) { if ($objectidnext) { - print '
' . $langs->trans('ClassifyCanceled') . '
'; + print '' . $langs->trans('ClassifyCanceled') . ''; } else { - print ''; + print '' . $langs->trans('ClassifyCanceled') . ''; } } } @@ -5013,7 +5013,7 @@ elseif ($id > 0 || ! empty($ref)) // Clone if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) { - print ''; + print '' . $langs->trans("ToClone") . ''; } // Clone as predefined / Create template @@ -5021,7 +5021,7 @@ elseif ($id > 0 || ! empty($ref)) { if (! $objectidnext && count($object->lines) > 0) { - print ''; + print '' . $langs->trans("ChangeIntoRepeatableInvoice") . ''; } } @@ -5030,7 +5030,7 @@ elseif ($id > 0 || ! empty($ref)) { if (! $objectidnext) { - print ''; + print '' . $langs->trans("CreateCreditNote") . ''; } } @@ -5045,9 +5045,9 @@ elseif ($id > 0 || ! empty($ref)) { if ($usercanunvalidate) { - print ''; + print '' . $langs->trans("CreateCreditNote") . ''; } else { - print '
' . $langs->trans("CreateCreditNote") . '
'; + print '' . $langs->trans("CreateCreditNote") . ''; } } @@ -5063,22 +5063,22 @@ elseif ($id > 0 || ! empty($ref)) { if(($object->total_ttc - $totalcreditnotes ) == 0 ) { - print ''; + print '' . $langs->trans("RemoveSituationFromCycle") . ''; } else { - print ''; + print '' . $langs->trans("RemoveSituationFromCycle") . ''; } } // Create next situation invoice if ($usercancreate && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { if ($object->is_last_in_cycle() && $object->situation_final != 1) { - print ''; + print '' . $langs->trans('CreateNextSituationInvoice') . ''; } elseif (!$object->is_last_in_cycle()) { - print ''; + print '' . $langs->trans('CreateNextSituationInvoice') . ''; } else { - print ''; + print '' . $langs->trans('CreateNextSituationInvoice') . ''; } } @@ -5088,31 +5088,31 @@ elseif ($id > 0 || ! empty($ref)) { //var_dump($isErasable); if ($isErasable == -4) { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable == -3) { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable == -2) { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable == -1) { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable <= 0) // Any other cases { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($objectidnext) { - print ''; + print '' . $langs->trans('Delete') . ''; } else { - print ''; + print '' . $langs->trans('Delete') . ''; } } else { - print ''; + print '' . $langs->trans('Delete') . ''; } } print '
'; diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 9b990d78922..d73d99f7078 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -413,11 +413,11 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $result=dol_compress_file($filein, $fileout, $format, $errorstring); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." : ".$errorstring); + $this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." into ".$fileout." : ".$errorstring); $result=dol_uncompress($fileout, $dirout); print __METHOD__." result=".join(',', $result)."\n"; - $this->assertEquals(0, count($result), "Pb with dol_uncompress_file"); + $this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout); } /** From 86e4ca55dfd9ec41ff43296c622231079037e302 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 13:55:29 +0200 Subject: [PATCH 49/84] Merge --- htdocs/theme/eldy/btn.inc.php | 3 ++- htdocs/theme/md/style.css.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index 2e42d42acaa..3ee6a164f75 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -11,7 +11,8 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> div.divButAction { margin-bottom: 1.4em; } -div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused { +div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused, div.tabsAction > a.butActionDelete, +div.tabsAction > span.butAction, div.tabsAction > span.butActionRefused, div.tabsAction > span.butActionDelete { margin-bottom: 1.4em !important; } div.tabsActionNoBottom > a.butAction, div.tabsActionNoBottom > a.butActionRefused { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8e0cf75047b..65436182755 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2571,7 +2571,9 @@ div.divButAction { margin-bottom: 1.4em; vertical-align: top; } -div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused { + +div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused, div.tabsAction > a.butActionDelete, +div.tabsAction > span.butAction, div.tabsAction > span.butActionRefused, div.tabsAction > span.butActionDelete { margin-bottom: 1.4em !important; } From dd97a2e6663484391397796b9e516cbf454dcbff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 14:11:11 +0200 Subject: [PATCH 50/84] CSS --- htdocs/theme/md/style.css.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9aec13e5fc7..05249c99b03 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -504,6 +504,9 @@ input[name=weight], input[name=volume], input[name=surface], input[name=sizeheig input[name=surface] { margin-right: 4px; } fieldset { border: 1px solid #AAAAAA !important; } .legendforfieldsetstep { padding-bottom: 10px; } +input#onlinepaymenturl, input#directdownloadlink { + opacity: 0.7; +} div#moretabsListaction { z-index: 5; From f88733f46a9539c4756546645cc62da430f93e0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 14:14:32 +0200 Subject: [PATCH 51/84] Html code simplest --- htdocs/comm/propal/card.php | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 92267d97033..8891c2280f0 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2471,39 +2471,39 @@ if ($action == 'create') { if ($usercanvalidate) { - print ''; + print '' . $langs->trans('Validate') . ''; } else - print ''; + print '' . $langs->trans('Validate') . ''; } // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { - print ''; + print '' . $langs->trans("AddAction") . '
'; }*/ // Edit if ($object->statut == Propal::STATUS_VALIDATED && $usercancreate) { - print ''; + print '' . $langs->trans('Modify') . ''; } // ReOpen if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $usercanclose) { - print ''; + print 'global->MAIN_JUMP_TAG) ? '' : '#reopen') . '"'; + print '>' . $langs->trans('ReOpen') . ''; } // Send if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED || !empty($conf->global->PROPOSAL_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { - print ''; + print '' . $langs->trans('SendMail') . ''; } else - print ''; + print '' . $langs->trans('SendMail') . ''; } // Create an order if (! empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateorder) { - print ''; + print '' . $langs->trans("AddOrder") . ''; } } @@ -2511,7 +2511,7 @@ if ($action == 'create') if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateintervention) { $langs->load("interventions"); - print ''; + print '' . $langs->trans("AddIntervention") . ''; } } @@ -2520,7 +2520,7 @@ if ($action == 'create') $langs->load("contracts"); if ($usercancreatecontract) { - print ''; + print '' . $langs->trans('AddContract') . ''; } } @@ -2529,7 +2529,7 @@ if ($action == 'create') { if (! empty($conf->facture->enabled) && $usercancreateinvoice) { - print ''; + print '' . $langs->trans("AddBill") . ''; } $arrayofinvoiceforpropal = $object->getInvoiceArrayList(); @@ -2537,30 +2537,30 @@ if ($action == 'create') { if ($usercanclose) { - print ''; + print 'socid . '">' . $langs->trans("ClassifyBilled") . ''; } else { - print ''; + print '' . $langs->trans("ClassifyBilled") . ''; } } } // Set accepted/refused if ($object->statut == Propal::STATUS_VALIDATED && $usercanclose) { - print ''; + print 'global->MAIN_JUMP_TAG) ? '' : '#close') . '"'; + print '>' . $langs->trans('SetAcceptedRefused') . ''; } // Clone if ($usercancreate) { - print ''; + print '' . $langs->trans("ToClone") . ''; } // Delete if ($usercandelete) { - print ''; + print '' . $langs->trans('Delete') . ''; } } } From b60ddc255c744a17a304a786eb27c68d287ada92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 14:17:53 +0200 Subject: [PATCH 52/84] Removed useless html tags --- htdocs/product/card.php | 22 +++++++++---------- htdocs/projet/card.php | 48 ++++++++++++++++++++--------------------- htdocs/societe/card.php | 12 +++++------ 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 22a8af0d270..df195d0c932 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1058,7 +1058,7 @@ else $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); print $form->selectarray('finished', $statutarray, GETPOST('finished', 'alpha'), 1); print ''; - + // Net Measure print ''.$langs->trans("NetMeasure").''; print ''; @@ -1070,7 +1070,7 @@ else print ''; print $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOSTISSET('weight_units')?GETPOST('weight_units', 'alpha'):(empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 2); print ''; - + // Brut Length if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { @@ -1438,7 +1438,7 @@ else $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); print $form->selectarray('finished', $statutarray, $object->finished); print ''; - + // Net Measure print ''.$langs->trans("NetMeasure").''; print ' '; @@ -1852,7 +1852,7 @@ else print ''.$langs->trans("Nature").''; print $object->getLibFinished(); print ''; - + // Net Measure print ''.$langs->trans("NetMeasure").''; if ($object->net_measure != '') @@ -2035,17 +2035,17 @@ if ($action != 'create' && $action != 'edit') { if ($usercancreate) { - if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print ''; + if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print 'id.'">'.$langs->trans("Modify").''; if (! isset($object->no_button_copy) || $object->no_button_copy <> 1) { if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { - print '
'.$langs->trans('ToClone').'
'."\n"; + print ''.$langs->trans('ToClone').''."\n"; } else { - print ''; + print 'id.'">'.$langs->trans("ToClone").''; } } } @@ -2057,21 +2057,21 @@ if ($action != 'create' && $action != 'edit') { if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { - print '
'.$langs->trans('Delete').'
'."\n"; + print ''.$langs->trans('Delete').''."\n"; } else { - print ''; + print 'id.'">'.$langs->trans("Delete").''; } } else { - print ''; + print ''.$langs->trans("Delete").''; } } else { - print ''; + print ''.$langs->trans("Delete").''; } } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 4c04ee6ee23..7469c99c3dd 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1172,13 +1172,13 @@ elseif ($object->id > 0) // "workflow" action so should appears somewhere else on // page. { - print ''; + print '' . $langs->trans("AddAction") . ''; }*/ // Send if ($object->statut != 2) { - print ''; + print '' . $langs->trans('SendMail').''; } // Modify @@ -1186,11 +1186,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans("Modify").''; } else { - print ''; + print ''.$langs->trans('Modify').''; } } @@ -1199,11 +1199,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans("Validate").''; } else { - print ''; + print ''.$langs->trans('Validate').''; } } @@ -1212,11 +1212,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans("Close").''; } else { - print ''; + print ''.$langs->trans('Close').''; } } @@ -1225,11 +1225,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans("ReOpen").''; } else { - print ''; + print ''.$langs->trans('ReOpen').''; } } @@ -1239,52 +1239,52 @@ elseif ($object->id > 0) if (! empty($conf->propal->enabled) && $user->rights->propal->creer) { $langs->load("propal"); - print ''; + print ''.$langs->trans("AddProp").''; } if (! empty($conf->commande->enabled) && $user->rights->commande->creer) { $langs->load("orders"); - print ''; + print ''.$langs->trans("CreateOrder").''; } if (! empty($conf->facture->enabled) && $user->rights->facture->creer) { $langs->load("bills"); - print ''; + print ''.$langs->trans("CreateBill").''; } if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer) { $langs->load("supplier_proposal"); - print ''; + print ''.$langs->trans("AddSupplierProposal").''; } if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->creer) { $langs->load("suppliers"); - print ''; + print ''.$langs->trans("AddSupplierOrder").''; } if (! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->creer) { $langs->load("suppliers"); - print ''; + print ''.$langs->trans("AddSupplierInvoice").''; } if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) { $langs->load("interventions"); - print ''; + print ''.$langs->trans("AddIntervention").''; } if (! empty($conf->contrat->enabled) && $user->rights->contrat->creer) { $langs->load("contracts"); - print ''; + print ''.$langs->trans("AddContract").''; } if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->creer) { $langs->load("trips"); - print ''; + print ''.$langs->trans("AddTrip").''; } if (! empty($conf->don->enabled) && $user->rights->don->creer) { $langs->load("donations"); - print ''; + print ''.$langs->trans("AddDonation").''; } } @@ -1293,11 +1293,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans('ToClone').''; } else { - print ''; + print ''.$langs->trans('ToClone').''; } } @@ -1306,11 +1306,11 @@ elseif ($object->id > 0) { if ($userDelete > 0 || ($object->statut == 0 && $user->rights->projet->creer)) { - print ''; + print ''.$langs->trans("Delete").''; } else { - print ''; + print ''.$langs->trans('Delete').''; } } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e855cb71b8c..cb11324eb68 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2654,17 +2654,17 @@ else if (! empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); - print ''; + print ''.$langs->trans('SendMail').''; } else { $langs->load("mails"); - print ''; + print ''.$langs->trans('SendMail').''; } if ($user->rights->societe->creer) { - print ''."\n"; + print ''.$langs->trans("Modify").'
'."\n"; } if (! empty($conf->adherent->enabled)) @@ -2679,18 +2679,18 @@ else if ($user->rights->societe->supprimer) { - print ''; + print ''.$langs->trans('Merge').''; } if ($user->rights->societe->supprimer) { if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile { - print '
'.$langs->trans('Delete').'
'."\n"; + print ''.$langs->trans('Delete').''."\n"; } else { - print ''."\n"; + print ''.$langs->trans('Delete').''."\n"; } } } From 4ca9fddfcc93ecc829f2ffc5e3710ae87824ba38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 14:26:49 +0200 Subject: [PATCH 53/84] Update product.class.php --- htdocs/product/class/product.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index aa0c575d8d7..2b3fc3ece65 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -787,12 +787,12 @@ class Product extends CommonObject * Update a record into database. * If batch flag is set to on, we create records into llx_product_batch * - * @param int $id Id of product - * @param User $user Object user making update - * @param int $notrigger Disable triggers - * @param string $action Current action for hookmanager ('add' or 'update') - * @param int $updatetype Update product type - * @return int 1 if OK, -1 if ref already exists, -2 if other error + * @param int $id Id of product + * @param User $user Object user making update + * @param int $notrigger Disable triggers + * @param string $action Current action for hookmanager ('add' or 'update') + * @param boolean $updatetype Update product type + * @return int 1 if OK, -1 if ref already exists, -2 if other error */ public function update($id, $user, $notrigger = false, $action = 'update', $updatetype = false) { From 8d75e83e5506219068af85161ac150e06e3eacf1 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Wed, 16 Oct 2019 14:32:17 +0200 Subject: [PATCH 54/84] use current local time on Now button use current local time for feed the date according to locale settings --- htdocs/core/class/html.form.class.php | 51 ++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2130a7d7e38..51e93557417 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5323,7 +5323,7 @@ class Form * @param int $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only * @param string $form_name Not used * @param int $d 1=Show days, month, years - * @param int $addnowlink Add a link "Now" + * @param int $addnowlink Add a link "Now", 1 with server time, 2 with local computer time * @param int $disabled Disable input fields * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. @@ -5605,12 +5605,32 @@ class Form { // Script which will be inserted in the onClick of the "Now" link $reset_scripts = ""; - + if ($addnowlink==2) // local computer time + { + // pad add leading 0 on numbers + $reset_scripts.="Number.prototype.pad = function(size) { + var s = String(this); + while (s.length < (size || 2)) {s = '0' + s;} + return s; + }; + var d = new Date();"; + } + // Generate the date part, depending on the use or not of the javascript calendar - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; + if($addnowlink==1) // server time expressed in user time setup + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y','tzuser').'\');'; + } + elseif($addnowlink==2) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(d.getMonth().pad());'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; + } /*if ($usecalendar == "eldy") { $base=DOL_URL_ROOT.'/core/'; @@ -5627,7 +5647,15 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; + if($addnowlink==1) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H','tzuser').'\');'; + } + elseif($addnowlink==2) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; + } + if ($fullday) $reset_scripts .= ' } '; } // Update the minute part @@ -5635,7 +5663,14 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; + if($addnowlink==1) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M','tzuser').'\');'; + } + elseif($addnowlink==2) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; + } if ($fullday) $reset_scripts .= ' } '; } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick From fce1f1991c9b275dd3fae6c9b64ed3da029207ff Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 16 Oct 2019 12:34:42 +0000 Subject: [PATCH 55/84] Fixing style errors. --- htdocs/core/class/html.form.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 51e93557417..0a069bb2ced 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5619,10 +5619,10 @@ class Form // Generate the date part, depending on the use or not of the javascript calendar if($addnowlink==1) // server time expressed in user time setup { - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day','tzuser').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d','tzuser').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m','tzuser').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; } elseif($addnowlink==2) { @@ -5649,7 +5649,7 @@ class Form //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; if($addnowlink==1) { - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; } elseif($addnowlink==2) { @@ -5665,7 +5665,7 @@ class Form //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; if($addnowlink==1) { - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M','tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; } elseif($addnowlink==2) { From cd825ba4be226536bcedef860f5b0a51717c4684 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 16 Oct 2019 15:46:46 +0200 Subject: [PATCH 56/84] internationalization --- htdocs/core/modules/expedition/doc/pdf_espadon.modules.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index ddc07db0380..21658ed32d0 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -146,7 +146,7 @@ class pdf_espadon extends ModelePdfExpedition /** * Function to build pdf onto disk * - * @param Object $object Object expedition to generate (or id if old method) + * @param Object $object Object expedition to generate (or id if old method) * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details @@ -370,7 +370,7 @@ class pdf_espadon extends ModelePdfExpedition // Notes if (! empty($object->note_public)) { - $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page + $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); } @@ -502,7 +502,7 @@ class pdf_espadon extends ModelePdfExpedition $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // weight From 10fd472392195997bb3326ec34bc7fe7b1caaa67 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 16 Oct 2019 15:59:08 +0200 Subject: [PATCH 57/84] internationalization --- .../expedition/doc/pdf_merou.modules.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index ad676dba22e..53f46ccc861 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -174,20 +174,20 @@ class pdf_merou extends ModelePdfExpedition $origin = $object->origin; - //Creation de l expediteur + //Create sender $this->expediteur = $mysoc; - //Creation du destinataire + //Create recipient $idcontact = $object->$origin->getIdContact('external', 'SHIPPING'); $this->destinataire = new Contact($this->db); if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); - //Creation du livreur + //Create deliverer $idcontact = $object->$origin->getIdContact('internal', 'LIVREUR'); $this->livreur = new User($this->db); if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); - // Definition de $dir et $file + // Definition of $dir and $file if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; @@ -273,7 +273,7 @@ class pdf_merou extends ModelePdfExpedition $tab_height = $this->page_hauteur - $tab_top - $heightforfooter; $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter; - // Affiche notes + // Display notes if (! empty($object->note_public)) { $pdf->SetFont('', '', $default_font_size - 1); @@ -314,7 +314,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); - // Description de la ligne produit + // Description of product line $libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1); $nexY = $pdf->GetY(); @@ -335,7 +335,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->Rect(10+3, $curY, 3, 3); $pdf->Rect(20+3, $curY, 3, 3); - //Insertion de la reference du produit + //Inserting the product reference $pdf->SetXY(30, $curY); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0); @@ -404,7 +404,7 @@ class pdf_merou extends ModelePdfExpedition $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - // Pied de page + // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -579,11 +579,11 @@ class pdf_merou extends ModelePdfExpedition } //*********************Entete**************************** - //Nom du Document + //Document name $pdf->SetXY($Xoff, 7); $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetTextColor(0, 0, 0); - $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Bordereau expedition + $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet //Num Expedition $Yoff = $Yoff+7; $Xoff = 142; @@ -601,7 +601,7 @@ class pdf_merou extends ModelePdfExpedition $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager); //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); - //Definition Emplacement du bloc Societe + //Definition Location of the Company block $Xoff = 110; $blSocX=90; $blSocY=24; @@ -632,7 +632,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } - // Date Expedition + // Date delivery $Yoff = $Yoff+7; $pdf->SetXY($blSocX-80, $blSocY+17); @@ -698,7 +698,7 @@ class pdf_merou extends ModelePdfExpedition } // Recipient name - // On peut utiliser le nom de la societe du contact + // You can use the name of the contact company if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { From 75a47eebe043e7a5a48fb49222fe8ea604910b75 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 16:17:51 +0200 Subject: [PATCH 58/84] Fix Method fetchAll must NEVER be used for table with more than 1000 record --- htdocs/accountancy/bookkeeping/list.php | 534 +++++++++++------- .../class/accountancyexport.class.php | 11 +- 2 files changed, 341 insertions(+), 204 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 2958a229d24..b14a118a342 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -155,6 +155,12 @@ $arrayfields=array( if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); +$listofformat=AccountancyExport::getType(); +$formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV; +if (empty($listofformat[$formatexportset])) $formatexportset = 1; + +$error = 0; + /* * Actions @@ -373,10 +379,97 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri exit; } } +if ($action == 'setreexport') { + $setreexport = GETPOST('value', 'int'); + if (! dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++; + + if (! $error) { + if ($conf->global->ACCOUNTING_REEXPORT == 1) { + setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); + } + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +// Build and execute select (used by page and export action) +// must de set after the action that set $filter +// -------------------------------------------------------------------- + +$sql = 'SELECT'; +$sql .= ' t.rowid,'; +$sql .= " t.doc_date,"; +$sql .= " t.doc_type,"; +$sql .= " t.doc_ref,"; +$sql .= " t.fk_doc,"; +$sql .= " t.fk_docdet,"; +$sql .= " t.thirdparty_code,"; +$sql .= " t.subledger_account,"; +$sql .= " t.subledger_label,"; +$sql .= " t.numero_compte,"; +$sql .= " t.label_compte,"; +$sql .= " t.label_operation,"; +$sql .= " t.debit,"; +$sql .= " t.credit,"; +$sql .= " t.lettering_code,"; +$sql .= " t.montant,"; +$sql .= " t.sens,"; +$sql .= " t.fk_user_author,"; +$sql .= " t.import_key,"; +$sql .= " t.code_journal,"; +$sql .= " t.journal_label,"; +$sql .= " t.piece_num,"; +$sql .= " t.date_creation,"; +$sql .= " t.tms as date_modification,"; +$sql .= " t.date_export"; +$sql .= ' FROM ' . MAIN_DB_PREFIX . $object->table_element . ' as t'; +// Manage filter +$sqlwhere = array (); +if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.doc_date') { + $sqlwhere[] = $key . '=\'' . $db->idate($value) . '\''; + } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { + $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { + $sqlwhere[] = $key . '\'' . $db->escape($value) . '\''; + } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { + $sqlwhere[] = $key . '=' . $value; + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { + $sqlwhere[] = $key . ' LIKE \'' . $db->escape($value) . '%\''; + } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { + $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + } elseif ($key == 't.tms>=' || $key == 't.tms<=') { + $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { + $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + } elseif ($key == 't.credit' || $key == 't.debit') { + $sqlwhere[] = natural_search($key, $value, 1, 1); + } else { + $sqlwhere[] = natural_search($key, $value, 0, 1); + } + } +} +$sql.= ' WHERE t.entity IN (' . getEntity('accountancy') . ')'; +if ($conf->global->ACCOUNTING_REEXPORT == 0) { + $sql .= " AND t.date_export IS NULL"; +} +if (count($sqlwhere) > 0) { + $sql .= ' AND ' . implode(' AND ', $sqlwhere); +} +if (! empty($sortfield)) { + $sql .= $db->order($sortfield, $sortorder); +} +//print $sql; + // Export into a file with format defined into setup (FEC, CSV, ...) +// Must be after definition of $sql if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { + // TODO Replace the fetchAll + ->export later that consume too much memory on large export with the query($sql) and loop on each line to export them. $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT); if ($result < 0) @@ -387,55 +480,54 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { { // Export files $accountancyexport = new AccountancyExport($db); - $accountancyexport->export($object->lines); + $accountancyexport->export($object->lines, $formatexportset); if (! empty($accountancyexport->errors)) { setEventMessages('', $accountancyexport->errors, 'errors'); - } else { + } + else + { // Specify as export : update field date_export - // TODO Move in class bookKeeping $error=0; $db->begin(); - if (is_array($object->lines)) { - foreach ($object->lines as $movement) { + if (is_array($object->lines)) + { + foreach ($object->lines as $movement) + { $now = dol_now(); + $sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " SET date_export = '" . $db->idate($now) . "'"; $sql .= " WHERE rowid = " . $movement->id; dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); - if ($result) { - $db->commit(); - // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); - } else { - $db->rollback(); - // setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); + if (! $result) + { + $error++; + break; } } } + + if (! $error) + { + $db->commit(); + // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); + } + else + { + $error++; + $db->rollback(); + setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); + } } exit; } } -if ($action == 'setreexport') { - $export = 0; - $setreexport = GETPOST('value', 'int'); - if (! dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++; - - if (! $error) { - if ($conf->global->ACCOUNTING_REEXPORT == 1) { - setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); - } - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} /* * View @@ -443,24 +535,43 @@ if ($action == 'setreexport') { $title_page = $langs->trans("Bookkeeping"); -llxHeader('', $title_page); - -// List +// Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT); - if ($nbtotalofrecords < 0) { - setEventMessages($object->error, $object->errors, 'errors'); +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { + $page = 0; + $offset = 0; } } +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; +} +else +{ + $sql.= $db->plimit($limit+1, $offset); -// TODO Do not use this -$result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT); -if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); } -$num=count($object->lines); + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title_page); + if ($action == 'delmouv') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num').$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); @@ -510,9 +621,6 @@ print ''; print ''; print ''; -$button .= ''; - -$listofformat=AccountancyExport::getType(); if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList"); else $buttonLabel = $langs->trans("ExportList"); @@ -524,13 +632,13 @@ if (! empty($conf->global->ACCOUNTING_REEXPORT)) { } $newcardbutton.= ''.$langs->trans("IncludeDocsAlreadyExported").''; -$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''), $user->rights->accounting->mouvements->export); +$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''), $user->rights->accounting->mouvements->export); $newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); $newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer); -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -650,7 +758,6 @@ if (! empty($arrayfields['t.code_journal']['checked'])) print ''; } - // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -727,171 +834,200 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -if ($num > 0) +$line = new BookKeepingLine(); + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + $line->id = $obj->rowid; + $line->doc_date = $db->jdate($obj->doc_date); + $line->doc_type = $obj->doc_type; + $line->doc_ref = $obj->doc_ref; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->montant; + $line->sens = $obj->sens; + $line->lettering_code = $obj->lettering_code; + $line->fk_user_author = $obj->fk_user_author; + $line->import_key = $obj->import_key; + $line->code_journal = $obj->code_journal; + $line->journal_label = $obj->journal_label; + $line->piece_num = $obj->piece_num; + $line->date_creation = $db->jdate($obj->date_creation); + $line->date_modification = $db->jdate($obj->date_modification); + $line->date_export = $db->jdate($obj->date_export); + + $total_debit += $line->debit; + $total_credit += $line->credit; + + print ''; + + // Piece number + if (! empty($arrayfields['t.piece_num']['checked'])) + { + print ''; + $object->id = $line->id; + $object->piece_num = $line->piece_num; + print $object->getNomUrl(1, '', 0, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Document date + if (! empty($arrayfields['t.doc_date']['checked'])) + { + print '' . dol_print_date($line->doc_date, 'day') . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Document ref + if (! empty($arrayfields['t.doc_ref']['checked'])) + { + print '' . $line->doc_ref . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Account number + if (! empty($arrayfields['t.numero_compte']['checked'])) + { + print '' . length_accountg($line->numero_compte) . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Subledger account + if (! empty($arrayfields['t.subledger_account']['checked'])) + { + print '' . length_accounta($line->subledger_account) . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Label operation + if (! empty($arrayfields['t.label_operation']['checked'])) + { + print '' . $line->label_operation . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Amount debit + if (! empty($arrayfields['t.debit']['checked'])) + { + print '' . ($line->debit ? price($line->debit) : ''). ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield']; + $totalarray['totaldebit'] += $line->debit; + } + + // Amount credit + if (! empty($arrayfields['t.credit']['checked'])) + { + print '' . ($line->credit ? price($line->credit) : '') . ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield']; + $totalarray['totalcredit'] += $line->credit; + } + + // Lettering code + if (! empty($arrayfields['t.lettering_code']['checked'])) + { + print '' . $line->lettering_code . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Journal code + if (! empty($arrayfields['t.code_journal']['checked'])) + { + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $line->code_journal); + $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); + print '' . $journaltoshow . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Creation operation date + if (! empty($arrayfields['t.date_creation']['checked'])) + { + print '' . dol_print_date($line->date_creation, 'dayhour') . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Modification operation date + if (! empty($arrayfields['t.tms']['checked'])) + { + print '' . dol_print_date($line->date_modification, 'dayhour') . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Exported operation date + if (! empty($arrayfields['t.date_export']['checked'])) + { + print '' . dol_print_date($line->date_export, 'dayhour') . ''; + if (! $i) $totalarray['nbfield']++; + } + + // Action column + print ''; + if (empty($line->date_export)) { + if ($user->rights->accounting->mouvements->creer) { + print '' . img_edit() . ''; + } + if ($user->rights->accounting->mouvements->supprimer) { + print ' ' . img_delete() . ''; + } + } + print ''; + + if (! $i) $totalarray['nbfield']++; + + print "\n"; + + $i++; +} + +// Show total line +if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield'])) { $i=0; - $totalarray=array(); - while ($i < min($num, $limit)) + print ''; + while ($i < $totalarray['nbfield']) { - $line = $object->lines[$i]; - - $total_debit += $line->debit; - $total_credit += $line->credit; - - print ''; - - // Piece number - if (! empty($arrayfields['t.piece_num']['checked'])) - { - print ''; - $object->id = $line->id; - $object->piece_num = $line->piece_num; - print $object->getNomUrl(1, '', 0, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Document date - if (! empty($arrayfields['t.doc_date']['checked'])) - { - print '' . dol_print_date($line->doc_date, 'day') . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Document ref - if (! empty($arrayfields['t.doc_ref']['checked'])) - { - print '' . $line->doc_ref . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Account number - if (! empty($arrayfields['t.numero_compte']['checked'])) - { - print '' . length_accountg($line->numero_compte) . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Subledger account - if (! empty($arrayfields['t.subledger_account']['checked'])) - { - print '' . length_accounta($line->subledger_account) . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Label operation - if (! empty($arrayfields['t.label_operation']['checked'])) - { - print '' . $line->label_operation . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Amount debit - if (! empty($arrayfields['t.debit']['checked'])) - { - print '' . ($line->debit ? price($line->debit) : ''). ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield']; - $totalarray['totaldebit'] += $line->debit; - } - - // Amount credit - if (! empty($arrayfields['t.credit']['checked'])) - { - print '' . ($line->credit ? price($line->credit) : '') . ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield']; - $totalarray['totalcredit'] += $line->credit; - } - - // Lettering code - if (! empty($arrayfields['t.lettering_code']['checked'])) - { - print '' . $line->lettering_code . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Journal code - if (! empty($arrayfields['t.code_journal']['checked'])) - { - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $line->code_journal); - $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); - print '' . $journaltoshow . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Creation operation date - if (! empty($arrayfields['t.date_creation']['checked'])) - { - print '' . dol_print_date($line->date_creation, 'dayhour') . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Modification operation date - if (! empty($arrayfields['t.tms']['checked'])) - { - print '' . dol_print_date($line->date_modification, 'dayhour') . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Exported operation date - if (! empty($arrayfields['t.date_export']['checked'])) - { - print '' . dol_print_date($line->date_export, 'dayhour') . ''; - if (! $i) $totalarray['nbfield']++; - } - - // Action column - print ''; - if (empty($line->date_export)) { - if ($user->rights->accounting->mouvements->creer) { - print '' . img_edit() . ''; - } - if ($user->rights->accounting->mouvements->supprimer) { - print ' ' . img_delete() . ''; - } - } - print ''; - - if (! $i) $totalarray['nbfield']++; - - print "\n"; - $i++; - } - - // Show total line - if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield'])) - { - $i=0; - print ''; - while ($i < $totalarray['nbfield']) + if ($i == 1) { - $i++; - if ($i == 1) - { - if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").''; - else print ''.$langs->trans("Totalforthispage").''; - } - elseif ($totalarray['totaldebitfield'] == $i) print ''.price($totalarray['totaldebit']).''; - elseif ($totalarray['totalcreditfield'] == $i) print ''.price($totalarray['totalcredit']).''; - else print ''; + if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; } - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print ''; + elseif ($totalarray['totaldebitfield'] == $i) print ''.price($totalarray['totaldebit']).''; + elseif ($totalarray['totalcreditfield'] == $i) print ''.price($totalarray['totalcredit']).''; + else print ''; } + $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print ''; } + print ""; print '
'; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index f90d5797d09..84a851eea50 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -224,22 +224,23 @@ class AccountancyExport /** * Function who chose which export to use with the default config, and make the export into a file * - * @param array $TData data - * @return void + * @param array $TData Array with data + * @param int $formatexportset Id of export format + * @return void */ - public function export(&$TData) + public function export(&$TData, $formatexportset) { global $conf, $langs; global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php // Define name of file to save - $filename = 'general_ledger-'.$this->getFormatCode($conf->global->ACCOUNTING_EXPORT_MODELCSV); + $filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $type_export = 'general_ledger'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) { + switch ($formatexportset) { case self::$EXPORT_TYPE_CONFIGURABLE : $this->exportConfigurable($TData); break; From 8f03813aa9eda51aa29f1ef88f51e0a761808531 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Wed, 16 Oct 2019 16:26:00 +0200 Subject: [PATCH 59/84] Phone layout and functional improvements --- htdocs/takepos/css/phone.css | 81 +++++++++++++++ htdocs/takepos/invoice.php | 48 ++++----- htdocs/takepos/phone.php | 190 +++++++++++++++++++++++++++++++++++ htdocs/takepos/takepos.php | 2 +- 4 files changed, 291 insertions(+), 30 deletions(-) create mode 100644 htdocs/takepos/css/phone.css create mode 100644 htdocs/takepos/phone.php diff --git a/htdocs/takepos/css/phone.css b/htdocs/takepos/css/phone.css new file mode 100644 index 00000000000..49d833ade17 --- /dev/null +++ b/htdocs/takepos/css/phone.css @@ -0,0 +1,81 @@ +html,body { + box-sizing: border-box; + padding:3px; + margin:0; + height:100%; + width:100%; +} + +.container{ + width: 100%; + height: 100%; + margin: 0 auto; + overflow: visible; + box-sizing: border-box; +} + +.phonerow1{ + margin: 0 auto; + width: 100%; + height: 40%; + min-height: 40%; +} + +.phonerow2{ + margin: 0 auto; + width: 100%; + height: 40%; +} + +.phonebuttonsrow{ + margin: 0 auto; + width: 100%; + height: 5%; +} + +.phonediv1{ + height:100%; + min-height: 100%; + width: 100%; + text-align: center; + box-sizing: border-box; + overflow: auto; + padding-top: 0; + padding-bottom: 10px; + padding-right: 5px; + padding-left: 5px; +} + +.phonediv2{ + height: 100%; + width: 100%; + box-sizing: border-box; + padding-top: 0; + padding-bottom: 10px; + padding-right: 5px; + padding-left: 5px; +} + +.phonediv3{ + height: 100%; + width: 100%; + box-sizing: border-box; + padding-top: 0; + padding-bottom: 10px; + padding-right: 5px; + padding-left: 5px; +} + +button.phonebutton { + display: inline-block; + position: relative; + padding: 0; + line-height: normal; + cursor: pointer; + vertical-align: middle; + text-align: center; + overflow: visible; /* removes extra width in IE */ + width:24%; + height:90%; + font-weight: bold; +} diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 1511d3520a1..a2c92aa13e4 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -570,13 +570,19 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) $label = $obj->label; $floor = $obj->floor; } - print $langs->trans('Place')." ".$label." - "; - print $langs->trans('Floor')." ".$floor." - "; + // In phone version only show when is invoice page + if ($mobilepage=="invoice" || $mobilepage=="") { + print $langs->trans('Place') . " " . $label . " - "; + print $langs->trans('Floor') . " " . $floor . " - "; + } +} +// In phone version only show when is invoice page +if ($mobilepage=="invoice" || $mobilepage=="") { + print $langs->trans('TotalTTC'); + print ' : ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ''; + print '
' . $sectionwithinvoicelink; + print ''; } -print $langs->trans('TotalTTC'); -print ' : '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; -print '
'.$sectionwithinvoicelink; -print ''; if ($_SESSION["basiclayout"]!=1) { print '' . $langs->trans('ReductionShort') . ''; @@ -595,16 +601,14 @@ if ($_SESSION["basiclayout"]==1) $htmlforlines = ''; foreach ($categories as $row){ $htmlforlines.= ''; + $htmlforlines.= '" onclick="LoadProducts(' . $row['id'] . ');">'; $htmlforlines.= ''; $htmlforlines.= $row['label']; $htmlforlines.= ''; $htmlforlines.= ''."\n"; } $htmlforlines.= ''; - $htmlforlines.= '
'; - $htmlforlines.= ''.$langs->trans("Floors").''; - $htmlforlines.= '
'; + $htmlforlines.= ''; print $htmlforlines; } @@ -618,17 +622,13 @@ if ($_SESSION["basiclayout"]==1) $htmlforlines = ''; foreach ($prods as $row) { $htmlforlines.= ''; + $htmlforlines.= '" onclick="AddProduct(\'' . $place . '\', ' . $row->id . ')">'; $htmlforlines.= ''; $htmlforlines.= $row->label; $htmlforlines.= ''; $htmlforlines.= ''."\n"; } $htmlforlines.= ''; - $htmlforlines.= '
'; - $htmlforlines.= ''.$langs->trans("Categories").''; - $htmlforlines.= ''.$langs->trans("Floors").''; - $htmlforlines.= '
'; print $htmlforlines; } @@ -641,24 +641,22 @@ if ($_SESSION["basiclayout"]==1) while($row = $db->fetch_array($resql)){ $rows[] = $row; $htmlforlines.= ''; + $htmlforlines.= '" onclick="LoadPlace(\'' . $row['label'] . '\')">'; $htmlforlines.= ''; $htmlforlines.= $row['label']; $htmlforlines.= ''; $htmlforlines.= ''."\n"; } $htmlforlines.= ''; - $htmlforlines.= '
'; - $htmlforlines.= ''.$langs->trans("Categories").''; - $htmlforlines.= ''.$langs->trans("Floors").''; - $htmlforlines.= '
'; print $htmlforlines; } } if ($placeid > 0) { - if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice") return; + //In Phone basic layout hide some content depends situation + if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice" && $action!="order") return; + if (is_array($invoice->lines) && count($invoice->lines)) { $tmplines = array_reverse($invoice->lines); @@ -716,14 +714,6 @@ else { // No invoice generated yet print ''; -if ($_SESSION["basiclayout"]==1 && $mobilepage=="invoice") -{ - print ''; -} - if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) { $soc = new Societe($db); diff --git a/htdocs/takepos/phone.php b/htdocs/takepos/phone.php new file mode 100644 index 00000000000..2bd21626f34 --- /dev/null +++ b/htdocs/takepos/phone.php @@ -0,0 +1,190 @@ + + * + * 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/takepos/phone.php + * \ingroup takepos + * \brief TakePOS Phone screen + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); + +require '../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$action = GETPOST('action', 'alpha'); +$setterminal = GETPOST('setterminal', 'int'); + +if ($setterminal>0) +{ + $_SESSION["takeposterminal"]=$setterminal; +} + +$langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter")); + +/* + * View + */ + +// Title +$title='TakePOS - Dolibarr '.DOL_VERSION; +if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; +$head=' + + +'; +top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + +?> + + + + +global->TAKEPOS_NUM_TERMINALS!="1" && $_SESSION["takeposterminal"]=="") print '
'.$langs->trans('TerminalSelect').'
'; +?> +
+
+ + + + +
+
+
+
+
+
+
+
+ +close(); diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index c49479c7ce1..7ff588b12c0 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -63,7 +63,7 @@ if ($conf->browser->layout == 'phone') if ($_SESSION["takeposterminal"]!="" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT==1) { $_SESSION["basiclayout"]=1; - header("Location: invoice.php?mobilepage=invoice"); + header("Location: phone.php?mobilepage=invoice"); exit; } } From 205967976cbc53ec91506ff8b73974c127f59f17 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 18:35:15 +0200 Subject: [PATCH 60/84] Can set a BOM to draft --- htdocs/bom/bom_card.php | 23 ++++++++----------- htdocs/core/actions_addupdatedelete.inc.php | 14 +++++++++++ htdocs/core/boxes/box_task.php | 1 - .../modulebuilder/template/myobject_card.php | 8 +++++-- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 8e6551e92ea..0949fa1a334 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -405,20 +405,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Confirmation of action xxxx - if ($action == 'xxx') + if ($action == 'setdraft') { + $text = $langs->trans('ConfirmSetToDraft', $object->ref); + $formquestion=array(); - /* - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); } // Call Hook formConfirm @@ -568,6 +560,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Send //print '' . $langs->trans('SendMail') . ''."\n"; + if ($user->rights->bom->write && $object->status == BOM::STATUS_VALIDATED) + { + print '' . $langs->trans("SetToDraft") . ''; + } + // Modify if ($user->rights->bom->write) { @@ -594,7 +591,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Close / Cancel if ($user->rights->bom->write && $object->status == BOM::STATUS_VALIDATED) { - print '' . $langs->trans("Disable") . ''; + print '' . $langs->trans("Disable") . ''; } // Re-open diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 7082bc5e882..e87333e4c01 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -289,6 +289,20 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissionedit) } } +// Action setdraft object +if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissionedit) +{ + $result = $object->setDraft($user); + if ($result >= 0) + { + // Nothing else done + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + // Action reopen object if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissionedit) { diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index dbe1757d55d..67ed84c0797 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -201,7 +201,6 @@ class box_task extends ModeleBoxes dol_print_error($this->db); } } - } /** diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index c443641ffd6..5727d596a6d 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -114,8 +114,6 @@ $permissiontoadd=$user->rights->mymodule->write; // Used by the include of actio /* * Actions - * - * Put here all code to do according to value of "action" parameter */ $parameters=array(); @@ -437,6 +435,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Send print '' . $langs->trans('SendMail') . ''."\n"; + // Back to draft + if (! empty($user->rights->mymodule->write) && $object->status == BOM::STATUS_VALIDATED) + { + print '' . $langs->trans("SetToDraft") . ''; + } + // Modify if (! empty($user->rights->mymodule->write)) { From 012ddd1cdcff471134e3cee971850c475ee8b71e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 18:37:26 +0200 Subject: [PATCH 61/84] Fix bom --- htdocs/bom/class/bom.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index d8e5387f075..9b2646b3e9d 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -95,8 +95,8 @@ class BOM extends CommonObject 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'), 'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), 'duration' => array('type'=>'real', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>161, 'notnull'=>-1,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>162, 'notnull'=>-1,), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-2, 'position'=>161, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-2, 'position'=>162, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>300, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), 'date_valid' => array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-2, 'position'=>502, 'notnull'=>0,), From 41dd53170e8d9c6744098ed8d57f5b901444845a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 19:07:17 +0200 Subject: [PATCH 62/84] Code comment --- htdocs/core/class/conf.class.php | 2 +- htdocs/main.inc.php | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 287d8121213..72aa4bc4265 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -227,7 +227,7 @@ class Conf $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); foreach ($filesList as $file) { $file=dol_sanitizeFileName($file); - include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; // This file must set $this->global->XXX vars. + include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; // This file can run code like setting $this->global->XXX vars. } } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b7bef1aa46a..4fc94feb1f4 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1926,8 +1926,6 @@ function top_menu_bookmark(User $user, Translate $langs) global $menumanager; $html = ''; - - // Define $bookmarks if (! empty($conf->bookmark->enabled) && $user->rights->bookmark->lire) { @@ -2015,7 +2013,6 @@ function top_menu_search(User $user, Translate $langs) $buttonList.='
'; - $searchInput = ''; @@ -2105,7 +2102,6 @@ function top_menu_search(User $user, Translate $langs) '; - return $html; } From e75f7d448c13d789e2c9156d10d65b531d42767b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 16 Oct 2019 20:00:01 +0200 Subject: [PATCH 63/84] Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen --- dev/initdata/generate-thirdparty.php | 1 - dev/setup/codesniffer/ruleset.xml | 12 ++++--- htdocs/accountancy/admin/accountmodel.php | 1 - htdocs/accountancy/admin/card.php | 1 - htdocs/accountancy/admin/categories.php | 2 -- htdocs/accountancy/admin/categories_list.php | 7 ++-- htdocs/accountancy/admin/closure.php | 1 - htdocs/accountancy/admin/defaultaccounts.php | 3 -- htdocs/accountancy/admin/export.php | 3 +- htdocs/accountancy/admin/journals_list.php | 1 - htdocs/accountancy/admin/productaccount.php | 2 -- .../bookkeeping/balancebymonth.php | 1 - htdocs/accountancy/bookkeeping/card.php | 3 -- htdocs/accountancy/bookkeeping/list.php | 5 --- .../accountancy/bookkeeping/listbyaccount.php | 3 -- .../thirdparty_lettering_customer.php | 2 -- .../thirdparty_lettering_supplier.php | 2 -- .../class/accountancyexport.class.php | 5 --- .../class/accountingaccount.class.php | 1 - .../accountancy/class/bookkeeping.class.php | 2 -- htdocs/accountancy/class/lettering.class.php | 1 - htdocs/accountancy/customer/card.php | 1 - htdocs/accountancy/customer/index.php | 4 --- htdocs/accountancy/expensereport/index.php | 3 -- htdocs/accountancy/journal/bankjournal.php | 3 -- .../journal/expensereportsjournal.php | 2 -- .../accountancy/journal/purchasesjournal.php | 2 -- htdocs/accountancy/journal/sellsjournal.php | 2 -- htdocs/accountancy/supplier/index.php | 3 -- htdocs/adherents/class/adherent.class.php | 1 - .../adherents/class/adherent_type.class.php | 1 - htdocs/adherents/document.php | 1 - .../adherents/tpl/linkedobjectblock.tpl.php | 1 - htdocs/adherents/type.php | 1 - htdocs/admin/agenda_other.php | 2 -- htdocs/admin/bank.php | 2 -- htdocs/admin/barcode.php | 3 -- htdocs/admin/bom.php | 2 -- htdocs/admin/boxes.php | 1 - htdocs/admin/commande.php | 3 -- htdocs/admin/company.php | 7 ---- htdocs/admin/compta.php | 1 - htdocs/admin/const.php | 1 - htdocs/admin/contract.php | 3 -- htdocs/admin/delais.php | 8 ----- htdocs/admin/dict.php | 1 - .../admin/dolistore/class/dolistore.class.php | 1 - htdocs/admin/expedition.php | 1 - htdocs/admin/expensereport.php | 3 -- htdocs/admin/external_rss.php | 1 - htdocs/admin/facture.php | 1 - htdocs/admin/fichinter.php | 3 -- htdocs/admin/holiday.php | 3 -- htdocs/admin/limits.php | 1 - htdocs/admin/livraison.php | 2 -- htdocs/admin/mails.php | 2 -- htdocs/admin/mails_emailing.php | 1 - htdocs/admin/menus/edit.php | 1 - htdocs/admin/modules.php | 1 - htdocs/admin/notification.php | 2 -- htdocs/admin/oauthlogintokens.php | 2 -- htdocs/admin/propal.php | 2 -- htdocs/admin/reception_setup.php | 1 - htdocs/admin/security.php | 2 -- htdocs/admin/sms.php | 1 - htdocs/admin/supplier_invoice.php | 2 -- htdocs/admin/supplier_order.php | 1 - htdocs/admin/supplier_payment.php | 2 -- htdocs/admin/supplier_proposal.php | 4 --- htdocs/admin/syslog.php | 1 - htdocs/admin/system/database-tables.php | 1 - htdocs/admin/ticket.php | 1 - htdocs/admin/translation.php | 2 -- htdocs/admin/user.php | 1 - htdocs/admin/usergroup.php | 1 - htdocs/admin/website.php | 1 - htdocs/asset/type.php | 1 - htdocs/barcode/printsheet.php | 1 - htdocs/blockedlog/admin/blockedlog_list.php | 1 - htdocs/blockedlog/ajax/authority.php | 2 -- htdocs/blockedlog/class/authority.class.php | 3 -- htdocs/blockedlog/class/blockedlog.class.php | 3 -- htdocs/bom/class/bom.class.php | 1 - htdocs/bookmarks/bookmarks.lib.php | 1 - htdocs/bookmarks/card.php | 1 - htdocs/cashdesk/admin/cashdesk.php | 2 -- htdocs/cashdesk/class/Facturation.class.php | 33 ------------------- htdocs/cashdesk/facturation.php | 2 -- htdocs/cashdesk/tpl/liste_articles.tpl.php | 2 -- htdocs/cashdesk/tpl/validation1.tpl.php | 5 --- htdocs/categories/class/categorie.class.php | 1 - htdocs/categories/photos.php | 1 - htdocs/categories/viewcat.php | 2 -- htdocs/comm/action/card.php | 1 - htdocs/comm/action/peruser.php | 2 -- htdocs/comm/action/rapport/index.php | 1 - htdocs/comm/index.php | 4 --- htdocs/comm/mailing/advtargetemailing.php | 8 ----- .../mailing/class/advtargetemailing.class.php | 8 ----- .../html.formadvtargetemailing.class.php | 8 ----- htdocs/comm/mailing/class/mailing.class.php | 2 -- htdocs/comm/propal/card.php | 1 - htdocs/comm/propal/class/propal.class.php | 3 -- htdocs/comm/propal/index.php | 1 - htdocs/comm/prospect/index.php | 1 - htdocs/commande/card.php | 1 - htdocs/commande/class/commande.class.php | 3 -- htdocs/commande/index.php | 5 --- htdocs/compta/accounting-files.php | 1 - htdocs/compta/bank/annuel.php | 1 - htdocs/compta/bank/bankentries_list.php | 4 --- htdocs/compta/bank/card.php | 1 - htdocs/compta/bank/categ.php | 3 -- htdocs/compta/bank/class/account.class.php | 2 -- htdocs/compta/bank/document.php | 1 - htdocs/compta/facture/card.php | 5 --- .../facture/class/facture-rec.class.php | 1 - htdocs/compta/facture/class/facture.class.php | 4 --- htdocs/compta/facture/list.php | 1 - htdocs/compta/localtax/card.php | 1 - htdocs/compta/localtax/clients.php | 2 -- htdocs/compta/paiement/cheque/card.php | 1 - .../cheque/class/remisecheque.class.php | 2 -- .../compta/paiement/class/paiement.class.php | 4 --- htdocs/compta/paiement/rapport.php | 1 - htdocs/compta/paiement_charge.php | 1 - .../class/bonprelevement.class.php | 2 -- htdocs/compta/recap-compta.php | 2 -- htdocs/compta/resultat/result.php | 1 - htdocs/compta/sociales/card.php | 1 - .../class/paymentsocialcontribution.class.php | 1 - htdocs/compta/stats/byratecountry.php | 5 --- htdocs/compta/stats/cabyprodserv.php | 5 --- htdocs/compta/stats/cabyuser.php | 5 --- htdocs/compta/stats/casoc.php | 5 --- htdocs/compta/tva/clients.php | 1 - htdocs/contact/class/contact.class.php | 1 - htdocs/contact/consumption.php | 2 -- htdocs/contrat/card.php | 1 - htdocs/contrat/class/contrat.class.php | 4 --- htdocs/contrat/index.php | 1 - htdocs/core/actions_builddoc.inc.php | 1 - htdocs/core/actions_massactions.inc.php | 2 -- htdocs/core/ajax/ajaxdirtree.php | 1 - htdocs/core/ajax/check_notifications.php | 1 - htdocs/core/ajax/price.php | 2 -- htdocs/core/ajax/ziptown.php | 1 - htdocs/core/boxes/box_activity.php | 1 - htdocs/core/boxes/box_goodcustomers.php | 1 - htdocs/core/boxes/box_project.php | 1 - htdocs/core/boxes/box_task.php | 1 - htdocs/core/class/CMailFile.class.php | 1 - htdocs/core/class/CSMSFile.class.php | 1 - .../core/class/commondocgenerator.class.php | 1 - htdocs/core/class/commonobject.class.php | 4 --- htdocs/core/class/discount.class.php | 1 - htdocs/core/class/extrafields.class.php | 2 -- htdocs/core/class/html.form.class.php | 1 - htdocs/core/class/html.formcron.class.php | 1 - htdocs/core/class/html.formother.class.php | 1 - htdocs/core/class/infobox.class.php | 1 - htdocs/core/class/link.class.php | 1 - htdocs/core/class/utils.class.php | 1 - htdocs/core/lib/bank.lib.php | 1 - htdocs/core/lib/functions.lib.php | 1 - htdocs/core/lib/functions2.lib.php | 1 - htdocs/core/lib/json.lib.php | 1 - htdocs/core/lib/ldap.lib.php | 1 - htdocs/core/lib/modulebuilder.lib.php | 1 - htdocs/core/lib/pdf.lib.php | 1 - htdocs/core/lib/product.lib.php | 1 - htdocs/core/lib/ticket.lib.php | 1 - htdocs/core/lib/usergroups.lib.php | 9 ----- .../expedition/doc/pdf_rouget.modules.php | 1 - .../facture/doc/pdf_sponge.modules.php | 4 --- .../modules/printing/printgcp.modules.php | 1 - .../modules/propale/doc/pdf_azur.modules.php | 2 -- .../modules/propale/doc/pdf_cyan.modules.php | 2 -- .../reception/doc/pdf_squille.modules.php | 3 -- .../modGeneratePassStandard.class.php | 1 - .../stock/doc/pdf_stdmovement.modules.php | 1 - htdocs/core/tpl/advtarget.tpl.php | 4 --- htdocs/core/tpl/contacts.tpl.php | 3 -- htdocs/core/tpl/object_discounts.tpl.php | 2 -- htdocs/core/tpl/objectline_create.tpl.php | 1 - htdocs/core/tpl/objectline_edit.tpl.php | 1 - htdocs/core/tpl/resource_view.tpl.php | 1 - .../interface_80_modStripe_Stripe.class.php | 1 - ...rface_90_modSociete_ContactRoles.class.php | 1 - ...face_99_modZapier_ZapierTriggers.class.php | 1 - .../class/actions_datapolicy.class.php | 5 --- .../datapolicy/class/datapolicycron.class.php | 1 - htdocs/datapolicy/mailing.php | 1 - htdocs/don/card.php | 4 --- htdocs/don/class/don.class.php | 1 - htdocs/don/class/paymentdonation.class.php | 1 - htdocs/don/index.php | 1 - htdocs/don/list.php | 1 - htdocs/don/payment/payment.php | 1 - htdocs/expedition/card.php | 1 - htdocs/expedition/class/expedition.class.php | 2 -- htdocs/expedition/note.php | 1 - .../class/expensereport.class.php | 4 --- htdocs/expensereport/export_csv.php | 2 -- .../tpl/linkedobjectblock.tpl.php | 1 - htdocs/fichinter/card-rec.php | 1 - htdocs/fichinter/class/fichinter.class.php | 4 --- .../class/fournisseur.commande.class.php | 4 --- .../fournisseur.commande.dispatch.class.php | 1 - .../fourn/class/fournisseur.facture.class.php | 2 -- .../fourn/class/fournisseur.product.class.php | 2 -- htdocs/fourn/class/paiementfourn.class.php | 1 - htdocs/fourn/commande/card.php | 2 -- htdocs/fourn/commande/dispatch.php | 2 -- htdocs/fourn/commande/index.php | 1 - htdocs/fourn/commande/list.php | 3 -- htdocs/fourn/commande/orderstoinvoice.php | 3 -- htdocs/fourn/facture/card.php | 1 - htdocs/fourn/facture/list.php | 1 - htdocs/fourn/index.php | 1 - htdocs/ftp/admin/ftpclient.php | 1 - htdocs/ftp/index.php | 1 - htdocs/holiday/card.php | 3 -- htdocs/holiday/class/holiday.class.php | 12 ------- htdocs/hrm/establishment/card.php | 1 - htdocs/imports/import.php | 2 -- htdocs/install/check.php | 2 -- htdocs/install/step1.php | 1 - htdocs/install/upgrade2.php | 2 -- htdocs/livraison/card.php | 2 -- htdocs/livraison/class/livraison.class.php | 1 - htdocs/loan/calcmens.php | 1 - htdocs/loan/createschedule.php | 4 --- htdocs/loan/schedule.php | 4 --- htdocs/margin/checkMargins.php | 1 - htdocs/margin/customerMargins.php | 1 - htdocs/margin/productMargins.php | 1 - htdocs/modulebuilder/index.php | 3 -- .../template/class/actions_mymodule.class.php | 2 -- .../template/class/myobject.class.php | 1 - ..._99_modMyModule_MyModuleTriggers.class.php | 1 - htdocs/mrp/class/mo.class.php | 1 - htdocs/opensurvey/card.php | 2 -- .../class/opensurveysondage.class.php | 1 - htdocs/opensurvey/results.php | 3 -- htdocs/opensurvey/wizard/choix_autre.php | 1 - htdocs/opensurvey/wizard/choix_date.php | 5 ++- htdocs/printing/admin/printing.php | 1 - htdocs/product/admin/price_rules.php | 4 --- htdocs/product/admin/product.php | 1 - htdocs/product/admin/product_tools.php | 1 - htdocs/product/ajax/products.php | 3 +- .../canvas/product/tpl/card_create.tpl.php | 1 - .../canvas/service/tpl/card_create.tpl.php | 1 - htdocs/product/card.php | 1 - htdocs/product/class/product.class.php | 3 -- htdocs/product/class/productbatch.class.php | 2 -- .../class/productcustomerprice.class.php | 9 ----- .../class/propalmergepdfproduct.class.php | 2 -- htdocs/product/document.php | 3 -- htdocs/product/price.php | 3 -- htdocs/product/reassort.php | 1 - htdocs/product/stock/card.php | 1 - htdocs/product/stock/class/entrepot.class.php | 1 - .../stock/class/mouvementstock.class.php | 1 - .../class/productstockentrepot.class.php | 1 - htdocs/product/stock/massstockmove.php | 2 -- htdocs/product/stock/movement_card.php | 2 +- htdocs/product/stock/product.php | 6 ---- htdocs/product/stock/productlot_document.php | 2 -- htdocs/product/stock/productlot_list.php | 1 - htdocs/projet/card.php | 1 - htdocs/projet/class/project.class.php | 1 - htdocs/projet/class/task.class.php | 2 -- htdocs/projet/element.php | 2 -- htdocs/projet/ganttview.php | 1 - htdocs/projet/graph_opportunities.inc.php | 1 - htdocs/projet/index.php | 1 - htdocs/public/donations/donateurs_code.php | 1 - htdocs/public/onlinesign/newonlinesign.php | 2 -- htdocs/public/opensurvey/studs.php | 1 - htdocs/public/payment/newpayment.php | 1 - htdocs/public/stripe/ipn.php | 4 --- htdocs/public/test/test_arrays.php | 1 - htdocs/public/ticket/create_ticket.php | 1 - htdocs/public/ticket/list.php | 1 - htdocs/reception/card.php | 2 -- htdocs/reception/class/reception.class.php | 1 - htdocs/reception/list.php | 2 -- htdocs/reception/note.php | 1 - .../class/html.formresource.class.php | 2 -- htdocs/resource/element_resource.php | 3 -- htdocs/salaries/card.php | 1 - htdocs/salaries/class/paymentsalary.class.php | 1 - htdocs/societe/card.php | 2 -- .../societe/class/api_thirdparties.class.php | 2 -- .../class/companybankaccount.class.php | 3 -- htdocs/societe/consumption.php | 2 -- htdocs/societe/paymentmodes.php | 4 --- htdocs/societe/price.php | 8 ----- htdocs/stripe/charge.php | 1 - htdocs/stripe/payment.php | 3 -- htdocs/stripe/payout.php | 1 - htdocs/stripe/transaction.php | 1 - htdocs/supplier_proposal/card.php | 2 -- .../class/supplier_proposal.class.php | 3 -- htdocs/support/inc.php | 1 - htdocs/takepos/admin/terminal.php | 1 - htdocs/theme/eldy/main_menu_fa_icons.inc.php | 1 - htdocs/theme/md/badges.inc.php | 1 - htdocs/ticket/index.php | 1 - htdocs/ticket/list.php | 1 - htdocs/user/card.php | 1 - htdocs/user/class/user.class.php | 1 - htdocs/user/class/userbankaccount.class.php | 1 - htdocs/user/clicktodial.php | 1 - htdocs/user/group/card.php | 1 - htdocs/user/notify/card.php | 1 - htdocs/user/passwordforgotten.php | 2 -- htdocs/variants/admin/admin.php | 1 - htdocs/variants/card.php | 9 ----- .../variants/class/ProductAttribute.class.php | 1 - .../class/ProductAttributeValue.class.php | 1 - .../class/ProductCombination.class.php | 6 ---- htdocs/variants/combinations.php | 12 ------- htdocs/variants/create.php | 1 - htdocs/variants/create_val.php | 1 - htdocs/variants/generator.php | 2 -- htdocs/webservices/server_actioncomm.php | 1 - htdocs/webservices/server_contact.php | 3 -- htdocs/webservices/server_invoice.php | 2 -- htdocs/webservices/server_order.php | 4 --- .../webservices/server_productorservice.php | 1 - htdocs/webservices/server_thirdparty.php | 2 -- htdocs/website/class/website.class.php | 1 - htdocs/website/index.php | 1 - .../accountancy/export-thirdpartyaccount.php | 1 - 337 files changed, 15 insertions(+), 710 deletions(-) diff --git a/dev/initdata/generate-thirdparty.php b/dev/initdata/generate-thirdparty.php index 54e17c7f8d7..f1e0f4f360b 100755 --- a/dev/initdata/generate-thirdparty.php +++ b/dev/initdata/generate-thirdparty.php @@ -116,7 +116,6 @@ for ($s = 0 ; $s < GEN_NUMBER_SOCIETE ; $s++) $contact->firstname = $listoflastname[mt_rand(0, count($listoflastname)-1)]; if ( $contact->create($user) ) { - } } diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 6773e1d2c03..32c44ce91e4 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -122,14 +122,14 @@ - + 0 0 - + @@ -195,7 +195,7 @@ --> - + @@ -213,6 +213,8 @@ 0 + + @@ -337,7 +339,7 @@ - @@ -375,7 +377,7 @@ 0 - + 0 diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 06a2fb60d67..2f23cd3eae8 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -677,7 +677,6 @@ if ($id) { foreach ($fieldlist as $field => $value) { - $showfield=1; $class="left"; $valuetoshow=$obj->{$fieldlist[$field]}; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index c49ed42741b..f54c477ff52 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -273,7 +273,6 @@ if ($action == 'create') { print ''; } elseif ($id > 0 || $ref) { - $result = $object->fetch($id, $ref, 1); if ($result > 0) { diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index a7fe40acefc..5fdd43eb020 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -130,7 +130,6 @@ if (! empty($cat_id)) } if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) { - print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, null, null, "90%"); print '
'; /*print ''; print ''; foreach ($list_account_main as $key) { - print ''; // Param $label = $langs->trans($key); diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 13d3a267956..6b47578761c 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -83,7 +83,6 @@ if (GETPOST('change_chart', 'alpha')) $chartofaccounts = GETPOST('chartofaccounts', 'int'); if (! empty($chartofaccounts)) { - if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { $error ++; } @@ -144,7 +143,6 @@ print ''; print '
'; foreach ($list_account_main as $key) { - print ''; // Param $label = $langs->trans($key); @@ -172,7 +170,6 @@ print '
'; print '
'; foreach ($list_account as $key) { - print ''; // Param $label = $langs->trans($key); diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index e13a66998b7..e506f5bf512 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -114,7 +114,7 @@ if ($action == 'update') { $error ++; } } - } + } if (! $error) { // reload @@ -203,7 +203,6 @@ print "\n"; $num = count($main_option); if ($num) { foreach ($main_option as $key) { - print ''; // Param diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index fcdf4de032c..44fe3e936cd 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -609,7 +609,6 @@ if ($id) $langs->load("accountancy"); foreach ($fieldlist as $field => $value) { - $showfield=1; $class="left"; $valuetoshow=$obj->{$fieldlist[$field]}; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 2922d3bdf23..091018dc909 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -117,7 +117,6 @@ if ($action == 'update') { ); if (in_array($accounting_product_mode, $accounting_product_modes)) { - if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { $error ++; } @@ -129,7 +128,6 @@ if ($action == 'update') { if (! empty($btn_changeaccount)) { //$msg = '
' . $langs->trans("Processing") . '...
'; if (! empty($chk_prod)) { - $accounting = new AccountingAccount($db); //$msg .= '
' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
'; diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index d0e9b940074..bdc78911513 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -105,7 +105,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $i < $num ) { - $row = $db->fetch_row($resql); print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 5f9ba37d341..cc6307bae2c 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -83,7 +83,6 @@ $object = new BookKeeping($db); */ if ($action == "confirm_update") { - $error = 0; if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { @@ -585,7 +584,6 @@ if ($action == 'create') if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print ''; @@ -601,7 +599,6 @@ if ($action == 'create') print "
' . length_accountg($row[0]) . '
"; if (count($object->linesmvt) > 0) { - $total_debit = 0; $total_credit = 0; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b14a118a342..5158e12ebb6 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -316,7 +316,6 @@ if (empty($reshook)) } if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { - $import_key = GETPOST('importkey', 'alpha'); if (! empty($import_key)) { @@ -331,7 +330,6 @@ if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->suppri } } if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { - $delyear = GETPOST('delyear', 'int'); if ($delyear==-1) { $delyear=0; @@ -362,7 +360,6 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme } } if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { - $mvt_num = GETPOST('mvt_num', 'int'); if (! empty($mvt_num)) { @@ -468,7 +465,6 @@ if (! empty($sortfield)) { // Export into a file with format defined into setup (FEC, CSV, ...) // Must be after definition of $sql if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { - // TODO Replace the fetchAll + ->export later that consume too much memory on large export with the query($sql) and loop on each line to export them. $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT); @@ -578,7 +574,6 @@ if ($action == 'delmouv') { print $formconfirm; } if ($action == 'delbookkeepingyear') { - $form_question = array (); $delyear = GETPOST('delyear'); $deljournal = GETPOST('deljournal'); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index d91772a6ab3..4f275e3e2b0 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -179,7 +179,6 @@ if (! empty($search_credit)) { if ($action == 'delmouvconfirm') { - $mvt_num = GETPOST('mvt_num', 'int'); if (! empty($mvt_num)) { @@ -229,7 +228,6 @@ if ($action == 'delmouv') { print $formconfirm; } if ($action == 'delbookkeepingyear') { - $form_question = array (); $delyear = GETPOST('delyear'); @@ -338,7 +336,6 @@ while ($i < min($num, $limit)) // Is it a break ? if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) { - // Affiche un Sous-Total par compte comptable if (isset($displayed_account_number)) { print ''; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index b7a19101758..4bc60fc904f 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -100,7 +100,6 @@ if ($result < 0) */ if ($action == 'lettering') { - $result = $lettering->updateLettering($toselect); if ($result < 0) { @@ -251,7 +250,6 @@ if ($resql) { $tmp = ''; while ( $obj = $db->fetch_object($resql) ) { - if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index eaa741e1722..df513f8d074 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -99,7 +99,6 @@ if ($result<0) * Action */ if ($action == 'lettering') { - $result = $lettering->updateLettering($toselect); if ($result < 0) { @@ -248,7 +247,6 @@ if ($resql) { $solde = 0; $tmp = ''; while ($obj = $db->fetch_object($resql)) { - if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 84a851eea50..7e8f14f2a53 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -549,7 +549,6 @@ class AccountancyExport $end_line = "\n"; foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d%m%Y'); print $line->id . $separator; @@ -585,7 +584,6 @@ class AccountancyExport $end_line = "\n"; foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d%m%Y'); print $line->piece_num . $separator; @@ -625,7 +623,6 @@ class AccountancyExport $end_line = "\n"; foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); print $date . $separator; @@ -934,7 +931,6 @@ class AccountancyExport $end_line = "\r\n"; foreach ($objectLines as $line) { - $date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); @@ -1087,7 +1083,6 @@ class AccountancyExport print $end_line; foreach($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%Y%m%d'); print $date . $separator; //Date diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index f9c2e3391ba..21cbdeb9662 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -407,7 +407,6 @@ class AccountingAccount extends CommonObject $result = $this->checkUsage(); if ($result > 0) { - $this->db->begin(); // if (! $error) { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 16dc458d833..24d2936680a 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1584,9 +1584,7 @@ class BookKeeping extends CommonObject dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - while ($obj = $this->db->fetch_object($result)) { - $line = new BookKeepingLine(); $line->id = $obj->rowid; diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index e20b49dbd25..ef63fc8b15f 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -149,7 +149,6 @@ class Lettering extends BookKeeping } } } elseif ($obj->type == 'payment') { - $sql = 'SELECT DISTINCT bk.rowid, fac.ref, fac.ref, pay.fk_bank, fac.rowid as fact_id'; $sql .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 52057485a30..00c4a945ff9 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -112,7 +112,6 @@ if (! empty($id)) { $i = 0; if ($num_lines) { - $objp = $db->fetch_object($result); print '' . "\n"; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 68649aa264d..f43ca801c25 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -97,7 +97,6 @@ if ($action == 'clean' || $action == 'validatehistory') } if ($action == 'validatehistory') { - $error = 0; $db->begin(); @@ -195,7 +194,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print ''; for($i = 1; $i <= 12; $i ++) { print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index d3fc63d3bf8..ea855921c5a 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -94,7 +94,6 @@ if ($action == 'clean' || $action == 'validatehistory') } if ($action == 'validatehistory') { - $error = 0; $db->begin(); @@ -187,7 +186,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print ' diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index b24e3361d16..2848ed4119e 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -94,7 +94,6 @@ $hookmanager->initHooks(array('membertypecard','globalcard')); */ if ($cancel) { - $action=''; if (! empty($backtopage)) { diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index a13b7bd1580..3caa3418af5 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -268,7 +268,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Active if (in_array($name, $def)) { - print ''."\n"; if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''; print ''."\n"; print ''."\n"; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 689202c023d..70b273e2fcc 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -253,7 +253,6 @@ $i = 0; $nbofbank = count($bankorder); while ($i < $nbofbank) { - print ''; print ''; // Chemin du binaire genbarcode sous linux if (! isset($_SERVER['WINDIR'])) { - print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -381,7 +380,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index ca90c836929..1e158bc7a7f 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -474,7 +474,6 @@ print ''; // Activate FileCache - Developement if ($conf->global->MAIN_FEATURES_LEVEL == 2 || ! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index cb07d741a06..5bb2dbe79ed 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -282,7 +282,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) { if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -299,7 +298,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print ''; @@ -423,7 +421,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index dde962fe9bc..e6ea9a2cb17 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -470,7 +470,6 @@ print ''."\n"; // Barcode if (! empty($conf->barcode->enabled)) { - print ''; print ''; @@ -555,7 +554,6 @@ print ''; // ProfID1 if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { - print ''; @@ -359,7 +357,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index d69a14deb2e..7e724c52280 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -265,7 +265,6 @@ print '
'; print ''.$langs->trans("DescWeather").' '; if($action == 'edit') { - $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod')); $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod')); if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; @@ -292,8 +291,6 @@ $text=''; $options='class="valignmiddle" height="60px"'; if ($action == 'edit') { - - print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>'; print '
'; @@ -364,9 +361,7 @@ if ($action == 'edit') { global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - print '
'; print '
'; print img_weather($text, 0, $options); @@ -386,7 +381,6 @@ if ($action == 'edit') { print '
'; print '
'; } else { - print '
'; print '
'; print img_weather($text, 0, $options); @@ -411,11 +405,9 @@ if ($action == 'edit') { print '
'; if($action == 'edit') { - print '
'; print '
'; } else { - print '
'; } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 31ade656480..501a6d18113 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1728,7 +1728,6 @@ else { if ($showemptyline) { - print '
'; $showemptyline=0; } diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 4951f57c22f..e65eb2bbb0a 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -226,7 +226,6 @@ class Dolistore $html .= self::get_categories($cat->id); $html .= "\n"; } else { - } } diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index e8dbfab9942..29ef6d40a1e 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -366,7 +366,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 8dde3449b6e..8a5cef82ceb 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -247,7 +247,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print ''; @@ -367,10 +366,8 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index d16f3e493f5..e3adeaca890 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -300,7 +300,6 @@ if ($resql) // Logo if ($result > 0 && empty($rss->error)) { - print ''; print ""; print ''; @@ -303,7 +302,6 @@ print '
'; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - /* * Documents models for Holidays */ @@ -369,7 +367,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index ea19b7034a6..27f99ecb4f1 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -172,7 +172,6 @@ if (empty($mysoc->country_code)) } else { - // Show examples print ''.$langs->trans("ExamplesWithCurrentSetup").":
\n"; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 1f8a74f6eb8..99cd481095b 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -356,8 +356,6 @@ foreach ($dirmodels as $reldir) { if (file_exists($dir.'/'.$file)) { - - $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index ff2b788a026..79d152fb7bf 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -364,7 +364,6 @@ if ($action == 'edit') // ID if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { - $mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID)?$conf->global->MAIN_MAIL_SMTPS_ID:''); print ''; print ''; print ''; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 4c8f4188e4b..db9efb0e5c7 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -294,7 +294,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print ''; @@ -596,7 +595,6 @@ if (empty($conf->facture->enabled)) $i = 0; while ($i < $num) { - $row = $db->fetch_row($resql); print '
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).'
'; if ($row[0] == 'tobind') { @@ -271,7 +269,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print '
'; if ($row[0] == 'tobind') { @@ -398,7 +395,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print '
' . $row[0] . '' . price(price2num($row[$i])) . '
'; if ($row[0] == 'tobind') { @@ -259,7 +257,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print '
'; if ($row[0] == 'tobind') { diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 2dd4f845c39..6e709835f42 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -167,7 +167,6 @@ $journal_label = $accountingjournalstatic->label; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); //print $sql; @@ -268,10 +267,8 @@ if ($result) { // get_url may return -1 which is not traversable if (is_array($links) && count($links) > 0) { - // Now loop on each link of record in bank. foreach ($links as $key => $val) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) { // So we excluded 'company' and 'user' here. We want only payment lines diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 23d97360563..6cefc893b39 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -115,7 +115,6 @@ $sql .= " ORDER BY er.date_debut"; dol_syslog('accountancy/journal/expensereportsjournal.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { - $taber = array (); $tabht = array (); $tabtva = array (); @@ -485,7 +484,6 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! } if (empty($action) || $action == 'view') { - llxHeader('', $langs->trans("ExpenseReportsJournal")); $nom = $langs->trans("ExpenseReportsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index c83c004c6b2..ddf456c85f0 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -242,7 +242,6 @@ if ($action == 'writebookkeeping') { $invoicestatic = new FactureFournisseur($db); foreach ($tabfac as $key => $val) { // Loop on each invoice - $errorforline = 0; $totalcredit = 0; @@ -716,7 +715,6 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! } if (empty($action) || $action == 'view') { - llxHeader('', $langs->trans("PurchasesJournal")); $nom = $langs->trans("PurchasesJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 17b2657b5dc..ed56065df0a 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -255,7 +255,6 @@ if ($action == 'writebookkeeping') { $invoicestatic = new Facture($db); foreach ($tabfac as $key => $val) { // Loop on each invoice - $errorforline = 0; $totalcredit = 0; @@ -654,7 +653,6 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if (empty($action) || $action == 'view') { - llxHeader('', $langs->trans("SellsJournal")); $nom = $langs->trans("SellsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 88a599d1fc5..faa48ac9176 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -95,7 +95,6 @@ if ($action == 'clean' || $action == 'validatehistory') } if ($action == 'validatehistory') { - $error = 0; $db->begin(); @@ -187,7 +186,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print '
'; if ($row[0] == 'tobind') { @@ -258,7 +256,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print '
'; if ($row[0] == 'tobind') { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 2bcbc21c3a0..e9bd50de0ff 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2370,7 +2370,6 @@ class Adherent extends CommonObject $langs->load("orders"); if (! dol_strlen($modele)) { - $modele = 'standard'; if ($this->modelpdf) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index a57a90a3aac..94df4b10ba0 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -383,7 +383,6 @@ class AdherentType extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->description = $this->db->escape($this->note); // Multilangs diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 092827ef731..a6343596632 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -90,7 +90,6 @@ if ($id > 0) $result=$membert->fetch($object->typeid); if ($result > 0) { - // Build file list $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); $totalsize=0; diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index 4334a54605b..8e2ec3ba730 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -39,7 +39,6 @@ $langs->load("members"); $total=0; foreach($linkedObjectBlock as $key => $objectlink) { - ?>
trans("Subscription"); ?>'."\n"; if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") { @@ -363,7 +362,6 @@ print '
'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'
' . $bankorder[$i][0] . "\n"; print $bankorder[$i][1]; @@ -341,7 +340,6 @@ foreach ($dirmodels as $reldir) { foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir . '/' . $file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 0475cdfccf1..b6c9a5dec9a 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -319,7 +319,6 @@ print '
'.$langs->trans("GenbarcodeLocation").''; @@ -335,7 +334,6 @@ if (! isset($_SERVER['WINDIR'])) // Module products if (! empty($conf->product->enabled)) { - print '
'.$langs->trans("SetDefaultBarcodeTypeProducts").''; @@ -346,7 +344,6 @@ if (! empty($conf->product->enabled)) // Module thirdparty if (! empty($conf->societe->enabled)) { - print '
'.$langs->trans("SetDefaultBarcodeTypeThirdParties").''; diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index e5e12d41808..5bf01de1053 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -255,7 +255,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print '
'.$module->name."\n"; print $module->info(); print '
'.$langs->trans("EnableFileCache").''; print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1); print '
'.$module->name."\n"; print $module->info(); print '
'; print '
'; if (! empty($mysoc->country_code)) { @@ -571,7 +569,6 @@ if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') // ProfId2 if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { - print '
'; if (! empty($mysoc->country_code)) { @@ -587,7 +584,6 @@ if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') // ProfId3 if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { - print '
'; if (! empty($mysoc->country_code)) { @@ -603,7 +599,6 @@ if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') // ProfId4 if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { - print '
'; if (! empty($mysoc->country_code)) { @@ -619,7 +614,6 @@ if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') // ProfId5 if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { - print '
'; if (! empty($mysoc->country_code)) { @@ -635,7 +629,6 @@ if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') // ProfId6 if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { - print '
'; if (! empty($mysoc->country_code)) { diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index bb2bfdde409..0955d7c6d17 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -68,7 +68,6 @@ if ($action == 'update') if (in_array($accounting_mode, $accounting_modes)) { - if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { $error++; } diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 53555a35586..37559c3d4ab 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -118,7 +118,6 @@ if (! empty($consts) && $action == 'update') // Mass delete if (! empty($consts) && $action == 'delete') { - $nbdeleted=0; foreach($consts as $const) { diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index e6c8c15c0d4..0aa97dd36e6 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -219,7 +219,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) { if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -236,7 +235,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print '
'.$module->nom."\n"; print $module->info(); print '
   
'.$module->nom."\n"; print $module->info(); print '
".$langs->trans("Logo")."'; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 759038930ef..dccfcdfdda1 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -720,7 +720,6 @@ if ($resql) $i = 0; while ($i < $num) { - $row = $db->fetch_row($resql); print '
'.$module->nom."\n"; print $module->info(); print '
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''; // SuperAdministrator access only @@ -384,7 +383,6 @@ if ($action == 'edit') // PW if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { - $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:''); print '
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''; // SuperAdministrator access only diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 3d6cfc2d228..94f3820c5b9 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -316,7 +316,6 @@ if ($action == 'edit') // ID if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) { - $mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING)?$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING:''); print '
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''; // SuperAdministrator access only diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 43888d3e061..5a54a9e5c9f 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -323,7 +323,6 @@ if ($action == 'create') $res = $db->query($sql); if ($res) { - while ($menu = $db->fetch_array($res)) { $parent_rowid = $menu['rowid']; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index f26e657679a..687c3750c89 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -729,7 +729,6 @@ if ($mode == 'common') print ''; } else { - print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index cc1d53d14f8..6d1a5c57cf6 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -164,7 +164,6 @@ print ''; $i=0; foreach($listofnotifiedevents as $notifiedevent) { - $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); @@ -209,7 +208,6 @@ $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); foreach($listofnotifiedevents as $notifiedevent) { - $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 20c0ae222eb..bb3c83c2ee2 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -122,7 +122,6 @@ dol_fiche_head($head, 'tokengeneration', '', -1, 'technic'); if ($mode == 'setup' && $user->admin) { - print $langs->trans("OAuthSetupForLogin")."

\n"; foreach($list as $key) @@ -381,7 +380,6 @@ if ($mode == 'userconf' && $user->admin) $sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid'; $resql = $db->query($sql); while ($row=$db->fetch_array($resql)) { - print '
'.$row['login'].''.$row['module'].'
'.$module->nom."\n"; print $module->info(); print '
'; diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 73cad8f69ad..833d6c25d22 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -207,7 +207,6 @@ if ($action == 'edit') } else { - if (! count($listofmethods)) print '
'.$langs->trans("NoSmsEngine", 'DoliStore').'
'; print '
'; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 27a126c7ef6..9cb387aedc9 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -237,7 +237,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) { if (substr($file, 0, 24) == 'mod_facture_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -365,7 +364,6 @@ foreach ($dirmodels as $reldir) if (is_dir($dir)) { - $handle=opendir($dir); diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index ac7d5e98539..6369efb1361 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -267,7 +267,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) { if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php') diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 65bb18fcc5f..8da430a9fa1 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -213,7 +213,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) { if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) @@ -337,7 +336,6 @@ foreach ($dirmodels as $reldir) if (is_dir($dir)) { - $handle=opendir($dir); diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 55fb4329d39..bd2cb10a3ad 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -246,7 +246,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) { if (substr($file, 0, 22) == 'mod_supplier_proposal_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -263,7 +262,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print ''; @@ -537,7 +535,6 @@ print ''; if ($conf->banque->enabled) { - print ''; } diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 92823045a62..bd93d7a9fc5 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -50,7 +50,6 @@ foreach ($dirsyslogs as $reldir) { $handle = opendir($newdir); if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { if (substr($file, 0, 11) == 'mod_syslog_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index 195b5c83143..01836dd4a72 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -202,7 +202,6 @@ else if ($resql) { while ($row = $db->fetch_row($resql)) { - $rescount = $db->query("SELECT COUNT(*) FROM " . $row[0]); if ($rescount) { $row_count = $db->fetch_row($rescount); diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index d97252dc53b..8bb39f0056b 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -214,7 +214,6 @@ foreach ($dirmodels as $reldir) { if (is_dir($dir)) { $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) { $file = $reg[1]; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index ba2dde77bec..4d234e266e8 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -108,7 +108,6 @@ if ($action == 'update') } else { - $db->rollback(); if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -158,7 +157,6 @@ if ($action == 'add') } else { - $db->rollback(); if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 2ead8e03210..ba6c3660bcd 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -239,7 +239,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index c0c4e3c57d8..190391b462b 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -186,7 +186,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 1c7fe75f0de..0343fecf69d 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -572,7 +572,6 @@ if ($id) // Lines with values while ($i < $num) { - $obj = $db->fetch_object($resql); //print_r($obj); print ''; diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 6803f9d65e7..459bd2d8edc 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -83,7 +83,6 @@ $hookmanager->initHooks(array('assettypecard','globalcard')); */ if ($cancel) { - $action=''; if (! empty($backtopage)) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index a0bb66f2b81..1ed7c449868 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -197,7 +197,6 @@ if ($action == 'builddoc') // For labels if ($mode == 'label') { - $txtforsticker="%PHOTO%"; // Photo will be barcode image, %BARCODE% posible when using TCPDF generator $textleft=make_substitutions((empty($conf->global->BARCODE_LABEL_LEFT_TEXT)?$txtforsticker:$conf->global->BARCODE_LABEL_LEFT_TEXT), $substitutionarray); $textheader=make_substitutions((empty($conf->global->BARCODE_LABEL_HEADER_TEXT)?'':$conf->global->BARCODE_LABEL_HEADER_TEXT), $substitutionarray); diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index b44f27f7fe8..1f0c82e780b 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -92,7 +92,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } if ($action === 'downloadblockchain') { - $auth = new BlockedLogAuthority($db); $bc = $auth->getLocalBlockChain(); diff --git a/htdocs/blockedlog/ajax/authority.php b/htdocs/blockedlog/ajax/authority.php index bcbb4a66f91..45479c1e4db 100644 --- a/htdocs/blockedlog/ajax/authority.php +++ b/htdocs/blockedlog/ajax/authority.php @@ -51,7 +51,6 @@ if($auth->fetch(0, $signature)<=0) { if(!empty($hash)) { - echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk'; } elseif(!empty($newblock)){ @@ -62,7 +61,6 @@ elseif(!empty($newblock)){ echo 'blockadded'; } else{ - echo 'blockalreadyadded'; } } diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 7325f9ae50c..cec6410b7b6 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -310,17 +310,14 @@ class BlockedLogAuthority $signature=$block_static->getSignature(); foreach($blocks as &$block) { - $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature; $res = file_get_contents($url); echo $block->signature.' '.$url. ' '.$res.'
'; if($res === 'blockalreadyadded' || $res === 'blockadded') { - $block->setCertified(); } else { - $this->error = $langs->trans('ImpossibleToContactAuthority ', $url); return -1; } diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 14366f46de7..24548f736f2 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -977,7 +977,6 @@ class BlockedLog if (empty($cachedlogs)) $cachedlogs=array(); if ($element=='all') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity; } @@ -1006,7 +1005,6 @@ class BlockedLog $res = $this->db->query($sql); if($res) { - $results=array(); $i = 0; @@ -1046,7 +1044,6 @@ class BlockedLog global $db,$conf,$mysoc; if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint - require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 9b2646b3e9d..84560d5a533 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -943,7 +943,6 @@ class BOM extends CommonObject $langs->load("mrp"); if (! dol_strlen($modele)) { - $modele = 'standard'; if ($this->modelpdf) { diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 1e54cc816fd..8128815ef3b 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -38,7 +38,6 @@ function printBookmarksList($aDb, $aLangs) $ret = ''."\n"; if (! empty($conf->use_javascript_ajax)) { // Bookmark autosubmit can't work when javascript is off. - require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; if (! isset($conf->global->BOOKMARKS_SHOW_IN_MENU)) $conf->global->BOOKMARKS_SHOW_IN_MENU=5; diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 0ba6d7569b5..7feb0aac37a 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -54,7 +54,6 @@ $object=new Bookmark($db); if ($action == 'add' || $action == 'addproduct' || $action == 'update') { - if ($action == 'update') { $invertedaction = 'edit'; } else { diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index 22b8fea0a05..f9c438149e7 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -125,7 +125,6 @@ print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s. print ''; if (! empty($conf->banque->enabled)) { - print ''; print ''; // Force warehouse (this is not a default value) print ''); } else { - echo (''); } ?> @@ -87,16 +85,13 @@ $langs->loadLangs(array("main","bills","banks")); getsetPaymentMode() == 'DIF' ) { - echo (''); } else { - echo (''); } // Affichage du montant rendu (reglement en especes) if ( $obj_facturation->montantRendu() ) { - echo (''); } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 48bb4179afc..cd3885b77b1 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1637,7 +1637,6 @@ class Categorie extends CommonObject { $nbfile = count($file['name']); for ($i = 0; $i <= $nbfile; $i ++) { - $originImage = $dir . $file['name'][$i]; // Cree fichier en taille origine diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 70cf6e3e8f7..6def65666a0 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -69,7 +69,6 @@ if ($id > 0) if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->id) { - $file = $_FILES['userfile']; if (is_array($file['name']) && count($file['name']) > 0) { diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 737b488c090..fb246b5358b 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -125,7 +125,6 @@ if ($id > 0 && $removeelem > 0) $elementtype = 'member'; } elseif ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) { - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); @@ -644,7 +643,6 @@ if ($type == Categorie::TYPE_CONTACT) } else { - print ''; print ''; print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index cc3accde763..6e8c5535f03 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -278,7 +278,6 @@ if (empty($reshook) && $action == 'add') $taskid = GETPOST('taskid', 'int'); if(!empty($taskid)){ - $taskProject = new Task($db); if($taskProject->fetch($taskid)>0){ $object->fk_project = $taskProject->fk_project; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index e6ee5e9d1d0..fc343f443a2 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -631,7 +631,6 @@ $currentdaytoshow = $firstdaytoshow; echo '
'; while($currentdaytoshow<$lastdaytoshow) { - echo '
'.$module->nom."\n"; print $module->info(); print '
'; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; if (! empty($conf->use_javascript_ajax)) @@ -559,7 +556,6 @@ if ($conf->banque->enabled) } else { - print '
'; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '.$langs->trans('NotAvailable').'
'.$langs->trans("CashDeskBankAccountForSell").''; $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH, 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", 1); @@ -146,7 +145,6 @@ if (! empty($conf->banque->enabled)) if (! empty($conf->stock->enabled)) { - print '
'.$langs->trans("CashDeskDoNotDecreaseStock").''; if (empty($conf->productbatch->enabled)) { diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 40b338ccca6..2f8a993829e 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -296,12 +296,10 @@ class Facturation } elseif ( $aId == 'RESET' ) { - $this->id = null; } else { - $this->id = $aId; } } @@ -343,7 +341,6 @@ class Facturation } elseif ( $aQte == 'RESET' ) { - $this->qte = null; } else @@ -408,13 +405,10 @@ class Facturation { if (is_null($aMontantRemise)) { - return $this->montant_remise; } elseif ( $aMontantRemise == 'RESET' ) { - $this->montant_remise = null; } else { - $this->montant_remise = $aMontantRemise; } } @@ -429,13 +423,10 @@ class Facturation { if (is_null($aPrix)) { - return $this->prix; } elseif ( $aPrix == 'RESET' ) { - $this->prix = null; } else { - $this->prix = $aPrix; } } @@ -449,13 +440,10 @@ class Facturation public function tva($aTva = null) { if (is_null($aTva)) { - return $this->tva; } elseif ( $aTva == 'RESET' ) { - $this->tva = null; } else { - $this->tva = $aTva; } } @@ -469,13 +457,10 @@ class Facturation public function numInvoice($aNumFacture = null) { if (is_null($aNumFacture)) { - return $this->num_facture; } elseif ( $aNumFacture == 'RESET' ) { - $this->num_facture = null; } else { - $this->num_facture = $aNumFacture; } } @@ -490,13 +475,10 @@ class Facturation { if (is_null($aModeReglement)) { - return $this->mode_reglement; } elseif ( $aModeReglement == 'RESET' ) { - $this->mode_reglement = null; } else { - $this->mode_reglement = $aModeReglement; } } @@ -511,13 +493,10 @@ class Facturation { if (is_null($aMontantEncaisse)) { - return $this->montant_encaisse; } elseif ( $aMontantEncaisse == 'RESET' ) { - $this->montant_encaisse = null; } else { - $this->montant_encaisse = $aMontantEncaisse; } } @@ -532,13 +511,10 @@ class Facturation { if (is_null($aMontantRendu)) { - return $this->montant_rendu; } elseif ( $aMontantRendu == 'RESET' ) { - $this->montant_rendu = null; } else { - $this->montant_rendu = $aMontantRendu; } } @@ -552,13 +528,10 @@ class Facturation public function paiementLe($aPaiementLe = null) { if (is_null($aPaiementLe)) { - return $this->paiement_le; } elseif ( $aPaiementLe == 'RESET' ) { - $this->paiement_le = null; } else { - $this->paiement_le = $aPaiementLe; } } @@ -572,13 +545,10 @@ class Facturation public function prixTotalHt($aTotalHt = null) { if (is_null($aTotalHt)) { - return $this->prix_total_ht; } elseif ( $aTotalHt == 'RESET' ) { - $this->prix_total_ht = null; } else { - $this->prix_total_ht = $aTotalHt; } } @@ -592,13 +562,10 @@ class Facturation public function montantTva($aMontantTva = null) { if (is_null($aMontantTva)) { - return $this->montant_tva; } elseif ( $aMontantTva == 'RESET' ) { - $this->montant_tva = null; } else { - $this->montant_tva = $aMontantTva; } } diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index f7e7c3af501..c52ecccef77 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -36,7 +36,6 @@ $form=new Form($db); // Get list of articles (in warehouse '$conf_fkentrepot' if defined and stock module enabled) if ( GETPOST('filtre', 'alpha') ) { - // Avec filtre $ret=array(); $i=0; @@ -88,7 +87,6 @@ if ( GETPOST('filtre', 'alpha') ) { } $tab_designations=$ret; } else { - // Sans filtre $ret=array(); $i=0; diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index a35abb46789..d892c1df0e6 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -57,10 +57,8 @@ else echo ('

'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'

'."\n"); if ( $tab[$i]['remise_percent'] > 0 ) { - $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; } else { - $remise_percent = ''; } diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index 64f340983ff..e8c16712b74 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -39,12 +39,10 @@ $langs->loadLangs(array("main","bills","banks")); montantTva() ) { - echo ('
'.$langs->trans("VAT").''.price(price2num($obj_facturation->montantTva(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("VAT").''.$langs->trans("NoVAT").'
'.$langs->trans("DateDue").''.$obj_facturation->paiementLe().'
'.$langs->trans("Received").''.price(price2num($obj_facturation->montantEncaisse(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("Change").''.price(price2num($obj_facturation->montantRendu(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'
'; echo ''; @@ -779,7 +778,6 @@ while($currentdaytoshow<$lastdaytoshow) { $i = 0; for ($iter_day = 0; $iter_day < 8; $iter_day++) { - if (($i + 1) < $begin_d || ($i + 1) > $end_d) { $i++; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 5d1b7ba919e..8cc1774cba2 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -144,7 +144,6 @@ if ($resql) if ($obj) { - print ''; // Date diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index c0d2c4703ca..43af4f8f1c0 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -208,7 +208,6 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) } else { - print ''; } print "
'.$langs->trans("NoProposal").'

"; @@ -379,7 +378,6 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) } else { - print ''.$langs->trans("NoOrder").''; } print ""; @@ -430,7 +428,6 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $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; @@ -470,7 +467,6 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande } else { - print ''.$langs->trans("NoSupplierOrder").''; } print ""; diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 9544a394508..1049431b7f2 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -114,7 +114,6 @@ if ($action == 'loadfilter') { } if ($action == 'add') { - $user_contact_query = false; $array_query = array (); @@ -168,7 +167,6 @@ if ($action == 'add') { } if (preg_match("/^contact_/", $key)) { - $array_query[$key] = GETPOST($key); $specials_date_key = array ( @@ -262,7 +260,6 @@ if ($action == 'clear') { } if ($action == 'savefilter' || $action == 'createfilter') { - $template_name = GETPOST('template_name'); $error = 0; @@ -272,7 +269,6 @@ if ($action == 'savefilter' || $action == 'createfilter') { } if (empty($error)) { - $array_query = array (); // Get extra fields @@ -325,7 +321,6 @@ if ($action == 'savefilter' || $action == 'createfilter') { } if (preg_match("/^contact_/", $key)) { - $array_query[$key] = GETPOST($key); $specials_date_key = array ( @@ -359,7 +354,6 @@ if ($action == 'savefilter' || $action == 'createfilter') { setEventMessages($advTarget->error, $advTarget->errors, 'errors'); } } elseif ($action == 'savefilter') { - $result = $advTarget->update($user); if ($result < 0) { setEventMessages($advTarget->error, $advTarget->errors, 'errors'); @@ -421,7 +415,6 @@ $formcompany = new FormCompany($db); $formother = new FormOther($db); if ($object->fetch($id) >= 0) { - $head = emailing_prepare_head($object); dol_fiche_head($head, 'advtargets', $langs->trans("Mailing"), 0, 'email'); @@ -465,7 +458,6 @@ if ($object->fetch($id) >= 0) { // Show email selectors if ($object->statut == 0 && $user->rights->mailing->creer) { - include DOL_DOCUMENT_ROOT . '/core/tpl/advtarget.tpl.php'; } } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 7346bf87543..465bf7dcc50 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -556,7 +556,6 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]= 't.entity IN ('.getEntity('societe').')'; if (count($arrayquery)>0) { - if (array_key_exists('cust_saleman', $arrayquery)) { $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as saleman ON saleman.fk_soc=t.rowid "; } @@ -565,7 +564,6 @@ class AdvanceTargetingMailing extends CommonObject } if (!empty($arrayquery['cust_name'])) { - $sqlwhere[]= $this->transformToSQL('t.nom', $arrayquery['cust_name']); } if (!empty($arrayquery['cust_code'])) { @@ -617,13 +615,11 @@ class AdvanceTargetingMailing extends CommonObject //Standard Extrafield feature if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $elementtype = Societe::$table_element; $extrafields->fetch_name_optionals_label($elementtype); foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) { - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { if (!empty($arrayquery['options_'.$key])) { @@ -713,7 +709,6 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]= 't.entity IN ('.getEntity('socpeople').')'; if (count($arrayquery)>0) { - if (array_key_exists('contact_categ', $arrayquery)) { $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_contact as contactcateg ON contactcateg.fk_socpeople=t.rowid "; } @@ -767,7 +762,6 @@ class AdvanceTargetingMailing extends CommonObject $extrafields->fetch_name_optionals_label($elementtype); foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) { - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { if (!empty($arrayquery['options_'.$key.'_cnct'])) { @@ -809,7 +803,6 @@ class AdvanceTargetingMailing extends CommonObject } if (!empty($arrayquery['cust_name'])) { - $sqlwhere[]= $this->transformToSQL('ts.nom', $arrayquery['cust_name']); } if (!empty($arrayquery['cust_code'])) { @@ -870,7 +863,6 @@ class AdvanceTargetingMailing extends CommonObject $extrafields->fetch_name_optionals_label($elementtype); foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) { - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { if (!empty($arrayquery['options_'.$key])) { diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 55b7177eb73..67ec7414e7c 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -114,7 +114,6 @@ class FormAdvTargetEmailing extends Form dol_syslog(get_class($this) . "::select_country sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); $i = 0; if ($num) { @@ -175,7 +174,6 @@ class FormAdvTargetEmailing extends Form $resql_usr = $this->db->query($sql_usr); if ($resql_usr) { while ( $obj_usr = $this->db->fetch_object($resql_usr) ) { - $label = $obj_usr->firstname . " " . $obj_usr->name . " (" . $obj_usr->login . ')'; $options_array [$obj_usr->rowid] = $label; @@ -249,7 +247,6 @@ class FormAdvTargetEmailing extends Form $sql = 'SELECT ' . $keyList . ', ' . $InfoFieldList [1]; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList [0]; if (! empty($InfoFieldList [3])) { - // We have to join on extrafield table if (strpos($InfoFieldList [3], 'extra') !== false) { $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList [0] . '_extrafields as extra'; @@ -266,7 +263,6 @@ class FormAdvTargetEmailing extends Form dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); $i = 0; if ($num) { @@ -306,7 +302,6 @@ class FormAdvTargetEmailing extends Form $resql=$this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -396,7 +391,6 @@ class FormAdvTargetEmailing extends Form $resql=$this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -442,8 +436,6 @@ class FormAdvTargetEmailing extends Form dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - - $out .= ''; print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4e72c6312e6..5cd3902b7d1 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -265,7 +265,6 @@ class Account extends CommonObject $string = ''; foreach ($this->getFieldsToShow() as $val) { - if ($val == 'BankCode') { $string .= $this->code_banque.' '; } elseif ($val == 'BankAccountNumber') { @@ -493,7 +492,6 @@ class Account extends CommonObject } if ($accline->insert() > 0) { - if ($categorie>0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; $sql .= "lineid, fk_categ"; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 0d517a43fec..32bfe66f7d1 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -97,7 +97,6 @@ $form = new Form($db); if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { - $upload_dir = $conf->bank->dir_output . '/' . $object->ref; // Onglets diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2a08c55eeba..f7ec617ee1d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1822,7 +1822,6 @@ if (empty($reshook)) } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - $ret = $object->fetch($id); if ($ret < 0) { dol_print_error($db, $object->error); @@ -2327,7 +2326,6 @@ if (empty($reshook)) // Change each progression persent on each lines foreach($object->lines as $line) { - // no traitement for special product if ($line->product_type == 9 ) continue; @@ -3185,7 +3183,6 @@ if ($action == 'create') if (! empty($conf->global->INVOICE_USE_SITUATION)) { if($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY){ - $rwStyle = 'display:none;'; if(GETPOST('type', 'int') == Facture::TYPE_SITUATION){ $rwStyle = ''; @@ -4347,7 +4344,6 @@ elseif ($id > 0 || ! empty($ref)) // List of previous situation invoices if (($object->situation_cycle_ref > 0) && ! empty($conf->global->INVOICE_USE_SITUATION)) { - print ''; @@ -4660,7 +4656,6 @@ elseif ($id > 0 || ! empty($ref)) // Retained warranty : usualy use on construction industry if(!empty($object->situation_final) && !empty($object->retained_warranty) && $displayWarranty){ - // Billed - retained warranty if($object->type == Facture::TYPE_SITUATION) { diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 18d153dc597..9ff90b7b025 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1839,7 +1839,6 @@ class FactureLigneRec extends CommonInvoiceLine $result = $this->db->query($sql); if ($result) { - $objp = $this->db->fetch_object($result); $this->id = $objp->rowid; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6149a161694..84835fa9608 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -848,7 +848,6 @@ class Facture extends CommonInvoice if (! $error) { - $result=$this->update_price(1); if ($result > 0) { @@ -1933,7 +1932,6 @@ class Facture extends CommonInvoice if (! $error) { - $this->ref_client = $ref_client; $this->db->commit(); @@ -3465,7 +3463,6 @@ class Facture extends CommonInvoice $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/facture/"); // Load file with numbering class (if found) @@ -5216,7 +5213,6 @@ class FactureLigne extends CommonInvoiceLine $returnPercent = floatval($res['situation_percent']); if($include_credit_note) { - $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd'; $sql.= ' JOIN ' . MAIN_DB_PREFIX . 'facture f ON (f.rowid = fd.fk_facture) '; $sql.= ' WHERE fd.fk_prev_id =' . $this->fk_prev_id; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 77abac6e4d1..1fed45f09cd 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -356,7 +356,6 @@ if ($massaction == 'withdrawrequest') } else { - $db->rollback(); setEventMessages($aBill->error, $aBill->errors, 'errors'); } diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 86388fd7e87..e7762b834e4 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -61,7 +61,6 @@ if ($_POST["cancel"] == $langs->trans("Cancel") && ! $id) if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { - $db->begin(); $datev=dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 1e6ab5b4da1..97f97bbc735 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -195,7 +195,6 @@ if($calc ==0 || $calc == 2) { if(($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) !=0) { - $intra = str_replace($find, $replace, $coll->tva_intra); if(empty($intra)) { @@ -269,7 +268,6 @@ if($calc ==0 || $calc == 1){ { if(($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) != 0) { - $intra = str_replace($find, $replace, $coll->tva_intra); if(empty($intra)) { diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 9ab469376e5..3afce69e94b 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -444,7 +444,6 @@ if ($action == 'new') foreach ($accounts as $bid => $account_label) { - print ' '; } elseif (GETPOST('action') == 'confirm_delete' && GETPOST('confirm') == 'yes' && GETPOST('socid') > 0) { - // La suppression n'a pas été possible require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $societe = new Societe($this->db); $societe->fetch(GETPOST('socid')); // On vérifie si il est utilisé if ((in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $societe->typent_id == 8) && $societe->isObjectUsed(GETPOST('socid'))) { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; $form = new Form($this->db); echo $form->formconfirm($_SERVER["PHP_SELF"] . "?socid=" . GETPOST('socid'), substr($langs->trans("DATAPOLICIES_POPUP_ANONYME_TITLE"), 0, strlen($langs->trans("DATAPOLICIES_POPUP_ANONYME_TITLE")) - 2), $langs->trans("DATAPOLICIES_POPUP_ANONYME_TEXTE"), 'anonymiser', '', '', 1); @@ -428,7 +424,6 @@ class ActionsDatapolicy $societe->fetch(GETPOST('socid')); if (!in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) && $societe->typent_id != 8) { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; $jsscript .= '