From c3518426bde70dacda369a99579f9f0600e04366 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 3 Jan 2020 22:05:49 +0100 Subject: [PATCH 01/14] NEW Accountancy - Add possibility to manage an short alternative label - use to simplify --- htdocs/accountancy/admin/account.php | 26 +++++++++++--- htdocs/accountancy/admin/card.php | 18 ++++++++-- .../class/accountingaccount.class.php | 35 ++++++++++++++----- .../core/class/html.formaccounting.class.php | 17 ++++++--- .../install/mysql/migration/11.0.0-12.0.0.sql | 1 + .../mysql/tables/llx_accounting_account.sql | 3 +- 6 files changed, 80 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 9c4536e94c4..4caad5cfa94 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2016-2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -41,6 +41,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'acc $search_account = GETPOST('search_account', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); +$search_labelshort = GETPOST('search_labelshort', 'alpha'); $search_accountparent = GETPOST('search_accountparent', 'alpha'); $search_pcgtype = GETPOST('search_pcgtype', 'alpha'); $search_pcgsubtype = GETPOST('search_pcgsubtype', 'alpha'); @@ -64,6 +65,7 @@ if (!$sortorder) $sortorder = "ASC"; $arrayfields = array( 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), 'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'), @@ -95,7 +97,8 @@ if (empty($reshook)) { $search_account = ""; $search_label = ""; - $search_accountparent = ""; + $search_labelshort = ""; + $search_accountparent = ""; $search_pcgtype = ""; $search_pcgsubtype = ""; $search_array_options = array(); @@ -190,7 +193,7 @@ if ($action == 'delete') { $pcgver = $conf->global->CHARTOFACCOUNTS; -$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, "; +$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.active, "; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity; @@ -200,6 +203,7 @@ $sql .= " WHERE asy.rowid = ".$pcgver; //print $sql; if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); +if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort); if (strlen(trim($search_accountparent))) $sql .= natural_search("aa.account_parent", $search_accountparent); if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype); if (strlen(trim($search_pcgsubtype))) $sql .= natural_search("aa.pcg_subtype", $search_pcgsubtype); @@ -232,6 +236,7 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($search_account) $param .= '&search_account='.urlencode($search_account); if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_labelshort) $param.= '&search_labelshort='.urlencode($search_labelshort); if ($search_accountparent) $param .= '&search_accountparent='.urlencode($search_accountparent); if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype); @@ -316,8 +321,9 @@ if ($resql) print ''; if (!empty($arrayfields['aa.account_number']['checked'])) print ''; if (!empty($arrayfields['aa.label']['checked'])) print ''; + if (!empty($arrayfields['aa.labelshort']['checked'])) print ''; if (!empty($arrayfields['aa.account_parent']['checked'])) print ''; - if (!empty($arrayfields['aa.pcg_type']['checked'])) print ''; + if (!empty($arrayfields['aa.pcg_type']['checked'])) print ''; if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print ''; if (!empty($arrayfields['aa.active']['checked'])) print ' '; print ''; @@ -329,8 +335,9 @@ if ($resql) print ''; if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); - if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); + if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']); if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -368,6 +375,15 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } + // Account label to show (label short) + if (! empty($arrayfields['aa.labelshort']['checked'])) + { + print ""; + print $obj->labelshort; + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Account parent if (!empty($arrayfields['aa.account_parent']['checked'])) { diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 33ff1e409e9..f2bc1907c7c 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -97,6 +97,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $object->account_parent = $account_parent; $object->account_category = GETPOST('account_category', 'alpha'); $object->label = GETPOST('label', 'alpha'); + $object->labelshort = GETPOST('labelshort', 'alpha'); $object->active = 1; $res = $object->create($user); @@ -162,6 +163,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $object->account_parent = $account_parent; $object->account_category = GETPOST('account_category', 'alpha'); $object->label = GETPOST('label', 'alpha'); + $object->labelshort = GETPOST('labelshort', 'alpha'); $result = $object->update($user); @@ -236,6 +238,10 @@ if ($action == 'create') { print ''.$langs->trans("Label").''; print ''; + // Label short + print '' . $langs->trans("LabelToShow") . ''; + print ''; + // Account parent print ''.$langs->trans("Accountparent").''; print ''; @@ -254,7 +260,7 @@ if ($action == 'create') { print ''; print ''; - // Chart of acounts subtype + // Chart of accounts subtype print ''.$langs->trans("Pcgsubtype").''; print ''; print ''; @@ -301,6 +307,10 @@ elseif ($id > 0 || $ref) { print ''.$langs->trans("Label").''; print ''; + // Label short + print '' . $langs->trans("LabelToShow") . ''; + print ''; + // Account parent print ''.$langs->trans("Accountparent").''; print ''; @@ -354,6 +364,10 @@ elseif ($id > 0 || $ref) { print ''.$langs->trans("Label").''; print ''.$object->label.''; + // Label to show + print '' . $langs->trans("LabelToShow") . ''; + print '' . $object->labelshort . ''; + // Account parent $accp = new AccountingAccount($db); if (!empty($object->account_parent)) { diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index b244d8be123..d1525b56833 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) @@ -120,7 +120,12 @@ class AccountingAccount extends CommonObject */ public $label; - /** + /** + * @var string Label short of account + */ + public $labelshort; + + /** * @var int ID */ public $fk_user_author; @@ -162,7 +167,7 @@ class AccountingAccount extends CommonObject global $conf; if ($rowid || $account_number) { - $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.pcg_subtype, a.account_number, a.account_parent, a.label, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active"; + $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.pcg_subtype, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active"; $sql .= ", ca.label as category_label"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid"; @@ -196,6 +201,7 @@ class AccountingAccount extends CommonObject $this->account_number = $obj->account_number; $this->account_parent = $obj->account_parent; $this->label = $obj->label; + $this->labelshort = $obj->labelshort; $this->account_category = $obj->fk_accounting_category; $this->account_category_label = $obj->category_label; $this->fk_user_author = $obj->fk_user_author; @@ -239,6 +245,8 @@ class AccountingAccount extends CommonObject $this->account_number = trim($this->account_number); if (isset($this->label)) $this->label = trim($this->label); + if (isset($this->labelshort)) + $this->labelshort = trim($this->labelshort); if (empty($this->pcg_type) || $this->pcg_type == '-1') { @@ -261,6 +269,7 @@ class AccountingAccount extends CommonObject $sql .= ", account_number"; $sql .= ", account_parent"; $sql .= ", label"; + $sql .= ", labelshort"; $sql .= ", fk_accounting_category"; $sql .= ", fk_user_author"; $sql .= ", active"; @@ -273,6 +282,7 @@ class AccountingAccount extends CommonObject $sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'"); $sql .= ", " . (empty($this->account_parent) ? 0 : (int) $this->account_parent); $sql .= ", " . (empty($this->label) ? "''" : "'" . $this->db->escape($this->label) . "'"); + $sql .= ", " . (empty($this->labelshort) ? "''" : "'" . $this->db->escape($this->labelshort) . "'"); $sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category); $sql .= ", " . $user->id; $sql .= ", " . (int) $this->active; @@ -344,6 +354,7 @@ class AccountingAccount extends CommonObject $sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'"; $sql .= " , account_parent = " . (int) $this->account_parent; $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "''"); + $sql .= " , labelshort = " . ($this->labelshort ? "'" . $this->db->escape($this->labelshort) . "'" : "''"); $sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category); $sql .= " , fk_user_modif = " . $user->id; $sql .= " , active = " . (int) $this->active; @@ -461,10 +472,11 @@ class AccountingAccount extends CommonObject * @param string $moretitle Add more text to title tooltip * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) * @return string String with URL */ - public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) - { + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0) + { global $langs, $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -482,11 +494,18 @@ class AccountingAccount extends CommonObject $picto = 'billr'; $label=''; + if (empty($this->labelshort) || $withcompletelabel == 1) + { + $labeltoshow = $this->label; + } else { + $labeltoshow = $this->labelshort; + } + $label = '' . $langs->trans("ShowAccountingAccount") . ''; if (! empty($this->account_number)) $label .= '
'.$langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); - if (! empty($this->label)) - $label .= '
'.$langs->trans('Label') . ': ' . $this->label; + if (! empty($labeltoshow)) + $label .= '
'.$langs->trans('Label') . ': ' . $labeltoshow; if ($moretitle) $label.=' - '.$moretitle; $linkclose=''; @@ -513,7 +532,7 @@ class AccountingAccount extends CommonObject } $label_link = length_accountg($this->account_number); - if ($withlabel) $label_link .= ' - ' . $this->label; + if ($withlabel) $label_link .= ' - ' . $labeltoshow; if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index c26a9cd7108..204aeea32f7 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2015 Ari Elbaz (elarifr) * Copyright (C) 2016 Marcos García - * Copyright (C) 2016-2017 Alexandre Spangaro + * Copyright (C) 2016-2020 Alexandre Spangaro * * 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 @@ -292,7 +292,7 @@ class FormAccounting extends Form { $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT) ? 50 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT; - $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; + $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.labelshort, aa.rowid, aa.fk_pcg_version"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; @@ -312,8 +312,17 @@ class FormAccounting extends Form $selected = 0; while ($obj = $this->db->fetch_object($resql)) { - $label = length_accountg($obj->account_number).' - '.$obj->label; - $label = dol_trunc($label, $trunclength); + if (empty($obj->labelshort)) + { + $labeltoshow = $obj->label; + } + else + { + $labeltoshow = $obj->labelshort; + } + + $label = length_accountg($obj->account_number) . ' - ' . $labeltoshow; + $label = dol_trunc($label, $trunclength); $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index b0ecc2b9639..775c6e15a29 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -52,6 +52,7 @@ create table llx_object_lang ALTER TABLE llx_object_lang ADD UNIQUE INDEX uk_object_lang (fk_object, type_object, property, lang); +ALTER TABLE llx_accounting_account ADD COLUMN labelshort varchar(255) DEFAULT NULL after label; diff --git a/htdocs/install/mysql/tables/llx_accounting_account.sql b/htdocs/install/mysql/tables/llx_accounting_account.sql index e06faab0f00..3dbe025dbd3 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.sql @@ -1,7 +1,7 @@ -- ============================================================================ -- Copyright (C) 2004-2006 Laurent Destailleur -- Copyright (C) 2014 Juanjo Menent --- Copyright (C) 2016 Alexandre Spangaro +-- Copyright (C) 2016-2020 Alexandre Spangaro -- -- 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 @@ -31,6 +31,7 @@ create table llx_accounting_account account_number varchar(32) NOT NULL, account_parent integer DEFAULT 0, -- Hierarchic parent. label varchar(255) NOT NULL, + labelshort varchar(255) DEFAULT NULL, fk_accounting_category integer DEFAULT 0, -- ID of personalized group for report fk_user_author integer DEFAULT NULL, fk_user_modif integer DEFAULT NULL, From 2ebad186b72b038743c5a2e00674f8e5ad4c5621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Jan 2020 10:54:19 +0100 Subject: [PATCH 02/14] doxygen --- htdocs/contact/class/contact.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 038cb82845e..e82ab7f1aea 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -181,6 +181,10 @@ class Contact extends CommonObject public $phone_mobile; public $fax; + /** + * Private or public + * @var int + */ public $priv; public $birthday; From 4b90d105e087ee2f1bd40d9a56e6bc813910f80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Jan 2020 14:20:19 +0100 Subject: [PATCH 03/14] can replace formconfirm in order supplier --- htdocs/fourn/commande/card.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 4e6523ff6cb..59c01d95297 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1907,13 +1907,10 @@ elseif (!empty($object->id)) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } - if (!$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; - } + $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; From 7e29e57affc5cf8af0fe7356b3e2103900376ca6 Mon Sep 17 00:00:00 2001 From: simicar29 <53998265+simicar29@users.noreply.github.com> Date: Tue, 7 Jan 2020 16:13:48 +0100 Subject: [PATCH 04/14] Avoid adding unsubscribed contacts in mailing list Add an sql criterion to exclude unsubscribed email adresses from count of contacts (function getNbOfRecipients) and avoid their inclusion in mailing lists (function add_to_target) --- htdocs/core/modules/mailings/contacts1.modules.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index b3687e4f603..8e7b6bff77e 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -105,6 +105,8 @@ class mailing_contacts1 extends MailingTargets $sql.= " WHERE c.entity IN (".getEntity('socpeople').")"; $sql.= " AND c.email != ''"; // Note that null != '' is false $sql.= " AND c.no_email = 0"; + $sql .= " AND (SELECT count(*) FROM ". MAIN_DB_PREFIX . "mailing_unsubscribe WHERE email = c.email) = 0"; + // exclude unsubscribed users $sql.= " AND c.statut = 1"; // The request must return a field called "nb" to be understandable by parent::getNbOfRecipients @@ -384,6 +386,8 @@ class mailing_contacts1 extends MailingTargets $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; $sql.= " AND sp.email <> ''"; $sql.= " AND sp.no_email = 0"; + $sql .= " AND (SELECT count(*) FROM ". MAIN_DB_PREFIX . "mailing_unsubscribe WHERE email = sp.email) = 0"; + // Exclude unsubscribed email adresses $sql.= " AND sp.statut = 1"; $sql.= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; // Filter on category From 066e0c931d6a3893b8b879a15e59096f563da7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Jan 2020 21:13:31 +0100 Subject: [PATCH 05/14] Update odf.php --- htdocs/includes/odtphp/odf.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 23e994d4bc8..01c3310a3f8 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -525,7 +525,7 @@ IMG; public function addImageToManifest($file) { // Get the file extension - $ext = substr(strrchr($val, '.'), 1); + $ext = substr(strrchr($file, '.'), 1); // Create the correct image XML entry to add to the manifest (this is necessary because ODT format requires that we keep a list of the images in the manifest.xml) $add = ' '."\n"; // Append the image to the manifest @@ -539,7 +539,7 @@ IMG; * @throws OdfException * @return void */ - public function exportAsAttachedFile($name="") + public function exportAsAttachedFile($name = "") { $this->_save(); if (headers_sent($filename, $linenum)) { @@ -772,6 +772,4 @@ IMG; $this->contentXml = preg_replace($searchreg, "", $this->contentXml); return $matches[1]; } - } - From 0214d15c5512f8b027a1c1ddf5174c8d9fe5148b Mon Sep 17 00:00:00 2001 From: Dev2a Date: Tue, 7 Jan 2020 21:39:20 +0100 Subject: [PATCH 06/14] Fix Check array of action after kooks --- htdocs/core/class/html.form.class.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6b0950b4f8d..103137aad99 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -591,23 +591,24 @@ class Form * Generate select HTML to choose massaction * * @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default. - * @param int $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action. + * @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action. * @param int $alwaysvisible 1=select button always visible - * @return string Select list + * @return string|void Select list */ public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0) { global $conf, $langs, $hookmanager; - if (count($arrayofaction) == 0) return; $disabled = 0; $ret = '
'; $ret .= ''; print '
'; print '

'.$langs->trans("OrganizeYourMeetingEasily").'

'; print '
'; From 53748b5e2ec27c51b1633c9a297ef15b8a949e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 9 Jan 2020 11:02:39 +0100 Subject: [PATCH 10/14] Update create_survey.php --- htdocs/opensurvey/wizard/create_survey.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 0f71b0ceabf..7bb7861edbe 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -136,6 +136,7 @@ print load_fiche_titre($langs->trans("CreatePoll").' (1 / 2)'); // debut du formulaire print '
'."\n"; +print ''; dol_fiche_head(); From 965f56cf9ddd05d94dbe0cdfe3cab953a6662c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 9 Jan 2020 11:03:06 +0100 Subject: [PATCH 11/14] Update choix_autre.php --- htdocs/opensurvey/wizard/choix_autre.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php index f8a3e13b80a..cb3ed346a52 100644 --- a/htdocs/opensurvey/wizard/choix_autre.php +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -119,6 +119,7 @@ if (empty($_SESSION['titre'])) //On prépare les données pour les inserer dans la base print ''."\n"; +print ''; print load_fiche_titre($langs->trans("CreatePoll").' (2 / 2)'); From b65e39b5cf774d19c5f5cb19386a365a2fefae32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 9 Jan 2020 11:04:53 +0100 Subject: [PATCH 12/14] Update choix_date.php --- htdocs/opensurvey/wizard/choix_date.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index 3692f79048e..a891d9530d9 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -328,6 +328,7 @@ else //Debut du formulaire et bandeaux de tete print ''."\n"; +print ''; print load_fiche_titre($langs->trans("CreatePoll").' (2 / 2)'); From 52dbd95223c73c6da8e7e80153daaeead22e8419 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Thu, 9 Jan 2020 23:02:05 +0000 Subject: [PATCH 13/14] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- .../mymodule/mod_myobject_advanced.php | 64 +++++++++---------- .../mymodule/mod_myobject_standard.php | 48 +++++++------- htdocs/mrp/mo_production.php | 4 +- 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php index 26866a6b9f1..371a287dffb 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php @@ -38,7 +38,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error message @@ -48,7 +48,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject /** * @var string name */ - public $name='advanced'; + public $name = 'advanced'; /** @@ -65,28 +65,28 @@ class mod_myobject_advanced extends ModeleNumRefMyObject $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("MyObject"), $langs->transnoentities("MyObject")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= ''; + $texte .= ''; + $texte .= ''; return $texte; } @@ -98,17 +98,17 @@ class mod_myobject_advanced extends ModeleNumRefMyObject */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $old_code_type=$mysoc->typent_code; - $mysoc->code_client='CCCCCCCCCC'; - $mysoc->typent_code='TTTTTTTTTT'; + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; - $mysoc->typent_code=$old_code_type; + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -123,22 +123,22 @@ class mod_myobject_advanced extends ModeleNumRefMyObject */ public function getNextValue($object) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask=$conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK; + $mask = $conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } $date = $object->date; - $numFinal=get_next_value($db, $mask, 'mymodule_myobject', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'mymodule_myobject', 'ref', '', null, $date); return $numFinal; } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php index e18e7636b6d..71926700aa4 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php @@ -34,19 +34,19 @@ class mod_myobject_standard extends ModeleNumRefMyObject * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $prefix='MYOBJECT'; + public $prefix = 'MYOBJECT'; /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string name */ - public $name='standard'; + public $name = 'standard'; /** @@ -80,26 +80,26 @@ class mod_myobject_standard extends ModeleNumRefMyObject */ public function canBeActivated() { - global $conf,$langs,$db; + global $conf, $langs, $db; - $coyymm=''; $max=''; + $coyymm = ''; $max = ''; - $posindice=8; + $posindice = 8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $row = $db->fetch_row($resql); - if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; } + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } } - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { $langs->load("errors"); - $this->error=$langs->trans('ErrorNumRefModel', $max); + $this->error = $langs->trans('ErrorNumRefModel', $max); return false; } @@ -114,21 +114,21 @@ class mod_myobject_standard extends ModeleNumRefMyObject */ public function getNextValue($object) { - global $db,$conf; + global $db, $conf; // D'abord on recupere la valeur max - $posindice=9; + $posindice = 9; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) $max = intval($obj->max); - else $max=0; + else $max = 0; } else { @@ -137,11 +137,11 @@ class mod_myobject_standard extends ModeleNumRefMyObject } //$date=time(); - $date=$object->date_creation; + $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); + 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); dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index e3b5e159913..fbf9540aab9 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -649,8 +649,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$tmpproduct->getNomUrl(1).''; print ''; $help = ''; - if ($line->qty_frozen) $help.=($help ? '
' : '').''.$langs->trans("QuantityFrozen").': '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; - if ($line->disable_stock_change) $help.=($help ? '
' : '').''.$langs->trans("DisableStockChange").': '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; + if ($line->qty_frozen) $help .= ($help ? '
' : '').''.$langs->trans("QuantityFrozen").': '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; + if ($line->disable_stock_change) $help .= ($help ? '
' : '').''.$langs->trans("DisableStockChange").': '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; if ($help) { print $form->textwithpicto($line->qty, $help, -1); } else { From 8691194627cd2c0d0ab0a4826c018748cde9c792 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Thu, 9 Jan 2020 23:03:10 +0000 Subject: [PATCH 14/14] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/core/lib/functions2.lib.php | 274 ++++++++++++++--------------- htdocs/mrp/class/mo.class.php | 12 +- htdocs/mrp/mo_production.php | 40 ++--- htdocs/projet/activity/perweek.php | 76 ++++---- 4 files changed, 201 insertions(+), 201 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 2eebf38ad56..87a1baa4064 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -573,7 +573,7 @@ function isValidVATID($company) elseif ($vatprefix == 'MC') $vatprefix = 'FR'; // Monaco is using french VAT numbers else $vatprefix = preg_quote($vatprefix, '/');*/ $vatprefix = '[a-zA-Z][a-zA-Z]'; - if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra))) + if (!preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra))) { return 0; } @@ -732,17 +732,17 @@ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = ' */ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $date = '', $mode = 'next', $bentityon = true, $objuser = null, $forceentity = null) { - global $conf,$user; + global $conf, $user; - if (! is_object($objsoc)) $valueforccc=$objsoc; - elseif ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=dol_string_unaccent($objsoc->code_fournisseur); - else $valueforccc=dol_string_unaccent($objsoc->code_client); + if (!is_object($objsoc)) $valueforccc = $objsoc; + elseif ($table == "commande_fournisseur" || $table == "facture_fourn") $valueforccc = dol_string_unaccent($objsoc->code_fournisseur); + else $valueforccc = dol_string_unaccent($objsoc->code_client); $sharetable = $table; if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function // Clean parameters - if ($date == '') $date=dol_now(); // We use local year and month of PHP server to search numbers + if ($date == '') $date = dol_now(); // We use local year and month of PHP server to search numbers // but we should use local year and month of user // For debugging @@ -811,73 +811,73 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; if (is_object($objuser)) $lastname = $objuser->lastname; - $maskuser=$regType[1]; - $maskuser_value=substr($lastname, 0, dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) - $maskuser_value=str_pad($maskuser_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask + $maskuser = $regType[1]; + $maskuser_value = substr($lastname, 0, dol_strlen($regType[1])); // get n first characters of user firstname (where n is length in mask) + $maskuser_value = str_pad($maskuser_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask } else { - $maskuser=''; - $maskuser_value=''; + $maskuser = ''; + $maskuser_value = ''; } // Personalized field {XXX-1} à {XXX-9} - $maskperso=array(); - $maskpersonew=array(); - $tmpmask=$mask; + $maskperso = array(); + $maskpersonew = array(); + $tmpmask = $mask; while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey)) { - $maskperso[$regKey[1]]='{'.$regKey[1].'-'.$regKey[2].'}'; - $maskpersonew[$regKey[1]]=str_pad('', $regKey[2], '_', STR_PAD_RIGHT); - $tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask); + $maskperso[$regKey[1]] = '{'.$regKey[1].'-'.$regKey[2].'}'; + $maskpersonew[$regKey[1]] = str_pad('', $regKey[2], '_', STR_PAD_RIGHT); + $tmpmask = preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask); } if (strstr($mask, 'user_extra_')) { $start = "{user_extra_"; $end = "\}"; - $extra= get_string_between($mask, "user_extra_", "}"); + $extra = get_string_between($mask, "user_extra_", "}"); if (!empty($user->array_options['options_'.$extra])) { - $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); + $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); } } - $maskwithonlyymcode=$mask; - $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode); - $maskwithonlyymcode=preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); - $maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); - $maskwithonlyymcode=preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode); - $maskwithonlyymcode=preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode); - foreach($maskperso as $key => $val) + $maskwithonlyymcode = $mask; + $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode); + foreach ($maskperso as $key => $val) { - $maskwithonlyymcode=preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode); } - $maskwithnocode=$maskwithonlyymcode; - $maskwithnocode=preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); - $maskwithnocode=preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); - $maskwithnocode=preg_replace('/\{y\}/i', 'y', $maskwithnocode); - $maskwithnocode=preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); + $maskwithnocode = $maskwithonlyymcode; + $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); + $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); + $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode); + $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); // Now maskwithnocode = 0000ddmmyyyyccc for example // and maskcounter = 0000 for example //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
"; //var_dump($reg); // If an offset is asked - if (! empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset=preg_replace('/^\+/', '', $reg[2]); - if (! empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset=preg_replace('/^\+/', '', $reg[3]); + if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); + if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); // Define $sqlwhere - $sqlwhere=''; - $yearoffset=0; // Use year of current $date by default - $yearoffsettype=false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x + $sqlwhere = ''; + $yearoffset = 0; // Use year of current $date by default + $yearoffsettype = false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x // If a restore to zero after a month is asked we check if there is already a value for this year. - if (! empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]); - if (! empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]); + if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]); + if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]); //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) - $maskraz=$yearoffsettype; // For backward compatibility - elseif ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) + $maskraz = $yearoffsettype; // For backward compatibility + elseif ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; //print "maskraz=".$maskraz; // -1=no reset @@ -1161,24 +1161,24 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if ($maskrefclient) { //print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskrefclient_clientcode=".$maskrefclient_clientcode."\n
";exit; - $maskrefclient_maskbefore='{'.$maskrefclient.'}'; - $maskrefclient_maskafter=$maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT); + $maskrefclient_maskbefore = '{'.$maskrefclient.'}'; + $maskrefclient_maskafter = $maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT); $numFinal = str_replace($maskrefclient_maskbefore, $maskrefclient_maskafter, $numFinal); } // Now we replace the type if ($masktype) { - $masktype_maskbefore='{'.$masktype.'}'; - $masktype_maskafter=$masktype_value; + $masktype_maskbefore = '{'.$masktype.'}'; + $masktype_maskafter = $masktype_value; $numFinal = str_replace($masktype_maskbefore, $masktype_maskafter, $numFinal); } // Now we replace the user if ($maskuser) { - $maskuser_maskbefore='{'.$maskuser.'}'; - $maskuser_maskafter=$maskuser_value; + $maskuser_maskbefore = '{'.$maskuser.'}'; + $maskuser_maskafter = $maskuser_value; $numFinal = str_replace($maskuser_maskbefore, $maskuser_maskafter, $numFinal); } } @@ -1214,69 +1214,69 @@ function get_string_between($string, $start, $end) */ function check_value($mask, $value) { - $result=0; + $result = 0; - $hasglobalcounter=false; + $hasglobalcounter = false; // Extract value for mask counter, mask raz and mask offset if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) { - $masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:''); - $maskcounter=$reg[1]; - $hasglobalcounter=true; + $masktri = $reg[1].(isset($reg[2]) ? $reg[2] : '').(isset($reg[3]) ? $reg[3] : ''); + $maskcounter = $reg[1]; + $hasglobalcounter = true; } else { // setting some defaults so the rest of the code won't fail if there is a third party counter - $masktri='00000'; - $maskcounter='00000'; + $masktri = '00000'; + $maskcounter = '00000'; } - $maskraz=-1; - $maskoffset=0; + $maskraz = -1; + $maskoffset = 0; if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; // Extract value for third party mask counter if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) { - $maskrefclient=$regClientRef[1].$regClientRef[2]; - $maskrefclient_maskclientcode=$regClientRef[1]; - $maskrefclient_maskcounter=$regClientRef[2]; - $maskrefclient_maskoffset=0; //default value of maskrefclient_counter offset - $maskrefclient_clientcode=substr('', 0, dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode - $maskrefclient_clientcode=str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode - $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like + $maskrefclient = $regClientRef[1].$regClientRef[2]; + $maskrefclient_maskclientcode = $regClientRef[1]; + $maskrefclient_maskcounter = $regClientRef[2]; + $maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset + $maskrefclient_clientcode = substr('', 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code to form maskrefclient_clientcode + $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode + $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; } - else $maskrefclient=''; + else $maskrefclient = ''; // fail if there is neither a global nor a third party counter - if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) + if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) { return 'ErrorBadMask'; } - $maskwithonlyymcode=$mask; - $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $maskcounter, $maskwithonlyymcode); - $maskwithonlyymcode=preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); - $maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); - $maskwithnocode=$maskwithonlyymcode; - $maskwithnocode=preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); - $maskwithnocode=preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); - $maskwithnocode=preg_replace('/\{y\}/i', 'y', $maskwithnocode); - $maskwithnocode=preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); + $maskwithonlyymcode = $mask; + $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $maskcounter, $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); + $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); + $maskwithnocode = $maskwithonlyymcode; + $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); + $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); + $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode); + $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); // Now maskwithnocode = 0000ddmmyyyyccc for example // and maskcounter = 0000 for example //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
"; // If an offset is asked - if (! empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset=preg_replace('/^\+/', '', $reg[2]); - if (! empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset=preg_replace('/^\+/', '', $reg[3]); + if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); + if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); // Define $sqlwhere // If a restore to zero after a month is asked we check if there is already a value for this year. - if (! empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz=preg_replace('/^@/', '', $reg[2]); - if (! empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz=preg_replace('/^@/', '', $reg[3]); + if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz = preg_replace('/^@/', '', $reg[2]); + if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz = preg_replace('/^@/', '', $reg[3]); if ($maskraz >= 0) { if ($maskraz == 99) { @@ -1286,8 +1286,8 @@ function check_value($mask, $value) if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; // Define reg - if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; - if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask'; + if ($maskraz > 1 && !preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; + if ($maskraz <= 1 && !preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask'; //print "x".$maskwithonlyymcode." ".$maskraz; } //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."
\n"; @@ -1616,16 +1616,16 @@ function version_webserver() */ function getListOfModels($db, $type, $maxfilenamelength = 0) { - global $conf,$langs; - $liste=array(); - $found=0; - $dirtoscan=''; + global $conf, $langs; + $liste = array(); + $found = 0; + $dirtoscan = ''; $sql = "SELECT nom as id, nom as doc_template_name, libelle as label, description as description"; - $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; - $sql.= " WHERE type = '".$type."'"; - $sql.= " AND entity IN (0,".$conf->entity.")"; - $sql.= " ORDER BY description DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; + $sql .= " WHERE type = '".$type."'"; + $sql .= " AND entity IN (0,".$conf->entity.")"; + $sql .= " ORDER BY description DESC"; dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); $resql = $db->query($sql); @@ -1635,48 +1635,48 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) $i = 0; while ($i < $num) { - $found=1; + $found = 1; $obj = $db->fetch_object($resql); // If this generation module needs to scan a directory, then description field is filled // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). - if (! empty($obj->description)) // A list of directories to scan is defined + if (!empty($obj->description)) // A list of directories to scan is defined { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $const=$obj->description; + $const = $obj->description; //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); - $dirtoscan= preg_replace('/[\r\n]+/', ',', trim($conf->global->$const)); + $dirtoscan = preg_replace('/[\r\n]+/', ',', trim($conf->global->$const)); - $listoffiles=array(); + $listoffiles = array(); // Now we add models found in directories scanned - $listofdir=explode(',', $dirtoscan); - foreach($listofdir as $key=>$tmpdir) + $listofdir = explode(',', $dirtoscan); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { unset($listofdir[$key]); continue; } + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } if (is_dir($tmpdir)) { // all type of template is allowed - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } if (count($listoffiles)) { - foreach($listoffiles as $record) + foreach ($listoffiles as $record) { - $max=($maxfilenamelength?$maxfilenamelength:28); - $liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'], $max, 'middle'); + $max = ($maxfilenamelength ? $maxfilenamelength : 28); + $liste[$obj->id.':'.$record['fullname']] = dol_trunc($record['name'], $max, 'middle'); } } else { - $liste[0]=$obj->label.': '.$langs->trans("None"); + $liste[0] = $obj->label.': '.$langs->trans("None"); } } else @@ -1685,14 +1685,14 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) { global $_Avery_Labels; include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; - foreach($_Avery_Labels as $key => $val) + foreach ($_Avery_Labels as $key => $val) { - $liste[$obj->id.':'.$key]=($obj->label?$obj->label:$obj->doc_template_name).' '.$val['name']; + $liste[$obj->id.':'.$key] = ($obj->label ? $obj->label : $obj->doc_template_name).' '.$val['name']; } } else // Common usage { - $liste[$obj->id]=$obj->label?$obj->label:$obj->doc_template_name; + $liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name; } } $i++; @@ -1762,7 +1762,7 @@ function getSoapParams() $proxyport = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PORT); $proxyuser = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_USER); $proxypass = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PASS); - $timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout + $timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout $response_timeout = (empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout //print extension_loaded('soap'); if ($proxyuse) @@ -1829,18 +1829,18 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') // Special cases, to work with non standard path if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'compta/facture/class'; - $module='facture'; - $myobject='facture'; + $module = 'facture'; + $myobject = 'facture'; } elseif ($objecttype == 'commande' || $objecttype == 'order') { $classpath = 'commande/class'; - $module='commande'; - $myobject='commande'; + $module = 'commande'; + $myobject = 'commande'; } - elseif ($objecttype == 'propal') { + elseif ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } - elseif ($objecttype == 'supplier_proposal') { + elseif ($objecttype == 'supplier_proposal') { $classpath = 'supplier_proposal/class'; } elseif ($objecttype == 'shipping') { @@ -1855,43 +1855,43 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') } elseif ($objecttype == 'contract') { $classpath = 'contrat/class'; - $module='contrat'; - $myobject='contrat'; + $module = 'contrat'; + $myobject = 'contrat'; } elseif ($objecttype == 'member') { $classpath = 'adherents/class'; - $module='adherent'; - $myobject='adherent'; + $module = 'adherent'; + $myobject = 'adherent'; } elseif ($objecttype == 'cabinetmed_cons') { $classpath = 'cabinetmed/class'; - $module='cabinetmed'; - $myobject='cabinetmedcons'; + $module = 'cabinetmed'; + $myobject = 'cabinetmedcons'; } elseif ($objecttype == 'fichinter') { $classpath = 'fichinter/class'; - $module='ficheinter'; - $myobject='fichinter'; + $module = 'ficheinter'; + $myobject = 'fichinter'; } elseif ($objecttype == 'task') { $classpath = 'projet/class'; - $module='projet'; - $myobject='task'; + $module = 'projet'; + $myobject = 'task'; } elseif ($objecttype == 'stock') { $classpath = 'product/stock/class'; - $module='stock'; - $myobject='stock'; + $module = 'stock'; + $myobject = 'stock'; } elseif ($objecttype == 'inventory') { $classpath = 'product/inventory/class'; - $module='stock'; - $myobject='inventory'; + $module = 'stock'; + $myobject = 'inventory'; } elseif ($objecttype == 'mo') { $classpath = 'mrp/class'; - $module='mrp'; - $myobject='mo'; + $module = 'mrp'; + $myobject = 'mo'; } // Generic case for $classfile and $classname @@ -2257,9 +2257,9 @@ function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88)) */ function colorValidateHex($color, $allow_white = true) { - if(!$allow_white && ($color === '#fff' || $color === '#ffffff') ) return false; + if (!$allow_white && ($color === '#fff' || $color === '#ffffff')) return false; - if(preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid + if (preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid { return true; } @@ -2277,7 +2277,7 @@ function colorValidateHex($color, $allow_white = true) */ function colorAgressiveness($hex, $ratio = -50, $brightness = 0) { - if (empty($ratio)) $ratio = 0; // To avoid null + if (empty($ratio)) $ratio = 0; // To avoid null // Steps should be between -255 and 255. Negative = darker, positive = lighter $ratio = max(-100, min(100, $ratio)); @@ -2293,7 +2293,7 @@ function colorAgressiveness($hex, $ratio = -50, $brightness = 0) $return = '#'; foreach ($color_parts as $color) { - $color = hexdec($color); // Convert to decimal + $color = hexdec($color); // Convert to decimal if ($ratio > 0) // We increase aggressivity { if ($color > 127) $color += ((255 - $color) * ($ratio / 100)); @@ -2607,9 +2607,9 @@ function convertBackOfficeMediasLinksToPublicLinks($notetoshow) { global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $notetoshow=preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow); + $notetoshow = preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow); return $notetoshow; } diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index f73d30d7b6c..b22e7e41b95 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -491,7 +491,7 @@ class Mo extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj) { @@ -543,7 +543,7 @@ class Mo extends CommonObject $error++; } - if (! $error) { + if (!$error) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); $this->db->commit(); return 1; @@ -602,14 +602,14 @@ class Mo extends CommonObject } // Lines to consume - if (! $error) { + if (!$error) { foreach ($bom->lines as $line) { $moline = new MoLine($this->db); $moline->fk_mo = $this->id; if ($line->qty_frozen) { - $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce + $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce } else { $moline->qty = round($line->qty * $this->qty / $bom->efficiency, 2); } @@ -1164,7 +1164,7 @@ class Mo extends CommonObject if (!dol_strlen($modele)) { //$modele = 'standard'; - $modele = ''; // Remove this once a pdf_standard.php exists. + $modele = ''; // Remove this once a pdf_standard.php exists. if ($this->modelpdf) { $modele = $this->modelpdf; @@ -1175,7 +1175,7 @@ class Mo extends CommonObject $modelpath = "core/modules/mrp/doc/"; - if (empty($modele)) return 1; // Remove this once a pdf_standard.php exists. + if (empty($modele)) return 1; // Remove this once a pdf_standard.php exists. return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index e3b5e159913..cacfd2ca02a 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -169,24 +169,24 @@ if (empty($reshook)) $db->begin(); // Process line to consume - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if ($line->role == 'toconsume') { $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); - $i=1; + $i = 1; while (GETPOSTISSET('qty-'.$line->id.'-'.$i)) { $qtytoprocess = price2num(GETPOST('qty-'.$line->id.'-'.$i)); if ($qtytoprocess != 0) { // Check warehouse is set if we should have to if (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i)) { // If there is a warehouse to set - if (! (GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. + if (!(GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); $error++; } - if ($tmpproduct->status_batch && (! GETPOST('batch-'.$line->id.'-'.$i))) { + if ($tmpproduct->status_batch && (!GETPOST('batch-'.$line->id.'-'.$i))) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); $error++; @@ -194,7 +194,7 @@ if (empty($reshook)) } $idstockmove = 0; - if (! $error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) { + if (!$error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) { // Record stock movement $id_product_batch = 0; $stockmove->origin = $object; @@ -205,7 +205,7 @@ if (empty($reshook)) } } - if (! $error) { + if (!$error) { $pos = 0; // Record consumption $moline = new MoLine($db); @@ -236,24 +236,24 @@ if (empty($reshook)) } // Process line to produce - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if ($line->role == 'toproduce') { $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); - $i=1; + $i = 1; while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) { $qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i)); if ($qtytoprocess != 0) { // Check warehouse is set if we should have to if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set - if (! (GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. + if (!(GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); $error++; } - if ($tmpproduct->status_batch && (! GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { + if ($tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); $error++; @@ -261,7 +261,7 @@ if (empty($reshook)) } $idstockmove = 0; - if (! $error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { + if (!$error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { // Record stock movement $id_product_batch = 0; $stockmove->origin = $object; @@ -272,7 +272,7 @@ if (empty($reshook)) } } - if (! $error) { + if (!$error) { $pos = 0; // Record production $moline = new MoLine($db); @@ -302,16 +302,16 @@ if (empty($reshook)) } } - if (! $error) { + if (!$error) { $consumptioncomplete = true; $productioncomplete = true; if (GETPOST('autoclose', 'int')) { - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if ($line->role == 'toconsume') { $arrayoflines = $object->fetchLinesLinked('consumed', $line->id); $alreadyconsumed = 0; - foreach($arrayoflines as $line2) { + foreach ($arrayoflines as $line2) { $alreadyconsumed += $line2['qty']; } @@ -322,7 +322,7 @@ if (empty($reshook)) if ($line->role == 'toproduce') { $arrayoflines = $object->fetchLinesLinked('produced', $line->id); $alreadyproduced = 0; - foreach($arrayoflines as $line2) { + foreach ($arrayoflines as $line2) { $alreadyproduced += $line2['qty']; } @@ -649,8 +649,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$tmpproduct->getNomUrl(1).''; print ''; $help = ''; - if ($line->qty_frozen) $help.=($help ? '
' : '').''.$langs->trans("QuantityFrozen").': '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; - if ($line->disable_stock_change) $help.=($help ? '
' : '').''.$langs->trans("DisableStockChange").': '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; + if ($line->qty_frozen) $help .= ($help ? '
' : '').''.$langs->trans("QuantityFrozen").': '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; + if ($line->disable_stock_change) $help .= ($help ? '
' : '').''.$langs->trans("DisableStockChange").': '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; if ($help) { print $form->textwithpicto($line->qty, $help, -1); } else { @@ -680,7 +680,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Warehouse print ''; if ($conf->productbatch->enabled) { - print ''; // Lot + print ''; // Lot } print ''; @@ -811,7 +811,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Warehouse print ''; if ($conf->productbatch->enabled) { - print ''; // Lot + print ''; // Lot } print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 4488342ab73..8b69fc6aa01 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -36,58 +36,58 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; // Load translation files required by the page -$langs->loadLangs(array('projects','users','companies')); +$langs->loadLangs(array('projects', 'users', 'companies')); -$action=GETPOST('action', 'aZ09'); -$mode=GETPOST("mode", 'alpha'); -$id=GETPOST('id', 'int'); -$taskid=GETPOST('taskid', 'int'); +$action = GETPOST('action', 'aZ09'); +$mode = GETPOST("mode", 'alpha'); +$id = GETPOST('id', 'int'); +$taskid = GETPOST('taskid', 'int'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'perweekcard'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'perweekcard'; -$mine=0; -if ($mode == 'mine') $mine=1; +$mine = 0; +if ($mode == 'mine') $mine = 1; -$projectid=''; -$projectid=isset($_GET["id"])?$_GET["id"]:$_POST["projectid"]; +$projectid = ''; +$projectid = isset($_GET["id"]) ? $_GET["id"] : $_POST["projectid"]; $hookmanager->initHooks(array('timesheetperweekcard')); // Security check -$socid=0; +$socid = 0; // For external user, no check is done on company because readability is managed by public status of project and assignement. // if ($user->socid > 0) $socid=$user->socid; $result = restrictedArea($user, 'projet', $projectid); -$now=dol_now(); -$nowtmp=dol_getdate($now); -$nowday=$nowtmp['mday']; -$nowmonth=$nowtmp['mon']; -$nowyear=$nowtmp['year']; +$now = dol_now(); +$nowtmp = dol_getdate($now); +$nowday = $nowtmp['mday']; +$nowmonth = $nowtmp['mon']; +$nowyear = $nowtmp['year']; -$year=GETPOST('reyear', 'int')?GETPOST('reyear', 'int'):(GETPOST("year", 'int')?GETPOST("year", "int"):date("Y")); -$month=GETPOST('remonth', 'int')?GETPOST('remonth', 'int'):(GETPOST("month", 'int')?GETPOST("month", "int"):date("m")); -$day=GETPOST('reday', 'int')?GETPOST('reday', 'int'):(GETPOST("day", 'int')?GETPOST("day", "int"):date("d")); -$week=GETPOST("week", "int")?GETPOST("week", "int"):date("W"); +$year = GETPOST('reyear', 'int') ?GETPOST('reyear', 'int') : (GETPOST("year", 'int') ?GETPOST("year", "int") : date("Y")); +$month = GETPOST('remonth', 'int') ?GETPOST('remonth', 'int') : (GETPOST("month", 'int') ?GETPOST("month", "int") : date("m")); +$day = GETPOST('reday', 'int') ?GETPOST('reday', 'int') : (GETPOST("day", 'int') ?GETPOST("day", "int") : date("d")); +$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = (int) $day; -$search_categ=GETPOST("search_categ", 'alpha'); -$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); -$search_task_ref=GETPOST('search_task_ref', 'alpha'); -$search_task_label=GETPOST('search_task_label', 'alpha'); -$search_project_ref=GETPOST('search_project_ref', 'alpha'); -$search_thirdparty=GETPOST('search_thirdparty', 'alpha'); -$search_declared_progress=GETPOST('search_declared_progress', 'alpha'); +$search_categ = GETPOST("search_categ", 'alpha'); +$search_usertoprocessid = GETPOST('search_usertoprocessid', 'int'); +$search_task_ref = GETPOST('search_task_ref', 'alpha'); +$search_task_label = GETPOST('search_task_label', 'alpha'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_thirdparty = GETPOST('search_thirdparty', 'alpha'); +$search_declared_progress = GETPOST('search_declared_progress', 'alpha'); -$startdayarray=dol_get_first_day_week($day, $month, $year); +$startdayarray = dol_get_first_day_week($day, $month, $year); $prev = $startdayarray; $prev_year = $prev['prev_year']; $prev_month = $prev['prev_month']; $prev_day = $prev['prev_day']; $first_day = $prev['first_day']; -$first_month= $prev['first_month']; +$first_month = $prev['first_month']; $first_year = $prev['first_year']; $week = $prev['week']; @@ -808,27 +808,27 @@ if (count($tasksarray) > 0) if ($conf->use_javascript_ajax) { print ' - '; + '; print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; for ($idw = 0; $idw < 7; $idw++) { - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $cssonholiday=''; - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print '
 
'; + print '
 
'; } print '
 
';