From 6c8293612d807d6eae8b9fd8daa45f7d962d96c1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 16:41:48 +0100 Subject: [PATCH 01/37] 13.0 --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 371c8be2f5e..18ae79180a0 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,10 @@ htdocs/includes/squizlabs/ htdocs/includes/webmozart/ htdocs/.well-known/apple-developer-merchantid-domain-association + +cyberoffice/ +mycyberoffice/ + # Node Modules build/yarn-error.log build/node_modules/ From f8fcf7c16b68fa4fe4bc80820be42808b5826df3 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 16 Apr 2021 16:55:19 +0200 Subject: [PATCH 02/37] FIX : type link extrafield case for advanced target emailing --- htdocs/comm/mailing/class/advtargetemailing.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 6987a27dacd..ff2e056344c 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -640,6 +640,10 @@ class AdvanceTargetingMailing extends CommonObject if ($arrayquery['options_'.$key]!=''){ $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; } + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { + if ($arrayquery['options_'.$key] > 0){ + $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; + } } else { if (is_array($arrayquery['options_'.$key])) { $sqlwhere[]= " (te.".$key." IN ('".implode("','", $arrayquery['options_'.$key])."'))"; @@ -666,7 +670,6 @@ class AdvanceTargetingMailing extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $this->thirdparty_lines[$i] = $obj->rowid; $i++; From 37f44f4a07d05bd25de1e7d4aa6a776ec52c9d9f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 16 Apr 2021 14:58:57 +0000 Subject: [PATCH 03/37] Fixing style errors. --- htdocs/comm/mailing/class/advtargetemailing.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index ff2e056344c..3a8a9396d29 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -643,7 +643,7 @@ class AdvanceTargetingMailing extends CommonObject } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { if ($arrayquery['options_'.$key] > 0){ $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; - } + } } else { if (is_array($arrayquery['options_'.$key])) { $sqlwhere[]= " (te.".$key." IN ('".implode("','", $arrayquery['options_'.$key])."'))"; From 5b6439ca5eb742a41d13a40fbe1f33b00a5817f2 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 19 Apr 2021 09:15:47 +0200 Subject: [PATCH 04/37] FIX : cast int --- htdocs/comm/mailing/class/advtargetemailing.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index ff2e056344c..730ca263f1d 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -638,7 +638,7 @@ class AdvanceTargetingMailing extends CommonObject } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') { if ($arrayquery['options_'.$key]!=''){ - $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; + $sqlwhere[]= " (te.".$key." = ".((int)$arrayquery['options_'.$key]).")"; } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { if ($arrayquery['options_'.$key] > 0){ From 8c428081ab94113a19ae70e0b1d8b8be4eeab84c Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 19 Apr 2021 09:17:33 +0200 Subject: [PATCH 05/37] FIX : test on link type --- htdocs/comm/mailing/class/advtargetemailing.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 4356039d080..bb472753204 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -638,11 +638,11 @@ class AdvanceTargetingMailing extends CommonObject } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') { if ($arrayquery['options_'.$key]!=''){ - $sqlwhere[]= " (te.".$key." = ".((int)$arrayquery['options_'.$key]).")"; + $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { if ($arrayquery['options_'.$key] > 0){ - $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; + $sqlwhere[]= " (te.".$key." = ".((int)$arrayquery['options_'.$key]).")"; } } else { if (is_array($arrayquery['options_'.$key])) { From 318a783237afa2c4c06226d282f28bcaf1cb7e31 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Apr 2021 07:19:45 +0000 Subject: [PATCH 06/37] Fixing style errors. --- htdocs/comm/mailing/class/advtargetemailing.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index bb472753204..cb539768cf9 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -642,7 +642,7 @@ class AdvanceTargetingMailing extends CommonObject } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { if ($arrayquery['options_'.$key] > 0){ - $sqlwhere[]= " (te.".$key." = ".((int)$arrayquery['options_'.$key]).")"; + $sqlwhere[]= " (te.".$key." = ".((int) $arrayquery['options_'.$key]).")"; } } else { if (is_array($arrayquery['options_'.$key])) { From a6c6f9eb08443c2dd4e0c4e7568573ed08002521 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Mon, 19 Apr 2021 10:20:51 +0200 Subject: [PATCH 07/37] add missing printFieldListFrom hook --- htdocs/fichinter/list.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index d054f5e5bcc..d690feb7407 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -223,6 +223,10 @@ if (!empty($conf->contrat->enabled)) { } 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 (f.rowid = ef.fk_object)"; if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; if (!$user->rights->societe->client->voir && empty($socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; From 74345c4f2156175434a2447e3966c86ac8b553fe Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 19 Apr 2021 16:03:22 +0200 Subject: [PATCH 08/37] fix warehouse label field edition --- htdocs/product/stock/card.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 6279b17d21a..1f53d3491fa 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -98,6 +98,7 @@ if (empty($reshook)) $object->ref = GETPOST("ref"); $object->fk_parent = GETPOST("fk_parent"); $object->libelle = GETPOST("libelle"); + $object->label = GETPOST("libelle"); $object->description = GETPOST("desc"); $object->statut = GETPOST("statut"); $object->lieu = GETPOST("lieu"); @@ -105,8 +106,8 @@ if (empty($reshook)) $object->zip = GETPOST("zipcode"); $object->town = GETPOST("town"); $object->country_id = GETPOST("country_id"); - $object->phone = GETPOST("phone"); - $object->fax = GETPOST("fax"); + $object->phone = GETPOST("phone"); + $object->fax = GETPOST("fax"); if (!empty($object->libelle)) { @@ -168,6 +169,7 @@ if (empty($reshook)) if ($object->fetch($id)) { $object->libelle = GETPOST("libelle"); + $object->label = GETPOST("libelle"); $object->fk_parent = GETPOST("fk_parent"); $object->description = GETPOST("desc"); $object->statut = GETPOST("statut"); @@ -176,8 +178,8 @@ if (empty($reshook)) $object->zip = GETPOST("zipcode"); $object->town = GETPOST("town"); $object->country_id = GETPOST("country_id"); - $object->phone = GETPOST("phone"); - $object->fax = GETPOST("fax"); + $object->phone = GETPOST("phone"); + $object->fax = GETPOST("fax"); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); From 1729497d621851330cbb40311bfdc905818763cf Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 20 Apr 2021 13:56:58 +0200 Subject: [PATCH 09/37] FIX Accountancy - Quadra export - wrong data on credit --- htdocs/accountancy/class/accountancyexport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index e24b1abe8b1..f884add80de 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -555,7 +555,7 @@ class AccountancyExport $Tab['signe_montant'] = '+'; // The amount must be in centimes without decimal points. - $Tab['montant'] = str_pad(abs(($data->debit - $abs->credit) * 100), 12, '0', STR_PAD_LEFT); + $Tab['montant'] = str_pad(abs(($data->debit - $data->credit) * 100), 12, '0', STR_PAD_LEFT); $Tab['contrepartie'] = str_repeat(' ', 8); // Force date format : %d%m%y From 95c7657acef236f85c534f1300cc3a02d733c99f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 20 Apr 2021 20:21:24 +0200 Subject: [PATCH 10/37] add gitingore for modulebuilders --- htdocs/modulebuilder/template/.gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/.gitignore b/htdocs/modulebuilder/template/.gitignore index 942cb8b03ba..150a55149b6 100644 --- a/htdocs/modulebuilder/template/.gitignore +++ b/htdocs/modulebuilder/template/.gitignore @@ -15,4 +15,6 @@ /.buildpath /.project # Other -*.back \ No newline at end of file +*.back +/.editorconfig +/.gitattributes From b2d6b73125ac16597b6d947519774c9f9bf6f6e2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 20 Apr 2021 20:23:45 +0200 Subject: [PATCH 11/37] add gitingore for modulebuilders --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index 18ae79180a0..371c8be2f5e 100644 --- a/.gitignore +++ b/.gitignore @@ -43,10 +43,6 @@ htdocs/includes/squizlabs/ htdocs/includes/webmozart/ htdocs/.well-known/apple-developer-merchantid-domain-association - -cyberoffice/ -mycyberoffice/ - # Node Modules build/yarn-error.log build/node_modules/ From a15d58065facaf0ef2cd3e46f6f8222aa48d4a55 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 20 Apr 2021 20:25:51 +0200 Subject: [PATCH 12/37] =?UTF-8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 371c8be2f5e..a008514f2ee 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,6 @@ yarn.lock package-lock.json doc/install.lock + +/htdocs/cyber* +/htdocs/mycyber* From efcc5e714a23eb4fe5a799ac7b2d2ea046014143 Mon Sep 17 00:00:00 2001 From: ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Thu, 22 Apr 2021 15:49:37 +0200 Subject: [PATCH 13/37] FIX #17363 --- htdocs/admin/payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 925c8fd6ff4..61f935572d2 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -184,7 +184,7 @@ foreach ($dirmodels as $reldir) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; } print ''; From ee96fb64707b646873179171451c3a6efed2ec2a Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 22 Apr 2021 15:56:12 +0200 Subject: [PATCH 14/37] FIX: payment creation: re-generate invoice PDF with correct display options --- htdocs/compta/paiement/class/paiement.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 05d2fe0c08b..221ff3de042 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -440,8 +440,13 @@ class Paiement extends CommonObject $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } + + $hidedetails = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0; + $hidedesc = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0; + $hideref = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0; + $ret = $invoice->fetch($facid); // Reload to get new records - $result = $invoice->generateDocument($invoice->modelpdf, $outputlangs); + $result = $invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) { setEventMessages($invoice->error, $invoice->errors, 'errors'); $error++; From ce022ab36cbbc4f2e1d46c02eefa5f90716f3443 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 22 Apr 2021 15:57:06 +0200 Subject: [PATCH 15/37] FIX: payment validation: invoices PDF were no re-generated, make it with correct display options --- htdocs/compta/paiement/card.php | 79 +++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 59da7387f62..f54417b8a6f 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -109,28 +109,71 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture-> $object->fetch($id); if ($object->valide($user) > 0) { - $db->commit(); - // Loop on each invoice linked to this payment to rebuild PDF - $factures = array(); - foreach ($factures as $id) - { - $fac = new Facture($db); - $fac->fetch($id); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $outputlangs = $langs; + if (!empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + + $hidedetails = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0; + $hidedesc = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0; + $hideref = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0; + + $sql = 'SELECT f.rowid as facid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s'; + $sql .= ' WHERE pf.fk_facture = f.rowid'; + $sql .= ' AND f.fk_soc = s.rowid'; + $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; + $sql .= ' AND pf.fk_paiement = '.$object->id; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + + if ($num > 0) + { + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $invoice = new Facture($db); + + if ($invoice->fetch($objp->facid) <= 0) { + $errors++; + setEventMessage($invoice->error, $invoice->errors, 'errors'); + break; + } + + if ($invoice->generateDocument($fac->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref) < 0) { + $errors++; + setEventMessage($invoice->error, $invoice->errors, 'errors'); + break; + } + + $i++; + } + } + + $db->free($resql); + } + else + { + $errors++; + setEventMessage($db->error, $db->errors, 'errors'); + } - $outputlangs = $langs; - if (!empty($_REQUEST['lang_id'])) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $fac->generateDocument($fac->modelpdf, $outputlangs); - } } - header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); - exit; + if (! $errors) { + $db->commit(); + + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); + exit; + } } else { From 196ebbb8e8d3edf924bcefbd280f6b670a4de03f Mon Sep 17 00:00:00 2001 From: Indelog Date: Thu, 22 Apr 2021 19:18:47 +0200 Subject: [PATCH 16/37] Fix : empty email on public membership form We can validate the public membership form whith an empty email when `$conf->global->ADHERENT_MAIL_REQUIRED` is set. This fix it. --- htdocs/public/members/new.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 1946125dbc2..f850cdff35c 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -208,9 +208,12 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; } - if (GETPOST("email") && !isValidEmail(GETPOST("email"))) { + if ($conf->global->ADHERENT_MAIL_REQUIRED && empty(GETPOST('email'))) { + $error++; + $errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."
\n"; + } elseif (GETPOST("email") && !isValidEmail(GETPOST("email"))) { ++ $langs->load('errors'); $error++; - $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; } $birthday = dol_mktime($_POST["birthhour"], $_POST["birthmin"], $_POST["birthsec"], $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); @@ -586,7 +589,7 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''; } // EMail -print ''.$langs->trans("Email").' *'."\n"; +print ''.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' *' : '').''."\n"; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''.$langs->trans("Login").' *'."\n"; From e7a4699bd930c54372497f70bc3430d1d3f1c5c7 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 22 Apr 2021 17:26:46 +0000 Subject: [PATCH 17/37] Fixing style errors. --- htdocs/public/members/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index f850cdff35c..3d0ecc6fd16 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -212,7 +212,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."
\n"; } elseif (GETPOST("email") && !isValidEmail(GETPOST("email"))) { -+ $langs->load('errors'); + + $langs->load('errors'); $error++; $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; } From 3d3fb17da31e83aa78f8b32a738d9746bc91c5c5 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 23 Apr 2021 15:41:43 +0200 Subject: [PATCH 18/37] Add parameter "option" to hook formattachOptions --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 974bdce6d26..0bb30241062 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -268,7 +268,7 @@ class FormFile $out .= "\n\n"; } - $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url'=>$url, 'perm'=>$perm); + $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url'=>$url, 'perm'=>$perm, 'options'=>$options); $res = $hookmanager->executeHooks('formattachOptions', $parameters, $object); if (empty($res)) { From 8b49585b64137442fddeba4f51b7b43776236833 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 24 Apr 2021 18:21:36 +0200 Subject: [PATCH 19/37] fix: return invoice id when create from order --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4ae9fe197fe..8d0e2bb8b47 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1387,7 +1387,7 @@ class Facture extends CommonInvoice if (!$error) { - return 1; + return $ret; } else return -1; } else return -1; } From e229348e2c52eec63e7a599658158a4a0e409e99 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 24 Apr 2021 18:24:25 +0200 Subject: [PATCH 20/37] .gitignre --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index a008514f2ee..371c8be2f5e 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,3 @@ yarn.lock package-lock.json doc/install.lock - -/htdocs/cyber* -/htdocs/mycyber* From bc924ca00ee4fd76270876a130df1a492d09700a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 24 Apr 2021 18:27:43 +0200 Subject: [PATCH 21/37] .gitignre --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8d0e2bb8b47..4ae9fe197fe 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1387,7 +1387,7 @@ class Facture extends CommonInvoice if (!$error) { - return $ret; + return 1; } else return -1; } else return -1; } From 48c26fd614ead9c3e3d6a7be8bb6a38d3e85082f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Apr 2021 18:43:24 +0200 Subject: [PATCH 22/37] Fix add option INVOICE_DISALLOW_REOPEN to lock problematic feature --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 907d18987ea..b9a3ae86811 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -189,7 +189,7 @@ if (empty($reshook)) $action = ''; } } // Change status of invoice - elseif ($action == 'reopen' && $usercancreate) { + elseif ($action == 'reopen' && $usercancreate && empty($conf->global->INVOICE_DISALLOW_REOPEN)) { $result = $object->fetch($id); if ($object->statut == Facture::STATUS_CLOSED || ($object->statut == Facture::STATUS_ABANDONED && ($object->close_code != 'replaced' || $object->getIdReplacingInvoice() == 0)) || ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted From 6c2d9d3b3c4d5cd00dd42750534d70257af4de3d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Apr 2021 13:17:47 +0200 Subject: [PATCH 23/37] Fix permission to reopen invoice. --- htdocs/compta/facture/card.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b9a3ae86811..60e5d4eb52a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -119,8 +119,11 @@ $usercancreate = $user->rights->facture->creer; $usercanissuepayment = $user->rights->facture->paiement; $usercandelete = $user->rights->facture->supprimer; $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate))); -$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send); -$usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen); +$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->send))); +$usercanreopen = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->reopen))); +if (!empty($conf->global->INVOICE_DISALLOW_REOPEN)) { + $usercanreopen = false; +} $usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate))); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); @@ -189,7 +192,7 @@ if (empty($reshook)) $action = ''; } } // Change status of invoice - elseif ($action == 'reopen' && $usercancreate && empty($conf->global->INVOICE_DISALLOW_REOPEN)) { + elseif ($action == 'reopen' && $usercanreopen) { $result = $object->fetch($id); if ($object->statut == Facture::STATUS_CLOSED || ($object->statut == Facture::STATUS_ABANDONED && ($object->close_code != 'replaced' || $object->getIdReplacingInvoice() == 0)) || ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted From 09d68dd7a649a4d8e84461ac24c852393d0feb15 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 26 Apr 2021 17:00:53 +0200 Subject: [PATCH 24/37] fix the productCombination class on updatePrice --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 9152336bbe4..d01fd5c37c7 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -534,7 +534,7 @@ class ProductCombination $new_price += $variation_price; } - $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq); + $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq,0, array(),$parent->default_vat_code); } } } else { From 8d07b43ccd9f19b3ea47d0fe7212e0b8049e274f Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 26 Apr 2021 17:05:21 +0200 Subject: [PATCH 25/37] space stickler --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index d01fd5c37c7..51499ead88d 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -534,7 +534,7 @@ class ProductCombination $new_price += $variation_price; } - $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq,0, array(),$parent->default_vat_code); + $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq,0, array(), $parent->default_vat_code); } } } else { From a8136a00b1933b8891e3e28b416767aedabccde3 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 26 Apr 2021 15:07:41 +0000 Subject: [PATCH 26/37] Fixing style errors. --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 51499ead88d..bc479b68653 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -534,7 +534,7 @@ class ProductCombination $new_price += $variation_price; } - $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq,0, array(), $parent->default_vat_code); + $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq, 0, array(), $parent->default_vat_code); } } } else { From e9b8e817738499d9470c34bbdb54fd2955270d21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 01:45:10 +0200 Subject: [PATCH 27/37] Update advtargetemailing.class.php --- htdocs/comm/mailing/class/advtargetemailing.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index cb539768cf9..b43daf4bf0c 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -641,8 +641,8 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { - if ($arrayquery['options_'.$key] > 0){ - $sqlwhere[]= " (te.".$key." = ".((int) $arrayquery['options_'.$key]).")"; + if ($arrayquery['options_'.$key] > 0) { + $sqlwhere[]= " (te.".$key." = ".((int) $arrayquery['options_'.$key]).")"; } } else { if (is_array($arrayquery['options_'.$key])) { From 12a4bc64adb983e6a76325c8bd6183d7cde962d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 02:01:46 +0200 Subject: [PATCH 28/37] Remove $_REQUEST --- htdocs/compta/paiement/card.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index ff9f93bc297..680a8c501a2 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -109,14 +109,13 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture if ($object->validate($user) > 0) { $db->commit(); - + // Loop on each invoice linked to this payment to rebuild PDF if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; - if (!empty($_REQUEST['lang_id'])) - { + if (GETPOST('lang_id', 'aZ09')) { $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); + $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } $hidedetails = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0; From 27aa7cdb48cb08ee3625f4e5a4042d173b6a35a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 02:08:36 +0200 Subject: [PATCH 29/37] Fix bad merge --- htdocs/compta/paiement/card.php | 2 +- htdocs/public/members/new.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 680a8c501a2..1bc1270e2d6 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -148,7 +148,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture break; } - if ($invoice->generateDocument($fac->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref) < 0) { + if ($invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref) < 0) { $errors++; setEventMessages($invoice->error, $invoice->errors, 'errors'); break; diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 3d0ecc6fd16..cddfd0524b1 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -212,7 +212,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."
\n"; } elseif (GETPOST("email") && !isValidEmail(GETPOST("email"))) { - + $langs->load('errors'); + $langs->load('errors'); $error++; $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; } From 098582d7a738241d59555107e375cad5f6145e46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 02:09:43 +0200 Subject: [PATCH 30/37] Fix bad merge --- htdocs/compta/paiement/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 17cfeaca8dc..d9a1d73ec27 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -148,7 +148,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture-> break; } - if ($invoice->generateDocument($fac->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref) < 0) { + if ($invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref) < 0) { $errors++; setEventMessage($invoice->error, $invoice->errors, 'errors'); break; From c7f38c4cf03dffac3291854ee5f0008725167648 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 02:10:52 +0200 Subject: [PATCH 31/37] Fix bad var --- htdocs/compta/paiement/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index f54417b8a6f..3f9e3551edd 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -148,7 +148,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture-> break; } - if ($invoice->generateDocument($fac->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref) < 0) { + if ($invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref) < 0) { $errors++; setEventMessage($invoice->error, $invoice->errors, 'errors'); break; From 2e9cf8d00b0c347cbc6c2bcfe94643f1be30baae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 02:15:58 +0200 Subject: [PATCH 32/37] Fix phpcs --- htdocs/compta/paiement/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 3f9e3551edd..dc892029829 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -165,7 +165,6 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture-> $errors++; setEventMessage($db->error, $db->errors, 'errors'); } - } if (! $errors) { From 0a0b3f414ad691fea848cd7b96dacdbbe1e0c441 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 02:54:33 +0200 Subject: [PATCH 33/37] Fix phpcs --- htdocs/compta/paiement/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 1bc1270e2d6..30d2b994959 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -159,9 +159,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture } $db->free($resql); - } - else - { + } else { $errors++; setEventMessages($db->error, $db->errors, 'errors'); } From 0037da1a5657a1bdb1a1c76fa0e0f1de82ec0df8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 23:29:53 +0200 Subject: [PATCH 34/37] FIX selection of project for reception must use PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS --- htdocs/reception/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 66aa1b300b8..18aa08b0d85 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -770,8 +770,8 @@ if ($action == 'create') $langs->load("projects"); print ''; print ''.$langs->trans("Project").''; - $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - print '   id).'">'.$langs->trans("AddProject").''; + print $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + print '   id).'">'; print ''; print ''; } From 18d2bef8f38c94d24731eab199237506588d4974 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Wed, 28 Apr 2021 11:58:34 +0200 Subject: [PATCH 35/37] Error 500 on propal card when we change the deadline if we don't use the automatic generation for PDF documents (MAIN_DISABLE_PDF_AUTOUPDATE is set to 1) when we change the deadline on a proposal we get an error 500. --- htdocs/comm/propal/card.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 73ea01bc3f8..99a6f759206 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -285,8 +285,28 @@ if (empty($reshook)) } elseif ($action == 'setecheance' && $usercancreate) { $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); - $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) + if ($result >= 0) + { + 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->model_pdf; + $ret = $object->fetch($id); // Reload to get new records + if ($ret > 0) { + $object->fetch_thirdparty(); + } + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + elseif ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'setdate_livraison' && $usercancreate) { From 6dcee425a1850c8802eede4a4835129643bbd430 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Apr 2021 15:07:31 +0200 Subject: [PATCH 36/37] Update card.php --- htdocs/comm/propal/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 99a6f759206..af88178fe27 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -305,9 +305,9 @@ if (empty($reshook)) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } + } else { + setEventMessages($object->error, $object->errors, 'errors'); } - elseif ($result < 0) - dol_print_error($db, $object->error); } elseif ($action == 'setdate_livraison' && $usercancreate) { $result = $object->setDeliveryDate($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); From 95ecb95ff142710a34bb2ee76cca7650431f5cf6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Apr 2021 20:47:28 +0200 Subject: [PATCH 37/37] FIX dol_print_date for %a and %b with some timezone --- htdocs/core/lib/functions.lib.php | 124 +++++++++++++++++------------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2a57a983496..37e55b42fde 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1991,19 +1991,15 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = // Clean parameters $to_gmt = false; $offsettz = $offsetdst = 0; - if ($tzoutput) - { + if ($tzoutput) { $to_gmt = true; // For backward compatibility - if (is_string($tzoutput)) - { - if ($tzoutput == 'tzserver') - { + if (is_string($tzoutput)) { + if ($tzoutput == 'tzserver') { $to_gmt = false; $offsettzstring = @date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion' - $offsettz = 0; - $offsetdst = 0; - } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') - { + $offsettz = 0; // Timezone offset with server timezone, so 0 + $offsetdst = 0; // Dst offset with server timezone, so 0 + } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') { $to_gmt = true; $offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion' $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore @@ -2011,54 +2007,77 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = } } } - if (!is_object($outputlangs)) $outputlangs = $langs; - if (!$format) $format = 'daytextshort'; + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } + if (!$format) { + $format = 'daytextshort'; + } // Do we have to reduce the length of date (year on 2 chars) to save space. // Note: dayinputnoreduce is same than day but no reduction of year length will be done $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0; // Test on original $format param. $format = preg_replace('/inputnoreduce/', '', $format); // so format 'dayinputnoreduce' is processed like day $formatwithoutreduce = preg_replace('/reduceformat/', '', $format); - if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat = 1; } // so format 'dayreduceformat' is processed like day + if ($formatwithoutreduce != $format) { + $format = $formatwithoutreduce; + $reduceformat = 1; + } // so format 'dayreduceformat' is processed like day // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. // TODO Add format daysmallyear and dayhoursmallyear - if ($format == 'day') $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); - elseif ($format == 'hour') $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); - elseif ($format == 'hourduration') $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); - elseif ($format == 'daytext') $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text); - elseif ($format == 'daytextshort') $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short); - elseif ($format == 'dayhour') $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short); - elseif ($format == 'dayhoursec') $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short); - elseif ($format == 'dayhourtext') $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); - elseif ($format == 'dayhourtextshort') $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); - // Format not sensitive to language - elseif ($format == 'dayhourlog') $format = '%Y%m%d%H%M%S'; - elseif ($format == 'dayhourldap') $format = '%Y%m%d%H%M%SZ'; - elseif ($format == 'dayhourxcard') $format = '%Y%m%dT%H%M%SZ'; - elseif ($format == 'dayxcard') $format = '%Y%m%d'; - elseif ($format == 'dayrfc') $format = '%Y-%m-%d'; // DATE_RFC3339 - elseif ($format == 'dayhourrfc') $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 - elseif ($format == 'standard') $format = '%Y-%m-%d %H:%M:%S'; + if ($format == 'day') { + $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); + } elseif ($format == 'hour') { + $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); + } elseif ($format == 'hourduration') { + $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); + } elseif ($format == 'daytext') { + $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text); + } elseif ($format == 'daytextshort') { + $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short); + } elseif ($format == 'dayhour') { + $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short); + } elseif ($format == 'dayhoursec') { + $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short); + } elseif ($format == 'dayhourtext') { + $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); + } elseif ($format == 'dayhourtextshort') { + $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); + } elseif ($format == 'dayhourlog') { + // Format not sensitive to language + $format = '%Y%m%d%H%M%S'; + } elseif ($format == 'dayhourldap') { + $format = '%Y%m%d%H%M%SZ'; + } elseif ($format == 'dayhourxcard') { + $format = '%Y%m%dT%H%M%SZ'; + } elseif ($format == 'dayxcard') { + $format = '%Y%m%d'; + } elseif ($format == 'dayrfc') { + $format = '%Y-%m-%d'; // DATE_RFC3339 + } elseif ($format == 'dayhourrfc') { + $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 + } elseif ($format == 'standard') { + $format = '%Y-%m-%d %H:%M:%S'; + } - if ($reduceformat) - { + if ($reduceformat) { $format = str_replace('%Y', '%y', $format); $format = str_replace('yyyy', 'yy', $format); } // If date undefined or "", we return "" - if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + if (dol_strlen($time) == 0) { + return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + } // Clean format - if (preg_match('/%b/i', $format)) // There is some text to translate - { + if (preg_match('/%b/i', $format)) { // There is some text to translate // We inhibate translation to text made by strftime functions. We will use trans instead later. $format = str_replace('%b', '__b__', $format); $format = str_replace('%B', '__B__', $format); } - if (preg_match('/%a/i', $format)) // There is some text to translate - { + if (preg_match('/%a/i', $format)) { // There is some text to translate // We inhibate translation to text made by strftime functions. We will use trans instead later. $format = str_replace('%a', '__a__', $format); $format = str_replace('%A', '__A__', $format); @@ -2067,13 +2086,11 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = // Analyze date $reg = array(); - if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 - { + if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); return ''; - } elseif (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) // Still available to solve problems in extrafields of type date - { - // This part of code should not be used. + } elseif (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) { // Still available to solve problems in extrafields of type date + // This part of code should not be used anymore. dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"], LOG_WARNING); //if (function_exists('debug_print_backtrace')) debug_print_backtrace(); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' @@ -2088,23 +2105,22 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt); } else { // Date is a timestamps - if ($time < 100000000000) // Protection against bad date values - { + if ($time < 100000000000) { // Protection against bad date values $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $ret = adodb_strftime($format, $timetouse, $to_gmt); - } else $ret = 'Bad value '.$time.' for date'; + $ret = adodb_strftime($format, $timetouse, $to_gmt); // If to_gmt = false then adodb_strftime use TZ of server + } else { + $ret = 'Bad value '.$time.' for date'; + } } - if (preg_match('/__b__/i', $format)) - { + if (preg_match('/__b__/i', $format)) { $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. - $month = adodb_strftime('%m', $timetouse); + $month = adodb_strftime('%m', $timetouse, $to_gmt); // If to_gmt = false then adodb_strftime use TZ of server $month = sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. - if ($encodetooutput) - { + if ($encodetooutput) { $monthtext = $outputlangs->transnoentities('Month'.$month); $monthtextshort = $outputlangs->transnoentities('MonthShort'.$month); } else { @@ -2117,11 +2133,11 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = //print 'x'.$outputlangs->charset_output.'-'.$ret.'x'; //return $ret; } - if (preg_match('/__a__/i', $format)) - { + if (preg_match('/__a__/i', $format)) { + //print "time=$time offsettz=$offsettz offsetdst=$offsetdst offsettzstring=$offsettzstring"; $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $w = adodb_strftime('%w', $timetouse); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $w = adodb_strftime('%w', $timetouse, $to_gmt); // If to_gmt = false then adodb_strftime use TZ of server $dayweek = $outputlangs->transnoentitiesnoconv('Day'.$w); $ret = str_replace('__A__', $dayweek, $ret); $ret = str_replace('__a__', dol_substr($dayweek, 0, 3), $ret);