From f613688b28c5b104d7816bc5ab5756d48a420b08 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 8 Apr 2021 13:37:09 +0200 Subject: [PATCH 001/490] add_option --- htdocs/admin/notification.php | 17 +++++++++++++++++ htdocs/core/class/notify.class.php | 24 +++++++++++++++++++++--- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/other.lang | 3 +++ htdocs/langs/fr_FR/admin.lang | 1 + htdocs/langs/fr_FR/other.lang | 3 +++ 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index e1cf115626f..6609021cc2a 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -97,6 +97,10 @@ if ($action == 'setvalue' && $user->admin) { $error++; } + $result = dolibarr_set_const($db, "NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE", GETPOST("notif_disable", "alphawithlgt"), 'chaine', 0, '', $conf->entity); + if ($result < 0) { + $error++; + } if (!$error) { $db->commit(); @@ -198,6 +202,19 @@ if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->globa } print ''; print ''; +$arrayofnotifto = array( +'', +$langs->trans('notiftouser'), +$langs->trans('notiftofixedemail'), +$langs->trans('notiftouserandtofixedemail') +); +var_dump($arrayofnotifto,$conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE); +print ''; +print $langs->trans("NotificationDisableConfirmMessage").''; +print ''; +print $form->selectarray("notif_disable", $arrayofnotifto, $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE, 0, 0, 0, '', 1, 0, 0, '', 'maxwidth400', 1); +print ''; +print ''; print ''; print '
'; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 345ec5b38e3..92555da891a 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -80,8 +80,8 @@ class Notify 'SHIPPING_VALIDATE', 'EXPENSE_REPORT_VALIDATE', 'EXPENSE_REPORT_APPROVE', - 'HOLIDAY_VALIDATE', - 'HOLIDAY_APPROVE', + 'HOLIDAY_VALIDATE', + 'HOLIDAY_APPROVE', 'ACTION_CREATE' ); @@ -108,10 +108,28 @@ class Notify */ public function confirmMessage($action, $socid, $object) { - global $langs; + global $conf, $langs; $langs->load("mails"); $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); + if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE)){ + if ($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 1 || $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 3){ + foreach($listofnotiftodo as $val){ + if ($val['type'] == 'touser'){ + unset($listofnotiftodo[$val['email']]); + $listofnotiftodo = array_merge($listofnotiftodo); + } + } + } + if ($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 2 || $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 3){ + foreach($listofnotiftodo as $val){ + if ($val['type'] == 'tofixedemail'){ + unset($listofnotiftodo[$val['email']]); + $listofnotiftodo = array_merge($listofnotiftodo); + } + } + } + } $texte = ''; $nb = -1; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5d78f312917..73d2a5ca558 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1673,6 +1673,7 @@ MailingDelay=Seconds to wait after sending next message NotificationSetup=Email Notification module setup NotificationEMailFrom=Sender email (From) for emails sent by the Notifications module FixedEmailTarget=Recipient +NotificationDisableConfirmMessage=Notification disable in confirm message ##### Sendings ##### SendingsSetup=Shipping module setup SendingsReceiptModel=Sending receipt model diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 5ae6c7727b3..91f173850ff 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -35,6 +35,9 @@ OnlyOneFieldForXAxisIsPossible=Only 1 field is currently possible as X-Axis. Onl AtLeastOneMeasureIsRequired=At least 1 field for measure is required AtLeastOneXAxisIsRequired=At least 1 field for X-Axis is required LatestBlogPosts=Latest Blog Posts +notiftouser=To users +notiftofixedemail=To fixed mail +notiftouserandtofixedemail=To user and fixed mail Notify_ORDER_VALIDATE=Sales order validated Notify_ORDER_SENTBYMAIL=Sales order sent by mail Notify_ORDER_SUPPLIER_SENTBYMAIL=Purchase order sent by email diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index ef48fc0a82d..02e0b27af5d 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1662,6 +1662,7 @@ MailingDelay=Temps d'attente, en seconde, avant d'envoyer le prochain message NotificationSetup=Configuration du module Notification par email NotificationEMailFrom=Adresse émettrice (From) des emails envoyés lors des notifications FixedEmailTarget=Email fixe cible destinataires +NotificationDisableConfirmMessage=Notifications desactivé dans les messages de confirmation ##### Sendings ##### SendingsSetup=Configuration du module Expédition/Livraison SendingsReceiptModel=Modèles de bordereau d'expédition diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index a8078129464..4e228ed50bd 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -35,6 +35,9 @@ OnlyOneFieldForXAxisIsPossible=1 seul champ est actuellement possible en tant qu AtLeastOneMeasureIsRequired=Au moins 1 champ de mesure est requis AtLeastOneXAxisIsRequired=Au moins 1 champ pour l'axe X est requis LatestBlogPosts=Derniers articles du Blog +notiftouser=Aux utilisateurs +notiftofixedemail=Vers les courriers fixe +notiftouserandtofixedemail=Aux utilisateurs et les courriers fixe Notify_ORDER_VALIDATE=Validation commande client Notify_ORDER_SENTBYMAIL=Envoi commande client par email Notify_ORDER_SUPPLIER_SENTBYMAIL=Envoi commande fournisseur par email From c2cd54325f43f01be686fd06cc8e9ff332c2f2d9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 8 Apr 2021 11:44:24 +0000 Subject: [PATCH 002/490] Fixing style errors. --- htdocs/admin/notification.php | 2 +- htdocs/core/class/notify.class.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 6609021cc2a..d467b6bb62d 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -208,7 +208,7 @@ $langs->trans('notiftouser'), $langs->trans('notiftofixedemail'), $langs->trans('notiftouserandtofixedemail') ); -var_dump($arrayofnotifto,$conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE); +var_dump($arrayofnotifto, $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE); print ''; print $langs->trans("NotificationDisableConfirmMessage").''; print ''; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 92555da891a..695a17a75d8 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -112,18 +112,18 @@ class Notify $langs->load("mails"); $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); - if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE)){ - if ($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 1 || $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 3){ - foreach($listofnotiftodo as $val){ - if ($val['type'] == 'touser'){ + if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE)) { + if ($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 1 || $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 3) { + foreach ($listofnotiftodo as $val) { + if ($val['type'] == 'touser') { unset($listofnotiftodo[$val['email']]); $listofnotiftodo = array_merge($listofnotiftodo); } } } - if ($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 2 || $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 3){ - foreach($listofnotiftodo as $val){ - if ($val['type'] == 'tofixedemail'){ + if ($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 2 || $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 3) { + foreach ($listofnotiftodo as $val) { + if ($val['type'] == 'tofixedemail') { unset($listofnotiftodo[$val['email']]); $listofnotiftodo = array_merge($listofnotiftodo); } From 822d9b227bdd2eb7e8b304f8fa501fe1d03adfb7 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 8 Apr 2021 13:50:55 +0200 Subject: [PATCH 003/490] Update notification.php --- htdocs/admin/notification.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 6609021cc2a..85e097dceb3 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -202,13 +202,14 @@ if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->globa } print ''; print ''; + $arrayofnotifto = array( '', $langs->trans('notiftouser'), $langs->trans('notiftofixedemail'), $langs->trans('notiftouserandtofixedemail') ); -var_dump($arrayofnotifto,$conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE); + print ''; print $langs->trans("NotificationDisableConfirmMessage").''; print ''; From d3053c0c1b8ffaac71253bc12d6f3f0f249280f0 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Wed, 28 Apr 2021 23:35:47 +0200 Subject: [PATCH 004/490] delete_fr_lang --- htdocs/langs/fr_FR/admin.lang | 1 - htdocs/langs/fr_FR/other.lang | 3 --- 2 files changed, 4 deletions(-) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 02e0b27af5d..ef48fc0a82d 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1662,7 +1662,6 @@ MailingDelay=Temps d'attente, en seconde, avant d'envoyer le prochain message NotificationSetup=Configuration du module Notification par email NotificationEMailFrom=Adresse émettrice (From) des emails envoyés lors des notifications FixedEmailTarget=Email fixe cible destinataires -NotificationDisableConfirmMessage=Notifications desactivé dans les messages de confirmation ##### Sendings ##### SendingsSetup=Configuration du module Expédition/Livraison SendingsReceiptModel=Modèles de bordereau d'expédition diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 4e228ed50bd..a8078129464 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -35,9 +35,6 @@ OnlyOneFieldForXAxisIsPossible=1 seul champ est actuellement possible en tant qu AtLeastOneMeasureIsRequired=Au moins 1 champ de mesure est requis AtLeastOneXAxisIsRequired=Au moins 1 champ pour l'axe X est requis LatestBlogPosts=Derniers articles du Blog -notiftouser=Aux utilisateurs -notiftofixedemail=Vers les courriers fixe -notiftouserandtofixedemail=Aux utilisateurs et les courriers fixe Notify_ORDER_VALIDATE=Validation commande client Notify_ORDER_SENTBYMAIL=Envoi commande client par email Notify_ORDER_SUPPLIER_SENTBYMAIL=Envoi commande fournisseur par email From c1e6109c4bfecda86c9ae06be638196729b2b616 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 29 Apr 2021 00:03:16 +0200 Subject: [PATCH 005/490] Update --- htdocs/admin/notification.php | 28 ++++++++++++++++++++++------ htdocs/core/class/notify.class.php | 24 +++++++++++------------- htdocs/langs/en_US/admin.lang | 3 ++- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 85e097dceb3..93263998cbe 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -204,16 +204,32 @@ print ''; print ''; $arrayofnotifto = array( -'', -$langs->trans('notiftouser'), -$langs->trans('notiftofixedemail'), -$langs->trans('notiftouserandtofixedemail') +-1 => '', +1 => $langs->trans('notiftouser'), +2 => $langs->trans('notiftofixedemail'), +3 => $langs->trans('notiftouserandtofixedemail') ); print ''; -print $langs->trans("NotificationDisableConfirmMessage").''; +print $langs->trans("NotificationDisableConfirmMessageUser").''; print ''; -print $form->selectarray("notif_disable", $arrayofnotifto, $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE, 0, 0, 0, '', 1, 0, 0, '', 'maxwidth400', 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER", $arrval, $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER); +} +print ''; +print ''; +print ''; +print $langs->trans("NotificationDisableConfirmMessageFix").''; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX", $arrval, $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX); +} print ''; print ''; print ''; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 695a17a75d8..11ca1c43d3e 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -112,21 +112,19 @@ class Notify $langs->load("mails"); $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); - if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE)) { - if ($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 1 || $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 3) { - foreach ($listofnotiftodo as $val) { - if ($val['type'] == 'touser') { - unset($listofnotiftodo[$val['email']]); - $listofnotiftodo = array_merge($listofnotiftodo); - } + if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER)) { + foreach ($listofnotiftodo as $val) { + if ($val['type'] == 'touser') { + unset($listofnotiftodo[$val['email']]); + $listofnotiftodo = array_merge($listofnotiftodo); } } - if ($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 2 || $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE == 3) { - foreach ($listofnotiftodo as $val) { - if ($val['type'] == 'tofixedemail') { - unset($listofnotiftodo[$val['email']]); - $listofnotiftodo = array_merge($listofnotiftodo); - } + } + if (!empty($conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX)) { + foreach ($listofnotiftodo as $val) { + if ($val['type'] == 'tofixedemail') { + unset($listofnotiftodo[$val['email']]); + $listofnotiftodo = array_merge($listofnotiftodo); } } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 73d2a5ca558..2154539939c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1673,7 +1673,8 @@ MailingDelay=Seconds to wait after sending next message NotificationSetup=Email Notification module setup NotificationEMailFrom=Sender email (From) for emails sent by the Notifications module FixedEmailTarget=Recipient -NotificationDisableConfirmMessage=Notification disable in confirm message +NotificationDisableConfirmMessageFix=Disable notification info in confirm message for fix notification +NotificationDisableConfirmMessageUser=Disable notification info in confirm message for user notification ##### Sendings ##### SendingsSetup=Shipping module setup SendingsReceiptModel=Sending receipt model From b6ddea57f3e462dd2ffa312e5252b78f7571323d Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 29 Apr 2021 00:17:55 +0200 Subject: [PATCH 006/490] update --- htdocs/admin/notification.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 6b17b9134f7..bf4928dc5a4 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -203,13 +203,6 @@ if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->globa print ''; print ''; -$arrayofnotifto = array( --1 => '', -1 => $langs->trans('notiftouser'), -2 => $langs->trans('notiftofixedemail'), -3 => $langs->trans('notiftouserandtofixedemail') -); - print ''; print $langs->trans("NotificationDisableConfirmMessageUser").''; print ''; From ba7b6a8d5146ba0d7f077701a8e8aae1b3acba2b Mon Sep 17 00:00:00 2001 From: kamel Date: Mon, 21 Jun 2021 16:38:36 +0200 Subject: [PATCH 007/490] FIX: Reload values of the specified entity when change entity in the execution of cron job --- htdocs/core/class/conf.class.php | 67 +++++++++++++++++++++++++++++ htdocs/cron/class/cronjob.class.php | 16 +++---- 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 8766d68c25b..ed919be568c 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -151,6 +151,19 @@ class Conf $this->productbatch = new stdClass(); } + /** + * Load setup values into conf object (read llx_const) for a specified entity + * Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called. + * + * @param DoliDB $db Database handler + * @param int $entity Entity to get + * @return int < 0 if KO, >= 0 if OK + */ + function setEntityValues($db, $entity) + { + $this->entity = $entity; + $this->setValues($db); + } /** * Load setup values into conf object (read llx_const) @@ -161,6 +174,60 @@ class Conf */ public function setValues($db) { + global $conf; + + // Unset all old modules values + if (!empty($this->modules)) { + foreach ($this->modules as $m) { + if (isset($this->$m)) unset($this->$m); + } + } + + // Properly declare multi-modules objects. + $this->global = new stdClass(); + $this->multicompany = new stdClass(); + + // First level object + // TODO Remove this part. + $this->expedition_bon = new stdClass(); + $this->delivery_note = new stdClass(); + $this->fournisseur = new stdClass(); + $this->product = new stdClass(); + $this->service = new stdClass(); + $this->contrat = new stdClass(); + $this->actions = new stdClass(); + $this->agenda = new stdClass(); + $this->commande = new stdClass(); + $this->propal = new stdClass(); + $this->facture = new stdClass(); + $this->contrat = new stdClass(); + $this->usergroup = new stdClass(); + $this->adherent = new stdClass(); + $this->bank = new stdClass(); + $this->notification = new stdClass(); + $this->mailing = new stdClass(); + $this->expensereport = new stdClass(); + $this->productbatch = new stdClass(); + $this->modules = array();; + $this->modules_parts = array( + 'css' => array(), + 'js' => array(), + 'tabs' => array(), + 'triggers' => array(), + 'login' => array(), + 'substitutions' => array(), + 'menus' => array(), + 'theme' => array(), + 'sms' => array(), + 'tpl' => array(), + 'barcode' => array(), + 'models' => array(), + 'societe' => array(), + 'hooks' => array(), + 'dir' => array(), + 'syslog' => array(), + ); + dol_syslog(get_class($this)."::setValues"); //Define all global constants into $this->global->key=value diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 2ffce20a924..e2b7c2da47b 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1081,7 +1081,7 @@ class Cronjob extends CommonObject dol_syslog("We try to run a job in entity ".$this->entity." when we are in entity ".$conf->entity, LOG_WARNING); } $savcurrententity = $conf->entity; - $conf->entity = $this->entity; + $conf->setEntityValues($this->db, $this->entity); dol_syslog(get_class($this)."::run_jobs entity for running job is ".$conf->entity); require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -1090,13 +1090,13 @@ class Cronjob extends CommonObject if ($result < 0) { $this->error = "User Error:".$user->error; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->entity = $savcurrententity; + $conf->setEntityValues($this->db, $savcurrententity); return -1; } else { if (empty($user->id)) { $this->error = " User user login:".$userlogin." do not exists"; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->entity = $savcurrententity; + $conf->setEntityValues($this->db, $savcurrententity); return -1; } } @@ -1126,7 +1126,7 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->entity = $savcurrententity; + $conf->setEntityValues($this->db, $savcurrententity); return -1; } @@ -1241,7 +1241,7 @@ class Cronjob extends CommonObject if ($ret === false) { $this->error = $langs->trans('CronCannotLoadLib').': '.$libpath; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->entity = $savcurrententity; + $conf->setEntityValues($this->db, $savcurrententity); return -1; } @@ -1250,7 +1250,7 @@ class Cronjob extends CommonObject $result = $langs->load($this->module_name.'@'.$this->module_name); // If this->module_name was an existing language file, this will make nothing if ($result < 0) { // If technical error dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR); - $conf->entity = $savcurrententity; + $conf->setEntityValues($this->db, $savcurrententity); return -1; } @@ -1316,11 +1316,11 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->entity = $savcurrententity; + $conf->setEntityValues($this->db, $savcurrententity); return -1; } - $conf->entity = $savcurrententity; + $conf->setEntityValues($this->db, $savcurrententity); return $error ?-1 : 1; } From dd61c497228aac8685dcd5774d7531a21c5fcf0f Mon Sep 17 00:00:00 2001 From: kamel Date: Mon, 21 Jun 2021 16:44:31 +0200 Subject: [PATCH 008/490] Correction --- htdocs/core/class/conf.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index ed919be568c..bc953faab2e 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -174,8 +174,6 @@ class Conf */ public function setValues($db) { - global $conf; - // Unset all old modules values if (!empty($this->modules)) { foreach ($this->modules as $m) { From 488d875854b29791e3a66dcddb372a506ffc0655 Mon Sep 17 00:00:00 2001 From: kamel Date: Mon, 21 Jun 2021 16:51:54 +0200 Subject: [PATCH 009/490] Correction --- htdocs/core/class/conf.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index bc953faab2e..4000dc4d6f1 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -159,7 +159,7 @@ class Conf * @param int $entity Entity to get * @return int < 0 if KO, >= 0 if OK */ - function setEntityValues($db, $entity) + public function setEntityValues($db, $entity) { $this->entity = $entity; $this->setValues($db); From a79abfd4e01e70850c8893c1c5b645bd5fdb962c Mon Sep 17 00:00:00 2001 From: henrynopo Date: Thu, 26 Aug 2021 10:37:03 +0800 Subject: [PATCH 010/490] Update card.php --- htdocs/compta/facture/card.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 31de2bbd4ff..4658c10873d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4052,6 +4052,8 @@ if ($action == 'create') { $i++; $close[$i]['code'] = 'badcustomer'; $i++; + $close[$i]['code'] = 'bankcharge'; + $i++; $close[$i]['code'] = 'other'; $i++; // Help @@ -4060,6 +4062,8 @@ if ($action == 'create') { $i++; $close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc"); $i++; + $close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBankChargeDesc"); + $i++; $close[$i]['label'] = $langs->trans("Other"); $i++; // Texte @@ -4068,6 +4072,8 @@ if ($action == 'create') { $i++; $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1); $i++; + $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBankCharge", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1); + $i++; $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("Other"), $close[$i]['label'], 1); $i++; // arrayreasons[code]=reason From a25580f97cfeda3e314926264063d85e0d251a18 Mon Sep 17 00:00:00 2001 From: henrynopo Date: Thu, 26 Aug 2021 10:38:53 +0800 Subject: [PATCH 011/490] Update bills.lang --- htdocs/langs/en_US/bills.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index a921aac9e48..6a88f2599dd 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -192,6 +192,7 @@ ConfirmClassifyPaidPartiallyReasonDiscount=Remaining unpaid (%s %s) is a ConfirmClassifyPaidPartiallyReasonDiscountNoVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I accept to lose the VAT on this discount. ConfirmClassifyPaidPartiallyReasonDiscountVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I recover the VAT on this discount without a credit note. ConfirmClassifyPaidPartiallyReasonBadCustomer=Bad customer +ConfirmClassifyPaidPartiallyReasonBankCharge=Deduction by bank (intermediary bank fees) ConfirmClassifyPaidPartiallyReasonProductReturned=Products partially returned ConfirmClassifyPaidPartiallyReasonOther=Amount abandoned for other reason ConfirmClassifyPaidPartiallyReasonDiscountNoVatDesc=This choice is possible if your invoice has been provided with suitable comments. (Example «Only the tax corresponding to the price that has been actually paid gives rights to deduction») @@ -199,6 +200,7 @@ ConfirmClassifyPaidPartiallyReasonDiscountVatDesc=In some countries, this choice ConfirmClassifyPaidPartiallyReasonAvoirDesc=Use this choice if all other does not suit ConfirmClassifyPaidPartiallyReasonBadCustomerDesc=A bad customer is a customer that refuses to pay his debt. ConfirmClassifyPaidPartiallyReasonProductReturnedDesc=This choice is used when payment is not complete because some of products were returned +ConfirmClassifyPaidPartiallyReasonBankChargeDesc=The unpaid amount is intermediary bank fees, deducted directly from the correct amount paid by the Customer. ConfirmClassifyPaidPartiallyReasonOtherDesc=Use this choice if all others are not suitable, for example in following situation:
- payment not complete because some products were shipped back
- amount claimed too important because a discount was forgotten
In all cases, amount over-claimed must be corrected in accountancy system by creating a credit note. ConfirmClassifyAbandonReasonOther=Other ConfirmClassifyAbandonReasonOtherDesc=This choice will be used in all other cases. For example because you plan to create a replacing invoice. From 2da16ade6c722e1464a6c8f571beaba150f194d9 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 8 Oct 2021 17:24:52 +0200 Subject: [PATCH 012/490] FIX: consistent UX when calling a tab from the invoice card with empty ref / id --- htdocs/compta/facture/card.php | 11 +++++++++++ htdocs/compta/facture/contact.php | 11 +++++++++++ htdocs/compta/facture/document.php | 11 +++++++++++ htdocs/compta/facture/info.php | 11 +++++++++++ htdocs/compta/facture/note.php | 11 +++++++++++ 5 files changed, 55 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e15b2722800..ab568332dd8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2756,6 +2756,17 @@ if (empty($reshook)) * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'compta', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index c340d68242e..c0e0a40c2c5 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -118,6 +118,17 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'contact', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index e880d77db74..64ebed251d3 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -85,6 +85,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'documents', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Documents'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index bad63cf1f61..9e40fd8b5a8 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -43,6 +43,17 @@ $ref = GETPOST("ref", 'alpha'); * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $form = new Form($db); $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 07084a0cf2c..428383b4907 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -64,6 +64,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Notes'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); From 65c0167d077605451f37351d94ef76cd8113fc69 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Sun, 10 Oct 2021 20:50:51 +0200 Subject: [PATCH 013/490] ADD : info of number of product still to dispatched in a supplier order --- htdocs/core/lib/fourn.lib.php | 4 ++ .../class/fournisseur.commande.class.php | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index efc9f60147c..e81bdb5e9d0 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -157,8 +157,12 @@ function ordersupplier_prepare_head($object) if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { $langs->load("stocks"); + $nbLineToDispatch = count($object->getNotCompletlyDispatchedLines()); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderDispatch"); + if ($nbLineToDispatch > 0) { + $head[$h][1] .= ''.$nbLineToDispatch.''; + } $head[$h][2] = 'dispatch'; $h++; } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 99ef4e54e87..5277f5b1d34 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2274,6 +2274,49 @@ class CommandeFournisseur extends CommonOrder return $ret; } + /** + * Return array of the lines that are waiting to be dispatched + * + * @return array Array of lines + */ + public function getNotCompletlyDispatchedLines() + { + $ret = array(); + + $sql = "SELECT supplierOrderDet.fk_product as product_id, supplierOrderDet.qty as qty_ordered, supplierOrderDet.fk_commande,"; + $sql .= " dispatch.rowid as dispatchedlineid, sum(dispatch.qty) as qty_dispatched"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as supplierOrderDet"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as dispatch ON supplierOrderDet.rowid = dispatch.fk_commandefourndet"; + $sql .= " WHERE supplierOrderDet.fk_commande = ".$this->id; + $sql .= " GROUP BY supplierOrderDet.fk_product"; + + $resql = $this->db->query($sql); + + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + + if ($objp) { + // If product not completly dispatched + if (is_null($objp->qty_dispatched) OR ($objp->qty_dispatched < $objp->qty_ordered)){ + $ret[] = array( + 'product_id' => $objp->product_id, + 'qty_ordered' => $objp->qty_ordered, + 'qty_dispatched' => $objp->qty_dispatched, + ); + } + } + $i++; + } + } else { + dol_print_error($this->db, 'Failed to execute request to get not completly dispatched lines'); + } + + return $ret; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** From 73bd05606c554802d3371cfb7235e365e8f0fff2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 10 Oct 2021 18:53:22 +0000 Subject: [PATCH 014/490] Fixing style errors. --- htdocs/fourn/class/fournisseur.commande.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5277f5b1d34..a9d3cbdcac5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2289,7 +2289,7 @@ class CommandeFournisseur extends CommonOrder $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as dispatch ON supplierOrderDet.rowid = dispatch.fk_commandefourndet"; $sql .= " WHERE supplierOrderDet.fk_commande = ".$this->id; $sql .= " GROUP BY supplierOrderDet.fk_product"; - + $resql = $this->db->query($sql); if ($resql) { @@ -2301,7 +2301,7 @@ class CommandeFournisseur extends CommonOrder if ($objp) { // If product not completly dispatched - if (is_null($objp->qty_dispatched) OR ($objp->qty_dispatched < $objp->qty_ordered)){ + if (is_null($objp->qty_dispatched) OR ($objp->qty_dispatched < $objp->qty_ordered)) { $ret[] = array( 'product_id' => $objp->product_id, 'qty_ordered' => $objp->qty_ordered, From a7563ff62e1fbef41f99bbb679674f0ef2cce67c Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Sun, 10 Oct 2021 21:15:14 +0200 Subject: [PATCH 015/490] Fix : Found non quoted or not casted var into sql request --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index a9d3cbdcac5..787d9ee321b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2287,7 +2287,7 @@ class CommandeFournisseur extends CommonOrder $sql .= " dispatch.rowid as dispatchedlineid, sum(dispatch.qty) as qty_dispatched"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as supplierOrderDet"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as dispatch ON supplierOrderDet.rowid = dispatch.fk_commandefourndet"; - $sql .= " WHERE supplierOrderDet.fk_commande = ".$this->id; + $sql .= " WHERE supplierOrderDet.fk_commande = ".((int) $this->id); $sql .= " GROUP BY supplierOrderDet.fk_product"; $resql = $this->db->query($sql); From 57052e2fbabffa16b25a25fe02a1966e117d09db Mon Sep 17 00:00:00 2001 From: atm-florian Date: Mon, 11 Oct 2021 11:10:14 +0200 Subject: [PATCH 016/490] FIX PR#18931 Remove useless explicit call to dol_shutdown --- htdocs/compta/facture/card.php | 1 - htdocs/compta/facture/contact.php | 1 - htdocs/compta/facture/document.php | 1 - htdocs/compta/facture/info.php | 1 - htdocs/compta/facture/note.php | 1 - 5 files changed, 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ab568332dd8..c772fd0ad7b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2763,7 +2763,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'compta', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index c0e0a40c2c5..7177463c30e 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -125,7 +125,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'contact', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 64ebed251d3..0818b944705 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -92,7 +92,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'documents', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 9e40fd8b5a8..955c41693c0 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -50,7 +50,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 428383b4907..dadb61b551d 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -71,7 +71,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } From 5d7587259d88e17df0c49f63d3bf791f239b62e7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 13 Oct 2021 21:21:16 +0200 Subject: [PATCH 017/490] FIX Accountancy - If deposit invoice is used, force binding in deposit accounting account to solve transaction --- htdocs/accountancy/customer/list.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 5ce9f5e13e8..2be7cd5f4ca 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -637,11 +637,15 @@ if ($result) { } // Manage Deposit - if ($objp->description == "(DEPOSIT)") { - $accountdeposittoventilated = new AccountingAccount($db); - $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); - $objp->code_sell_l = $accountdeposittoventilated->ref; - $objp->aarowid_suggest = $accountdeposittoventilated->rowid; + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT)) { + if ($objp->description == "(DEPOSIT)" || $objp->ftype == $facture_static::TYPE_DEPOSIT) { + $accountdeposittoventilated = new AccountingAccount($db); + $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); + $objp->code_sell_l = $accountdeposittoventilated->ref; + $objp->code_sell_p = ''; + $objp->code_sell_t = ''; + $objp->aarowid_suggest = $accountdeposittoventilated->rowid; + } } if (!empty($objp->code_sell_p)) { From 9e3a00521d8a1f7e4daa221cce5d2f393bee29ef Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 13 Oct 2021 21:36:04 +0200 Subject: [PATCH 018/490] FIX also on customer index for automatic binding --- htdocs/accountancy/customer/index.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 0ee9c865603..7dc88a6939a 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -170,6 +170,8 @@ if ($action == 'validatehistory') { } else { $num_lines = $db->num_rows($result); + $facture_static = new Facture($db); + $isSellerInEEC = isInEEC($mysoc); $i = 0; @@ -213,6 +215,18 @@ if ($action == 'validatehistory') { } } + // Manage Deposit + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT)) { + if ($objp->description == "(DEPOSIT)" || $objp->ftype == $facture_static::TYPE_DEPOSIT) { + $accountdeposittoventilated = new AccountingAccount($db); + $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); + $objp->code_sell_l = $accountdeposittoventilated->ref; + $objp->code_sell_p = ''; + $objp->code_sell_t = ''; + $objp->aarowid_suggest = $accountdeposittoventilated->rowid; + } + } + if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); From ff7727466ad129070c0b56965eb0457f0ddf1795 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 14 Oct 2021 17:13:44 +0200 Subject: [PATCH 019/490] Function updateExtrafield : replace empty value to null --- htdocs/core/class/commonobject.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5a5e1a58928..50c6f1893ea 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5492,7 +5492,6 @@ abstract class CommonObject } $sql .= ")"; - $resql = $this->db->query($sql); if (!$resql) { @@ -5792,7 +5791,7 @@ abstract class CommonObject } if ($linealreadyfound) { - if ($this->array_options["options_".$key] === null) { + if ($this->array_options["options_".$key] === '') { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null"; } else { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; From bd52613331d59d0d3cf8f08872319ce6c1312ea2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Oct 2021 17:06:10 +0200 Subject: [PATCH 020/490] Fix phpcs --- htdocs/compta/facture/stats/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 03fcf5b37d0..c8961762a81 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -109,7 +109,6 @@ if ($mode == 'supplier') { $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_fournisseur as cat ON (f.fk_soc = cat.fk_soc)'; $stats->where .= ' AND cat.fk_categorie IN ('.implode(',', $custcats).')'; } - } // Build graphic number of object From 152aab4903afa548d25874c34d404a36bad9d0b9 Mon Sep 17 00:00:00 2001 From: kamel Date: Mon, 18 Oct 2021 10:10:31 +0200 Subject: [PATCH 021/490] Add test if actual entity is different to the entity provided --- htdocs/core/class/conf.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 4000dc4d6f1..3f938fe778c 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -161,8 +161,10 @@ class Conf */ public function setEntityValues($db, $entity) { - $this->entity = $entity; - $this->setValues($db); + if ($this->entity != $entity) { + $this->entity = $entity; + $this->setValues($db); + } } /** From f328bb32f6ab545c1b98c8be47c9daa5dbdf04c0 Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 19 Oct 2021 17:34:03 +0200 Subject: [PATCH 022/490] Corrections --- htdocs/core/class/conf.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 3f938fe778c..7b35aad3075 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -163,8 +163,10 @@ class Conf { if ($this->entity != $entity) { $this->entity = $entity; - $this->setValues($db); + return $this->setValues($db); } + + return 0; } /** @@ -176,6 +178,8 @@ class Conf */ public function setValues($db) { + dol_syslog(get_class($this)."::setValues"); + // Unset all old modules values if (!empty($this->modules)) { foreach ($this->modules as $m) { @@ -228,8 +232,6 @@ class Conf 'syslog' => array(), ); - dol_syslog(get_class($this)."::setValues"); - //Define all global constants into $this->global->key=value $sql = "SELECT ".$db->decrypt('name')." as name,"; $sql .= " ".$db->decrypt('value')." as value, entity"; From 02bb39d4384933a052e38e551f73c6c7b109d985 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 21 Oct 2021 05:06:50 +0200 Subject: [PATCH 023/490] FIX Accountancy simplified - Salaries are not present in report --- htdocs/compta/resultat/clientfourn.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index f2f192271ac..0b38a8f66c9 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -862,7 +862,8 @@ if ($modecompta == 'BOOKKEEPING') { $sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=s.fk_user"; $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; if (!empty($date_start) && !empty($date_end)) { $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; From be7c1c8a235a58ca8300cd7b0c765fc7010e85b2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 21 Oct 2021 05:18:56 +0200 Subject: [PATCH 024/490] Typo & translation --- htdocs/compta/resultat/clientfourn.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 0b38a8f66c9..2de55d1801f 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -9,6 +9,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Maxime DEMAREST + * Copyright (C) 2021 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 @@ -366,7 +367,7 @@ if ($modecompta == 'BOOKKEEPING') { } } else { /* - * Factures clients + * Customer invoices */ print ''.$langs->trans("CustomersInvoices").''; @@ -386,8 +387,8 @@ if ($modecompta == 'BOOKKEEPING') { } } elseif ($modecompta == 'RECETTES-DEPENSES') { /* - * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les - * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) + * List of payments (old payments are not seen by this query because, on older versions, they were not linked via payment_invoice. + * old versions, they were not linked via payment_invoice. They are added later) */ $sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -434,7 +435,7 @@ if ($modecompta == 'BOOKKEEPING') { dol_print_error($db); } - // On ajoute les paiements clients anciennes version, non lie par paiement_facture + // We add the old customer payments, not linked by payment_invoice if ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT 'Autres' as name, '0' as idp, sum(p.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -673,7 +674,7 @@ if ($modecompta == 'BOOKKEEPING') { /* - * Charges sociales non deductibles + * Social / Fiscal contributions who are not deductible */ print ''.$langs->trans("SocialContributionsNondeductibles").''; @@ -760,7 +761,7 @@ if ($modecompta == 'BOOKKEEPING') { /* - * Charges sociales deductibles + * Social / Fiscal contributions who are deductible */ print ''.$langs->trans("SocialContributionsDeductibles").''; @@ -932,7 +933,7 @@ if ($modecompta == 'BOOKKEEPING') { /* - * Expense + * Expense report */ if (!empty($conf->expensereport->enabled)) { @@ -1088,7 +1089,7 @@ if ($modecompta == 'BOOKKEEPING') { } /* - * Payement Loan + * Payment Loan */ if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN) && !empty($conf->loan->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { @@ -1209,7 +1210,7 @@ if ($modecompta == 'BOOKKEEPING') { print ''.price($amount)."\n"; print "\n"; - // VAT to retreive + // VAT to retrieve $amount = 0; $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; From a1c0e1ad1f4fae5d30c929e6b042450b655a2bcb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 21 Oct 2021 05:45:37 +0200 Subject: [PATCH 025/490] Better fix with backward compatibility with old salary module --- htdocs/compta/resultat/clientfourn.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 2de55d1801f..e5984e527ae 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -869,8 +869,19 @@ if ($modecompta == 'BOOKKEEPING') { if (!empty($date_start) && !empty($date_end)) { $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; } + $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, s.fk_user, p.label, dm"; + // For backward compatibility with old module salary + $sql .= " UNION "; + $sql .= " SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; + $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; + if (!empty($date_start) && !empty($date_end)) { + $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; + } $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm"; + $newsortfield = $sortfield; if ($newsortfield == 's.nom, s.rowid') { $newsortfield = 'u.firstname, u.lastname'; From d2b96fe0f64a7bf3563ece5fe3c8051ad8a1398c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 21 Oct 2021 06:08:48 +0200 Subject: [PATCH 026/490] Correct link to salary list with user search --- htdocs/compta/resultat/clientfourn.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index e5984e527ae..1d2edd5c918 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -34,6 +34,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -861,7 +862,7 @@ if ($modecompta == 'BOOKKEEPING') { $column = 'p.datep'; } - $sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; + $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=s.fk_user"; @@ -873,7 +874,7 @@ if ($modecompta == 'BOOKKEEPING') { // For backward compatibility with old module salary $sql .= " UNION "; - $sql .= " SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; + $sql .= " SELECT u.rowid, u.firstname, u.lastname, p.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; @@ -913,7 +914,10 @@ if ($modecompta == 'BOOKKEEPING') { print ' '; - print "".$langs->trans("Salary")." fk_user."\">".$obj->firstname." ".$obj->lastname."\n"; + $userstatic = new User($db); + $userstatic->fetch($obj->fk_user); + + print "".$langs->trans("Salary")." getFullName($langs)."\">".$obj->firstname." ".$obj->lastname."\n"; if ($modecompta == 'CREANCES-DETTES') { print ''.price(-$obj->amount).''; From 806c53d4c4c343299ffe4e6690f2889a9d50c2d8 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 21 Oct 2021 09:49:14 +0200 Subject: [PATCH 027/490] FIX Ret PR --- htdocs/core/class/commonobject.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 50c6f1893ea..a4fc828ef4b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5745,6 +5745,11 @@ abstract class CommonObject $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); } break; + case 'boolean': + if (empty($this->array_options["options_".$key])) { + $this->array_options["options_".$key] = null; + } + break; /* case 'link': $param_list = array_keys($attributeParam['options']); @@ -5791,7 +5796,7 @@ abstract class CommonObject } if ($linealreadyfound) { - if ($this->array_options["options_".$key] === '') { + if ($this->array_options["options_".$key] === null) { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null"; } else { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; From f68c3c17aaaddd90703a3341ad9aed6f110438c1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 21 Oct 2021 15:50:04 +0200 Subject: [PATCH 028/490] fix php warning --- htdocs/core/extrafieldsinexport.inc.php | 2 +- htdocs/core/modules/modSociete.class.php | 21 +++++++++++++++++++ .../societe/mod_codeclient_elephant.php | 4 ++-- htdocs/societe/admin/societe.php | 6 +++--- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php index 70dd0077e57..fc2210eabd8 100644 --- a/htdocs/core/extrafieldsinexport.inc.php +++ b/htdocs/core/extrafieldsinexport.inc.php @@ -48,7 +48,7 @@ if ($resql) { // This can fail when class is used on old database (during mig case 'sellist': $tmp = ''; $tmpparam = jsonOrUnserialize($obj->param); // $tmp may be array 'options' => array 'c_currencies:code_iso:code_iso' => null - if ($tmpparam['options'] && is_array($tmpparam['options'])) { + if (is_array($tmpparam) && array_key_exists('options', $tmpparam) && $tmpparam['options'] && is_array($tmpparam['options'])) { $tmpkeys = array_keys($tmpparam['options']); $tmp = array_shift($tmpkeys); } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index c3eba65673b..2cba93e29b7 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -121,6 +121,27 @@ class modSociete extends DolibarrModules $this->const[$r][4] = 0; $r++; + $this->const[$r][0] = "SOCIETE_SHOW_VAT_IN_LIST"; + $this->const[$r][1] = "yesno"; + $this->const[$r][2] = "0"; + $this->const[$r][3] = "Display customer ref into select list"; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "COMPANY_USE_SEARCH_TO_SELECT"; + $this->const[$r][1] = "yesno"; + $this->const[$r][2] = "0"; + $this->const[$r][3] = "Use easy find customer"; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "CONTACT_USE_SEARCH_TO_SELECT"; + $this->const[$r][1] = "yesno"; + $this->const[$r][2] = "0"; + $this->const[$r][3] = "use easy find contact"; + $this->const[$r][4] = 0; + $r++; + // Boxes $this->boxes = array( 0=>array('file'=>'box_clients.php', 'enabledbydefaulton'=>'Home'), diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index c18b768a724..8bb3a7bb2a1 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -132,7 +132,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode // Parametrage du prefix customers $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):'; - $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; $texte .= '  '; @@ -140,7 +140,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode // Parametrage du prefix suppliers $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):'; - $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; $texte .= ''; $texte .= ''; diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 18bc3a3785b..536eb0546cc 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -746,7 +746,7 @@ if (!$conf->use_javascript_ajax) { '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', ); - print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp'); + print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, (property_exists($conf->global, 'COMPANY_USE_SEARCH_TO_SELECT')?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:''), 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp'); print ''; print ''; print ""; @@ -767,7 +767,7 @@ if (!$conf->use_javascript_ajax) { '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', ); - print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp'); + print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, (property_exists($conf->global, 'CONTACT_USE_SEARCH_TO_SELECT')?$conf->global->CONTACT_USE_SEARCH_TO_SELECT:''), 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp'); print ''; print ''; print ""; @@ -870,7 +870,7 @@ if (empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { print ''; print ''.$langs->trans("DefaultCustomerType").''; print ''; - print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT, 'defaultcustomertype', 'defaultcustomertype', 'admin'); + print $formcompany->selectProspectCustomerType((property_exists($conf->global, 'THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')?$conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT:''), 'defaultcustomertype', 'defaultcustomertype', 'admin'); print ''; print ''; print ''; From 75f579c3ad88a9eea3529bbd5808545ec908321b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 22 Oct 2021 00:59:09 +0200 Subject: [PATCH 029/490] New table element_tag --- .../mysql/tables/llx_element_tag.key.sql | 23 ++++++++++++++++++ .../install/mysql/tables/llx_element_tag.sql | 24 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_element_tag.key.sql create mode 100644 htdocs/install/mysql/tables/llx_element_tag.sql diff --git a/htdocs/install/mysql/tables/llx_element_tag.key.sql b/htdocs/install/mysql/tables/llx_element_tag.key.sql new file mode 100644 index 00000000000..fc1e3e7861d --- /dev/null +++ b/htdocs/install/mysql/tables/llx_element_tag.key.sql @@ -0,0 +1,23 @@ +-- ============================================================================ +-- Copyright (C) 2021 Maxime Kohlhaas +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +ALTER TABLE llx_element_tag ADD PRIMARY KEY pk_element_tag (fk_categorie, fk_socpeople); +ALTER TABLE llx_element_tag ADD INDEX idx_element_tag_fk_categorie (fk_categorie); +ALTER TABLE llx_element_tag ADD INDEX idx_element_tag_fk_socpeople (fk_socpeople); + +ALTER TABLE llx_element_tag ADD CONSTRAINT fk_element_tag_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); diff --git a/htdocs/install/mysql/tables/llx_element_tag.sql b/htdocs/install/mysql/tables/llx_element_tag.sql new file mode 100644 index 00000000000..937137727e7 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_element_tag.sql @@ -0,0 +1,24 @@ +-- ============================================================================ +-- Copyright (C) 2021 Maxime Kohlhaas +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +create table llx_element_tag +( + fk_categorie integer NOT NULL, + fk_element integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; From 0c8291b60fd4ecf936e221220b3a79d46c55a161 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 22 Oct 2021 04:35:23 +0200 Subject: [PATCH 030/490] Fix INNER JOIN & Add urlencode() --- htdocs/compta/resultat/clientfourn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 1d2edd5c918..b5aca49aaae 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -864,7 +864,7 @@ if ($modecompta == 'BOOKKEEPING') { $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=s.fk_user"; $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; if (!empty($date_start) && !empty($date_end)) { @@ -917,7 +917,7 @@ if ($modecompta == 'BOOKKEEPING') { $userstatic = new User($db); $userstatic->fetch($obj->fk_user); - print "".$langs->trans("Salary")." getFullName($langs)."\">".$obj->firstname." ".$obj->lastname."\n"; + print "".$langs->trans("Salary")." getFullName($langs))."\">".$obj->firstname." ".$obj->lastname."\n"; if ($modecompta == 'CREANCES-DETTES') { print ''.price(-$obj->amount).''; From 3f211417c2218b927b31a1c3335d7797f3265182 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 22 Oct 2021 12:19:16 +0200 Subject: [PATCH 031/490] review --- htdocs/core/modules/modSociete.class.php | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 2cba93e29b7..c3eba65673b 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -121,27 +121,6 @@ class modSociete extends DolibarrModules $this->const[$r][4] = 0; $r++; - $this->const[$r][0] = "SOCIETE_SHOW_VAT_IN_LIST"; - $this->const[$r][1] = "yesno"; - $this->const[$r][2] = "0"; - $this->const[$r][3] = "Display customer ref into select list"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "COMPANY_USE_SEARCH_TO_SELECT"; - $this->const[$r][1] = "yesno"; - $this->const[$r][2] = "0"; - $this->const[$r][3] = "Use easy find customer"; - $this->const[$r][4] = 0; - $r++; - - $this->const[$r][0] = "CONTACT_USE_SEARCH_TO_SELECT"; - $this->const[$r][1] = "yesno"; - $this->const[$r][2] = "0"; - $this->const[$r][3] = "use easy find contact"; - $this->const[$r][4] = 0; - $r++; - // Boxes $this->boxes = array( 0=>array('file'=>'box_clients.php', 'enabledbydefaulton'=>'Home'), From b94d74f194e0b96aa9f382b94a0cdb00242e2650 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 22 Oct 2021 14:58:09 +0200 Subject: [PATCH 032/490] fix php8 warning --- .../tpl/extrafields_list_print_fields.tpl.php | 3 +++ htdocs/societe/consumption.php | 24 ++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index 7d547d52dea..280be4de434 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -50,6 +50,9 @@ if (!empty($extrafieldsobjectkey) && !empty($extrafields->attributes[$extrafield print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey); print ''; if (!$i) { + if (empty($totalarray)) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index c4bd26e1fc2..bbaf9e1c5de 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -50,6 +50,8 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +$optioncss = GETPOST('optioncss', 'alpha'); + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -160,16 +162,16 @@ if ($object->client) { $obj = $db->fetch_object($resql); $nbFactsClient = $obj->nb; $thirdTypeArray['customer'] = $langs->trans("customer"); - if ($conf->propal->enabled && $user->rights->propal->lire) { + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); } - if ($conf->commande->enabled && $user->rights->commande->lire) { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); } - if ($conf->facture->enabled && $user->rights->facture->lire) { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); } - if ($conf->contrat->enabled && $user->rights->contrat->lire) { + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } } @@ -232,7 +234,7 @@ $sql_select = ''; if ($type_element == 'fichinter') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $documentstatic = new Fichinter($db); - $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, '; + $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, NULL as paid,'; $tables_from = MAIN_DB_PREFIX."fichinter as f LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as d ON d.fk_fichinter = f.rowid"; // Must use left join to work also with option that disable usage of lines. $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND f.entity = ".$conf->entity; @@ -254,7 +256,7 @@ if ($type_element == 'invoice') { // Customer : show products from invoices if ($type_element == 'propal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $documentstatic = new Propal($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, NULL as paid,'; $tables_from = MAIN_DB_PREFIX."propal as c,".MAIN_DB_PREFIX."propaldet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_propal = c.rowid"; @@ -266,7 +268,7 @@ if ($type_element == 'propal') { if ($type_element == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $documentstatic = new Commande($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, NULL as paid, '; $tables_from = MAIN_DB_PREFIX."commande as c,".MAIN_DB_PREFIX."commandedet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_commande = c.rowid"; @@ -290,7 +292,7 @@ if ($type_element == 'supplier_invoice') { // Supplier : Show products from inv if ($type_element == 'supplier_proposal') { require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; $documentstatic = new SupplierProposal($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, NULL as paid, '; $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_supplier_proposal = c.rowid"; @@ -302,7 +304,7 @@ if ($type_element == 'supplier_proposal') { if ($type_element == 'supplier_order') { // Supplier : Show products from orders. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $documentstatic = new CommandeFournisseur($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, NULL as paid, '; $tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_commande = c.rowid"; @@ -315,7 +317,7 @@ if ($type_element == 'contract') { // Order require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $documentstatic = new Contrat($db); $documentstaticline = new ContratLigne($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, NULL as paid,'; $tables_from = MAIN_DB_PREFIX."contrat as c,".MAIN_DB_PREFIX."contratdet as d"; $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_contrat = c.rowid"; @@ -423,7 +425,7 @@ if ($sql_select) { if ($year) { $param .= "&year=".urlencode($year); } - if ($optioncss != '') { + if ($optioncss) { $param .= '&optioncss='.urlencode($optioncss); } From 5d0f5439a063ff89d65ed822d553d47a4c251d9a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 22 Oct 2021 14:59:48 +0200 Subject: [PATCH 033/490] fix php8 warning --- htdocs/societe/consumption.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index bbaf9e1c5de..9f6a444dc63 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -221,6 +221,7 @@ print '
'; print ''; $sql_select = ''; +$documentstaticline = ''; /*if ($type_element == 'action') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -343,7 +344,7 @@ if (!empty($sql_select)) { $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; } if ($type_element != 'fichinter') { - $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,'; + $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity, NULL as total_ht'; } $sql .= " s.rowid as socid "; if ($type_element != 'fichinter') { @@ -654,7 +655,7 @@ if ($sql_select) { $total_qty += $objp->prod_qty; print ''.price($objp->total_ht).''; - $total_ht += $objp->total_ht; + $total_ht += (float) $objp->total_ht; print ''.price($objp->total_ht / (empty($objp->prod_qty) ? 1 : $objp->prod_qty)).''; From 5faf5e08b36c0b14db5b176b5b1efb5fb50e5d37 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 22 Oct 2021 15:09:34 +0200 Subject: [PATCH 034/490] fix php8 warning --- htdocs/societe/consumption.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 9f6a444dc63..d9abbd61c22 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -235,7 +235,8 @@ $documentstaticline = ''; if ($type_element == 'fichinter') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $documentstatic = new Fichinter($db); - $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, NULL as paid,'; + $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, NULL as paid, '; + $sql_select .= 'NULL as fk_product, NULL as info_bits, NULL as date_start, NULL as date_end, NULL as prod_qty, NULL as total_ht, '; $tables_from = MAIN_DB_PREFIX."fichinter as f LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as d ON d.fk_fichinter = f.rowid"; // Must use left join to work also with option that disable usage of lines. $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND f.entity = ".$conf->entity; @@ -245,7 +246,7 @@ if ($type_element == 'fichinter') { // Customer : show products from invoices if ($type_element == 'invoice') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $documentstatic = new Facture($db); - $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; + $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, d.fk_remise_except, '; $tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d"; $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_facture = f.rowid"; @@ -344,7 +345,7 @@ if (!empty($sql_select)) { $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; } if ($type_element != 'fichinter') { - $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity, NULL as total_ht'; + $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity, '; } $sql .= " s.rowid as socid "; if ($type_element != 'fichinter') { @@ -570,6 +571,7 @@ if ($sql_select) { description) { + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); @@ -655,6 +657,9 @@ if ($sql_select) { $total_qty += $objp->prod_qty; print ''.price($objp->total_ht).''; + if (empty($total_ht)) { + $total_ht = 0; + } $total_ht += (float) $objp->total_ht; print ''.price($objp->total_ht / (empty($objp->prod_qty) ? 1 : $objp->prod_qty)).''; From fa21b27cedc3c67a5097932bae90114156820fa8 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 22 Oct 2021 15:27:16 +0200 Subject: [PATCH 035/490] Validate Holiday : keep files --- htdocs/holiday/card.php | 1 + htdocs/holiday/class/holiday.class.php | 39 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 150a9c0754b..93e748a51d2 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -266,6 +266,7 @@ if (empty($reshook)) { // If update and we are an approver, we can update with another approver if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) { + $object->fetch($id); $object->oldcopy = dol_clone($object); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 5ecc4d7325a..665e43c6ffd 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -701,6 +701,7 @@ class Holiday extends CommonObject public function validate($user = null, $notrigger = 0) { global $conf, $langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; // Define new ref @@ -740,6 +741,44 @@ class Holiday extends CommonObject } } + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // Now we rename also files into index + $sql = 'UPDATE ' . MAIN_DB_PREFIX . "ecm_files set filename = CONCAT('" . $this->db->escape($this->newref) . "', SUBSTR(filename, " . (strlen($this->ref) + 1) . ")), filepath = 'holiday/" . $this->db->escape($this->newref) . "'"; + $sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%' AND filepath = 'holiday/" . $this->db->escape($this->ref) . "' and entity = " . ((int)$conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->error = $this->db->lasterror(); + } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->holiday->multidir_output[$this->entity] . '/' . $oldref; + $dirdest = $conf->holiday->multidir_output[$this->entity] . '/' . $newref; + if (!$error && file_exists($dirsource)) { + dol_syslog(get_class($this) . "::validate rename dir " . $dirsource . " into " . $dirdest); + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($dirdest, 'files', 1, '^' . preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^' . preg_quote($oldref, '/') . '/', $newref, $dirsource); + $dirsource = $fileentry['path'] . '/' . $dirsource; + $dirdest = $fileentry['path'] . '/' . $dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { From 87ac58efb66d526fac07017c42de4627c9cf1d3f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 22 Oct 2021 15:27:36 +0200 Subject: [PATCH 036/490] fix php 8 --- htdocs/core/lib/pdf.lib.php | 20 +++++++++---------- .../bank/doc/pdf_sepamandate.modules.php | 2 +- htdocs/document.php | 1 + htdocs/societe/paymentmodes.php | 18 +++++++++-------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index e9b2e558595..420921bcc9e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1045,7 +1045,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $line2 .= ($line2 ? " - " : "").$fromcompany->email; } } - if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code == 'DE')) { + if ($showdetails == 2 || $showdetails == 3 || (!empty($fromcompany->country_code) && $fromcompany->country_code == 'DE')) { // Managers if ($fromcompany->managers) { $line2 .= ($line2 ? " - " : "").$fromcompany->managers; @@ -1054,11 +1054,11 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Line 3 of company infos // Juridical status - if ($fromcompany->forme_juridique_code) { + if (!empty($fromcompany->forme_juridique_code) && $fromcompany->forme_juridique_code) { $line3 .= ($line3 ? " - " : "").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); } // Capital - if ($fromcompany->capital) { + if (!empty($fromcompany->capital) && $fromcompany->capital) { $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) { $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); @@ -1067,7 +1067,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } } // Prof Id 1 - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { + if (!empty($fromcompany->idprof1) && $fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { $field = $outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code); if (preg_match('/\((.*)\)/i', $field, $reg)) { $field = $reg[1]; @@ -1075,7 +1075,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); } // Prof Id 2 - if ($fromcompany->idprof2) { + if (!empty($fromcompany->idprof2) && $fromcompany->idprof2) { $field = $outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code); if (preg_match('/\((.*)\)/i', $field, $reg)) { $field = $reg[1]; @@ -1085,7 +1085,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Line 4 of company infos // Prof Id 3 - if ($fromcompany->idprof3) { + if (!empty($fromcompany->idprof3) && $fromcompany->idprof3) { $field = $outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code); if (preg_match('/\((.*)\)/i', $field, $reg)) { $field = $reg[1]; @@ -1093,7 +1093,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); } // Prof Id 4 - if ($fromcompany->idprof4) { + if (!empty($fromcompany->idprof4) && $fromcompany->idprof4) { $field = $outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code); if (preg_match('/\((.*)\)/i', $field, $reg)) { $field = $reg[1]; @@ -1101,7 +1101,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); } // Prof Id 5 - if ($fromcompany->idprof5) { + if (!empty($fromcompany->idprof5) && $fromcompany->idprof5) { $field = $outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code); if (preg_match('/\((.*)\)/i', $field, $reg)) { $field = $reg[1]; @@ -1109,7 +1109,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); } // Prof Id 6 - if ($fromcompany->idprof6) { + if (!empty($fromcompany->idprof6) && $fromcompany->idprof6) { $field = $outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code); if (preg_match('/\((.*)\)/i', $field, $reg)) { $field = $reg[1]; @@ -1117,7 +1117,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); } // IntraCommunautary VAT - if ($fromcompany->tva_intra != '') { + if (!empty($fromcompany->tva_intra) && $fromcompany->tva_intra != '') { $line4 .= ($line4 ? " - " : "").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); } diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 49e311f1c89..2259897f044 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -282,7 +282,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $sepaname = '______________________________________________'; if ($thirdparty->id > 0) { - $sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : ''); + $sepaname = $thirdparty->name.($object->proprio ? ' ('.$object->proprio.')' : ''); } $posY = $pdf->GetY(); $posY += 3; diff --git a/htdocs/document.php b/htdocs/document.php index 3c06801c9a0..611517b0258 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -138,6 +138,7 @@ if (in_array($modulepart, array('facture_paiement', 'unpaid'))) { */ // If we have a hash public (hashp), we guess the original_file. +$ecmfile=''; if (!empty($hashp)) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile = new EcmFiles($db); diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 6a0b9fac742..d1bf19b069d 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -773,16 +773,16 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $obj = $db->fetch_object($resql); $nbFactsClient = $obj->nb; $thirdTypeArray['customer'] = $langs->trans("customer"); - if ($conf->propal->enabled && $user->rights->propal->lire) { + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); } - if ($conf->commande->enabled && $user->rights->commande->lire) { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); } - if ($conf->facture->enabled && $user->rights->facture->lire) { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); } - if ($conf->contrat->enabled && $user->rights->contrat->lire) { + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } @@ -1304,7 +1304,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } print_liste_field_titre("DefaultRIB", '', '', '', '', '', '', '', 'center '); print_liste_field_titre('', '', '', '', '', '', '', '', 'center '); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch '); print "\n"; foreach ($rib_list as $rib) { @@ -1393,7 +1393,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $out = ''; if (is_array($modellist) && count($modellist)) { - $out .= ''; + $out .= 'global->MAIN_JUMP_TAG) ? '' : '#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">'; $out .= ''; $out .= ''; $out .= ''; @@ -1407,14 +1407,16 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $modelselected = $conf->global->BANKADDON_PDF; } - $out .= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out .= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100'); $out .= ajax_combobox('modelrib'.$rib->id); + $allowgenifempty = 0; + // Language code (if multilang) if ($conf->global->MAIN_MULTILANGS) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - $defaultlang = $codelang ? $codelang : $langs->getDefaultLang(); + $defaultlang = $langs->getDefaultLang(); $morecss = 'maxwidth150'; if ($conf->browser->layout == 'phone') { $morecss = 'maxwidth100'; From 87b4805bc041237a87ab3da8788020a1306e40cf Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 22 Oct 2021 13:35:30 +0000 Subject: [PATCH 037/490] Fixing style errors. --- htdocs/holiday/card.php | 1 - htdocs/holiday/class/holiday.class.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 93e748a51d2..150a9c0754b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -266,7 +266,6 @@ if (empty($reshook)) { // If update and we are an approver, we can update with another approver if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) { - $object->fetch($id); $object->oldcopy = dol_clone($object); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 665e43c6ffd..6271f1d43e8 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -748,7 +748,7 @@ class Holiday extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index $sql = 'UPDATE ' . MAIN_DB_PREFIX . "ecm_files set filename = CONCAT('" . $this->db->escape($this->newref) . "', SUBSTR(filename, " . (strlen($this->ref) + 1) . ")), filepath = 'holiday/" . $this->db->escape($this->newref) . "'"; - $sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%' AND filepath = 'holiday/" . $this->db->escape($this->ref) . "' and entity = " . ((int)$conf->entity); + $sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%' AND filepath = 'holiday/" . $this->db->escape($this->ref) . "' and entity = " . ((int) $conf->entity); $resql = $this->db->query($sql); if (!$resql) { $error++; From 3d8a5d745a87f774e2d635ea3ee6dbe2de727ff1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 22 Oct 2021 17:42:57 +0200 Subject: [PATCH 038/490] fix php 8 warning --- htdocs/ticket/list.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 04e411b54a6..666758a907a 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -390,7 +390,11 @@ foreach ($search as $key => $val) { } continue; } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if (array_key_exists($key, $object->fields)) { + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + } else { + $mode_search = 0; + } if ($search[$key] != '') { $sql .= natural_search($key, $search[$key], $mode_search); } @@ -912,6 +916,7 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a // -------------------------------------------------------------------- $i = 0; $totalarray = array(); +$totalarray['nbfield']=0; $cacheofoutputfield = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -946,15 +951,17 @@ while ($i < min($num, $limit)) { } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; From 17773f84143a13419edef2c48b40b88ba5c598fe Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 22 Oct 2021 18:26:23 +0200 Subject: [PATCH 039/490] FIX tcpdf vulnerability to roman numeral bomb, cf. tecnickom/TCPDF issue #315 --- dev/dolibarr_changes.txt | 12 ++++++++++++ .../tecnickcom/tcpdf/include/tcpdf_static.php | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index ecd25ce692b..8cb0e002d16 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -175,6 +175,18 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php - protected $default_monospaced_font = 'courier'; + protected $default_monospaced_font = 'freemono'; +* In tecnickcom/tcpdf/include/tcpdf_static, in function intToRoman, right at the beginning + of the function, replace: + + $roman = ''; + +with: + + $roman = ''; + if ($number >= 4000) { + // do not represent numbers above 4000 in Roman numerals + return strval($number); + } diff --git a/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php b/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php index 67bb255d187..9ed6233b46c 100644 --- a/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php +++ b/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php @@ -1440,6 +1440,10 @@ class TCPDF_STATIC { */ public static function intToRoman($number) { $roman = ''; + if ($number >= 4000) { + // do not represent numbers above 4000 in Roman numerals + return strval($number); + } while ($number >= 1000) { $roman .= 'M'; $number -= 1000; From 1f1e01aa88ee4a7bc72184cbeedf2f6585dedf04 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 22 Oct 2021 23:38:35 +0200 Subject: [PATCH 040/490] fix php 8 warning --- htdocs/comm/action/card.php | 2 +- htdocs/contact/list.php | 1 + htdocs/product/card.php | 7 ++-- htdocs/product/fournisseurs.php | 57 ++++++++++++++++++--------------- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index e56a2e89fcf..f852d7e9938 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -2207,7 +2207,7 @@ if ($id > 0) { $delallowed = $user->rights->agenda->myactions->create; - print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); + print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang()); print '
'; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 71e888540b2..3808c651cae 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -1019,6 +1019,7 @@ print "\n"; $i = 0; $totalarray = array(); +$totalarray['nbfield'] = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index b4c951a953f..ce633975af8 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2175,8 +2175,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0, 2); print ''; - if ((($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') - || ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) { + if ((($object->status_batch == '1' && !empty($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') + || ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && !empty($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS)))) { print ''.$langs->trans("ManageLotMask").''; print $object->batch_mask; print ''; @@ -2686,7 +2686,6 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') { // Documents $objectref = dol_sanitizeFileName($object->ref); - $relativepath = $comref.'/'.$objectref.'.pdf'; if (!empty($conf->product->multidir_output[$object->entity])) { $filedir = $conf->product->multidir_output[$object->entity].'/'.$objectref; //Check repertories of current entities } else { @@ -2696,7 +2695,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') { $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); + print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $langs->getDefaultLang(), '', $object); $somethingshown = $formfile->numoffiles; print '
'; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index a3ae38184e9..02e0211c01d 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -931,7 +931,7 @@ END; 'pfp.fk_availability'=>array('label'=>$langs->trans("Availability"), 'enabled' => !empty($conf->global->FOURN_PRODUCT_AVAILABILITY), 'checked'=>0, 'position'=>4), 'pfp.quantity'=>array('label'=>$langs->trans("QtyMin"), 'checked'=>1, 'position'=>5), 'pfp.unitprice'=>array('label'=>$langs->trans("UnitPriceHT"), 'checked'=>1, 'position'=>9), - 'pfp.multicurrency_unitprice'=>array('label'=>$langs->trans("UnitPriceHTCurrency"), 'enabled' => $conf->multicurrency->enabled, 'checked'=>0, 'position'=>10), + 'pfp.multicurrency_unitprice'=>array('label'=>$langs->trans("UnitPriceHTCurrency"), 'enabled' => (!empty($conf->multicurrency->enabled)), 'checked'=>0, 'position'=>10), 'pfp.delivery_time_days'=>array('label'=>$langs->trans("NbDaysToDelivery"), 'checked'=>1, 'position'=>13), 'pfp.supplier_reputation'=>array('label'=>$langs->trans("ReputationForThisProduct"), 'checked'=>1, 'position'=>14), 'pfp.fk_barcode_type'=>array('label'=>$langs->trans("BarcodeType"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>15), @@ -942,14 +942,19 @@ END; // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; + if ($extrafields->attributes["product_fournisseur_price"] && array_key_exists('label', $extrafields->attributes["product_fournisseur_price"])) { + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; - if (!empty($extralabels)) { - foreach ($extralabels as $key => $value) { - // Show field if not hidden - if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { - $extratitle = $langs->trans($value); - $arrayfields['ef.'.$key] = array('label'=>$extratitle, 'checked'=>0, 'position'=>(end($arrayfields)['position'] + 1), 'langfile'=>$extrafields->attributes["product_fournisseur_price"]['langfile'][$key], 'help'=>$extrafields->attributes["product_fournisseur_price"]['help'][$key]); + if (!empty($extralabels)) { + foreach ($extralabels as $key => $value) { + // Show field if not hidden + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + $extratitle = $langs->trans($value); + $arrayfields['ef.' . $key] = array('label' => $extratitle, 'checked' => 0, + 'position' => (end($arrayfields)['position'] + 1), + 'langfile' => $extrafields->attributes["product_fournisseur_price"]['langfile'][$key], + 'help' => $extrafields->attributes["product_fournisseur_price"]['help'][$key]); + } } } } @@ -1023,29 +1028,31 @@ END; // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; + if ($extrafields->attributes["product_fournisseur_price"] && array_key_exists('label', $extrafields->attributes["product_fournisseur_price"])) { + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; - if (!empty($extralabels)) { - foreach ($extralabels as $key => $value) { - // Show field if not hidden - if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { - if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) { - $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); - } - if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) { - $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); - } else { - $extratitle = $langs->trans($value); - } - if (!empty($arrayfields['ef.'.$key]['checked'])) { - print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($extralabels)) { + foreach ($extralabels as $key => $value) { + // Show field if not hidden + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) { + $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); + } + if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) { + $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); + } else { + $extratitle = $langs->trans($value); + } + if (!empty($arrayfields['ef.' . $key]['checked'])) { + print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.' . $key, '', $param, '', $sortfield, $sortorder, 'right '); + } } } } } if (is_object($hookmanager)) { - $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $parameters = array('id_fourn'=>(!empty($id_fourn)?$id_fourn:''), 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -1213,7 +1220,7 @@ END; } if (is_object($hookmanager)) { - $parameters = array('id_pfp'=>$productfourn->product_fourn_price_id, 'id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $parameters = array('id_pfp'=>$productfourn->product_fourn_price_id, 'id_fourn'=>(!empty($id_fourn)?$id_fourn:''), 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); } From 5275d3cd48411596ce600546c98e68ef7deadd67 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 23 Oct 2021 02:20:06 +0200 Subject: [PATCH 041/490] Fix #19083 : wrong field list in sql request --- htdocs/recruitment/recruitmentcandidature_list.php | 6 ++---- htdocs/recruitment/recruitmentjobposition_list.php | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 7a5a88bc6c4..30e147f355d 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -237,13 +237,11 @@ $title = $langs->trans('ListOfCandidatures'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) { - $sql .= 't.'.$key.', '; -} +$sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } } // Add fields from hooks diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index c82c8312b40..de4905aa337 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -243,10 +243,11 @@ $title = $langs->trans('ListOfPositionsToBeFilled'); // -------------------------------------------------------------------- $sql = 'SELECT '; $sql .= $object->getFieldList('t'); + // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } } // Add fields from hooks From 604052d1a1bf4e80359fcac9489e74dfd4f4ae38 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 23 Oct 2021 02:28:53 +0200 Subject: [PATCH 042/490] Fix #19070 : Api subproducts was returning false --- htdocs/product/class/api_products.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 189161712d5..2d6c627ec41 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -405,7 +405,7 @@ class Products extends DolibarrApi $childsArbo = $this->product->getChildsArbo($id, 1); - $keys = ['rowid', 'qty', 'fk_product_type', 'label', 'incdec']; + $keys = ['rowid', 'qty', 'fk_product_type', 'label', 'incdec', 'ref']; $childs = []; foreach ($childsArbo as $values) { $childs[] = array_combine($keys, $values); From 452a8cfe18199dc81c80cd95cc667b4e9600bf80 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 23 Oct 2021 10:27:24 +0200 Subject: [PATCH 043/490] FIX wrong position of error message --- htdocs/societe/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 5c9c0f63e94..e5a624ec07f 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2509,7 +2509,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - print ''; $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' ('.$langs->trans("WrongCustomerCode").')'; From aec5e41656af8c091ab5bab47351f4420504660f Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 23 Oct 2021 19:09:23 +0200 Subject: [PATCH 044/490] Fix : fix php 8.0 warnings --- htdocs/contact/card.php | 2 ++ htdocs/core/class/html.form.class.php | 7 ++++--- htdocs/product/card.php | 10 ++++++---- htdocs/product/list.php | 4 ++-- htdocs/product/reassort.php | 1 + htdocs/product/reassortlot.php | 1 + htdocs/product/stats/card.php | 1 + htdocs/societe/list.php | 1 + 8 files changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 8493fd03f3c..8011b4aa678 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -548,6 +548,8 @@ $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans(" if ($socid > 0) { $objsoc = new Societe($db); $objsoc->fetch($socid); +} else { + $objsoc = 0; } if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3c544357ad7..35155f0eb61 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1005,6 +1005,7 @@ class Form $langs->load("dict"); $out = ''; + $moreattrib = ''; $incotermArray = array(); $sql = "SELECT rowid, code"; @@ -1444,7 +1445,7 @@ class Form $label .= ' ('.$obj->name_alias.')'; } - if ($conf->global->SOCIETE_SHOW_VAT_IN_LIST && !empty($obj->tva_intra)) { + if (!empty($conf->global->SOCIETE_SHOW_VAT_IN_LIST) && !empty($obj->tva_intra)) { $label .= ' - '.$obj->tva_intra.''; } @@ -8088,7 +8089,7 @@ class Form } } else { // There is no list of fields already customized for user foreach ($array as $key => $val) { - if ($array[$key]['checked'] < 0) { + if (!empty($array[$key]['checked']) && $array[$key]['checked'] < 0) { $array[$key]['checked'] = 0; } } @@ -8116,7 +8117,7 @@ class Form } // Note: $val['checked'] <> 0 means we must show the field into the combo list - $listoffieldsforselection .= '
  • '; + $listoffieldsforselection .= '
  • '; $listcheckedstring .= (empty($val['checked']) ? '' : $key.','); } } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 28c7b0d1d5d..6bc98f273dc 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1172,8 +1172,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $tooltip .= '
    '.$langs->trans("GenericMaskCodes3"); $tooltip .= '
    '.$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); $tooltip .= '
    '.$langs->trans("GenericMaskCodes5"); - if (($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') - || ($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced')) { + if ((!empty($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') + || (!empty($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced')) { print ''.$langs->trans("ManageLotMask").''; $inherited_mask_lot = $conf->global->LOT_ADVANCED_MASK; $inherited_mask_sn = $conf->global->SN_ADVANCED_MASK; @@ -1221,10 +1221,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($showbarcode) { print ''.$langs->trans('BarcodeType').''; if (GETPOSTISSET('fk_barcode_type')) { - $fk_barcode_type = GETPOST('fk_barcode_type'); + $fk_barcode_type = GETPOST('fk_barcode_type')?:0; } else { if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { - $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; + $fk_barcode_type = getDolGlobalInt("PRODUIT_DEFAULT_BARCODE_TYPE"); + } else { + $fk_barcode_type=0; } } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index aaf9903aa85..8ec03d408f3 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -256,7 +256,7 @@ $arrayfields = array( // MultiPrices -if ($conf->global->PRODUIT_MULTIPRICES) { +if (!empty($conf->global->PRODUIT_MULTIPRICES)) { for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i; if (!empty($conf->global->$keyforlabel)) { @@ -405,7 +405,7 @@ $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; } if (!empty($searchCategoryProductList) || !empty($catid)) { diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index c327b24e8f0..b0a1ce87ddd 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -46,6 +46,7 @@ $toolowstock = GETPOST('toolowstock'); $tosell = GETPOST("tosell"); $tobuy = GETPOST("tobuy"); $fourn_id = GETPOST("fourn_id", 'int'); +$sbarcode = GETPOST("sbarcode", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index c8eae99d7cf..e75d1504267 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -50,6 +50,7 @@ $toolowstock = GETPOST('toolowstock'); $tosell = GETPOST("tosell"); $tobuy = GETPOST("tobuy"); $fourn_id = GETPOST("fourn_id", 'int'); +$sbarcode = GETPOST("sbarcode", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 9232dc419b4..7e5c566f94c 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -67,6 +67,7 @@ $currentyear = $tmp['year']; if (empty($search_year)) { $search_year = $currentyear; } +$moreforfilter = ""; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7013acdae56..5f6238554d8 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1363,6 +1363,7 @@ print "\n"; $i = 0; $totalarray = array(); +$totalarray['nbfield'] = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); From bc353c19a95a449586d2f32bcd6ec5bbe75148df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Oct 2021 19:22:41 +0200 Subject: [PATCH 045/490] Update card.php --- htdocs/contact/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 8011b4aa678..b77e47beaa4 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -545,11 +545,9 @@ $formcompany = new FormCompany($db); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$objsoc = new Societe($db); if ($socid > 0) { - $objsoc = new Societe($db); $objsoc->fetch($socid); -} else { - $objsoc = 0; } if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { From cdba9909be6b1a3f154308b382585a75819279fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Oct 2021 20:53:46 +0200 Subject: [PATCH 046/490] fix warnings --- htdocs/accountancy/admin/productaccount.php | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index b3d6ac87780..f1f81347fe1 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -253,18 +253,18 @@ $form = new FormAccounting($db); // so we need to get those the rowid of those default value first $accounting = new AccountingAccount($db); // TODO: we should need to check if result is already exists accountaccount rowid..... -$aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); -$aarowid_servbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT, 1); -$aarowid_servbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT, 1); -$aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); -$aarowid_prodbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT, 1); -$aarowid_prodbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT, 1); -$aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1); -$aarowid_servsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT, 1); -$aarowid_servsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT, 1); -$aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1); -$aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT, 1); -$aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1); +$aarowid_servbuy = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_BUY_ACCOUNT'), 1); +$aarowid_servbuy_intra = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT'), 1); +$aarowid_servbuy_export = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT'), 1); +$aarowid_prodbuy = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_BUY_ACCOUNT'), 1); +$aarowid_prodbuy_intra = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT'), 1); +$aarowid_prodbuy_export = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT'), 1); +$aarowid_servsell = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT'), 1); +$aarowid_servsell_intra = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT'), 1); +$aarowid_servsell_export = $accounting->fetch('', getDolGlobalString('ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT'), 1); +$aarowid_prodsell = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT'), 1); +$aarowid_prodsell_intra = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT'), 1); +$aarowid_prodsell_export = $accounting->fetch('', getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT'), 1); $aacompta_servbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servbuy_intra = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); @@ -281,7 +281,7 @@ $aacompta_prodsell_export = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXP llxHeader('', $langs->trans("ProductsBinding")); -$pcgverid = $conf->global->CHARTOFACCOUNTS; +$pcgverid = getDolGlobalString('CHARTOFACCOUNTS'); $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); if (empty($pcgvercode)) { $pcgvercode = $pcgverid; From 08e5b55d165d64e4fea8ad547ffc80f2821919b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Oct 2021 21:06:37 +0200 Subject: [PATCH 047/490] can specify default in getDolGlobalString and getDolGlobalInt --- htdocs/accountancy/admin/productaccount.php | 24 ++++++++++----------- htdocs/core/lib/functions.lib.php | 12 ++++++----- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index b3d6ac87780..0cd39995545 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -266,18 +266,18 @@ $aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_P $aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT, 1); $aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1); -$aacompta_servbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servbuy_intra = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servbuy_export = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy_export = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell_intra = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_servsell_export = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodsell_export = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy = getDolGlobalString('ACCOUNTING_SERVICE_BUY_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servbuy_intra = getDolGlobalString('ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servbuy_export = getDolGlobalString('ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodbuy = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodbuy_intra = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodbuy_export = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servsell = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servsell_intra = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_servsell_export = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodsell_intra = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); +$aacompta_prodsell_export = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); llxHeader('', $langs->trans("ProductsBinding")); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 98a879410b0..2021976793f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -44,25 +44,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; /** * Return dolibarr global constant string value * @param string $key key to return value, return '' if not set + * @param string $default value to return * @return string */ -function getDolGlobalString($key) +function getDolGlobalString($key, $default = '') { global $conf; // return $conf->global->$key ?? ''; - return (string) (empty($conf->global->$key) ? '' : $conf->global->$key); + return (string) (empty($conf->global->$key) ? $default : $conf->global->$key); } /** * Return dolibarr global constant int value * @param string $key key to return value, return 0 if not set + * @param int $default value to return * @return int */ -function getDolGlobalInt($key) +function getDolGlobalInt($key, $default = 0) { global $conf; - // return $conf->global->$key ?? 0; - return (int) (empty($conf->global->$key) ? 0 : $conf->global->$key); + // return $conf->global->$key ?? $default; + return (int) (empty($conf->global->$key) ? $default : $conf->global->$key); } /** From 635cb34606836cdd3f275de4437ddb392b8f6dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Oct 2021 21:10:43 +0200 Subject: [PATCH 048/490] fix warning --- htdocs/accountancy/admin/productaccount.php | 1 + htdocs/core/lib/functions.lib.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 0cd39995545..9fe7d771130 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -70,6 +70,7 @@ $search_onpurchase = GETPOST('search_onpurchase', 'alpha'); $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $btn_changeaccount = GETPOST('changeaccount', 'alpha'); $btn_changetype = GETPOST('changetype', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); if (empty($accounting_product_mode)) { $accounting_product_mode = 'ACCOUNTANCY_SELL'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2021976793f..46d225e43f5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -50,7 +50,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; function getDolGlobalString($key, $default = '') { global $conf; - // return $conf->global->$key ?? ''; + // return $conf->global->$key ?? $default; return (string) (empty($conf->global->$key) ? $default : $conf->global->$key); } From 29371487a05f6d0f6bbc4e7b4d4a32773e48aff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Oct 2021 21:14:32 +0200 Subject: [PATCH 049/490] fix warning --- htdocs/accountancy/admin/account.php | 1 + htdocs/accountancy/admin/subaccount.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index a9e0a5dc509..c2ac133069d 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -38,6 +38,7 @@ $cancel = GETPOST('cancel', 'alpha'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); $massaction = GETPOST('massaction', 'aZ09'); +$optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingaccountlist'; // To manage different context of search $search_account = GETPOST('search_account', 'alpha'); diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index 26c02de3467..cc0d4de9f31 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -36,6 +36,7 @@ $cancel = GETPOST('cancel', 'alpha'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); $massaction = GETPOST('massaction', 'aZ09'); +$optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingsubaccountlist'; // To manage different context of search $search_subaccount = GETPOST('search_subaccount', 'alpha'); @@ -367,6 +368,7 @@ if ($resql) { print "\n"; $totalarray = array(); + $totalarray['nbfield'] = 0; $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); From 3a7ae07896af7cee0305f88631939ea8d1551015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Oct 2021 21:21:16 +0200 Subject: [PATCH 050/490] replace deprecated --- htdocs/categories/viewcat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 78d01a19e19..2c6ed74ae8a 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1048,7 +1048,7 @@ if ($type == Categorie::TYPE_USER) { print ''; print ''; print ''; print '
    '; print $langs->trans("AddProjectIntoCategory").'  '; - $form->select_users('', 'elemid'); + $form->select_dolusers('', 'elemid'); print '
    '; From a503a4dcc66723f7d0b6e6a239f7efe20c3efd2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Oct 2021 22:12:57 +0200 Subject: [PATCH 051/490] Fix scrutinizer --- htdocs/categories/class/categorie.class.php | 4 ---- htdocs/hrm/class/skill.class.php | 2 +- htdocs/mrp/mo_production.php | 4 +++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6691823ab6f..4f8c6b28d41 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -759,8 +759,6 @@ class Categorie extends CommonObject } return -1; } - - return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -816,8 +814,6 @@ class Categorie extends CommonObject $this->error = $this->db->lasterror(); return -1; } - - return 0; } /** diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 45e9eb6701c..478b267ac1f 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -384,7 +384,7 @@ class Skill extends CommonObject /** * Load object lines in memory from the database * - * @return int | array <0 if KO, 0 if not found, array if OK + * @return array|int <0 if KO, 0 if not found, array if OK */ public function fetchLines() { diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 0e2edb81203..d7cc53cdc8b 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -284,7 +284,9 @@ if (empty($reshook)) { if (!$error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { // Record stock movement $id_product_batch = 0; - $stockmove->origin = $object; + $stockmove->origin_type = $object->element; + $stockmove->origin_id = $object->id; + $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); if ($idstockmove < 0) { $error++; From b9075660af380c0873d9034bd428ac5be0de44c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Oct 2021 22:15:23 +0200 Subject: [PATCH 052/490] fix warnings --- .../compta/cashcontrol/cashcontrol_list.php | 33 ++++--------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index b46ff9433e3..85f6ff5fe11 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -22,27 +22,6 @@ * \brief List page for cashcontrol */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -81,7 +60,7 @@ $pagenext = $page + 1; // Initialize technical objects $object = new CashControl($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->monmodule->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->takepos->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels @@ -141,16 +120,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = ($user->rights->cashdesk->run || $user->rights->takepos->run); -$permissiontoadd = ($user->rights->cashdesk->run || $user->rights->takepos->run); -$permissiontodelete = ($user->rights->cashdesk->run || $user->rights->takepos->run); +$permissiontoread = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run)); +$permissiontoadd = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run)); +$permissiontodelete = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run)); // Security check if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; accessforbidden(); } -if (!$user->rights->cashdesk->run && !$user->rights->takepos->run) { +if (empty($user->rights->cashdesk->run) && empty($user->rights->takepos->run)) { accessforbidden(); } @@ -341,7 +320,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); +llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'classforhorizontalscrolloftabs'); $arrayofselected = is_array($toselect) ? $toselect : array(); From b027db49b505c4f85206ec763496c9bc47cdb607 Mon Sep 17 00:00:00 2001 From: Jean Date: Sat, 23 Oct 2021 22:21:50 +0200 Subject: [PATCH 053/490] FIX #18934 Non-registration in the extrafieldsline database for deliveries --- htdocs/delivery/card.php | 13 ++++++++---- htdocs/delivery/class/delivery.class.php | 27 ++++++++++++++++++------ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index a845b7aff95..67a80084710 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -114,7 +114,7 @@ if ($action == 'add') { $idl = "idl".$i; $qtytouse = price2num(GETPOST($qty)); if ($qtytouse > 0) { - $object->addline(GETPOST($idl), price2num($qtytouse)); + $object->addline(GETPOST($idl), price2num($qtytouse), $arrayoptions); } } @@ -603,7 +603,7 @@ if ($action == 'create') { // Create. Seems to no be used print ""; // Display lines extrafields - if (!empty($extrafields)) { + //if (!empty($extrafields)) { $colspan = 2; $mode = ($object->statut == 0) ? 'edit' : 'view'; @@ -618,8 +618,13 @@ if ($action == 'create') { // Create. Seems to no be used $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options); } - print $object->lines[$i]->showOptionals($extrafields, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), $i); - } + else { + $srcLine = new DeliveryLine($db); + $extrafields->fetch_name_optionals_label($srcLine->table_element); + + } + print $object->lines[$i]->showOptionals($extrafields, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), ''); + //} } $i++; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 019187fca28..775cd96e2c3 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -211,7 +211,7 @@ class Delivery extends CommonObject $origin_id = $this->lines[$i]->commande_ligne_id; // For backward compatibility } - if (!$this->create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->description)) { + if (!$this->create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->description, $this->lines[$i]->array_options)) { $error++; } } @@ -264,7 +264,7 @@ class Delivery extends CommonObject * @param string $description Description * @return int <0 if KO, >0 if OK */ - public function create_line($origin_id, $qty, $fk_product, $description) + public function create_line($origin_id, $qty, $fk_product, $description, $array_options = 0) { // phpcs:enable $error = 0; @@ -282,6 +282,15 @@ class Delivery extends CommonObject if (!$this->db->query($sql)) { $error++; } + + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."deliverydet"); + + if (is_array($array_options) && count($array_options) > 0) { + $line = new DeliveryLine($this->db); + $line->id = $id; + $line->array_options = $array_options; + $result = $line->insertExtraFields(); + } if ($error == 0) { return 1; @@ -531,7 +540,9 @@ class Delivery extends CommonObject $line->description = $expedition->lines[$i]->description; $line->qty = $expedition->lines[$i]->qty_shipped; $line->fk_product = $expedition->lines[$i]->fk_product; - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) { // For avoid conflicts if trigger used + $line->array_options = $expedition->lines[$i]->array_options; + } $this->lines[$i] = $line; } @@ -593,14 +604,18 @@ class Delivery extends CommonObject * @param int $qty Qty * @return void */ - public function addline($origin_id, $qty) + public function addline($origin_id, $qty, $array_options = 0) { - $num = count($this->lines); + global $conf; + + $num = count($this->lines); $line = new DeliveryLine($this->db); $line->origin_id = $origin_id; $line->qty = $qty; - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used + $line->array_options = $array_options; + } $this->lines[$num] = $line; } From f7a41f1848280957b2221a2e6faa578c1e36782e Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Sat, 23 Oct 2021 20:22:10 +0000 Subject: [PATCH 054/490] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/compta/facture/list.php | 30 +++++----- htdocs/core/actions_addupdatedelete.inc.php | 6 +- .../core/modules/modMultiCurrency.class.php | 2 +- .../class/conferenceorboothattendee.class.php | 6 +- .../conferenceorboothattendee_card.php | 2 +- htdocs/main.inc.php | 58 +++++++++---------- htdocs/modulebuilder/index.php | 2 +- htdocs/societe/list.php | 10 ++-- htdocs/takepos/pay.php | 8 +-- 9 files changed, 62 insertions(+), 62 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a3273a2cca2..84ad5bd0f31 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -116,7 +116,7 @@ $search_date_startyear = GETPOST('search_date_startyear', 'int'); $search_date_endday = GETPOST('search_date_endday', 'int'); $search_date_endmonth = GETPOST('search_date_endmonth', 'int'); $search_date_endyear = GETPOST('search_date_endyear', 'int'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_date_valid_startday = GETPOST('search_date_valid_startday', 'int'); $search_date_valid_startmonth = GETPOST('search_date_valid_startmonth', 'int'); @@ -124,7 +124,7 @@ $search_date_valid_startyear = GETPOST('search_date_valid_startyear', 'int'); $search_date_valid_endday = GETPOST('search_date_valid_endday', 'int'); $search_date_valid_endmonth = GETPOST('search_date_valid_endmonth', 'int'); $search_date_valid_endyear = GETPOST('search_date_valid_endyear', 'int'); -$search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver +$search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver $search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear); $search_datelimit_startday = GETPOST('search_datelimit_startday', 'int'); $search_datelimit_startmonth = GETPOST('search_datelimit_startmonth', 'int'); @@ -380,11 +380,11 @@ if ($action == 'makepayment_confirm' && $user->rights->facture->paiement) { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $arrayofselected = is_array($toselect) ? $toselect : array(); if (!empty($arrayofselected)) { - $bankid=GETPOST('bankid', 'int'); - $paiementid=GETPOST('paiementid', 'int'); - $paiementdate=dol_mktime(12, 0, 0, GETPOST('datepaimentmonth', 'int'), GETPOST('datepaimentday', 'int'), GETPOST('datepaimentyear', 'year')); + $bankid = GETPOST('bankid', 'int'); + $paiementid = GETPOST('paiementid', 'int'); + $paiementdate = dol_mktime(12, 0, 0, GETPOST('datepaimentmonth', 'int'), GETPOST('datepaimentday', 'int'), GETPOST('datepaimentyear', 'year')); foreach ($arrayofselected as $toselectid) { - $errorpayment=0; + $errorpayment = 0; $facture = new Facture($db); $result = $facture->fetch($toselectid); if ($result < 0) { @@ -397,7 +397,7 @@ if ($action == 'makepayment_confirm' && $user->rights->facture->paiement) { $totaldeposits = $facture->getSumDepositsUsed(); $totalpay = $paiementAmount + $totalcreditnotes + $totaldeposits; $remaintopay = price2num($facture->total_ttc - $totalpay); - if ($remaintopay!=0) { + if ($remaintopay != 0) { $resultBank = $facture->setBankAccount($bankid); if ($resultBank < 0) { setEventMessage($facture->error, 'errors'); @@ -410,12 +410,12 @@ if ($action == 'makepayment_confirm' && $user->rights->facture->paiement) { $paiement->paiementid = $paiementid; $paiement_id = $paiement->create($user, 1, $facture->thirdparty); if ($paiement_id < 0) { - setEventMessage($facture->ref . ' ' . $paiement->error, 'errors'); + setEventMessage($facture->ref.' '.$paiement->error, 'errors'); $errorpayment++; } else { $result = $paiement->addPaymentToBank($user, 'payment', '', $bankid, '', ''); if ($result < 0) { - setEventMessages($facture->ref . ' ' . $paiement->error, $paiement->errors, 'errors'); + setEventMessages($facture->ref.' '.$paiement->error, $paiement->errors, 'errors'); $errorpayment++; } } @@ -555,7 +555,7 @@ $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as u if (!$sall) { $sql .= ', SUM(pf.amount) as dynamount_payed, SUM(pf.multicurrency_amount) as multicurrency_dynamount_payed'; } -if ($search_categ_cus && $search_categ_cus!=-1) { +if ($search_categ_cus && $search_categ_cus != -1) { $sql .= ", cc.fk_categorie, cc.fk_soc"; } // Add fields from extrafields @@ -801,7 +801,7 @@ if (!$sall) { $sql .= ' country.code,'; $sql .= " p.rowid, p.ref, p.title,"; $sql .= " u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender"; - if ($search_categ_cus && $search_categ_cus!=-1) { + if ($search_categ_cus && $search_categ_cus != -1) { $sql .= ", cc.fk_categorie, cc.fk_soc"; } // Add fields from extrafields @@ -821,7 +821,7 @@ if (!$sall) { // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 " . $hookmanager->resPrint) : ""; +$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 ".$hookmanager->resPrint) : ""; $sql .= ' ORDER BY '; $listfield = explode(',', $sortfield); @@ -914,7 +914,7 @@ if ($resql) { if ($search_date_valid_endyear) { $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear); } - if ($search_datelimit_startday) { + if ($search_datelimit_startday) { $param .= '&search_datelimit_startday='.urlencode($search_datelimit_startday); } if ($search_datelimit_startmonth) { @@ -1059,7 +1059,7 @@ if ($resql) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } } - if (in_array($massaction, array('presend', 'predelete' ,'makepayment'))) { + if (in_array($massaction, array('presend', 'predelete', 'makepayment'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -1097,7 +1097,7 @@ if ($resql) { $trackid = 'inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($massaction=='makepayment') { + if ($massaction == 'makepayment') { $formconfirm = ''; $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index e4483258b92..6fd84f4eda3 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -73,7 +73,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $value = GETPOST($key, 'restricthtml'); } elseif ($object->fields[$key]['type'] == 'date') { - $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt + $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt } elseif ($object->fields[$key]['type'] == 'datetime') { $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel'); } elseif ($object->fields[$key]['type'] == 'duration') { @@ -87,7 +87,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { $value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2'); } else { if ($key == 'lang') { - $value = GETPOST($key, 'aZ09')?GETPOST($key, 'aZ09'):""; + $value = GETPOST($key, 'aZ09') ?GETPOST($key, 'aZ09') : ""; } else { $value = GETPOST($key, 'alphanohtml'); } @@ -190,7 +190,7 @@ if ($action == 'update' && !empty($permissiontoadd)) { $value = GETPOST($key, 'restricthtml'); } } elseif ($object->fields[$key]['type'] == 'date') { - $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt + $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt } elseif ($object->fields[$key]['type'] == 'datetime') { $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel'); } elseif ($object->fields[$key]['type'] == 'duration') { diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index e89a2a4fe3e..98d7222f082 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -302,7 +302,7 @@ class modMultiCurrency extends DolibarrModules $multicurrency = new MultiCurrency($this->db); - if (! $multicurrency->checkCodeAlreadyExists($conf->currency)) { + if (!$multicurrency->checkCodeAlreadyExists($conf->currency)) { $langs->loadCacheCurrencies(''); $multicurrency->code = $conf->currency; diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index df955a617ba..96131aa5946 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -100,7 +100,7 @@ class ConferenceOrBoothAttendee extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"), 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'picto'=>'agenda'), @@ -119,7 +119,7 @@ class ConferenceOrBoothAttendee extends CommonObject 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'default'=>0,'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'),), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'default'=>0, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'),), ); public $rowid; public $ref; @@ -787,7 +787,7 @@ class ConferenceOrBoothAttendee extends CommonObject } if ($option == 'conforboothidproject') { - $url .= '&conforboothid='.((int) $this->fk_actioncomm).'&withproject=1' ; + $url .= '&conforboothid='.((int) $this->fk_actioncomm).'&withproject=1'; } } diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index b76a80020b6..101bc10a0aa 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -202,7 +202,7 @@ $title = $langs->trans("ConferenceOrBoothAttendee"); $help_url = ''; llxHeader('', $title, $help_url); -$result = $projectstatic->fetch(empty($confOrBooth->fk_project)?$fk_project:$confOrBooth->fk_project); +$result = $projectstatic->fetch(empty($confOrBooth->fk_project) ? $fk_project : $confOrBooth->fk_project); if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { $projectstatic->fetchComments(); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 47107f725cd..4d233b9a290 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -72,7 +72,7 @@ function realCharForNumericEntities($matches) return chr((int) $newstringnumentity); } - return '&#'.$matches[1]; // Value will be unchanged because regex was /&#( )/ + return '&#'.$matches[1]; // Value will be unchanged because regex was /&#( )/ } /** @@ -94,7 +94,7 @@ function testSqlAndScriptInject($val, $type) do { $oldval = $val; $val = html_entity_decode($val, ENT_QUOTES | ENT_HTML5); - $val = preg_replace_callback('/&#(x?[0-9][0-9a-f]+)/i', 'realCharForNumericEntities', $val); // Sometimes we have entities without the ; at end so html_entity_decode does not work but entities is still interpreted by browser. + $val = preg_replace_callback('/&#(x?[0-9][0-9a-f]+)/i', 'realCharForNumericEntities', $val); // Sometimes we have entities without the ; at end so html_entity_decode does not work but entities is still interpreted by browser. } while ($oldval != $val); //print "after decoding $val\n"; @@ -454,7 +454,7 @@ if (!defined('NOTOKENRENEWAL') && !defined('NOSESSION')) { // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] $token = dol_hash(uniqid(mt_rand(), false), 'md5'); // Generates a hash of a random number. We don't need a secured hash, just a changing random value. $_SESSION['newtoken'] = $token; - dol_syslog("NEW TOKEN generated by : " . $_SERVER['PHP_SELF'], LOG_DEBUG); + dol_syslog("NEW TOKEN generated by : ".$_SERVER['PHP_SELF'], LOG_DEBUG); } } } @@ -494,20 +494,20 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( // If token is not provided or empty, error (we are in case it is mandatory) if (!GETPOST('token', 'alpha') || GETPOST('token', 'alpha') == 'notrequired') { if (GETPOST('uploadform', 'int')) { - dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused. File size too large."); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused. File size too large."); $langs->loadLangs(array("errors", "install")); print $langs->trans("ErrorFileSizeTooLarge").' '; print $langs->trans("ErrorGoBackAndCorrectParameters"); die; } else { if (defined('CSRFCHECK_WITH_TOKEN')) { - dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (CSRFCHECK_WITH_TOKEN protection) in main.inc.php. Token not provided.", LOG_WARNING); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (CSRFCHECK_WITH_TOKEN protection) in main.inc.php. Token not provided.", LOG_WARNING); print "Access to a page that needs a token (constant CSRFCHECK_WITH_TOKEN is defined) is refused by CSRF protection in main.inc.php. Token not provided.\n"; } else { - dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (POST method or GET with a sensible value for 'action' parameter) in main.inc.php. Token not provided.", LOG_WARNING); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (POST method or GET with a sensible value for 'action' parameter) in main.inc.php. Token not provided.", LOG_WARNING); print "Access to this page this way (POST method or GET with a sensible value for 'action' parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n"; print "If you access your server behind a proxy using url rewriting and the parameter is provided by caller, you might check that all HTTP header are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0"; - if (! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) { + if (!empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) { print " instead of ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN; } print " into setup).\n"; @@ -520,7 +520,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( $sessiontokenforthisurl = (empty($_SESSION['token']) ? '' : $_SESSION['token']); // TODO Get the sessiontokenforthisurl into the array of session token if (GETPOSTISSET('token') && GETPOST('token') != 'notrequired' && GETPOST('token', 'alpha') != $sessiontokenforthisurl) { - dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (invalid token), so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (invalid token), so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING); //print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers. setEventMessages('SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry', null, 'warnings'); //if ($conf->global->MAIN_FEATURES_LEVEL >= 1) setEventMessages('Unset POST and GET params by CSRF protection in main.inc.php (Token provided was not generated by the previous page).'."
    \n".'$_SERVER[REQUEST_URI] = '.$_SERVER['REQUEST_URI'].' $_SERVER[REQUEST_METHOD] = '.$_SERVER['REQUEST_METHOD'].' GETPOST(token) = '.GETPOST('token', 'alpha').' $_SESSION[token] = '.$_SESSION['token'], null, 'warnings'); @@ -785,7 +785,7 @@ if (!defined('NOLOGIN')) { // End test login / passwords if (!$login || (in_array('ldap', $authmode) && empty($passwordtotest))) { // With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success. // No data to test login, so we show the login page. - dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." - action=".GETPOST('action', 'aZ09')." - actionlogin=".GETPOST('actionlogin', 'aZ09')." - showing the login form and exit", LOG_INFO); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." - action=".GETPOST('action', 'aZ09')." - actionlogin=".GETPOST('actionlogin', 'aZ09')." - showing the login form and exit", LOG_INFO); if (defined('NOREDIRECTBYMAINTOLOGIN')) { return 'ERROR_NOT_LOGGED'; } else { @@ -1176,7 +1176,7 @@ if (!defined('NOLOGIN')) { $user->getrights(); } -dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"].' - action='.GETPOST('action', 'aZ09').', massaction='.GETPOST('massaction', 'aZ09').(defined('NOTOKENRENEWAL') ? ' NOTOKENRENEWAL='.constant('NOTOKENRENEWAL') : ''), LOG_NOTICE); +dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"].' - action='.GETPOST('action', 'aZ09').', massaction='.GETPOST('massaction', 'aZ09').(defined('NOTOKENRENEWAL') ? ' NOTOKENRENEWAL='.constant('NOTOKENRENEWAL') : ''), LOG_NOTICE); //Another call for easy debugg //dol_syslog("Access to ".$_SERVER["PHP_SELF"].' '.$_SERVER["HTTP_REFERER"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST)); @@ -2281,7 +2281,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_company') .'
    '. $langs->trans("ThirdParty") .'
    + '. img_picto('', 'object_company').'
    '.$langs->trans("ThirdParty").'
    '; } @@ -2292,7 +2292,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_contact') .'
    '. $langs->trans("Contact") .'
    + '. img_picto('', 'object_contact').'
    '.$langs->trans("Contact").'
    '; } @@ -2303,7 +2303,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_propal') .'
    '. $langs->trans("Proposal") .'
    + '. img_picto('', 'object_propal').'
    '.$langs->trans("Proposal").'
    '; } @@ -2314,7 +2314,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_order') .'
    '. $langs->trans("Order") .'
    + '. img_picto('', 'object_order').'
    '.$langs->trans("Order").'
    '; } @@ -2325,7 +2325,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_bill') .'
    '. $langs->trans("Bill") .'
    + '. img_picto('', 'object_bill').'
    '.$langs->trans("Bill").'
    '; } @@ -2336,7 +2336,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_contract') .'
    '. $langs->trans("Contract") .'
    + '. img_picto('', 'object_contract').'
    '.$langs->trans("Contract").'
    '; } @@ -2347,7 +2347,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_propal') .'
    '. $langs->trans("AskPrice") .'
    + '. img_picto('', 'object_propal').'
    '.$langs->trans("AskPrice").'
    '; } @@ -2358,7 +2358,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_order') .'
    '. $langs->trans("SupplierOrder") .'
    + '. img_picto('', 'object_order').'
    '.$langs->trans("SupplierOrder").'
    '; } @@ -2369,7 +2369,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_bill') .'
    '. $langs->trans("SupplierBill") .'
    + '. img_picto('', 'object_bill').'
    '.$langs->trans("SupplierBill").'
    '; } @@ -2380,7 +2380,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_product') .'
    '. $langs->trans("Product") .'
    + '. img_picto('', 'object_product').'
    '.$langs->trans("Product").'
    '; } @@ -2391,7 +2391,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_service') .'
    '. $langs->trans("Service") .'
    + '. img_picto('', 'object_service').'
    '.$langs->trans("Service").'
    '; } @@ -2402,7 +2402,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_trip') .'
    '. $langs->trans("ExpenseReport") .'
    + '. img_picto('', 'object_trip').'
    '.$langs->trans("ExpenseReport").'
    '; } @@ -2413,7 +2413,7 @@ function top_menu_quickadd()
    - '. img_picto('', 'object_holiday') .'
    '. $langs->trans("Holidays") .'
    + '. img_picto('', 'object_holiday').'
    '.$langs->trans("Holidays").'
    '; } @@ -2858,12 +2858,12 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ $bugbaseurl .= urlencode("[*Short description*]\n"); $bugbaseurl .= urlencode("\n"); $bugbaseurl .= urlencode("## Environment\n"); - $bugbaseurl .= urlencode("- **Version**: " . DOL_VERSION . "\n"); - $bugbaseurl .= urlencode("- **OS**: " . php_uname('s') . "\n"); - $bugbaseurl .= urlencode("- **Web server**: " . $_SERVER["SERVER_SOFTWARE"] . "\n"); - $bugbaseurl .= urlencode("- **PHP**: " . php_sapi_name() . ' ' . phpversion() . "\n"); - $bugbaseurl .= urlencode("- **Database**: " . $db::LABEL . ' ' . $db->getVersion() . "\n"); - $bugbaseurl .= urlencode("- **URL(s)**: " . $_SERVER["REQUEST_URI"] . "\n"); + $bugbaseurl .= urlencode("- **Version**: ".DOL_VERSION."\n"); + $bugbaseurl .= urlencode("- **OS**: ".php_uname('s')."\n"); + $bugbaseurl .= urlencode("- **Web server**: ".$_SERVER["SERVER_SOFTWARE"]."\n"); + $bugbaseurl .= urlencode("- **PHP**: ".php_sapi_name().' '.phpversion()."\n"); + $bugbaseurl .= urlencode("- **Database**: ".$db::LABEL.' '.$db->getVersion()."\n"); + $bugbaseurl .= urlencode("- **URL(s)**: ".$_SERVER["REQUEST_URI"]."\n"); $bugbaseurl .= urlencode("\n"); $bugbaseurl .= urlencode("## Expected and actual behavior\n"); $bugbaseurl .= urlencode("[*Verbose description*]\n"); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index f339f085484..cab90270d64 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3592,7 +3592,7 @@ if ($module == 'initmodule') { print ''; } } else { - print ' '.$langs->trans("CLIFile").' : '.$langs->trans("FileNotYetGenerated");''; + print ' '.$langs->trans("CLIFile").' : '.$langs->trans("FileNotYetGenerated"); ''; print ''.img_picto('Generate', 'generate', 'class="paddingleft"').''; print ''; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7013acdae56..148b72858d2 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -258,7 +258,7 @@ $arrayfields = array( 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - $arrayfields['s.price_level'] =array('label'=>"PriceLevel", 'position'=>30, 'checked'=>0); + $arrayfields['s.price_level'] = array('label'=>"PriceLevel", 'position'=>30, 'checked'=>0); } // Extra fields @@ -467,10 +467,10 @@ if ($search_sale && $search_sale != '-1') { $sql .= ", sc.fk_soc, sc.fk_user"; } // We'll need these fields in order to filter by categ -if ($search_categ_cus && $search_categ_cus!=-1) { +if ($search_categ_cus && $search_categ_cus != -1) { $sql .= ", cc.fk_categorie, cc.fk_soc"; } -if ($search_categ_sup && $search_categ_sup!=-1) { +if ($search_categ_sup && $search_categ_sup != -1) { $sql .= ", cs.fk_categorie, cs.fk_soc"; } // Add fields from extrafields @@ -573,7 +573,7 @@ if ($search_account_supplier_code) { $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code); } if ($search_address) { - $sql.= natural_search('s.address', $search_address); + $sql .= natural_search('s.address', $search_address); } if ($search_town) { $sql .= natural_search("s.town", $search_town); @@ -751,7 +751,7 @@ if ($search_alias != '') { $param .= "&search_alias=".urlencode($search_alias); } if ($search_address != '') { - $param .= '&search_address=' . urlencode($search_address); + $param .= '&search_address='.urlencode($search_address); } if ($search_town != '') { $param .= "&search_town=".urlencode($search_town); diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 687bd9ff19a..ffa33fbe8fc 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -336,7 +336,7 @@ print ''; + print ''; } else { print ''; } @@ -362,7 +362,7 @@ print ''; + print ''; } else { $button = array_pop($action_buttons); print ''; @@ -389,7 +389,7 @@ print ''; + print ''; } else { $button = array_pop($action_buttons); print ''; @@ -417,7 +417,7 @@ while ($i < count($arrayOfValidPaymentModes)) { } } - print ''; + print ''; $i = $i + 1; } From 00b617d17fee7ea93897da8f7dd958e08c785506 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 23 Oct 2021 22:22:45 +0200 Subject: [PATCH 055/490] Fix #18961 : no_email field has been replaced by mailing_unsubscribe table --- htdocs/contact/list.php | 20 ++++++++----- .../modules/mailings/contacts1.modules.php | 30 ++++++++----------- .../modules/mailings/modules_mailings.php | 18 ----------- .../public/emailing/mailing-unsubscribe.php | 14 --------- 4 files changed, 24 insertions(+), 58 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 295e63c9606..935e90e6085 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -175,7 +175,7 @@ $arrayfields = array( 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'position'=>32, 'checked'=>1), 'p.fax'=>array('label'=>"Fax", 'position'=>33, 'checked'=>0), 'p.email'=>array('label'=>"EMail", 'position'=>40, 'checked'=>1), - 'p.no_email'=>array('label'=>"No_Email", 'position'=>41, 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))), + 'mu.rowid'=>array('label'=>"No_Email", 'position'=>41, 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))), 'p.thirdparty'=>array('label'=>"ThirdParty", 'position'=>50, 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200), 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), @@ -298,7 +298,7 @@ $contactstatic = new Contact($db); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); $sql = "SELECT s.rowid as socid, s.nom as name,"; -$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; +$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email,"; $sql .= " p.socialnetworks, p.photo,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql .= " co.label as country, co.code as country_code"; @@ -306,6 +306,9 @@ $sql .= " co.label as country, co.code as country_code"; if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } +if(!empty($conf->mailing->enabled)) { + $sql .= ", mu.rowid as no_email"; +} // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -318,6 +321,7 @@ if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_conta if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; +if(!empty($conf->mailing->enabled)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = p.email"; $sql .= ' WHERE p.entity IN ('.getEntity('socpeople').')'; if (!$user->rights->societe->client->voir && !$socid) //restriction { @@ -374,8 +378,8 @@ if (strlen($search_town)) $sql .= natural_search("p.town", $search_town); if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } - -if ($search_no_email != '' && $search_no_email >= 0) $sql .= " AND p.no_email = ".$db->escape($search_no_email); +if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND mu.rowid IS NOT NULL"; +if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND mu.rowid IS NULL"; if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type @@ -662,7 +666,7 @@ if (!empty($arrayfields['p.email']['checked'])) print ''; print ''; } -if (!empty($arrayfields['p.no_email']['checked'])) +if (!empty($arrayfields['mu.rowid']['checked'])) { print ''; print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email); @@ -751,7 +755,7 @@ if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_ if (!empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['mu.rowid']['checked'])) print_liste_field_titre($arrayfields['mu.rowid']['label'], $_SERVER["PHP_SELF"], "mu.rowid", $begin, $param, '', $sortfield, $sortorder, 'center '); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { @@ -905,9 +909,9 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } // No EMail - if (!empty($arrayfields['p.no_email']['checked'])) + if (!empty($arrayfields['mu.rowid']['checked'])) { - print ''.yn($obj->no_email).''; + print ''.yn(!is_null($obj->no_email) ? 1 : 0).''; if (!$i) $totalarray['nbfield']++; } if (!empty($conf->socialnetworks->enabled)) { diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 9d7a23ce9fd..bc370f5552e 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -80,7 +80,7 @@ class mailing_contacts1 extends MailingTargets $statssql[0] .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $statssql[0] .= " WHERE c.entity IN (".getEntity('socpeople').")"; $statssql[0] .= " AND c.email != ''"; // Note that null != '' is false - $statssql[0] .= " AND c.no_email = 0"; + $statssql[0] .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0"; $statssql[0] .= " AND c.statut = 1"; return $statssql; @@ -104,7 +104,6 @@ class mailing_contacts1 extends MailingTargets $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; $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"; @@ -132,9 +131,8 @@ class mailing_contacts1 extends MailingTargets $sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - /*$sql.= " AND sp.email != ''"; // Note that null != '' is false - $sql.= " AND sp.no_email = 0"; - $sql.= " AND sp.statut = 1";*/ + $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.statut = 1"; $sql .= " AND (sp.poste IS NOT NULL AND sp.poste != '')"; $sql .= " GROUP BY sp.poste"; $sql .= " ORDER BY sp.poste"; @@ -166,10 +164,9 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_contact as cs"; - $sql .= " WHERE sp.statut = 1"; // Note that null != '' is false - //$sql.= " AND sp.no_email = 0"; - //$sql.= " AND sp.email != ''"; - //$sql.= " AND sp.entity IN (".getEntity('socpeople').")"; + $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; + $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_socpeople = sp.rowid"; $sql .= " GROUP BY c.label"; @@ -241,10 +238,9 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_societe as cs"; - $sql .= " WHERE sp.statut = 1"; // Note that null != '' is false - //$sql.= " AND sp.no_email = 0"; - //$sql.= " AND sp.email != ''"; - //$sql.= " AND sp.entity IN (".getEntity('socpeople').")"; + $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; + $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_soc = sp.fk_soc"; $sql .= " GROUP BY c.label"; @@ -283,10 +279,9 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_fournisseur as cs"; - $sql .= " WHERE sp.statut = 1"; // Note that null != '' is false - //$sql.= " AND sp.no_email = 0"; - //$sql.= " AND sp.email != ''"; - //$sql.= " AND sp.entity IN (".getEntity('socpeople').")"; + $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; + $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_soc = sp.fk_soc"; $sql .= " GROUP BY c.label"; @@ -385,7 +380,6 @@ class mailing_contacts1 extends MailingTargets if ($filter_category_supplier <> 'all') $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as c3s"; $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"; diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index ffba2571d23..d4ccc3ddb38 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -209,24 +209,6 @@ class MailingTargets // This can't be abstract as it is used for some method dol_syslog(__METHOD__.": mailing ".$j." targets added"); - /* - //Update the status to show thirdparty mail that don't want to be contacted anymore' - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " SET statut=3"; - $sql .= " WHERE fk_mailing=".$mailing_id." AND email in (SELECT email FROM ".MAIN_DB_PREFIX."societe where fk_stcomm=-1)"; - $sql .= " AND source_type='thirdparty'"; - dol_syslog(__METHOD__.": mailing update status to display thirdparty mail that do not want to be contacted"); - $result=$this->db->query($sql); - - //Update the status to show contact mail that don't want to be contacted anymore' - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " SET statut=3"; - $sql .= " WHERE fk_mailing=".$mailing_id." AND source_type='contact' AND (email in (SELECT sc.email FROM ".MAIN_DB_PREFIX."socpeople AS sc "; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid=sc.fk_soc WHERE s.fk_stcomm=-1 OR no_email=1))"; - dol_syslog(__METHOD__.": mailing update status to display contact mail that do not want to be contacted",LOG_DEBUG); - $result=$this->db->query($sql); - */ - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut=3"; $sql .= " WHERE fk_mailing=".$mailing_id." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))"; diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index d26bae234db..7b0fbf0ef72 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -100,20 +100,6 @@ if (!empty($tag) && ($unsuscrib == '1')) $resql = $db->query($sql); if (!$resql) dol_print_error($db); - /* - // Update status communication of thirdparty prospect (old usage) - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=-1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag = '".$db->escape($tag)."' AND source_type='thirdparty' AND source_id is not null)"; - - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); - - // Update status communication of contact prospect (old usage) - $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag = '".$db->escape($tag)."' AND source_type='contact' AND source_id is not null)"; - - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); - */ - // Update status communication of email (new usage) $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$db->escape($obj->entity).", '".$db->escape($obj->email)."')"; From 29950a6afa83f3df3330d8e29c137302e1481999 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 23 Oct 2021 22:27:29 +0200 Subject: [PATCH 056/490] Replace != by <> in SQL requests --- htdocs/core/modules/mailings/contacts1.modules.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index bc370f5552e..bd4300ea71d 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -79,7 +79,7 @@ class mailing_contacts1 extends MailingTargets $statssql[0] .= " count(distinct(c.email)) as nb"; $statssql[0] .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $statssql[0] .= " WHERE c.entity IN (".getEntity('socpeople').")"; - $statssql[0] .= " AND c.email != ''"; // Note that null != '' is false + $statssql[0] .= " AND c.email <> ''"; // Note that null != '' is false $statssql[0] .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0"; $statssql[0] .= " AND c.statut = 1"; @@ -103,7 +103,7 @@ class mailing_contacts1 extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; $sql .= " WHERE c.entity IN (".getEntity('socpeople').")"; - $sql .= " AND c.email != ''"; // Note that null != '' is false + $sql .= " AND c.email <> ''"; // Note that null != '' is false $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0"; // exclude unsubscribed users $sql .= " AND c.statut = 1"; @@ -131,9 +131,9 @@ class mailing_contacts1 extends MailingTargets $sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.email <> ''"; // Note that null != '' is false $sql .= " AND sp.statut = 1"; - $sql .= " AND (sp.poste IS NOT NULL AND sp.poste != '')"; + $sql .= " AND (sp.poste IS NOT NULL AND sp.poste <> '')"; $sql .= " GROUP BY sp.poste"; $sql .= " ORDER BY sp.poste"; $resql = $this->db->query($sql); @@ -165,7 +165,7 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_contact as cs"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.email <> ''"; // Note that null != '' is false $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_socpeople = sp.rowid"; @@ -239,7 +239,7 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.email <> ''"; // Note that null != '' is false $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_soc = sp.fk_soc"; @@ -280,7 +280,7 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_fournisseur as cs"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.email <> ''"; // Note that null != '' is false $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_soc = sp.fk_soc"; From 06c1d79c05edeb1647352c1fc6068593a8fef8d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Oct 2021 22:36:55 +0200 Subject: [PATCH 057/490] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 35155f0eb61..68bba0e04b5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8117,7 +8117,7 @@ class Form } // Note: $val['checked'] <> 0 means we must show the field into the combo list - $listoffieldsforselection .= '
  • '; + $listoffieldsforselection .= '
  • '; $listcheckedstring .= (empty($val['checked']) ? '' : $key.','); } } From 53e9da4748bcf9a8493ad0a30a3cf5a471a11686 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 23 Oct 2021 20:37:07 +0000 Subject: [PATCH 058/490] Fixing style errors. --- htdocs/delivery/card.php | 22 ++++++++++------------ htdocs/delivery/class/delivery.class.php | 18 +++++++++--------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 67a80084710..ee41019d218 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -609,20 +609,18 @@ if ($action == 'create') { // Create. Seems to no be used $object->lines[$i]->fetch_optionals(); - if ($action == 'create_delivery') { - $srcLine = new ExpeditionLigne($db); + if ($action == 'create_delivery') { + $srcLine = new ExpeditionLigne($db); + $extrafields->fetch_name_optionals_label($srcLine->table_element); + $srcLine->id = $expedition->lines[$i]->id; + $srcLine->fetch_optionals(); + + $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options); + } else { + $srcLine = new DeliveryLine($db); $extrafields->fetch_name_optionals_label($srcLine->table_element); - $srcLine->id = $expedition->lines[$i]->id; - $srcLine->fetch_optionals(); - - $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options); - } - else { - $srcLine = new DeliveryLine($db); - $extrafields->fetch_name_optionals_label($srcLine->table_element); - - } + } print $object->lines[$i]->showOptionals($extrafields, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), ''); //} } diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 775cd96e2c3..dee6d021e17 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -282,14 +282,14 @@ class Delivery extends CommonObject if (!$this->db->query($sql)) { $error++; } - + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."deliverydet"); - + if (is_array($array_options) && count($array_options) > 0) { - $line = new DeliveryLine($this->db); - $line->id = $id; - $line->array_options = $array_options; - $result = $line->insertExtraFields(); + $line = new DeliveryLine($this->db); + $line->id = $id; + $line->array_options = $array_options; + $result = $line->insertExtraFields(); } if ($error == 0) { @@ -541,7 +541,7 @@ class Delivery extends CommonObject $line->qty = $expedition->lines[$i]->qty_shipped; $line->fk_product = $expedition->lines[$i]->fk_product; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) { // For avoid conflicts if trigger used - $line->array_options = $expedition->lines[$i]->array_options; + $line->array_options = $expedition->lines[$i]->array_options; } $this->lines[$i] = $line; } @@ -608,13 +608,13 @@ class Delivery extends CommonObject { global $conf; - $num = count($this->lines); + $num = count($this->lines); $line = new DeliveryLine($this->db); $line->origin_id = $origin_id; $line->qty = $qty; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used - $line->array_options = $array_options; + $line->array_options = $array_options; } $this->lines[$num] = $line; } From 993226000adf11832afea49156e7f23cd8dae4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 23 Oct 2021 22:39:27 +0200 Subject: [PATCH 059/490] Update viewcat.php --- htdocs/categories/viewcat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 2c6ed74ae8a..9231e215b7f 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1048,7 +1048,7 @@ if ($type == Categorie::TYPE_USER) { print ''; print ''; print ''; print '
    '; print $langs->trans("AddProjectIntoCategory").'  '; - $form->select_dolusers('', 'elemid'); + print $form->select_dolusers('', 'elemid'); print '
    '; From 321cfb38113dae8f580a6224ad01062b42c05c75 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Oct 2021 22:44:37 +0200 Subject: [PATCH 060/490] Update cashcontrol_list.php --- htdocs/compta/cashcontrol/cashcontrol_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 85f6ff5fe11..89781fcb211 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -60,7 +60,7 @@ $pagenext = $page + 1; // Initialize technical objects $object = new CashControl($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->takepos->dir_output.'/temp/massgeneration/'.$user->id; +//$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels From a58f713f6d64c9aa8f60a47914faf40a9278752a Mon Sep 17 00:00:00 2001 From: Polkiko Date: Sat, 23 Oct 2021 23:12:23 +0200 Subject: [PATCH 061/490] NEW Canceled purchase orders do not qualify for total in project overview (and are hidden) If purchase order has been canceled then it does not qualify for total amount and is not shown in table. It can be seen by clicking on the "show/hide" button. --- htdocs/langs/en_US/projects.lang | 4 +++- htdocs/langs/es_ES/projects.lang | 2 ++ htdocs/projet/element.php | 27 ++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 2fda7e1df0e..570caef7f95 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -37,6 +37,8 @@ OpportunitiesStatusForOpenedProjects=Leads amount of open projects by status OpportunitiesStatusForProjects=Leads amount of projects by status ShowProject=Show project ShowTask=Show task +ShowCanceled=Show canceled +HideCanceled=Hide canceled SetProject=Set project NoProject=No project defined or owned NbOfProjects=Number of projects @@ -274,4 +276,4 @@ AddPersonToTask=Add also to tasks UsageOrganizeEvent=Usage: Event Organization PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE=Classify project as closed when all its tasks are completed (100%% progress) PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with all tasks at 100 %% progress won't be affected: you will have to close them manually. This option only affects open projects. -SelectLinesOfTimeSpentToInvoice=Select lines of time spent that are unbilled, then bulk action "Generate Invoice" to bill them \ No newline at end of file +SelectLinesOfTimeSpentToInvoice=Select lines of time spent that are unbilled, then bulk action "Generate Invoice" to bill them diff --git a/htdocs/langs/es_ES/projects.lang b/htdocs/langs/es_ES/projects.lang index 6beabd61c1c..01aad98a391 100644 --- a/htdocs/langs/es_ES/projects.lang +++ b/htdocs/langs/es_ES/projects.lang @@ -37,6 +37,8 @@ OpportunitiesStatusForOpenedProjects=Importe oportunidades de proyectos por esta OpportunitiesStatusForProjects=Importe oportunidades de proyectos por estado ShowProject=Ver proyecto ShowTask=Ver tarea +ShowCanceled=Mostrar cancelados +HideCanceled=Ocultar cancelados SetProject=Definir proyecto NoProject=Ningún proyecto definido NbOfProjects=Numero de proyectos diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 9e14a53e7ea..0002da42a82 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1048,6 +1048,24 @@ foreach ($listofreferent as $key => $value) { } $addform .= '
    '; } + if ($key == "order_supplier") { + $addform .= ' + '.$langs->trans("ShowCanceled").' + + '; + } print load_fiche_titre($langs->trans($title), $addform, ''); @@ -1170,9 +1188,16 @@ foreach ($listofreferent as $key => $value) { if (!empty($element->close_code) && $element->close_code == 'replaced') { $qualifiedfortotal = false; // Replacement invoice, do not include into total } + } elseif (($key == 'order_supplier') && ($element->status == 7)) { + $qualifiedfortotal = false; // It makes no sense to include canceled orders in the total + } + + if (($key == "order_supplier") && ($element->status == 7)) { + print ''; + } else { + print ''; } - print ''; // Remove link print ''; From 77c716565e6baff527a398eccaca15aa8d3b0896 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 23 Oct 2021 23:42:06 +0200 Subject: [PATCH 062/490] Fix #18922 : multicurrency sync in http with good currencylayer url --- htdocs/multicurrency/class/multicurrency.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 5067a6e91d5..3cdcd30dd70 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -643,13 +643,12 @@ class MultiCurrency extends CommonObject include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - $urlendpoint = 'http://apilayer.net/api/live?access_key='.$key; - //$urlendpoint.='&format=1'; - $urlendpoint .= (empty($conf->global->MULTICURRENCY_APP_SOURCE) ? '' : '&source='.$conf->global->MULTICURRENCY_APP_SOURCE); + $urlendpoint = 'http://api.currencylayer.com/live?access_key='.$key; + $urlendpoint .= '&source=' . (empty($conf->global->MULTICURRENCY_APP_SOURCE) ? 'USD' : $conf->global->MULTICURRENCY_APP_SOURCE); dol_syslog("Call url endpoint ".$urlendpoint); - $resget = getURLContent($urlendpoint, 'GET', '', 1, array(), array('http', 'https'), 1); + $resget = getURLContent($urlendpoint); if ($resget['content']) { $response = $resget['content']; From 86ff951254c7078ce34d354ec37900faed735f8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Oct 2021 23:43:43 +0200 Subject: [PATCH 063/490] Fix ?: --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 6bc98f273dc..d6761f9fddb 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1221,7 +1221,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($showbarcode) { print ''.$langs->trans('BarcodeType').''; if (GETPOSTISSET('fk_barcode_type')) { - $fk_barcode_type = GETPOST('fk_barcode_type')?:0; + $fk_barcode_type = GETPOST('fk_barcode_type')?GETPOST('fk_barcode_type'):0; } else { if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { $fk_barcode_type = getDolGlobalInt("PRODUIT_DEFAULT_BARCODE_TYPE"); From 983e28691bbd2186dda67a6a325e2b49f2a5d52d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 24 Oct 2021 00:02:55 +0200 Subject: [PATCH 064/490] Use a subselect instead of a join --- htdocs/contact/list.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 935e90e6085..64207863c79 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -175,7 +175,7 @@ $arrayfields = array( 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'position'=>32, 'checked'=>1), 'p.fax'=>array('label'=>"Fax", 'position'=>33, 'checked'=>0), 'p.email'=>array('label'=>"EMail", 'position'=>40, 'checked'=>1), - 'mu.rowid'=>array('label'=>"No_Email", 'position'=>41, 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))), + 'unsubscribed'=>array('label'=>"No_Email", 'position'=>41, 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))), 'p.thirdparty'=>array('label'=>"ThirdParty", 'position'=>50, 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200), 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), @@ -307,7 +307,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } if(!empty($conf->mailing->enabled)) { - $sql .= ", mu.rowid as no_email"; + $sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) as unsubscribed"; } // Add fields from hooks $parameters = array(); @@ -321,7 +321,6 @@ if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_conta if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -if(!empty($conf->mailing->enabled)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = p.email"; $sql .= ' WHERE p.entity IN ('.getEntity('socpeople').')'; if (!$user->rights->societe->client->voir && !$socid) //restriction { @@ -378,8 +377,8 @@ if (strlen($search_town)) $sql .= natural_search("p.town", $search_town); if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } -if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND mu.rowid IS NOT NULL"; -if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND mu.rowid IS NULL"; +if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) > 0"; +if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0"; if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type @@ -666,7 +665,7 @@ if (!empty($arrayfields['p.email']['checked'])) print ''; print ''; } -if (!empty($arrayfields['mu.rowid']['checked'])) +if (!empty($arrayfields['unsubscribed']['checked'])) { print ''; print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email); @@ -755,7 +754,7 @@ if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_ if (!empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['mu.rowid']['checked'])) print_liste_field_titre($arrayfields['mu.rowid']['label'], $_SERVER["PHP_SELF"], "mu.rowid", $begin, $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['unsubscribed']['checked'])) print_liste_field_titre($arrayfields['unsubscribed']['label'], $_SERVER["PHP_SELF"], "unsubscribed", $begin, $param, '', $sortfield, $sortorder, 'center '); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { @@ -909,9 +908,9 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } // No EMail - if (!empty($arrayfields['mu.rowid']['checked'])) + if (!empty($arrayfields['unsubscribed']['checked'])) { - print ''.yn(!is_null($obj->no_email) ? 1 : 0).''; + print ''.yn(($obj->unsubscribed > 0) ? 1 : 0).''; if (!$i) $totalarray['nbfield']++; } if (!empty($conf->socialnetworks->enabled)) { From 0a2c950401ded7ce6af036b045b036ff76f55eb7 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 24 Oct 2021 00:31:57 +0200 Subject: [PATCH 065/490] Fix #18916 : mass stock movements not displayed if error while adding line --- htdocs/product/stock/massstockmove.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 9f3390d34af..ed7095473ea 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -443,6 +443,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { */ $now = dol_now(); +$error = 0; $form = new Form($db); $formproduct = new FormProduct($db); From f2cd7a7a5640cbc0ed37bd4952bf534335d5b58a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Oct 2021 00:37:37 +0200 Subject: [PATCH 066/490] Removed the div class="ficheaddleft" --- htdocs/compta/index.php | 4 +-- htdocs/compta/tva/card.php | 2 -- htdocs/compta/tva/index.php | 4 +-- htdocs/contrat/index.php | 4 +-- htdocs/don/card.php | 2 -- htdocs/don/index.php | 4 +-- htdocs/don/stats/index.php | 4 +-- .../conferenceorbooth_document.php | 2 -- .../conferenceorboothattendee_card.php | 2 -- .../conferenceorboothattendee_list.php | 2 -- .../eventorganizationindex.php | 4 +-- htdocs/expedition/index.php | 4 +-- htdocs/expedition/stats/index.php | 4 +-- htdocs/expensereport/card.php | 4 +-- htdocs/expensereport/index.php | 4 +-- htdocs/expensereport/stats/index.php | 4 +-- htdocs/fichinter/card.php | 6 ++--- htdocs/fichinter/index.php | 4 +-- htdocs/fichinter/stats/index.php | 4 +-- htdocs/fourn/card.php | 4 +-- htdocs/fourn/commande/card.php | 6 ++--- htdocs/fourn/commande/index.php | 4 +-- htdocs/fourn/facture/card.php | 9 ++----- htdocs/fourn/facture/index.php | 2 -- htdocs/fourn/index.php | 6 ++--- htdocs/holiday/document.php | 2 -- htdocs/hrm/evaluation_card.php | 4 +-- htdocs/hrm/index.php | 4 +-- htdocs/hrm/job_card.php | 4 +-- htdocs/hrm/position_card.php | 8 +++--- htdocs/hrm/skill_card.php | 4 +-- .../knowledgemanagementindex.php | 4 +-- .../modulebuilder/template/mymoduleindex.php | 4 +-- htdocs/mrp/index.php | 4 +-- htdocs/partnership/partnershipindex.php | 4 +-- htdocs/product/card.php | 8 +++--- htdocs/product/index.php | 4 +-- htdocs/product/stats/card.php | 4 +-- htdocs/product/stock/card.php | 2 -- htdocs/product/stock/index.php | 6 ++--- htdocs/product/stock/movement_card.php | 6 ++--- htdocs/product/stock/movement_list.php | 2 -- htdocs/product/stock/product.php | 3 +-- htdocs/product/stock/productlot_card.php | 4 +-- htdocs/projet/activity/index.php | 4 +-- htdocs/projet/index.php | 4 +-- htdocs/projet/stats/index.php | 2 +- htdocs/projet/tasks/stats/index.php | 4 +-- htdocs/projet/tasks/time.php | 4 +-- htdocs/reception/index.php | 5 ++-- htdocs/reception/stats/index.php | 4 +-- htdocs/recruitment/recruitmentindex.php | 4 +-- htdocs/salaries/card.php | 2 -- htdocs/salaries/stats/index.php | 4 +-- htdocs/supplier_proposal/index.php | 4 +-- htdocs/takepos/admin/orderprinters.php | 7 ++---- htdocs/theme/eldy/global.inc.php | 21 +++++----------- htdocs/theme/md/style.css.php | 25 ++++++------------- htdocs/ticket/stats/index.php | 4 +-- 59 files changed, 108 insertions(+), 170 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 29f41587224..332f68c1293 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -112,7 +112,7 @@ print getCustomerInvoiceDraftTable($max, $socid); print '
    '; print getDraftSupplierTable($max, $socid); -print '
    '; +print '
    '; // Latest modified customer invoices @@ -749,7 +749,7 @@ if ($resql) { } -print '
    '; +print '
    '; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardAccountancy', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 83740385f2b..4264f786d3a 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -614,7 +614,6 @@ if ($id) { print ''; print '
    '; - print '
    '; $nbcols = 3; if (!empty($conf->banque->enabled)) { @@ -717,7 +716,6 @@ if ($id) { dol_print_error($db); } - print '
    '; print '
    '; print ''; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index e1ac3f96a2d..fed0cf209c1 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -514,7 +514,7 @@ if ($refresh === true) { print ''; - print '
    '; + print '
    '; /* @@ -544,7 +544,7 @@ if ($refresh === true) { pt($db, $sql, $langs->trans("Month")); - print '
    '; + print ''; } llxFooter(); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 626d81892b1..99739260b36 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -298,7 +298,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { } -print '
    '; +print '
    '; // Last modified contracts @@ -622,7 +622,7 @@ if ($resql) { } -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardContracts', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 5caf81e815a..b4c84c15203 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -778,7 +778,6 @@ if (!empty($id) && $action != 'edit') { print ''; print '
    '; - print '
    '; /* * Payments @@ -836,7 +835,6 @@ if (!empty($id) && $action != 'edit') { dol_print_error($db); } - print '
    '; print '
    '; print ''; diff --git a/htdocs/don/index.php b/htdocs/don/index.php index 36323d332b7..85e2eb3e48f 100644 --- a/htdocs/don/index.php +++ b/htdocs/don/index.php @@ -190,7 +190,7 @@ print ''; print ""; -print '
    '; +print '
    '; $max = 10; @@ -252,7 +252,7 @@ if ($resql) { } -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardDonation', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index 59a73ad5b19..bb7d6b314aa 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -276,7 +276,7 @@ print ''; print ''; -print '
    '; +print '
    '; // Show graphs @@ -293,7 +293,7 @@ if ($mesg) { print ''; -print '
    '; +print ''; print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php index 8b064c12b72..458af551bc9 100644 --- a/htdocs/eventorganization/conferenceorbooth_document.php +++ b/htdocs/eventorganization/conferenceorbooth_document.php @@ -220,7 +220,6 @@ if (!empty($withproject)) { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -279,7 +278,6 @@ if (!empty($withproject)) { print '
    '; - print '
    '; print '
    '; print ''; diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index 101bc10a0aa..a4dc780c8d9 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -317,7 +317,6 @@ if (!empty($withproject)) { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -410,7 +409,6 @@ if (!empty($withproject)) { print '
    '; - print '
    '; print '
    '; print ''; diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 12d62e0ab76..6489efb0bb9 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -497,7 +497,6 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -590,7 +589,6 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { print '
    '; - print '
    '; print '
    '; print ''; diff --git a/htdocs/eventorganization/eventorganizationindex.php b/htdocs/eventorganization/eventorganizationindex.php index d708883c249..77c2ec512f4 100644 --- a/htdocs/eventorganization/eventorganizationindex.php +++ b/htdocs/eventorganization/eventorganizationindex.php @@ -144,7 +144,7 @@ if (! empty($conf->eventorganization->enabled) && $user->rights->eventorganizati END MODULEBUILDER DRAFT MYOBJECT */ -print '
    '; +print '
    '; $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; @@ -205,7 +205,7 @@ if (! empty($conf->eventorganization->enabled) && $user->rights->eventorganizati } */ -print '
    '; +print ''; // End of page llxFooter(); diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index a08339d652f..49777518509 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -124,7 +124,7 @@ if ($resql) { //print ''; -print '
    '; +print '
    '; $max = 5; @@ -283,7 +283,7 @@ if ($resql) { } -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardWarehouseSendings', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index e5718added1..fc8d69e4ce7 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -291,7 +291,7 @@ print ''; print ''; -print '
    '; +print '
    '; // Show graphs @@ -308,7 +308,7 @@ if ($mesg) { print ''; -print '
    '; +print ''; print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 386817e03af..fca9d9b9681 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1850,7 +1850,6 @@ if ($action == 'create') { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -1903,7 +1902,7 @@ if ($action == 'create') { $nbcols++; } - print '
    '; + print '
    '; print ''; print ''; @@ -2002,7 +2001,6 @@ if ($action == 'create') { } print "
    '.$langs->trans('Payments').'
    "; - print '
    '; print '
    '; print ''; diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index c87cc08fb40..d731c4c8c82 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -185,7 +185,7 @@ print ''; // Right area -print '
    '; +print '
    '; $max = 10; @@ -265,7 +265,7 @@ if ($result) { dol_print_error($db); } -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardExpenseReport', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index d9fe6a72c87..500fe874747 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -292,7 +292,7 @@ foreach ($data as $val) { print ''; print ''; -print '
    '; +print '
    '; // Show graphs @@ -309,7 +309,7 @@ if ($mesg) { print ''; -print '
    '; +print ''; print '
    '; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 9fb15bac425..a9b85840bca 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1246,7 +1246,6 @@ if ($action == 'create') { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -1260,7 +1259,6 @@ if ($action == 'create') { print "
    "; - print '
    '; print '
    '; print ''; @@ -1668,14 +1666,14 @@ if ($action == 'create') { $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; + print '
    '; // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'fichinter', $socid, 1); - print '
    '; + print ''; } diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 169ddfdccbf..0f0fc0acc99 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -229,7 +229,7 @@ if (!empty($conf->ficheinter->enabled)) { } -print '
    '; +print '
    '; $max = 5; @@ -381,7 +381,7 @@ if (!empty($conf->ficheinter->enabled)) { } } -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardInterventions', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index aec9ab7e839..f1247adb457 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -300,7 +300,7 @@ print ''; print ''; -print '
    '; +print '
    '; // Show graphs @@ -317,7 +317,7 @@ if ($mesg) { print ''; -print '
    '; +print ''; print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 67ed2d4e741..16e89850ae4 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -371,7 +371,7 @@ if ($object->id > 0) { print ''; - print '
    '; + print '
    '; $boxstat = ''; @@ -813,7 +813,7 @@ if ($object->id > 0) { } } - print '
    '; + print ''; print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f025e3ce6c7..dea816b9574 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2249,7 +2249,6 @@ if ($action == 'create') { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -2308,7 +2307,6 @@ if ($action == 'create') { }*/ - print ''; print ''; print ''; @@ -2640,7 +2638,7 @@ if ($action == 'create') { $linktoelem = $form->showLinkToObjectBlock($object, null, array('supplier_order', 'order_supplier')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; + print '
    '; if ($action == 'classifyreception') { if ($usercanreceived && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { @@ -2686,7 +2684,7 @@ if ($action == 'create') { $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'order_supplier', $socid, 1, 'listaction'.($genallowed ? 'largetitle' : '')); - print '
    '; + print ''; } /* diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 4d93f6d3818..7d6b3b6936a 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -272,7 +272,7 @@ if ($resql) { } -print '
    '; +print '
    '; /* @@ -417,7 +417,7 @@ print "

    "; } */ -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardOrdersSuppliers', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d32f7eebb93..946958594d8 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2948,7 +2948,6 @@ if ($action == 'create') { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -3325,7 +3324,6 @@ if ($action == 'create') { print '
    '; print '
    '; - print '
    '; print ''; print ''; @@ -3574,17 +3572,14 @@ if ($action == 'create') { $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice_supplier')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; - //print ''; - //print '
    '; + print '
    '; // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'invoice_supplier', $socid, 1, 'listaction'.($genallowed ? 'largetitle' : '')); - print '
    '; - //print ''; + print ''; } } } diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index 5479ad22462..21d3e4cfa58 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -73,7 +73,6 @@ if ($tmp) { print ''; print '
    '; -print '
    '; $tmp = getPurchaseInvoiceLatestEditTable($maxLatestEditCount, $socid); if ($tmp) { @@ -87,7 +86,6 @@ if ($tmp) { print '
    '; } -print '
    '; print '
    '; print ''; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 7dfd17495c3..1dc3e963db7 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -221,8 +221,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S } -//print ''; -print '
    '; +print '
    '; /* @@ -318,8 +317,7 @@ if (count($companystatic->SupplierCategories)) { } -//print "\n"; -print '
    '; +print ''; // End of page llxFooter(); diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index c4e779efe52..959543f436b 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -283,7 +283,6 @@ if ($object->id) { /* print ''; print '
    '; - print '
    '; print '
    '; @@ -340,7 +339,6 @@ if ($object->id) { print ''; print ''; - print '
    '; print '
    '; */ print ''; diff --git a/htdocs/hrm/evaluation_card.php b/htdocs/hrm/evaluation_card.php index 2716bbf8a83..28e030ffc42 100644 --- a/htdocs/hrm/evaluation_card.php +++ b/htdocs/hrm/evaluation_card.php @@ -682,7 +682,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; + print '
    '; $MAXEVENT = 10; @@ -695,7 +695,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); - print '
    '; + print ''; } //Select mail models is same action as presend diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index ac9d01035af..0b887667561 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -175,7 +175,7 @@ if (!empty($conf->holiday->enabled)) { } -print '
    '; +print '
    '; @@ -404,7 +404,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme } } -print '
    '; +print ''; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $parameters = array('user' => $user); diff --git a/htdocs/hrm/job_card.php b/htdocs/hrm/job_card.php index 23343c5c09b..42ee4d6f4b1 100644 --- a/htdocs/hrm/job_card.php +++ b/htdocs/hrm/job_card.php @@ -450,7 +450,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; + print '
    '; $MAXEVENT = 10; @@ -463,7 +463,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, $object->element . '@' . $object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); - print '
    '; + print ''; } // Presend form diff --git a/htdocs/hrm/position_card.php b/htdocs/hrm/position_card.php index 4e003372a1c..4d6b36b52f3 100644 --- a/htdocs/hrm/position_card.php +++ b/htdocs/hrm/position_card.php @@ -344,7 +344,7 @@ function DisplayPositionCard(&$object) // } // // -// print '
    '; +// print '
    '; // // $MAXEVENT = 10; // @@ -355,7 +355,7 @@ function DisplayPositionCard(&$object) // $formactions = new FormActions($db); // $somethingshown = $formactions->showactions($object, '', $object->id, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty // -// print '
    '; +// print ''; //} @@ -373,7 +373,7 @@ if ($action !== 'edit' && $action !== 'create') { $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; + print '
    '; $MAXEVENT = 10; @@ -385,7 +385,7 @@ if ($action !== 'edit' && $action !== 'create') { $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, $object->element . '@' . $object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); - print '
    '; + print ''; } diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 3b649ebf485..ed66dc4ebb9 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -836,7 +836,7 @@ if ($action != "create" && $action != "edit") { $linktoelem = $form->showLinkToObjectBlock($object, null, array('skill')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; + print '
    '; $MAXEVENT = 10; @@ -848,7 +848,7 @@ if ($action != "create" && $action != "edit") { $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, $object->element . '@' . $object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); - print '
    '; + print ''; } // End of page diff --git a/htdocs/knowledgemanagement/knowledgemanagementindex.php b/htdocs/knowledgemanagement/knowledgemanagementindex.php index d9b1f07e6e0..ccb3503eb2f 100644 --- a/htdocs/knowledgemanagement/knowledgemanagementindex.php +++ b/htdocs/knowledgemanagement/knowledgemanagementindex.php @@ -145,7 +145,7 @@ if (! empty($conf->knowledgemanagement->enabled) && $user->rights->knowledgemana END MODULEBUILDER DRAFT MYOBJECT */ -print '
    '; +print '
    '; $NBMAX = (empty($conf->global->MAIN_SIZE_SHORTLIST_LIMIT) ? 25 : $conf->global->MAIN_SIZE_SHORTLIST_LIMIT); @@ -202,7 +202,7 @@ if (! empty($conf->knowledgemanagement->enabled) && $user->rights->knowledgemana } */ -print '
    '; +print ''; // End of page llxFooter(); diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index c0c98d88e8f..15f3d83ac54 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -173,7 +173,7 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read) END MODULEBUILDER DRAFT MYOBJECT */ -print '
    '; +print '
    '; $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; @@ -234,7 +234,7 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read) } */ -print '
    '; +print ''; // End of page llxFooter(); diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index cbb7b5da305..c4480f76ed0 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -147,7 +147,7 @@ if ($conf->use_javascript_ajax) { print '
    '; -print '
    '; +print '
    '; /* * Last modified BOM @@ -245,7 +245,7 @@ if ($resql) { dol_print_error($db); } -print '
    '; +print ''; $parameters = array( //'type' => $type, diff --git a/htdocs/partnership/partnershipindex.php b/htdocs/partnership/partnershipindex.php index f1a9f8c507b..0b8a6cd33c9 100644 --- a/htdocs/partnership/partnershipindex.php +++ b/htdocs/partnership/partnershipindex.php @@ -133,7 +133,7 @@ if (! empty($conf->partnership->enabled) && $user->rights->partnership->read) { END MODULEBUILDER DRAFT MYOBJECT */ -print '
    '; +print '
    '; $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; @@ -190,7 +190,7 @@ if (! empty($conf->partnership->enabled) && $user->rights->partnership->read) { } */ -print '
    '; +print ''; // End of page llxFooter(); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index d6761f9fddb..75d11aee3b9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2323,7 +2323,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; - print '
    '; + print '
    '; print '
    '; print ''; @@ -2479,7 +2479,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "
    \n"; print '
    '; - print '
    '; + print ''; print '
    '; print dol_get_fiche_end(); @@ -2701,7 +2701,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') { print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); $somethingshown = $formfile->numoffiles; - print '
    '; + print '
    '; $MAXEVENT = 10; @@ -2714,7 +2714,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') { $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'product', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product - print '
    '; + print ''; } // End of page diff --git a/htdocs/product/index.php b/htdocs/product/index.php index e3be4b91415..082e8a4d8d2 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -274,7 +274,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA print ''; print ''; } -print '
    '; +print '
    '; /* @@ -416,7 +416,7 @@ if (!empty($conf->global->MAIN_SHOW_PRODUCT_ACTIVITY_TRIM)) { } -print '
    '; +print ''; $parameters = array('type' => $type, 'user' => $user); $reshook = $hookmanager->executeHooks('dashboardProductsServices', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 46799773276..ef4abef5173 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -474,8 +474,8 @@ if ($result || empty($id)) { } // div not closed if ($i % 2 == 1) { - print "\n".'
    '."\n"; - print "\n".'
    '; + print "\n".'
    '."\n"; + print "\n".'
    '; print '

    '."\n"; } } diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 14f433b2713..7b81b147b1d 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -505,7 +505,6 @@ if ($action == 'create') { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -551,7 +550,6 @@ if ($action == 'create') { print "
    "; - print '
    '; print '
    '; print ''; diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index b64068df48b..9aad5f382cc 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -134,8 +134,7 @@ if ($result) { } -//print ''; -print '
    '; +print '
    '; // Latest movements @@ -235,8 +234,7 @@ if ($resql) { dol_print_error($db); } -//print ''; -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardWarehouse', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 24e5ae2b689..b5373fc9de6 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -605,7 +605,6 @@ if ($resql) { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -637,7 +636,6 @@ if ($resql) { print "
    "; - print '
    '; print '
    '; print ''; @@ -1205,7 +1203,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); $somethingshown = $formfile->numoffiles; - print '
    '; + print '
    '; $MAXEVENT = 10; @@ -1218,7 +1216,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product - print '
    '; + print ''; } diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index f3b9ea40559..e028c49396b 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -718,7 +718,6 @@ if ($object->id > 0) { print ''; print '
    '; - print '
    '; print '
    '; print ''; @@ -760,7 +759,6 @@ if ($object->id > 0) { print "
    "; - print '
    '; print '
    '; print ''; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index f8c88ce6d01..23900c85c0b 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -709,7 +709,7 @@ if ($id > 0 || $ref) { print ''; print ''; - print '
    '; + print '
    '; print ''; @@ -863,7 +863,6 @@ if ($id > 0 || $ref) { print "
    "; - print '
    '; print '
    '; print '
    '; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 36e230b911d..cbf7c901b37 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -569,7 +569,7 @@ if ($action != 'presend') { print $formfile->showdocuments('product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $langs->default_lang, '', $object); } - print '
    '; + print '
    '; $MAXEVENT = 10; @@ -577,7 +577,7 @@ if ($action != 'presend') { $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'productlot', 0, 1, '', $MAXEVENT); - print '
    '; + print ''; } // End of page diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index bdce4353faf..453a4078978 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -159,7 +159,7 @@ print ""; print ''; -print '
    '; +print '
    '; /* Affichage de la liste des projets d'hier */ @@ -557,7 +557,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH } -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardActivities', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 9998906601d..e1f86bcffc9 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -197,7 +197,7 @@ include DOL_DOCUMENT_ROOT.'/projet/graph_opportunities.inc.php'; print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppstatus, array('projectlabel', 'plannedworkload', 'declaredprogress', 'prospectionstatus', 'projectstatus')); -print '
    '; +print '
    '; // Latest modified projects $sql = "SELECT p.rowid, p.ref, p.title, p.dateo, p.datee, p.fk_statut as status, p.tms as datem"; @@ -418,7 +418,7 @@ if (empty($conf->global->PROJECT_HIDE_PROJECT_LIST_ON_PROJECT_AREA)) { print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array()); } -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardProjects', $parameters, $projectstatic); // Note that $action and $object may have been modified by hook diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index afd86f3ed07..c5acc20bfe6 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -349,7 +349,7 @@ foreach ($data_all_year as $val) { print ''; print ''; -print '
    '; +print '
    '; $stringtoshow = '
    '; if ($mesg) { diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index 76c74ba343c..60cbdf37072 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -205,7 +205,7 @@ foreach ($data_all_year as $val) { print '
    '; print '
    '; -print '
    '; +print '
    '; $stringtoshow = '
    '; if ($mesg) { @@ -219,7 +219,7 @@ $stringtoshow .= '
    '; print $stringtoshow; -print '
    '; +print ''; print '
    '; // End of page diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index d171d130a41..ec8593db7fc 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -816,10 +816,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { print ''; print '
    '; - print '
    '; print '
    '; - print ''; + print '
    '; // Description print '
    '.$langs->trans("Description").''; @@ -835,7 +834,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { print '
    '; - print '
    '; print '
    '; print ''; diff --git a/htdocs/reception/index.php b/htdocs/reception/index.php index 965e3f12082..580de4aca1a 100644 --- a/htdocs/reception/index.php +++ b/htdocs/reception/index.php @@ -135,8 +135,7 @@ if ($resql) { } -//print ''; -print '
    '; +print '
    '; $max = 5; @@ -265,7 +264,7 @@ if ($resql) { } } -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardWarehouseReceptions', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 3e8ccb7f017..8f20ed58065 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -282,7 +282,7 @@ foreach ($data as $val) { print ''; -print '
    '; +print '
    '; // Show graphs @@ -299,7 +299,7 @@ if ($mesg) { print ''; -print '
    '; +print ''; print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/recruitment/recruitmentindex.php b/htdocs/recruitment/recruitmentindex.php index c0e5449b649..b4d943584cd 100644 --- a/htdocs/recruitment/recruitmentindex.php +++ b/htdocs/recruitment/recruitmentindex.php @@ -320,7 +320,7 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->read) END MODULEBUILDER DRAFT MYOBJECT */ -print '
    '; +print '
    '; $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; @@ -463,7 +463,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme } } -print '
    '; +print ''; // End of page llxFooter(); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index b2da534fda8..0d47a90796f 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -854,7 +854,6 @@ if ($id) { print ''; print '
    '; - print '
    '; $nbcols = 3; if (!empty($conf->banque->enabled)) { @@ -955,7 +954,6 @@ if ($id) { dol_print_error($db); } - print '
    '; print '
    '; print ''; diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index ecc62c2a237..7eefe7982fc 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -256,7 +256,7 @@ print ''; print ''; -print '
    '; +print '
    '; // Show graphs @@ -273,7 +273,7 @@ if ($mesg) { print ''; -print '
    '; +print ''; print '
    '; diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 04eff4ce896..f151651d186 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -211,7 +211,7 @@ if (!empty($conf->supplier_proposal->enabled)) { } } -print '
    '; +print '
    '; $max = 5; @@ -385,7 +385,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa } } -print '
    '; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardSupplierProposal', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/takepos/admin/orderprinters.php b/htdocs/takepos/admin/orderprinters.php index eb23f26806c..cddf839375a 100644 --- a/htdocs/takepos/admin/orderprinters.php +++ b/htdocs/takepos/admin/orderprinters.php @@ -135,14 +135,11 @@ print load_fiche_titre($langs->trans("OrderPrinters")); //print ''; print '
    '; +print '
    '; -//print ''; -print '
    '; +print '
    '; -//print ''; -print '
    '; - print '

    '; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 1e0f8dffc1e..81f99ba381a 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1963,7 +1963,7 @@ div.fichethirdleft { print "float: ".$left.";\n"; } ?> browser->layout != 'phone') { - print "width: 50%;\n"; + print "width: calc(50% - 14px);\n"; } ?> browser->layout == 'phone') { print "padding-bottom: 6px;\n"; @@ -1974,15 +1974,12 @@ div.fichetwothirdright { print "float: ".$right.";\n"; } ?> browser->layout != 'phone') { - print "width: 50%;\n"; + print "width: calc(50% - 14px);\n"; } ?> browser->layout == 'phone') { print "padding-bottom: 6px\n"; } ?> } -div.fichetwothirdright div.ficheaddleft { - padding-: 28px; -} div.fichehalfleft { browser->layout != 'phone') { print "float: ".$left.";\n"; @@ -2037,9 +2034,6 @@ div.secondcolumn div.box { width: auto; padding-bottom: 6px; } - div.fichetwothirdright div.ficheaddleft { - padding-left: 0; - } div.fichehalfleft { float: none; width: auto; @@ -3996,8 +3990,8 @@ div.tabBar .noborder { /* Prepare to remove class pair - impair */ .noborder:not(.editmode) > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) { background: linear-gradient(bottom, var(----colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); background: -o-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); @@ -4011,8 +4005,8 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft } .noborder:not(.editmode) > tbody > tr:nth-child(odd):not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre) +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre) { background: linear-gradient(bottom, var(--colorbacklinepair2) 0%, var(--colorbacklinepair2) 100%); background: -o-linear-gradient(bottom, var(--colorbacklinepair2) 0%, var(--colorbacklinepair2) 100%); @@ -4041,9 +4035,6 @@ ul.noborder li:nth-child(even):not(.liste_titre) { padding-left: 0px; padding-bottom: 10px; } -.ficheaddleft div.boxstats, .ficheaddright div.boxstats { - border: none; -} .boxstatsborder { /* border: 1px solid #CCC !important; */ } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 51e625438fd..c38eb032e0a 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1965,7 +1965,7 @@ div.fichethirdleft { print "float: ".$left.";\n"; } ?> browser->layout != 'phone') { - print "width: 50%;\n"; + print "width: calc(50% - 14px);\n"; } ?> browser->layout == 'phone') { print "padding-bottom: 6px;\n"; @@ -1976,15 +1976,12 @@ div.fichetwothirdright { print "float: ".$right.";\n"; } ?> browser->layout != 'phone') { - print "width: 50%;\n"; + print "width: calc(50% - 14px);\n"; } ?> browser->layout == 'phone') { print "padding-bottom: 6px\n"; } ?> } -div.fichetwothirdright div.ficheaddleft { - padding-left: 20px; -} div.fichehalfleft { browser->layout != 'phone') { print "float: ".$left.";\n"; @@ -2042,9 +2039,6 @@ div.secondcolumn div.box { width: auto; padding-bottom: 6px; } - div.fichetwothirdright div.ficheaddleft { - padding-left: 0; - } div.fichehalfleft { float: none; width: auto; @@ -3989,8 +3983,8 @@ div .tdtop { /* Prepare to remove class pair - impair */ .noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) { background: linear-gradient(to bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); background: -o-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); @@ -4004,8 +3998,8 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft } .noborder > tbody > tr:nth-child(odd):not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre) +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre) { background: linear-gradient(to bottom, var(--colorbacklinepair1) 0%, var(--colorbacklinepair2) 100%); background: -o-linear-gradient(bottom, var(--colorbacklinepair1) 0%, var(--colorbacklinepair2) 100%); @@ -4034,9 +4028,6 @@ ul.noborder li:nth-child(even):not(.liste_titre) { padding-left: 0px; padding-bottom: 12px; } -.ficheaddleft div.boxstats, .ficheaddright div.boxstats { - border: none; -} .boxstatsborder { /* border: 1px solid #CCC !important; */ } @@ -6877,7 +6868,7 @@ div.clipboardCPValue.hidewithsize { input#addedfile { width: 95%; } - + #divbodywebsite { word-break: break-all; } @@ -6886,7 +6877,7 @@ div.clipboardCPValue.hidewithsize { border-left: unset; boerder-right: unset; padding-left: 5px; - } + } } diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index 1a50d709514..d76800f6da5 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -297,7 +297,7 @@ print ''; print '
    '; -print '
    '; +print '
    '; // Show graphs @@ -314,7 +314,7 @@ if ($mesg) { print ''; -print '
    '; +print ''; print '
    '; print dol_get_fiche_end(); From d3d3a87ce9ca1ee8eb9328f87a367dd9c5625210 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sun, 24 Oct 2021 01:38:13 +0200 Subject: [PATCH 067/490] Add new class to help setup generation --- htdocs/core/class/html.formsetup.class.php | 403 ++++++++++++++++++ htdocs/modulebuilder/template/admin/setup.php | 157 +------ 2 files changed, 410 insertions(+), 150 deletions(-) create mode 100644 htdocs/core/class/html.formsetup.class.php diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php new file mode 100644 index 00000000000..095cf0d8887 --- /dev/null +++ b/htdocs/core/class/html.formsetup.class.php @@ -0,0 +1,403 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +/** + * This class help you create setup render + */ +class formSetup{ + + /** + * @var DoliDB Database handler. + */ + public $db; + + /** @var formSetupItem[] */ + public $arrayOfParameters = array(); + + public $setupNotEmpty = 0; + + /** @var Translate */ + public $langs; + + /** @var Form */ + public $form; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db, $outputLangs = false) + { + global $langs; + $this->db = $db; + $this->form = new Form($this->db); + + if($outputLangs){ + $this->langs = $outputLangs; + } + else{ + $this->langs = $langs; + } + } + + /** + * @return string + */ + public function generateOutput($edit = false){ + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + + $out = ''; + $out.= ''; + $out.= ' '; + $out.= ' '; + $out.= ''; + + foreach ($this->arrayOfParameters as $const => $item) { + $out.= $this->generateLineOutput($item, $edit); + } + + $out.= '
    '.$this->langs->trans("Parameter").''.$this->langs->trans("Value").'
    '; + return $out; + } + + /** + * @param formSetupItem $item + * @param bool $edit + * @return string + */ + public function generateLineOutput($item, $edit = false){ + + $out = ''; + if ($item->enabled==1) { + $this->setupNotEmpty++; + $out.= ''; + + $out.= ''; + $out.= ''; + $out.= $this->form->textwithpicto($item->getNameText(), $item->getHelpText(), 1, 'info', '', 0, 3, 'tootips'.$item->confKey); + $out.= ''; + $out.= ''; + + $out.= ''; + + if($edit){ + $item->generateInputField(); + } + else{ + $item->generateOutputField(); + } + + if(!empty($item->errors)){ + // TODO : move set event message in a methode to be called by cards not by this class + setEventMessages(null, $item->errors, 'errors'); + } + + $out.= ''; + $out.= ''; + } + + return $out; + } + + + /** + * @param string $confKey + * @param array $params + * @ + */ + public function addItemsFromParamsArray($params){ + + if(!array($params)){ return false; } + + foreach ($params as $confKey => $param){ + $this->addItemFromParams($confKey, $param); // todo manage error + } + } + + + /** + * From old + * @param string $confKey + * @param array $params + */ + public function addItemFromParams($confKey, $params){ + + if(empty($confKey) || !empty($params['type'])){ return false; } + + /* + * Exemple from old module builder setup page + * // 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1), + // 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1), + //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), + //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), + //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), + //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), + //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), + */ + + $item = new formSetupItem($this->db); + $item->type = $params['type']; + + if(!empty($params['enabled'])) { + $item->enabled = $params['enabled']; + } + + if(!empty($params['css'])){ + $item->enabled = $params['css']; + } + + $this->arrayOfParameters[$item->confKey] = $item; + + return true; + } + +} + + +class formSetupItem +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** @var Translate */ + public $langs; + + /** @var Form */ + public $form; + + /** @var string $confKey the conf key used in database */ + public $confKey; + + /** @var string|false $nameText */ + public $nameText = false; + + /** @var string $helpText */ + public $helpText = ''; + + /** @var bool|string set this var to override field output */ + public $fieldOverride = false; + + /** + * @var string $errors + */ + public $errors = array(); + + /** + * @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' + */ + public $type; + + public $enabled = 0; + + public $cssClass = ''; + + /** + * Constructor + * + * @param $confKey + */ + public function __construct($confKey) + { + global $langs, $db; + $this->db = $db; + $this->form = new Form($this->db); + $this->langs = $langs; + + $this->confKey = $confKey; + } + + public function getHelpText(){ + if(!empty($this->helpText)){ return $this->helpText; } + return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : ''); + } + + public function getNameText(){ + if(!empty($this->nameText)){ return $this->nameText; } + return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : ''); + } + + public function generateInputField(){ + global $conf, $user; + + if(!empty($this->fieldOverride)){ + return $this->fieldOverride; + } + + $out = ''; + + if ($this->type == 'textarea') { + $out.= '\n"; + } elseif ($this->type== 'html') { + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor($this->confKey, $conf->global->{$this->confKey}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor->Create(); + } elseif ($this->type == 'yesno') { + $out.= $this->form->selectyesno($this->confKey, $conf->global->{$this->confKey}, 1); + } elseif (preg_match('/emailtemplate:/', $this->type)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); + + $tmp = explode(':', $this->type); + $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang + //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); + $arrayOfMessageName = array(); + if (is_array($formmail->lines_model)) { + foreach ($formmail->lines_model as $modelMail) { + //var_dump($modelmail); + $moreonlabel = ''; + if (!empty($arrayOfMessageName[$modelMail->label])) { + $moreonlabel = ' (' . $this->langs->trans("SeveralLangugeVariatFound") . ')'; + } + // The 'label' is the key that is unique if we exclude the language + $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\(|\)/', '', $modelMail->label)) . $moreonlabel; + } + } + $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $conf->global->{$this->confKey}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + } elseif (preg_match('/category:/', $this->type)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($this->db); + + $tmp = explode(':', $this->type); + $out.= img_picto('', 'category', 'class="pictofixedwidth"'); + $out.= $formother->select_categories($tmp[1], $conf->global->{$this->confKey}, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + } elseif (preg_match('/thirdparty_type/', $this->type)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($this->db); + $out.= $formcompany->selectProspectCustomerType($conf->global->{$this->confKey}, $this->confKey); + } elseif ($this->type == 'securekey') { + $out.= ''; + if (!empty($conf->use_javascript_ajax)) { + $out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"'); + } + if (!empty($conf->use_javascript_ajax)) { + $out.= "\n".''; + } + } elseif ($this->type == 'product') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $selected = (empty($conf->global->{$this->confKey}) ? '' : $conf->global->{$this->confKey}); + $this->form->select_produits($selected, $this->confKey, '', 0); + } + } else { + $out.= ''; + } + + return $out; + } + + + /** + * add error + * @param array|string $errors + */ + public function setErrors($errors){ + if(is_array($errors)){ + if(!empty($errors)){ + foreach ($errors as $error){ + $this->setErrors($error); + } + } + } + elseif(!empty($errors)){ + $this->errors[] = $errors; + } + } + + public function generateOutputField(){ + global $conf, $user; + + if(!empty($this->fieldOverride)){ + return $this->fieldOverride; + } + + $out = ''; + + if ($this->type == 'textarea') { + print dol_nl2br($conf->global->{$this->confKey}); + } elseif ($this->type== 'html') { + print $conf->global->{$this->confKey}; + } elseif ($this->type == 'yesno') { + print ajax_constantonoff($this->confKey); + } elseif (preg_match('/emailtemplate:/', $this->type)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); + + $tmp = explode(':', $this->type); + + $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $conf->global->{$this->confKey}); + if ($template<0) { + $this->setErrors($formmail->errors); + } + print $this->langs->trans($template->label); + } elseif (preg_match('/category:/', $this->type)) { + $c = new Categorie($this->db); + $result = $c->fetch($conf->global->{$this->confKey}); + if ($result < 0) { + $this->setErrors($c->errors); + } + $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text + $toprint = array(); + foreach ($ways as $way) { + $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; + } + print '
      ' . implode(' ', $toprint) . '
    '; + } elseif (preg_match('/thirdparty_type/', $this->type)) { + if ($conf->global->{$this->confKey}==2) { + print $this->langs->trans("Prospect"); + } elseif ($conf->global->{$this->confKey}==3) { + print $this->langs->trans("ProspectCustomer"); + } elseif ($conf->global->{$this->confKey}==1) { + print $this->langs->trans("Customer"); + } elseif ($conf->global->{$this->confKey}==0) { + print $this->langs->trans("NorProspectNorCustomer"); + } + } elseif ($this->type == 'product') { + $product = new Product($this->db); + $resprod = $product->fetch($conf->global->{$this->confKey}); + if ($resprod > 0) { + print $product->ref; + } elseif ($resprod < 0) { + $this->setErrors($product->errors); + } + } else { + print $conf->global->{$this->confKey}; + } + + return $out; + } + +} diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 7c6c6b2c04e..390f45d955c 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -222,96 +222,17 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "mymo echo ''.$langs->trans("MyModuleSetupPage").'

    '; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; +$formSetup = new formSetup($db); + +$formSetup->addItemsFromParamsArray($arrayofparameters); + if ($action == 'edit') { print ''; print ''; print ''; - print ''; - print ''; - - foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; - } - } - print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; - print ''; - - if ($val['type'] == 'textarea') { - print '\n"; - } elseif ($val['type']== 'html') { - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); - $doleditor->Create(); - } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); - } elseif (preg_match('/emailtemplate:/', $val['type'])) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $tmp = explode(':', $val['type']); - $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang - //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); - $arrayofmessagename = array(); - if (is_array($formmail->lines_model)) { - foreach ($formmail->lines_model as $modelmail) { - //var_dump($modelmail); - $moreonlabel = ''; - if (!empty($arrayofmessagename[$modelmail->label])) { - $moreonlabel = ' (' . $langs->trans("SeveralLangugeVariatFound") . ')'; - } - // The 'label' is the key that is unique if we exclude the language - $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel; - } - } - print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); - } elseif (preg_match('/category:/', $val['type'])) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - $formother = new FormOther($db); - - $tmp = explode(':', $val['type']); - print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); - } elseif (preg_match('/thirdparty_type/', $val['type'])) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; - $formcompany = new FormCompany($db); - print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); - } elseif ($val['type'] == 'securekey') { - print ''; - if (!empty($conf->use_javascript_ajax)) { - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"'); - } - if (!empty($conf->use_javascript_ajax)) { - print "\n".''; - } - } elseif ($val['type'] == 'product') { - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); - $form->select_produits($selected, $constname, '', 0); - } - } else { - print ''; - } - print '
    '; + print $formSetup->generateOutput(true); print '
    '; print ''; @@ -321,72 +242,8 @@ if ($action == 'edit') { print '
    '; } else { if (!empty($arrayofparameters)) { - print ''; - print ''; - foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; - } - } - - print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print $form->textwithpicto($langs->trans($constname), $tooltiphelp); - print ''; - - if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); - } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; - } elseif ($val['type'] == 'yesno') { - print ajax_constantonoff($constname); - } elseif (preg_match('/emailtemplate:/', $val['type'])) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $tmp = explode(':', $val['type']); - - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); - if ($template<0) { - setEventMessages(null, $formmail->errors, 'errors'); - } - print $langs->trans($template->label); - } elseif (preg_match('/category:/', $val['type'])) { - $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); - if ($result < 0) { - setEventMessages(null, $c->errors, 'errors'); - } - $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text - $toprint = array(); - foreach ($ways as $way) { - $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; - } - print '
      ' . implode(' ', $toprint) . '
    '; - } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { - print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { - print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { - print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { - print $langs->trans("NorProspectNorCustomer"); - } - } elseif ($val['type'] == 'product') { - $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); - if ($resprod > 0) { - print $product->ref; - } elseif ($resprod < 0) { - setEventMessages(null, $object->errors, "errors"); - } - } else { - print $conf->global->{$constname}; - } - print '
    '; + print $formSetup->generateOutput(); print '
    '; print ''.$langs->trans("Modify").''; From fdcb9674d8470419daddb3c1b970113117f6a46b Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sun, 24 Oct 2021 02:09:49 +0200 Subject: [PATCH 068/490] Remove prints --- htdocs/core/class/html.formsetup.class.php | 38 +++++++++++----------- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 095cf0d8887..27b0e3fb615 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -69,7 +69,7 @@ class formSetup{ $out.= ' '.$this->langs->trans("Value").''; $out.= ''; - foreach ($this->arrayOfParameters as $const => $item) { + foreach ($this->arrayOfParameters as $item) { $out.= $this->generateLineOutput($item, $edit); } @@ -98,10 +98,10 @@ class formSetup{ $out.= ''; if($edit){ - $item->generateInputField(); + $out.= $item->generateInputField(); } else{ - $item->generateOutputField(); + $out.= $item->generateOutputField(); } if(!empty($item->errors)){ @@ -125,7 +125,6 @@ class formSetup{ public function addItemsFromParamsArray($params){ if(!array($params)){ return false; } - foreach ($params as $confKey => $param){ $this->addItemFromParams($confKey, $param); // todo manage error } @@ -139,7 +138,7 @@ class formSetup{ */ public function addItemFromParams($confKey, $params){ - if(empty($confKey) || !empty($params['type'])){ return false; } + if(empty($confKey) || empty($params['type'])){ return false; } /* * Exemple from old module builder setup page @@ -155,13 +154,14 @@ class formSetup{ $item = new formSetupItem($this->db); $item->type = $params['type']; + $item->confKey = $confKey; if(!empty($params['enabled'])) { $item->enabled = $params['enabled']; } if(!empty($params['css'])){ - $item->enabled = $params['css']; + $item->cssClass = $params['css']; } $this->arrayOfParameters[$item->confKey] = $item; @@ -233,7 +233,7 @@ class formSetupItem public function getNameText(){ if(!empty($this->nameText)){ return $this->nameText; } - return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : ''); + return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey',$this->confKey)); } public function generateInputField(){ @@ -313,7 +313,7 @@ class formSetupItem $this->form->select_produits($selected, $this->confKey, '', 0); } } else { - $out.= ''; + $out.= ''; } return $out; @@ -347,11 +347,11 @@ class formSetupItem $out = ''; if ($this->type == 'textarea') { - print dol_nl2br($conf->global->{$this->confKey}); + $out.= dol_nl2br($conf->global->{$this->confKey}); } elseif ($this->type== 'html') { - print $conf->global->{$this->confKey}; + $out.= $conf->global->{$this->confKey}; } elseif ($this->type == 'yesno') { - print ajax_constantonoff($this->confKey); + $out.= ajax_constantonoff($this->confKey); } elseif (preg_match('/emailtemplate:/', $this->type)) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($this->db); @@ -362,7 +362,7 @@ class formSetupItem if ($template<0) { $this->setErrors($formmail->errors); } - print $this->langs->trans($template->label); + $out.= $this->langs->trans($template->label); } elseif (preg_match('/category:/', $this->type)) { $c = new Categorie($this->db); $result = $c->fetch($conf->global->{$this->confKey}); @@ -374,27 +374,27 @@ class formSetupItem foreach ($ways as $way) { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; } - print '
      ' . implode(' ', $toprint) . '
    '; + $out.= '
      ' . implode(' ', $toprint) . '
    '; } elseif (preg_match('/thirdparty_type/', $this->type)) { if ($conf->global->{$this->confKey}==2) { - print $this->langs->trans("Prospect"); + $out.= $this->langs->trans("Prospect"); } elseif ($conf->global->{$this->confKey}==3) { - print $this->langs->trans("ProspectCustomer"); + $out.= $this->langs->trans("ProspectCustomer"); } elseif ($conf->global->{$this->confKey}==1) { - print $this->langs->trans("Customer"); + $out.= $this->langs->trans("Customer"); } elseif ($conf->global->{$this->confKey}==0) { - print $this->langs->trans("NorProspectNorCustomer"); + $out.= $this->langs->trans("NorProspectNorCustomer"); } } elseif ($this->type == 'product') { $product = new Product($this->db); $resprod = $product->fetch($conf->global->{$this->confKey}); if ($resprod > 0) { - print $product->ref; + $out.= $product->ref; } elseif ($resprod < 0) { $this->setErrors($product->errors); } } else { - print $conf->global->{$this->confKey}; + $out.= $conf->global->{$this->confKey}; } return $out; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f75ba12abe5..96fba681373 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2198,3 +2198,4 @@ SkinAndColors=Skin and colors IfYouUseASecondTaxYouMustSetYouUseTheMainTax=If you want to use a second tax, you must enable also the first sales tax IfYouUseAThirdTaxYouMustSetYouUseTheMainTax=If you want to use a third tax, you must enable also the first sales tax PDF_USE_1A=Generate PDF with PDF/A-1b format +MissingTranslationForConfKey = Missing translation for %s From 61576dad539cc363fa3efdfbb55e9f9512cb5cf7 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 24 Oct 2021 00:17:18 +0000 Subject: [PATCH 069/490] Fixing style errors. --- htdocs/core/class/html.formsetup.class.php | 73 ++++++++++++---------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 27b0e3fb615..70dd11e47ae 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -19,7 +19,8 @@ /** * This class help you create setup render */ -class formSetup{ +class formSetup +{ /** * @var DoliDB Database handler. @@ -48,10 +49,9 @@ class formSetup{ $this->db = $db; $this->form = new Form($this->db); - if($outputLangs){ + if ($outputLangs) { $this->langs = $outputLangs; - } - else{ + } else { $this->langs = $langs; } } @@ -59,7 +59,8 @@ class formSetup{ /** * @return string */ - public function generateOutput($edit = false){ + public function generateOutput($edit = false) + { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; @@ -82,7 +83,8 @@ class formSetup{ * @param bool $edit * @return string */ - public function generateLineOutput($item, $edit = false){ + public function generateLineOutput($item, $edit = false) + { $out = ''; if ($item->enabled==1) { @@ -97,14 +99,13 @@ class formSetup{ $out.= ''; - if($edit){ + if ($edit) { $out.= $item->generateInputField(); - } - else{ + } else { $out.= $item->generateOutputField(); } - if(!empty($item->errors)){ + if (!empty($item->errors)) { // TODO : move set event message in a methode to be called by cards not by this class setEventMessages(null, $item->errors, 'errors'); } @@ -122,10 +123,11 @@ class formSetup{ * @param array $params * @ */ - public function addItemsFromParamsArray($params){ + public function addItemsFromParamsArray($params) + { - if(!array($params)){ return false; } - foreach ($params as $confKey => $param){ + if (!array($params)) { return false; } + foreach ($params as $confKey => $param) { $this->addItemFromParams($confKey, $param); // todo manage error } } @@ -136,9 +138,10 @@ class formSetup{ * @param string $confKey * @param array $params */ - public function addItemFromParams($confKey, $params){ + public function addItemFromParams($confKey, $params) + { - if(empty($confKey) || empty($params['type'])){ return false; } + if (empty($confKey) || empty($params['type'])) { return false; } /* * Exemple from old module builder setup page @@ -156,11 +159,11 @@ class formSetup{ $item->type = $params['type']; $item->confKey = $confKey; - if(!empty($params['enabled'])) { + if (!empty($params['enabled'])) { $item->enabled = $params['enabled']; } - if(!empty($params['css'])){ + if (!empty($params['css'])) { $item->cssClass = $params['css']; } @@ -168,7 +171,6 @@ class formSetup{ return true; } - } @@ -226,20 +228,23 @@ class formSetupItem $this->confKey = $confKey; } - public function getHelpText(){ - if(!empty($this->helpText)){ return $this->helpText; } + public function getHelpText() + { + if (!empty($this->helpText)) { return $this->helpText; } return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : ''); } - public function getNameText(){ - if(!empty($this->nameText)){ return $this->nameText; } - return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey',$this->confKey)); + public function getNameText() + { + if (!empty($this->nameText)) { return $this->nameText; } + return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey', $this->confKey)); } - public function generateInputField(){ + public function generateInputField() + { global $conf, $user; - if(!empty($this->fieldOverride)){ + if (!empty($this->fieldOverride)) { return $this->fieldOverride; } @@ -324,23 +329,24 @@ class formSetupItem * add error * @param array|string $errors */ - public function setErrors($errors){ - if(is_array($errors)){ - if(!empty($errors)){ - foreach ($errors as $error){ + public function setErrors($errors) + { + if (is_array($errors)) { + if (!empty($errors)) { + foreach ($errors as $error) { $this->setErrors($error); } } - } - elseif(!empty($errors)){ + } elseif (!empty($errors)) { $this->errors[] = $errors; } } - public function generateOutputField(){ + public function generateOutputField() + { global $conf, $user; - if(!empty($this->fieldOverride)){ + if (!empty($this->fieldOverride)) { return $this->fieldOverride; } @@ -399,5 +405,4 @@ class formSetupItem return $out; } - } From 3fae8d1756c5653f295194a5c40eac7900716de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Oct 2021 09:25:35 +0200 Subject: [PATCH 070/490] fix warnings --- htdocs/eventorganization/conferenceorbooth_list.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 0deb1707cfc..198f169a390 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -421,7 +421,7 @@ if ($projectid > 0) { // Show message $message = 'global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...'); + $message .= '&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')); $message .= "&project=".$projectid.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; print $message; print ""; @@ -433,7 +433,7 @@ if ($projectid > 0) { //print ''; print ''; $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.((int) $project->id); - $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.((int) $project->id), 'md5'); + $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $project->id), 'md5'); $linksuggest .= '&securekey='.urlencode($encodedsecurekey); //print ''; + } print ''; } From 2436f0967b9826aee392f8e4f20c204003616354 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Oct 2021 14:37:15 +0200 Subject: [PATCH 149/490] Fix translation of Nature of member in import. --- htdocs/core/modules/modAdherent.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index d620c6244b7..66cc9799a6b 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -286,7 +286,7 @@ class modAdherent extends DolibarrModules $this->export_label[$r] = 'MembersAndSubscriptions'; $this->export_permission[$r] = array(array("adherent", "export")); $this->export_fields_array[$r] = array( - 'a.rowid'=>'Id', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'Nature', + 'a.rowid'=>'Id', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'MemberNature', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'd.nom'=>"State", 'co.code'=>"CountryCode", 'co.label'=>"Country", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datevalid'=>'DateValidation', @@ -339,7 +339,7 @@ class modAdherent extends DolibarrModules $this->import_tables_creator_array[$r] = array('a'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r] = array( 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname*", 'a.firstname'=>"Firstname", 'a.gender'=>"Gender", 'a.login'=>"Login*", "a.pass"=>"Password", - "a.fk_adherent_type"=>"MemberType*", 'a.morphy'=>'Nature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", + "a.fk_adherent_type"=>"MemberType*", 'a.morphy'=>'MemberNature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'a.state_id'=>'StateId', 'a.country'=>"CountryId", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status*", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription' From 7393abea8f816643a56b98af31c792831cf50e76 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Oct 2021 14:42:26 +0200 Subject: [PATCH 150/490] Fix phpcs --- htdocs/contact/list.php | 2 +- htdocs/core/modules/mailings/modules_mailings.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 48cc6fafa61..7397cf8b61f 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -345,7 +345,7 @@ $sql .= " co.label as country, co.code as country_code"; if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } -if(!empty($conf->mailing->enabled)) { +if (!empty($conf->mailing->enabled)) { $sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) as unsubscribed"; } // Add fields from hooks diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 1a533591b18..1250c7a9550 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -213,7 +213,7 @@ class MailingTargets // This can't be abstract as it is used for some method $sql .= " AND source_type='thirdparty'"; dol_syslog(__METHOD__.": mailing update status to display thirdparty mail that do not want to be contacted"); $result=$this->db->query($sql); - + //Update the status to show contact mail that don't want to be contacted anymore' $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut=3"; @@ -222,7 +222,7 @@ class MailingTargets // This can't be abstract as it is used for some method dol_syslog(__METHOD__.": mailing update status to display contact mail that do not want to be contacted",LOG_DEBUG); $result=$this->db->query($sql); */ - + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut=3"; $sql .= " WHERE fk_mailing=".((int) $mailing_id)." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))"; From e4b3dda7f0e9cae4e1e0326368ccfc89b4cf68e3 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Tue, 26 Oct 2021 15:27:12 +0200 Subject: [PATCH 151/490] Update functions.lib.php FIX : Duplicate entry in array FIX : Unasigned variable FIX : Type mismatch FIX : Wrong variable --- htdocs/core/lib/functions.lib.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 897b248824f..d6d8bc8600f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2390,7 +2390,7 @@ 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 - dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); + 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 anymore. @@ -3659,9 +3659,9 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right', 'trip'=>'wallet', 'expensereport'=>'wallet', 'group'=>'users', 'movement'=>'people-carry', 'sign-out'=>'sign-out-alt', - 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'switch_on_red'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bookmark'=>'star', - 'bank'=>'university', 'close_title'=>'times', 'delete'=>'trash', 'edit'=>'pencil-alt', 'filter'=>'filter', - 'list-alt'=>'list-alt', 'calendar'=>'calendar-alt', 'calendarmonth'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarmonth'=>'calendar-alt', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table', + 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'switch_on_red'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', + 'bank'=>'university', 'close_title'=>'times', 'delete'=>'trash', 'filter'=>'filter', + 'list-alt'=>'list-alt', 'calendar'=>'calendar-alt', 'calendarmonth'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table', 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice', 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'other'=>'square', @@ -3671,7 +3671,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', 'refresh'=>'redo', 'region'=>'map-marked', 'resource'=>'laptop-house', 'state'=>'map-marked-alt', 'security'=>'key', 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', - 'supplier'=>'building', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', + 'supplier'=>'building', 'technic'=>'cogs', 'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt', 'uncheck'=>'times', 'uparrow'=>'share', 'vcard'=>'address-card', @@ -4462,7 +4462,7 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss $result = ($nodiv ? '' : '
    ').' '.$text.($nodiv ? '' : '
    '); if ($textfordropdown) { - $tmpresult .= ''.$langs->trans($textfordropdown).' '.img_picto($langs->trans($textfordropdown), '1downarrow').''; + $tmpresult = ''.$langs->trans($textfordropdown).' '.img_picto($langs->trans($textfordropdown), '1downarrow').''; $tmpresult .= ' - '; print "\n"; @@ -612,9 +581,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea '; } } - print ' '.$alreadyconsumed; + print ' '.price2num($alreadyconsumed, 'MS'); print ''; // Warehouse print ''; print ''; + // Stock if ($conf->stock->enabled) { print ''; if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) { print img_warning($langs->trans('StockTooLow')).' '; } - print $tmpproduct->stock_reel; // Available + print price2num($tmpproduct->stock_reel, 'MS'); // Available print ''; } + // Lot if ($conf->productbatch->enabled) { - print ''; // Lot + print ''; } + // Action delete line if ($permissiontodelete) { - $href = $_SERVER["PHP_SELF"]; - $href .= '?id='.$object->id; - $href .= '&action=deleteline'; - $href .= '&lineid='.$line->id; + $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id); print ''; - print '
    '; - print img_picto('', "delete"); + print ''; + print img_picto('', 'delete'); print ''; print ''; } @@ -911,16 +919,26 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Show detailed of already consumed with js code to collapse foreach ($arrayoflines as $line2) { print ''; + + // Date print ''; $tmpstockmovement->id = $line2['fk_stock_movement']; print ''.img_picto($langs->trans("StockMovement"), 'movement', 'class="paddingright"').''; print dol_print_date($line2['date'], 'dayhour', 'tzuserrel'); print ''; + + // Already consumed print ''; + + // Qty print ''.$line2['qty'].''; + + // Cost price if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print ''; } + + // Warehouse print ''; if ($line2['fk_warehouse'] > 0) { $result = $tmpwarehouse->fetch($line2['fk_warehouse']); @@ -929,6 +947,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } print ''; + + // Stock + if ($conf->stock->enabled) { + print ''; + } + // Lot Batch print ''; if ($line2['batch'] != '') { @@ -936,6 +960,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $tmpbatch->getNomUrl(1); } print ''; + + // Action delete line + if ($permissiontodelete) { + print ''; + } + print ''; } @@ -954,11 +984,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $disable = 'disabled'; } + // Qty print ''; + + // Cost if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print ''; } + + // Already consumed print ''; + + // Warehouse print ''; if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { if (empty($line->disable_stock_change)) { @@ -970,10 +1007,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } else { print ''.$langs->trans("NoStockChangeOnServices").''; } - // Lot / Batch print ''; + + // Stock + if ($conf->stock->enabled) { + print ''; + } + + // Lot / Batch if ($conf->productbatch->enabled) { - print ''; + print 'aaa'; if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); print ''; @@ -981,6 +1024,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ''; } + + // Action delete line + if ($permissiontodelete) { + print ''; + } + print ''; } } @@ -1003,13 +1052,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $nblinetoproduce++; } } - $newlinetext = ''; - if ($object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall') { - if ($nblinetoproduce == 0 || $object->mrptype == 1) { - $newlinetext = ''.$langs->trans("AddNewProduceLines").''; - } + + $newcardbutton = ''; + $url = $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addproduceline&token='.newToken(); + $permissiontoaddaproductline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall'; + $parameters = array('morecss'=>'reposition'); + if ($nblinetoproduce == 0 || $object->mrptype == 1) { + $newcardbutton = dolGetButtonTitle($langs->trans('AddNewProduceLines'), '', 'fa fa-plus-circle size15x', $url, '', $permissiontoaddaproductline, $parameters); } - print load_fiche_titre($langs->trans('Production'), '', '', 0, '', '', $newlinetext); + + print load_fiche_titre($langs->trans('Production'), $newcardbutton, '', 0, '', ''); print '
    '; print ''; @@ -1044,7 +1096,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; print ''; print ''; // Qty print ''; @@ -1052,10 +1104,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Qty already produced - print ''; + print ''; // Lot - serial if ($conf->productbatch->enabled) { @@ -1155,7 +1207,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $href .= '&action=deleteline'; $href .= '&lineid='.$line->id; print ''; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index e485ea3d543..ce9c26c5480 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -451,9 +451,10 @@ if ($action == 'create') { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index 36897c7aef0..db6560a9970 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -81,9 +81,10 @@ if (!empty($conf->projet->enabled)) { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index e028c49396b..7d261a73f7a 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -671,9 +671,10 @@ if ($object->id > 0) { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 96953d93824..de6ccc2c7e7 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1351,9 +1351,10 @@ if ($action == 'create') { if (!empty($objectsrc->fk_project)) { $proj = new Project($db); $proj->fetch($objectsrc->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index 1c368dc9caa..a7cec515e29 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -172,9 +172,10 @@ if ($id > 0 || !empty($ref)) { if (!empty($objectsrc->fk_project)) { $proj = new Project($db); $proj->fetch($objectsrc->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index a75dd432082..725c23ae738 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -149,9 +149,10 @@ if ($id > 0 || !empty($ref)) { if (!empty($objectsrc->fk_project)) { $proj = new Project($db); $proj->fetch($objectsrc->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index e6a8a02d59a..7b74283d90a 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -349,9 +349,7 @@ if (!$ret) { if (!empty($act->fk_project)) { $proj = new Project($db); $proj->fetch($act->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); if ($proj->title) { $morehtmlref .= ' - '.$proj->title; } @@ -533,9 +531,10 @@ if (!$ret) { if (!empty($fichinter->fk_project)) { $proj = new Project($db); $proj->fetch($fichinter->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 0d47a90796f..931605dace0 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -750,9 +750,10 @@ if ($id) { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php index 47d03e62380..3181770cfcc 100644 --- a/htdocs/salaries/document.php +++ b/htdocs/salaries/document.php @@ -197,9 +197,10 @@ if ($object->id) { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/salaries/info.php b/htdocs/salaries/info.php index 173e03c2c7d..b6a818e6f54 100644 --- a/htdocs/salaries/info.php +++ b/htdocs/salaries/info.php @@ -160,9 +160,10 @@ if (!empty($conf->projet->enabled)) { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 6fc7f4df73a..a5837c2557f 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1492,9 +1492,10 @@ if ($action == 'create') { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index faa9127779c..f1756f17814 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -157,9 +157,10 @@ if ($id > 0 || !empty($ref)) { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 3d5ce3fbb47..a8b85fc25b5 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -144,9 +144,10 @@ if ($object->id > 0) { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index 7d6d72276d8..0b796937d2e 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -99,9 +99,10 @@ if (!empty($conf->projet->enabled)) { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index 6466c6f42cb..5a19a94b402 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -128,9 +128,10 @@ if ($id > 0 || !empty($ref)) { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; + $morehtmlref .= ' : '.$proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.$proj->title; + } } else { $morehtmlref .= ''; } diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index ab23a55e525..f66f2c51f49 100755 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -111,8 +111,8 @@ class Workstation extends CommonObject 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>512, 'notnull'=>-1, 'visible'=>-2,), 'nb_operators_required' => array('type'=>'integer', 'label'=>'NbOperatorsRequired', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1,), - 'thm_operator_estimated' => array('type'=>'double', 'help'=>'THMEstimatedHelp','label'=>'THMOperatorEstimated', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1,), - 'thm_machine_estimated' => array('type'=>'double', 'help'=>'THMEstimatedHelp', 'label'=>'THMMachineEstimated', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1,), + 'thm_operator_estimated' => array('type'=>'double', 'help'=>'THMOperatorEstimatedHelp','label'=>'THMOperatorEstimated', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1,), + 'thm_machine_estimated' => array('type'=>'double', 'help'=>'THMMachineEstimatedHelp', 'label'=>'THMMachineEstimated', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>1,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'default'=>1, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled'),), ); public $rowid; From 0cb6c7296ada2733a23c7969d9ba120a0202f315 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 29 Oct 2021 11:19:38 +0200 Subject: [PATCH 195/490] FIX look and feel --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 195b2957e76..5fdf4a4ef37 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2718,7 +2718,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
    '; print '
    '; - print '
    '; - print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300'); + print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 1, array(), 0, '1', 0, 'maxwidth300'); print ''; // Warehouse - print ''; print ''; + print ''; print ''; - print ''; + print ''; print img_picto('', "delete"); print ''; print '
    '; + print '
    '; // Tags / categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { From 72069dc2086d6c74e00d3df1423b00ed963e8cb2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Oct 2021 11:35:09 +0200 Subject: [PATCH 196/490] Fix css --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 195b2957e76..7c820f92e8e 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2489,7 +2489,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
    '; print '
    '; - print '
    '; + print '
    '; // Type Prospect/Customer/Supplier print ''; // Progression print ''; print ''; -print ''; +print ''; print ''; print '
    '.$langs->trans('NatureOfThirdParty').''; @@ -2718,7 +2718,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
    '; print '
    '; - print ''; + print '
    '; // Tags / categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { From 1336d3e7910904a79d910671d3420c973d453266 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 29 Oct 2021 12:25:50 +0200 Subject: [PATCH 197/490] Fix: Import don't work if extrafield is separator --- htdocs/core/modules/modAdherent.class.php | 2 +- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modProjet.class.php | 2 +- htdocs/core/modules/modResource.class.php | 2 +- htdocs/core/modules/modService.class.php | 2 +- htdocs/core/modules/modSociete.class.php | 4 ++-- htdocs/core/modules/modUser.class.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 911a4bbd5b9..deaa1bd70b7 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -329,7 +329,7 @@ class modAdherent extends DolibarrModules 'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b029448cd58..a560bb3ee46 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -491,7 +491,7 @@ class modProduct extends DolibarrModules if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 77d339da035..7f71c30a6ac 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -293,7 +293,7 @@ class modProjet extends DolibarrModules $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation"); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 0d1353076ec..62c86e2e2a8 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -265,7 +265,7 @@ class modResource extends DolibarrModules $this->import_tables_array[$r] = array('r'=>MAIN_DB_PREFIX.'resource', 'extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array('r.ref'=>"ResourceFormLabel_ref*", 'r.fk_code_type_resource'=>'ResourceTypeCode', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>'DateCreation'); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index b7933bcf3f4..dd8e211ce13 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -459,7 +459,7 @@ class modService extends DolibarrModules if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'product' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b0346054323..bd947b59fd7 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -453,7 +453,7 @@ class modSociete extends DolibarrModules ); if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->import_fields_array[$r]['s.price_level'] = 'PriceLevel'; // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -602,7 +602,7 @@ class modSociete extends DolibarrModules 's.note_public' => "NotePublic" ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on an old database (during a migration for example) { diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index e5ba3289d05..9859d0e4830 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -291,7 +291,7 @@ class modUser extends DolibarrModules 'u.statut'=>'Status' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'user' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { From be6b1e29ad69840c909bc4876901b8bb7fc26326 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Oct 2021 13:32:32 +0200 Subject: [PATCH 198/490] Add logs --- htdocs/core/lib/geturl.lib.php | 5 ++++- htdocs/societe/tpl/linesalesrepresentative.tpl.php | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 3398189a771..70eca219e03 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -249,7 +249,10 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request dol_syslog("getURLContent request=".$request); - //dol_syslog("getURLContent response =".response); // This may contains binary data, so we dont output it + if (!empty($conf->global->MAIN_GETURLCONTENT_OUTPUT_RESPONSE)) { + // This may contains binary data, so we dont output reponse by default. + dol_syslog("getURLContent response =".response); + } dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it $rep = array(); diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index a885cab03ed..125264e14d7 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -21,6 +21,8 @@ if (empty($conf) || !is_object($conf)) { exit; } +print ''; + // Sale representative print ''; + if($subelement != 'project') { + if (!empty($conf->projet->enabled) && !$this->ispublic) { + $formproject = new FormProjets($this->db); + print ''; + } } // Attached files diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 08d9330a4c6..32d9cdfbb78 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1,7 +1,8 @@ - * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2018 Laurent Destailleur +/* Copyright (C) 2013-2016 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2018 Laurent Destailleur + * Copyright (C) 2021 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 @@ -192,9 +193,15 @@ if (empty($reshook)) { $result = $object->add_contact($contactid, GETPOST("type"), 'external'); } - // altairis: link ticket to project - if (GETPOST('projectid') > 0) { - $object->setProject(GETPOST('projectid')); + // Link ticket to project + if(GETPOST('origin', 'alpha') == 'projet') { + $projectid = GETPOST('originid', 'int'); + } else { + $projectid = GETPOST('projectid', 'int'); + } + + if ($projectid > 0) { + $object->setProject($projectid); } // Auto assign user From 3242400855c5fb399c71782bed990f7d3195d559 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 31 Oct 2021 06:26:41 +0100 Subject: [PATCH 210/490] Clean module HRM --- htdocs/core/modules/modHRM.class.php | 126 +++++++++++++-------------- 1 file changed, 60 insertions(+), 66 deletions(-) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index d6870244521..d03ede8a55e 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2021 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 @@ -13,25 +13,27 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * or see https://www.gnu.org/ */ /** - * \file htdocs/core/modules/modHRM.class.php - * \ingroup HRM - * \brief Description and activation file for the module HRM + * \defgroup HRM Module hrm + * \file htdocs/core/modules/modHRM.class.php + * \ingroup HRM + * \brief Description and activation file for the module HRM */ include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php"; + /** - * Class to describe and activate the HRM module + * Description and activation class for module HRM */ class modHRM extends DolibarrModules { /** - * Constructor. - * Define names, constants, directories, boxes, permissions + * Constructor. Define names, constants, directories, boxes, permissions * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ public function __construct($db) { @@ -39,34 +41,27 @@ class modHRM extends DolibarrModules $this->db = $db; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). $this->numero = 4000; + // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'hrm'; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "hr"; $this->module_position = '50'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModulehrmDesc' not found (hrm is name of module). - $this->description = "hrm Description product "; - // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = "hrm Description long"; - - // Author - $this->editor_name = 'Editor name'; - $this->editor_url = 'https://www.example.com'; - - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = '1.0'; - // Url to the file with your last numberversion of this module - //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; - - // Key used in llx_const table to save module status enabled/disabled (where HRMTEST is value of property name of module in uppercase) + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "HRM"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - // To use a supported fa-xxx css style of font awesome, use this->picto='xxx' $this->picto = 'hrm'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) @@ -110,32 +105,20 @@ class modHRM extends DolibarrModules $this->config_page_url = array("hrm.php"); // Dependencies - // A condition to hide module - $this->hidden = false; - // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->depends = array(); - $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) - $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) - - // The language file dedicated to your module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5, 6); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(11, 0); // Minimum version of Dolibarr required by module $this->langfiles = array("hrm"); - // Prerequisites - $this->phpmin = array(5, 6); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(11, -3); // Minimum version of Dolibarr required by module - - // Messages at activation - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - //$this->automatic_activation = array('FR'=>'HrmTestWasAutomaticallyActivatedBecauseOfYourCountryChoice'); - //$this->always_enabled = true; // If true, can't be disabled - // Constants - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array(1 => array('HRMTEST_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), - // 2 => array('HRMTEST_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) - // ); - $this->const = array(); + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); + // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) + $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') + $r = 0; if (!isset($conf->hrm) || !isset($conf->hrm->enabled)) { @@ -207,67 +190,78 @@ class modHRM extends DolibarrModules // ), ); - // Permissions provided by this module - $this->rights = array(); + + // Permissions + $this->rights = array(); // Permission array used by this module $r = 0; - // Add here entries to declare new permissions - /* BEGIN MODULEBUILDER PERMISSIONS */ // Skill / Job / Position - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + $this->rights[$r][0] = 4010; // Permission id (must not be already used) $this->rights[$r][1] = $langs->trans('ReadSkillJobPosition'); // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'all'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read) $r++; - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + + $this->rights[$r][0] = 4011; // Permission id (must not be already used) $this->rights[$r][1] = $langs->trans('CreateUpdateSkillJobPosition'); // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'all'; $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) $r++; - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + + $this->rights[$r][0] = 4012; // Permission id (must not be already used) $this->rights[$r][1] = $langs->trans('DeleteSkillJobPosition'); // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'all'; $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) $r++; //Eval - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + $this->rights[$r][0] = 4020; // Permission id (must not be already used) $this->rights[$r][1] = $langs->trans('ReadEval'); // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read) $r++; - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + + $this->rights[$r][0] = 4021; // Permission id (must not be already used) $this->rights[$r][1] = $langs->trans('CreateUpdateEval'); // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) $r++; - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + + $this->rights[$r][0] = 4022; // Permission id (must not be already used) $this->rights[$r][1] = $langs->trans('ValidateEval'); // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; $this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) $r++; - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + + $this->rights[$r][0] = 4023; // Permission id (must not be already used) $this->rights[$r][1] = $langs->trans('DeleteEval'); // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) $r++; // Comparison - $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) + $this->rights[$r][0] = 4030; // Permission id (must not be already used) $this->rights[$r][1] = $langs->trans('SeeComparisonMenu'); // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'compare'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) $r++; } /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus - * (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Enabling module ('', 'noboxes') - * @return int if OK, 0 if KO + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @return int 1 if OK, 0 if KO */ public function init($options = '') { From 62ce27886b57391e3c1330c7eb87e20255e05816 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 31 Oct 2021 07:04:31 +0100 Subject: [PATCH 211/490] Remove useless language key --- htdocs/langs/en_US/hrm.lang | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index 430124cecba..29ceba717ce 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -23,8 +23,6 @@ HrmSetup = Hrm setup HrmSetupPage = Hrm setup page HRM_MAXRANK=Maximum rank for a skill HRM_DEFAULT_SKILL_DESCRIPTION=Default description of ranks when skill is created -HrmAbout = About Hrm -traduction_note=Translate deplacement=Shift DateEval=Evaluation date JobCard=Job card From 84c3c9d025712eb69b6de55a486ec64ca7ef0b39 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 31 Oct 2021 07:12:26 +0100 Subject: [PATCH 212/490] Remove useless language key --- htdocs/langs/en_US/hrm.lang | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index 29ceba717ce..56fcfba16de 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -80,11 +80,3 @@ NoEval=No evaluation done for this employee HowManyUserWithThisMaxNote=Number of users with this rank HighestRank=Highest rank SkillComparison=Skill comparison -ReadSkillJobPosition=Read skills / jobs / positions -CreateUpdateSkillJobPosition=Create / update skills / jobs / positions -DeleteSkillJobPosition=Delete skills / jobs / positions -ReadEval=Read evaluations -CreateUpdateEval=Create / update evaluations -ValidateEval=Validate evaluations -DeleteEval=Delete evaluations -SeeComparisonMenu=Access skills comparison menu From 70ed6331711a8ed0e50f0bac20bb65b405907d55 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 31 Oct 2021 07:23:34 +0100 Subject: [PATCH 213/490] Update label perms --- htdocs/core/modules/modHRM.class.php | 18 +++++++++--------- htdocs/langs/en_US/admin.lang | 8 ++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index d03ede8a55e..9c5e509ecd3 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -197,50 +197,50 @@ class modHRM extends DolibarrModules // Skill / Job / Position $this->rights[$r][0] = 4010; // Permission id (must not be already used) - $this->rights[$r][1] = $langs->trans('ReadSkillJobPosition'); // Permission label + $this->rights[$r][1] = 'Read skill/job/position'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'all'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read) $r++; $this->rights[$r][0] = 4011; // Permission id (must not be already used) - $this->rights[$r][1] = $langs->trans('CreateUpdateSkillJobPosition'); // Permission label + $this->rights[$r][1] = 'Create/modify skill/job/position'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'all'; $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) $r++; $this->rights[$r][0] = 4012; // Permission id (must not be already used) - $this->rights[$r][1] = $langs->trans('DeleteSkillJobPosition'); // Permission label + $this->rights[$r][1] = 'Delete skill/job/position'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'all'; $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) $r++; - //Eval + // Evaluation $this->rights[$r][0] = 4020; // Permission id (must not be already used) - $this->rights[$r][1] = $langs->trans('ReadEval'); // Permission label + $this->rights[$r][1] = 'Read evaluation'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read) $r++; $this->rights[$r][0] = 4021; // Permission id (must not be already used) - $this->rights[$r][1] = $langs->trans('CreateUpdateEval'); // Permission label + $this->rights[$r][1] = 'Create/modify evaluation'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) $r++; $this->rights[$r][0] = 4022; // Permission id (must not be already used) - $this->rights[$r][1] = $langs->trans('ValidateEval'); // Permission label + $this->rights[$r][1] = 'Validate evaluation'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; $this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) $r++; $this->rights[$r][0] = 4023; // Permission id (must not be already used) - $this->rights[$r][1] = $langs->trans('DeleteEval'); // Permission label + $this->rights[$r][1] = 'Delete evaluation'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) @@ -248,7 +248,7 @@ class modHRM extends DolibarrModules // Comparison $this->rights[$r][0] = 4030; // Permission id (must not be already used) - $this->rights[$r][1] = $langs->trans('SeeComparisonMenu'); // Permission label + $this->rights[$r][1] = 'See comparison menu'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'compare'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d9099f567fa..508d56a46c5 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -961,6 +961,14 @@ Permission4001=See employees Permission4002=Create employees Permission4003=Delete employees Permission4004=Export employees +Permission4010=Read skill/job/position +Permission4011=Create/modify skill/job/position +Permission4012=Delete skill/job/position +Permission4020=Read evaluation +Permission4021=Create/modify evaluation +Permission4022=Validate evaluation +Permission4023=Delete evaluation +Permission4030=See comparison menu Permission10001=Read website content Permission10002=Create/modify website content (html and javascript content) Permission10003=Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers. From 57a479e32838d039766a2c160834bcddb7a129e0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 31 Oct 2021 07:27:37 +0100 Subject: [PATCH 214/490] Remove useless language key --- htdocs/langs/en_US/hrm.lang | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index 56fcfba16de..8724bb805a6 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -19,8 +19,7 @@ Employees=Employees Employee=Employee NewEmployee=New employee ListOfEmployees=List of employees -HrmSetup = Hrm setup -HrmSetupPage = Hrm setup page +HrmSetup=HRM module setup HRM_MAXRANK=Maximum rank for a skill HRM_DEFAULT_SKILL_DESCRIPTION=Default description of ranks when skill is created deplacement=Shift From ca766c2e712a2e6e50b1e078541da8e0b70ee642 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sun, 31 Oct 2021 09:29:20 +0100 Subject: [PATCH 215/490] Factoring --- htdocs/core/class/html.formsetup.class.php | 73 +++++++++++++++++----- 1 file changed, 59 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index eb5a9710da1..219308bd5e6 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -63,11 +63,9 @@ class formSetup */ public function generateOutput($editMode = false) { - - $out = ''; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $out.= ''; + $out = ''; if ($editMode) { $out .= ''; } @@ -168,7 +166,7 @@ class formSetup */ $item = new formSetupItem($confKey); - $item->type = $params['type']; + $item->setTypeFromTypeString($params['type']); if (!empty($params['enabled'])) { $item->enabled = $params['enabled']; @@ -186,7 +184,7 @@ class formSetup /** * used to export param array for /core/actions_setmoduleoptions.inc.php template * @return array $arrayofparameters for /core/actions_setmoduleoptions.inc.php - * @deprecated + * @deprecated yes this method came deprecated because it exists only for manage setup convertion */ public function exportItemsAsParamsArray() { @@ -279,7 +277,7 @@ class formSetupItem * And set var as protected when its done configuration must be done by method * @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' */ - public $type = 'string'; + protected $type = 'string'; public $enabled = 1; @@ -349,14 +347,12 @@ class formSetupItem $out = ''; - if ($this->type == 'textarea') { - $out.= '\n"; + if ($this->type == 'title') { + $out.= $this->generateOutputField(); // title have no input + } elseif ($this->type == 'textarea') { + $out.= $this->generateInputFieldTextarea(); } elseif ($this->type== 'html') { - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); - $doleditor->Create(); + $out.= $this->generateInputFieldHtml(); } elseif ($this->type == 'yesno') { $out.= $this->form->selectyesno($this->confKey, $this->fieldValue, 1); } elseif (preg_match('/emailtemplate:/', $this->type)) { @@ -423,6 +419,42 @@ class formSetupItem return $out; } + /** + * generate input field for textarea + * @return string + */ + public function generateInputFieldTextarea() + { + $out = '\n"; + return $out; + } + /** + * generate input field for html + * @return string + */ + public function generateInputFieldHtml() + { + global $conf; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + return $doleditor->Create(1); + } + + /** + * set the type from string : used for old module builder setup conf style conversion and tests + * because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist + * to be sure we can manage evolution easily + * @param string $type possible values based on old module builder setup : 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' + * @deprecated yes this method came deprecated because it exists only for manage setup convertion + * @return bool + */ + public function setTypeFromTypeString($type) + { + $this->type = $type; + return true; + } /** * Add error @@ -459,7 +491,9 @@ class formSetupItem $out = ''; - if ($this->type == 'textarea') { + if ($this->type == 'title') { + // nothing to do + } elseif ($this->type == 'textarea') { $out.= dol_nl2br($this->fieldValue); } elseif ($this->type== 'html') { $out.= $this->fieldValue; @@ -609,4 +643,15 @@ class formSetupItem $this->type = 'category:'.$catType; return $this; } + + /** + * Set type of input as a simple title + * no data to store + * @return self + */ + public function setAsTitle() + { + $this->type = 'title'; + return $this; + } } From dcc98b6026df8c8f89705324952e906759800ba4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 12:54:08 +0100 Subject: [PATCH 216/490] Fix filter on product on statistic page --- htdocs/product/popuprop.php | 4 +-- htdocs/product/stats/card.php | 55 +++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 8ffae0bee8c..32a2cd08cc9 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -178,7 +178,7 @@ $arrayofmode = array( 'facture' => 'Facture' ); $title .= ' '.$form->selectarray('mode', $arrayofmode, $mode, 1); -$title .= ' '; +$title .= ' '; print ''; @@ -198,7 +198,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort print '
    '; print ''."\n"; // Loop on record // -------------------------------------------------------------------- $i = 0; -$totalarray = array(); $warehouse = new Entrepot($db); From 466f064d9a5a63e690ac3175ef5dbef6fb6d5326 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 30 Oct 2021 12:08:32 +0200 Subject: [PATCH 200/490] fixes to be pure markdown --- README-FR.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/README-FR.md b/README-FR.md index 81fdff13047..a67bf204076 100644 --- a/README-FR.md +++ b/README-FR.md @@ -8,12 +8,10 @@ Il est simple d'utilisation et modulaire, vous permettant de n'activez que les f ![ScreenShot](https://www.dolibarr.org/medias/dolibarr_screenshot1_1920x1080.jpg) - ## LICENCE Dolibarr est distribué sous les termes de la licence GNU General Public License v3+ ou supérieure. - ## INSTALLER DOLIBARR ### Configuration simple @@ -54,7 +52,6 @@ Vous pouvez aussi utiliser un serveur Web et une base de données prise en charg - Suivez les instructions de l'installateur - ## METTRE A JOUR DOLIBARR Pour mettre à jour Dolibarr depuis une vieille version vers celle ci: @@ -65,14 +62,12 @@ Pour mettre à jour Dolibarr depuis une vieille version vers celle ci: - Au prochain accès, Dolibarr proposera la page de "mise à jour" des données (si nécessaire). Si un fichier install.lock existe pour verrouiller le processus de mise à jour, il sera demandé de le supprimer manuellement (vous devriez trouver le fichier install.lock dans le répertoire utilisé pour stocker les documents générés ou transférés sur le serveur. Dans la plupart des cas, c'est le répertoire appelé "documents") -*Note: Le processus de migration peut être lancé manuellement et plusieurs fois, sans risque, en appelant la page /install/* - +Note: *Le processus de migration peut être lancé manuellement et plusieurs fois, sans risque, en appelant la page /install/* ## CE QUI EST NOUVEAU See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file. - ## CE QUE DOLIBARR PEUT FAIRE ### Modules principaux (tous optionnels) @@ -122,7 +117,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Peux être multi-société par ajout du module externe multi-société. - Plusieurs thèmes visuels. - Application simple à utiliser. -- Requiert PHP et MariaDb, Mysql ou Postgresql (Voir versions exactes sur https://wiki.dolibarr.org/index.php/Prérequis). +- Requiert PHP et MariaDb, Mysql ou Postgresql (Voir versions exactes sur [https://wiki.dolibarr.org/index.php/Prérequis](https://wiki.dolibarr.org/index.php/Prérequis)). - Compatible avec toutes les offres Cloud du marché respectant les prérequis de base de données et PHP. - APIs. - Génération PDF et ODT des éléments (factures, propositions commerciales, commandes, bons expéditions, etc...) @@ -142,7 +137,6 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) Dolibarr peut aussi être étendu à volonté avec l'ajout de module/applications externes développées par des développeus tiers, disponible sur [DoliStore](https://www.dolistore.com). - ## CE QUE DOLIBARR NE PEUT PAS (ENCORE) FAIRE Voici un liste de fonctionnalités pas encore gérées par Dolibarr: @@ -152,18 +146,15 @@ Voici un liste de fonctionnalités pas encore gérées par Dolibarr: - Dolibarr n'embarque pas de Webmail intégré nativement. - Dolibarr ne fait pas le café (pas encore). - ## DOCUMENTATION La documentation utilisateur, développeur et traducteur est disponible sous forme de ressources de la communauté via le site [Wiki](https://wiki.dolibarr.org). - ## CONTRIBUER Ce projet existe grâce à ses nombreux contributeurs [[Contribuer](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. - - +[![Dolibarr](https://opencollective.com/dolibarr/contributors.svg?width=890&button=false)](https://github.com/Dolibarr/dolibarr/graphs/contributors) ## CREDITS @@ -171,7 +162,6 @@ Dolibarr est le résultat du travail de nombreux contributeurs depuis des année Voir le fichier [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) - ## ACTUALITES ET RESEAUX SOCIAUX Suivez le projet Dolibarr project sur les réseaux francophones From 5f09f11a679bf2bc17e7313e1fd90b89a0d55cd2 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 30 Oct 2021 12:25:40 +0200 Subject: [PATCH 201/490] fixes to be pure markdown --- README.md | 123 +++++++++++++++++++++++++----------------------------- 1 file changed, 57 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 54fdf1e958b..b0f7a2c3761 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ You can use a web server and a supported database (MariaDB, MySQL or PostgreSQL) On GNU/Linux, first check if your distribution has already packaged Dolibarr. -#### Generic install steps: +#### Generic install steps - Check that your installed PHP version is supported [see PHP support](https://wiki.dolibarr.org/index.php/Releases). @@ -71,86 +71,87 @@ On GNU/Linux, first check if your distribution has already packaged Dolibarr. - Follow the installer instructions - ### Saas/Cloud setup -If you don't have time to install it yourself, you can try some commercial 'ready to use' Cloud offers (See https://saas.dolibarr.org). However, this third solution is not free. - +If you don't have time to install it yourself, you can try some commercial 'ready to use' Cloud offers (See [https://saas.dolibarr.org](https://saas.dolibarr.org)). However, this third solution is not free. ## UPGRADING Dolibarr supports upgrading, usually without the need for any (commercial) support (depending on if you use any commercial extensions). It supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate! - + - At first make a backup of your Dolibarr files & then [see](https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr) - Check that your installed PHP version is supported by the new version [see PHP support](./doc/phpmatrix.md). - Overwrite all old files from 'dolibarr' directory with files provided into the new version's package. - At first next access, Dolibarr will redirect you to the "install/" page to follow the upgrade process.  If an `install.lock` file exists to lock any other upgrade process, the application will ask you to remove the file manually (you should find the `install.lock` file in the directory used to store generated and uploaded documents, in most cases, it is the directory called "*documents*"). - ## WHAT'S NEW See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file. - ## FEATURES ### Main application/modules (all optional) -- Third-Parties Management: Customers, Prospects (Leads) and/or Suppliers + Contacts -- Members/Membership/Foundation management +- Third-Parties Management: Customers, Prospects (Leads) and/or Suppliers + Contacts +- Members/Membership/Foundation management - Product Management -- Products and/or Services catalog -- Stock / Warehouse management + Inventory -- Barcodes -- Batches / Lots / Serials -- Product Variants + Product Management + +- Products and/or Services catalog +- Stock / Warehouse management + Inventory +- Barcodes +- Batches / Lots / Serials +- Product Variants - Bill of Materials (BOM) -- Manufacturing Orders +- Manufacturing Orders - Customer/Sales Management -- Customers/Prospects + Contacts management -- Opportunities or Leads management -- Commercial proposals management -- Customer Orders management -- Contracts/Subscription management -- Interventions management -- Ticket System -- Shipping management -- Customer Invoices/Credit notes and payment management -- Point of Sale (POS) + Customer/Sales Management - Supplier/Purchase Management -- Suppliers/Vendors + Contacts -- Supplier (price) requests -- Purchase Orders management -- Delivery/Receiption -- Supplier Invoices/credit notes and payment management -- INCOTERMS +- Customers/Prospects + Contacts management +- Opportunities or Leads management +- Commercial proposals management +- Customer Orders management +- Contracts/Subscription management +- Interventions management +- Ticket System +- Shipping management +- Customer Invoices/Credit notes and payment management +- Point of Sale (POS) - Finance / Accounting -- Invoices / Payments -- Bank accounts management -- Direct debit orders management (European SEPA) -- Accounting management -- Donations management -- Loan management -- Margins -- Reports + Supplier/Purchase Management - Collaboration -- Shared calendar/agenda (with ical and vcal export for third party tools integration) -- Projects & Tasks management -- Ticket System +- Suppliers/Vendors + Contacts +- Supplier (price) requests +- Purchase Orders management +- Delivery/Receiption +- Supplier Invoices/credit notes and payment management +- INCOTERMS + + Finance / Accounting + +- Invoices / Payments +- Bank accounts management +- Direct debit orders management (European SEPA) +- Accounting management +- Donations management +- Loan management +- Margins +- Reports + + Collaboration + +- Shared calendar/agenda (with ical and vcal export for third party tools integration) +- Projects & Tasks management +- Ticket System - Surveys - HR -- Employee's leave requests management -- Expense reports -- Recruitment management -- Timesheets + HR +- Employee's leave requests management +- Expense reports +- Recruitment management +- Timesheets ### Other application/modules @@ -171,7 +172,6 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) (around 100 modules available by default, 1000+ on the addon market place) - ### Other general features - Localization in most major languages @@ -190,27 +190,24 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Canadian double taxes (federal/province) and other countries using cumulative VAT - Tunisian tax stamp - Argentina invoice numbering using A,B,C... - - Compatible with [European directives] (https://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) + - Compatible with [European directives](https://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) - Compatible with European GDPR rules - ... - Flexible PDF & ODT generation for invoices, proposals, orders... - ... - ### System Environment / Requirements - PHP -- MariaDB, MySQL or PostgreSQL +- MariaDB, MySQL or PostgreSQL - Compatible with all Cloud solutions that match PHP & MySQL or PostgreSQL prerequisites. See exact requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite) - ### Extending Dolibarr can be extended with a lot of other external application or modules from third party developers available at the [DoliStore](https://www.dolistore.com). - ## WHAT DOLIBARR CAN'T DO YET These are features that Dolibarr does **not** yet fully support: @@ -220,21 +217,18 @@ These are features that Dolibarr does **not** yet fully support: - No native embedded Webmail, but you can send email to contacts in Dolibarr with e.g. offers, invoices, etc. - Dolibarr can't do coffee (yet) - ## DOCUMENTATION Administrator, user, developer and translator's documentations are available along with other community resources in the [Wiki](https://wiki.dolibarr.org). - ## CONTRIBUTING -This project exists thanks to all the people who contribute. +This project exists thanks to all the people who contribute. Please read the instructions how to contribute (report a bug/error, a feature request, send code ...) [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)] A view on Contributors: - - +[![Dolibarr](https://opencollective.com/dolibarr/contributors.svg?width=890&button=false)](https://github.com/Dolibarr/dolibarr/graphs/contributors) ## CREDITS @@ -242,7 +236,6 @@ Dolibarr is the work of many contributors over the years and uses some fine PHP See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file. - ## NEWS AND SOCIAL NETWORKS Follow Dolibarr project on: @@ -253,8 +246,6 @@ Follow Dolibarr project on: - [YouTube](https://www.youtube.com/user/DolibarrERPCRM) - [GitHub](https://github.com/Dolibarr/dolibarr) - ### Sponsors Support this project by becoming a sponsor. Your logo will show up here. 🙏 [[Become a sponsor/backer](https://opencollective.com/dolibarr#backer)] - From 3a862212905ceebf3a1de29b33dd1abede9ae25f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 30 Oct 2021 12:54:13 +0200 Subject: [PATCH 202/490] add more customisation --- htdocs/core/class/html.formsetup.class.php | 327 +++++++++++++----- htdocs/modulebuilder/template/admin/setup.php | 28 +- 2 files changed, 272 insertions(+), 83 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 27b0e3fb615..f781afe0079 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -19,7 +19,8 @@ /** * This class help you create setup render */ -class formSetup{ +class formSetup +{ /** * @var DoliDB Database handler. @@ -27,7 +28,7 @@ class formSetup{ public $db; /** @var formSetupItem[] */ - public $arrayOfParameters = array(); + public $params = array(); public $setupNotEmpty = 0; @@ -37,10 +38,12 @@ class formSetup{ /** @var Form */ public $form; + /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param Translate $outputLangs if needed can use another lang */ public function __construct($db, $outputLangs = false) { @@ -48,41 +51,53 @@ class formSetup{ $this->db = $db; $this->form = new Form($this->db); - if($outputLangs){ + if ($outputLangs) { $this->langs = $outputLangs; - } - else{ + } else { $this->langs = $langs; } } /** + * @param bool $editMode true will display output on edit mod * @return string */ - public function generateOutput($edit = false){ + public function generateOutput($editMode = false) + { + $out = ''; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $out = '
    '; @@ -45,7 +47,7 @@ if ($action == 'editsalesrepresentatives') { $arrayselected = $object->getSalesRepresentatives($user, 1); } print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%"); - print ''; + print ''; print ''; } else { $listsalesrepresentatives = $object->getSalesRepresentatives($user); From 09621af54e54830922fb44b1f8c26a2cd284c20e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 29 Oct 2021 22:49:29 +0200 Subject: [PATCH 199/490] FIX $totalarray is overwritten, totals were lost --- htdocs/product/stock/list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index b8f998c0ec0..a86bc83982b 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -566,7 +566,6 @@ print '
    '; + $out.= ''; + if ($editMode) { + $out .= ''; + } + + $out.= '
    '; + $out.= ''; $out.= ''; $out.= ' '; $out.= ' '; $out.= ''; + $out.= ''; - foreach ($this->arrayOfParameters as $item) { - $out.= $this->generateLineOutput($item, $edit); + $out.= ''; + foreach ($this->params as $item) { + $out.= $this->generateLineOutput($item, $editMode); } + $out.= ''; $out.= '
    '.$this->langs->trans("Parameter").''.$this->langs->trans("Value").'
    '; return $out; } /** - * @param formSetupItem $item - * @param bool $edit - * @return string + * @param formSetupItem $item the setup item + * @param bool $editMode Display as edit mod + * @return string the html output for an setup item */ - public function generateLineOutput($item, $edit = false){ + public function generateLineOutput($item, $editMode = false) + { $out = ''; if ($item->enabled==1) { @@ -97,14 +112,13 @@ class formSetup{ $out.= '
    '; - if($edit){ + if ($editMode) { $out.= $item->generateInputField(); - } - else{ + } else { $out.= $item->generateOutputField(); } - if(!empty($item->errors)){ + if (!empty($item->errors)) { // TODO : move set event message in a methode to be called by cards not by this class setEventMessages(null, $item->errors, 'errors'); } @@ -118,14 +132,14 @@ class formSetup{ /** - * @param string $confKey - * @param array $params - * @ + * @param array $params an array of arrays of params from old modulBuilder params + * @deprecated was used to test module builder convertion to this form usage + * @return null */ - public function addItemsFromParamsArray($params){ - - if(!array($params)){ return false; } - foreach ($params as $confKey => $param){ + public function addItemsFromParamsArray($params) + { + if (!array($params)) { return false; } + foreach ($params as $confKey => $param) { $this->addItemFromParams($confKey, $param); // todo manage error } } @@ -133,12 +147,14 @@ class formSetup{ /** * From old - * @param string $confKey - * @param array $params + * @param string $confKey the conf name to store + * @param array $params an array of params from old modulBuilder params + * @deprecated was used to test module builder convertion to this form usage + * @return bool */ - public function addItemFromParams($confKey, $params){ - - if(empty($confKey) || empty($params['type'])){ return false; } + public function addItemFromParams($confKey, $params) + { + if (empty($confKey) || empty($params['type'])) { return false; } /* * Exemple from old module builder setup page @@ -152,26 +168,56 @@ class formSetup{ //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), */ - $item = new formSetupItem($this->db); + $item = new formSetupItem($confKey); $item->type = $params['type']; - $item->confKey = $confKey; - if(!empty($params['enabled'])) { + if (!empty($params['enabled'])) { $item->enabled = $params['enabled']; } - if(!empty($params['css'])){ + if (!empty($params['css'])) { $item->cssClass = $params['css']; } - $this->arrayOfParameters[$item->confKey] = $item; + $this->params[$item->confKey] = $item; return true; } + /** + * Reload for each item default conf + * note: this will override custom configuration + * @return bool + */ + public function reloadConfs() + { + + if (!array($this->params)) { return false; } + foreach ($this->params as $item) { + $item->reloadConf(); + } + + return true; + } + + + + /** + * Create a new item + * @param $confKey the conf key used in database + * @return formSetupItem the new setup item created + */ + public function newItem($confKey) + { + $item = new formSetupItem($confKey); + $this->params[$item->confKey] = $item; + return $this->params[$item->confKey]; + } } - +/** + * This class help to create item for class formSetup + */ class formSetupItem { /** @@ -194,67 +240,108 @@ class formSetupItem /** @var string $helpText */ public $helpText = ''; - /** @var bool|string set this var to override field output */ + /** @var string $value */ + public $fieldValue; + + /** @var bool|string set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too */ public $fieldOverride = false; + /** @var bool|string set this var to override field output */ + public $fieldInputOverride = false; + + /** @var bool|string set this var to override field output */ + public $fieldOutputOverride = false; + /** * @var string $errors */ public $errors = array(); /** + * TODO each type must have setAs{type} method to help configuration + * And set var as protected when its done configuration must be done by method * @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' */ - public $type; + public $type = 'string'; - public $enabled = 0; + public $enabled = 1; public $cssClass = ''; /** * Constructor * - * @param $confKey + * @param $confKey the conf key used in database */ public function __construct($confKey) { - global $langs, $db; + global $langs, $db, $conf; $this->db = $db; $this->form = new Form($this->db); $this->langs = $langs; $this->confKey = $confKey; + $this->fieldValue = $conf->global->{$this->confKey}; } - public function getHelpText(){ - if(!empty($this->helpText)){ return $this->helpText; } + /** + * reload conf value from databases + * @return null + */ + public function reloadConf() + { + global $conf; + $this->fieldValue = $conf->global->{$this->confKey}; + } + + /** + * Get help text or generate it + * @return int|string + */ + public function getHelpText() + { + if (!empty($this->helpText)) { return $this->helpText; } return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : ''); } - public function getNameText(){ - if(!empty($this->nameText)){ return $this->nameText; } - return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey',$this->confKey)); + /** + * Get field name text or generate it + * @return false|int|string + */ + public function getNameText() + { + if (!empty($this->nameText)) { return $this->nameText; } + return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey', $this->confKey)); } - public function generateInputField(){ + /** + * generate input field + * @return bool|string + */ + public function generateInputField() + { global $conf, $user; - if(!empty($this->fieldOverride)){ + if (!empty($this->fieldOverride)) { return $this->fieldOverride; } + if (!empty($this->fieldInputOverride)) { + return $this->fieldInputOverride; + } + $out = ''; if ($this->type == 'textarea') { $out.= '\n"; } elseif ($this->type== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($this->confKey, $conf->global->{$this->confKey}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); } elseif ($this->type == 'yesno') { - $out.= $this->form->selectyesno($this->confKey, $conf->global->{$this->confKey}, 1); + $out.= $this->form->selectyesno($this->confKey, $this->fieldValue, 1); } elseif (preg_match('/emailtemplate:/', $this->type)) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($this->db); @@ -274,7 +361,7 @@ class formSetupItem $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\(|\)/', '', $modelMail->label)) . $moreonlabel; } } - $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $conf->global->{$this->confKey}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue, 'None', 0, 0, '', 0, 0, 0, '', '', 1); } elseif (preg_match('/category:/', $this->type)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -282,13 +369,13 @@ class formSetupItem $tmp = explode(':', $this->type); $out.= img_picto('', 'category', 'class="pictofixedwidth"'); - $out.= $formother->select_categories($tmp[1], $conf->global->{$this->confKey}, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + $out.= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); } elseif (preg_match('/thirdparty_type/', $this->type)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($this->db); - $out.= $formcompany->selectProspectCustomerType($conf->global->{$this->confKey}, $this->confKey); + $out.= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey); } elseif ($this->type == 'securekey') { - $out.= ''; + $out.= ''; if (!empty($conf->use_javascript_ajax)) { $out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"'); } @@ -309,11 +396,11 @@ class formSetupItem } } elseif ($this->type == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $selected = (empty($conf->global->{$this->confKey}) ? '' : $conf->global->{$this->confKey}); + $selected = (empty($this->fieldValue) ? '' : $this->fieldValue); $this->form->select_produits($selected, $this->confKey, '', 0); } } else { - $out.= ''; + $out.= ''; } return $out; @@ -321,35 +408,44 @@ class formSetupItem /** - * add error - * @param array|string $errors + * Add error + * @param array|string $errors the error text + * @return null */ - public function setErrors($errors){ - if(is_array($errors)){ - if(!empty($errors)){ - foreach ($errors as $error){ + public function setErrors($errors) + { + if (is_array($errors)) { + if (!empty($errors)) { + foreach ($errors as $error) { $this->setErrors($error); } } - } - elseif(!empty($errors)){ + } elseif (!empty($errors)) { $this->errors[] = $errors; } } - public function generateOutputField(){ + /** + * @return bool|string Generate the output html for this item + */ + public function generateOutputField() + { global $conf, $user; - if(!empty($this->fieldOverride)){ + if (!empty($this->fieldOverride)) { return $this->fieldOverride; } + if (!empty($this->fieldOutputOverride)) { + return $this->fieldOutputOverride; + } + $out = ''; if ($this->type == 'textarea') { - $out.= dol_nl2br($conf->global->{$this->confKey}); + $out.= dol_nl2br($this->fieldValue); } elseif ($this->type== 'html') { - $out.= $conf->global->{$this->confKey}; + $out.= $this->fieldValue; } elseif ($this->type == 'yesno') { $out.= ajax_constantonoff($this->confKey); } elseif (preg_match('/emailtemplate:/', $this->type)) { @@ -358,14 +454,14 @@ class formSetupItem $tmp = explode(':', $this->type); - $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $conf->global->{$this->confKey}); + $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $this->fieldValue); if ($template<0) { $this->setErrors($formmail->errors); } $out.= $this->langs->trans($template->label); } elseif (preg_match('/category:/', $this->type)) { $c = new Categorie($this->db); - $result = $c->fetch($conf->global->{$this->confKey}); + $result = $c->fetch($this->fieldValue); if ($result < 0) { $this->setErrors($c->errors); } @@ -376,28 +472,105 @@ class formSetupItem } $out.= '
      ' . implode(' ', $toprint) . '
    '; } elseif (preg_match('/thirdparty_type/', $this->type)) { - if ($conf->global->{$this->confKey}==2) { + if ($this->fieldValue==2) { $out.= $this->langs->trans("Prospect"); - } elseif ($conf->global->{$this->confKey}==3) { + } elseif ($this->fieldValue==3) { $out.= $this->langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$this->confKey}==1) { + } elseif ($this->fieldValue==1) { $out.= $this->langs->trans("Customer"); - } elseif ($conf->global->{$this->confKey}==0) { + } elseif ($this->fieldValue==0) { $out.= $this->langs->trans("NorProspectNorCustomer"); } } elseif ($this->type == 'product') { $product = new Product($this->db); - $resprod = $product->fetch($conf->global->{$this->confKey}); + $resprod = $product->fetch($this->fieldValue); if ($resprod > 0) { $out.= $product->ref; } elseif ($resprod < 0) { $this->setErrors($product->errors); } } else { - $out.= $conf->global->{$this->confKey}; + $out.= $this->fieldValue; } return $out; } + /* + * METHODS FOR SETTING DISPLAY TYPE + */ + + /** + * Set type of input as string + * @return null + */ + public function setAsString() + { + $this->type = 'string'; + } + + /** + * Set type of input as textarea + * @return null + */ + public function setAsTextarea() + { + $this->type = 'textarea'; + } + + /** + * Set type of input as html editor + * @return null + */ + public function setAsHtml() + { + $this->type = 'html'; + } + + /** + * Set type of input as emailtemplate selector + * @return null + */ + public function setAsEmailTemplate() + { + $this->type = 'emailtemplate'; + } + + /** + * Set type of input as thirdparty_type selector + * @return null + */ + public function setAsThirdpartyType() + { + $this->type = 'thirdparty_type'; + } + + /** + * Set type of input as Yes + * @return null + */ + public function setAsYesNo() + { + $this->type = 'yesno'; + } + + /** + * Set type of input as secure key + * @return null + */ + public function setAsSecureKey() + { + $this->type = 'securekey'; + } + + /** + * Set type of input as a category selector + * TODO add default value + * @param int $catType Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. + * @return null + */ + public function setAsCategory($catType) + { + $this->type = 'category:'.$catType; + } } diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 390f45d955c..e3e32cf6f6b 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -85,6 +85,27 @@ $arrayofparameters = array( //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), ); +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; +$formSetup = new formSetup($db); + +$formSetup->addItemsFromParamsArray($arrayofparameters); + +// Hôte +$item = $formSetup->newItem('GPC_HOST'); +$item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; + +// Setup conf MYMODULE_MYPARAM1 as a simple string input +$item = $formSetup->newItem('MYMODULE_MYPARAM1'); + +// // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title +$item = $formSetup->newItem('MYMODULE_MYPARAM2'); +$item->nameText = $item->getNameText().' https://console.developers.google.com/apis/credentials'; + +// Clé pour API : Client Secret +$formSetup->newItem('GPC_GOOGLE_CLIENT_SECRET'); + + + $error = 0; $setupnotempty = 0; @@ -97,6 +118,7 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); if ((float) DOL_VERSION >= 6) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + $formSetup->reloadConfs(); } if ($action == 'updateMask') { @@ -222,11 +244,6 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "mymo echo ''.$langs->trans("MyModuleSetupPage").'

    '; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; -$formSetup = new formSetup($db); - -$formSetup->addItemsFromParamsArray($arrayofparameters); - if ($action == 'edit') { print '
    '; print ''; @@ -242,7 +259,6 @@ if ($action == 'edit') { print '
    '; } else { if (!empty($arrayofparameters)) { - print $formSetup->generateOutput(); print '
    '; From 5179f2c90b26fab6bbd0ed121ff68f3ff7d7b22f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 30 Oct 2021 13:03:23 +0200 Subject: [PATCH 203/490] Add demo data --- htdocs/modulebuilder/template/admin/setup.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index e3e32cf6f6b..f7f30c19228 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -90,8 +90,9 @@ $formSetup = new formSetup($db); $formSetup->addItemsFromParamsArray($arrayofparameters); + // Hôte -$item = $formSetup->newItem('GPC_HOST'); +$item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; // Setup conf MYMODULE_MYPARAM1 as a simple string input @@ -99,12 +100,15 @@ $item = $formSetup->newItem('MYMODULE_MYPARAM1'); // // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title $item = $formSetup->newItem('MYMODULE_MYPARAM2'); -$item->nameText = $item->getNameText().' https://console.developers.google.com/apis/credentials'; - -// Clé pour API : Client Secret -$formSetup->newItem('GPC_GOOGLE_CLIENT_SECRET'); +$item->nameText = $item->getNameText().' more html text '; +// Setup conf MYMODULE_MYPARAM3 +$item = $formSetup->newItem('MYMODULE_MYPARAM3'); +$item->setAsThirdpartyType(); + +// Setup conf MYMODULE_MYPARAM4 : quick define write style +$formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); $error = 0; $setupnotempty = 0; From 47c131af743d500fbb735bb60a8d3c6268e726bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Oct 2021 14:10:55 +0200 Subject: [PATCH 204/490] Fix regression --- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 6aa2a066e89..d2e3c43a3aa 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4774,7 +4774,7 @@ div.visible { display: block; } -div.hidden, td.hidden, img.hidden, span.hidden, div.showifmore { +div.hidden, header.hidden, td.hidden, img.hidden, span.hidden, div.showifmore { display: none; } .unvisible { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index c7ad8870c2e..4acf119eff7 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4660,7 +4660,7 @@ div.visible { display: block; } -div.hidden, td.hidden, img.hidden, span.hidden, div.showifmore { +div.hidden, header.hidden, td.hidden, img.hidden, span.hidden, div.showifmore { display: none; } From cdf1538ffacac651367a423cffce3b83d0c93ec9 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 30 Oct 2021 16:36:51 +0200 Subject: [PATCH 205/490] fix save using template --- htdocs/core/class/html.formsetup.class.php | 59 +++++++++++++++---- htdocs/modulebuilder/template/admin/setup.php | 19 +++++- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index f229d12101d..eb5a9710da1 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -183,6 +183,24 @@ class formSetup return true; } + /** + * used to export param array for /core/actions_setmoduleoptions.inc.php template + * @return array $arrayofparameters for /core/actions_setmoduleoptions.inc.php + * @deprecated + */ + public function exportItemsAsParamsArray() + { + $arrayofparameters = array(); + foreach ($this->params as $key => $item) { + $arrayofparameters[$item->confKey] = array( + 'type' => $item->type, + 'enabled' => $item->enabled + ); + } + + return $arrayofparameters; + } + /** * Reload for each item default conf * note: this will override custom configuration @@ -396,7 +414,7 @@ class formSetupItem } elseif ($this->type == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $selected = (empty($this->fieldValue) ? '' : $this->fieldValue); - $this->form->select_produits($selected, $this->confKey, '', 0); + $out.= $this->form->select_produits($selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1); } } else { $out.= ''; @@ -501,75 +519,94 @@ class formSetupItem /** * Set type of input as string - * @return null + * @return self */ public function setAsString() { $this->type = 'string'; + return $this; } /** * Set type of input as textarea - * @return null + * @return self */ public function setAsTextarea() { $this->type = 'textarea'; + return $this; } /** * Set type of input as html editor - * @return null + * @return self */ public function setAsHtml() { $this->type = 'html'; + return $this; } /** * Set type of input as emailtemplate selector - * @return null + * @param string $templateType email template type + * @return self */ - public function setAsEmailTemplate() + public function setAsEmailTemplate($templateType) { - $this->type = 'emailtemplate'; + $this->type = 'emailtemplate:'.$templateType; + return $this; } /** * Set type of input as thirdparty_type selector - * @return null + * @return self */ public function setAsThirdpartyType() { $this->type = 'thirdparty_type'; + return $this; } /** * Set type of input as Yes - * @return null + * @return self */ public function setAsYesNo() { $this->type = 'yesno'; + return $this; } /** * Set type of input as secure key - * @return null + * @return self */ public function setAsSecureKey() { $this->type = 'securekey'; + return $this; + } + + /** + * Set type of input as product + * @return self + */ + public function setAsProduct() + { + $this->type = 'product'; + return $this; } /** * Set type of input as a category selector * TODO add default value * @param int $catType Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. - * @return null + * @return self */ public function setAsCategory($catType) { $this->type = 'category:'.$catType; + return $this; } } diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index f7f30c19228..007e9d84b12 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -94,22 +94,33 @@ $formSetup->addItemsFromParamsArray($arrayofparameters); // Hôte $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; +$item->cssClass = 'minwidth500'; + // Setup conf MYMODULE_MYPARAM1 as a simple string input $item = $formSetup->newItem('MYMODULE_MYPARAM1'); -// // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title +// Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title $item = $formSetup->newItem('MYMODULE_MYPARAM2'); $item->nameText = $item->getNameText().' more html text '; - // Setup conf MYMODULE_MYPARAM3 $item = $formSetup->newItem('MYMODULE_MYPARAM3'); $item->setAsThirdpartyType(); -// Setup conf MYMODULE_MYPARAM4 : quick define write style +// Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style $formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); +// Setup conf MYMODULE_MYPARAM5 +$formSetup->newItem('MYMODULE_MYPARAM5')->setAsEmailTemplate('thirdparty'); + +// Setup conf MYMODULE_MYPARAM6 +$formSetup->newItem('MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled + +// Setup conf MYMODULE_MYPARAM7 +$formSetup->newItem('MYMODULE_MYPARAM7')->setAsProduct(); + + $error = 0; $setupnotempty = 0; @@ -121,6 +132,8 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); */ if ((float) DOL_VERSION >= 6) { + // TODO Add save setup by formSetup + $arrayofparameters = $formSetup->exportItemsAsParamsArray(); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $formSetup->reloadConfs(); } From 0017c159742dfdae473886e0c1064e866bdbf1d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Oct 2021 17:19:46 +0200 Subject: [PATCH 206/490] Debug v15 --- htdocs/comm/propal/card.php | 8 +- htdocs/core/bookmarks_page.php | 65 +++++---- htdocs/core/class/html.form.class.php | 3 +- htdocs/core/multicompany_page.php | 147 +++++++++++++++++++++ htdocs/langs/en_US/bookmarks.lang | 1 + htdocs/langs/en_US/propal.lang | 6 +- htdocs/projet/class/project.class.php | 4 +- htdocs/public/onlinesign/newonlinesign.php | 27 +++- htdocs/public/stripe/ipn.php | 25 +++- 9 files changed, 235 insertions(+), 51 deletions(-) create mode 100644 htdocs/core/multicompany_page.php diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c301e054e96..c046281f18e 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2014,15 +2014,15 @@ if ($action == 'create') { $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; } // Project if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref .= '
    '.$langs->trans('Project').' '; - if (!$usercancreate) { + $morehtmlref .= '
    '.$langs->trans('Project').''; + if ($usercancreate) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } @@ -2041,7 +2041,7 @@ if ($action == 'create') { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ' : '.$proj->getNomUrl(1); + $morehtmlref .= ': '.$proj->getNomUrl(1); if ($proj->title) { $morehtmlref .= ' - '.$proj->title; } diff --git a/htdocs/core/bookmarks_page.php b/htdocs/core/bookmarks_page.php index af2ba15829c..46c4b38988e 100644 --- a/htdocs/core/bookmarks_page.php +++ b/htdocs/core/bookmarks_page.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/bookmarks_page.php - * \brief File to return a page with the complete list of bookmarks (all search input fields) + * \brief File to return a page with the complete list of bookmarks */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language @@ -45,7 +45,7 @@ if (GETPOST('lang', 'aZ09')) { $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php } -$langs->load("main"); +$langs->loadLangs(array("bookmarks")); $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); @@ -57,7 +57,7 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $title = $langs->trans("Bookmarks"); -// URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests +// URL http://mydolibarr/core/bookmarks_page?dol_use_jmobile=1 can be used for tests $head = ''."\n"; $arrayofjs = array(); $arrayofcss = array(); @@ -69,8 +69,6 @@ print ''."\n"; print '
    '; //print '
    '; -$nbofsearch = 0; - // Instantiate hooks of thirdparty module $hookmanager->initHooks(array('bookmarks')); @@ -78,32 +76,43 @@ $hookmanager->initHooks(array('bookmarks')); $bookmarkList = ''; $searchForm = ''; -$arrayresult = array(); -//include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; - - -// Menu with list of bookmarks -$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; -$sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)"; -$sql .= " AND entity IN (".getEntity('bookmarks').")"; -$sql .= " ORDER BY position"; -if ($resql = $db->query($sql)) { - $bookmarkList = ''; - - $searchForm .= ''; +if (empty($conf->bookmarks->enabled)) { + $langs->load("admin"); + $bookmarkList .= '
    '.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Bookmarks")).''; + $bookmarkList .= '

    '; } else { - dol_print_error($db); -} + // Menu with list of bookmarks + $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; + $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)"; + $sql .= " AND entity IN (".getEntity('bookmarks').")"; + $sql .= " ORDER BY position"; + if ($resql = $db->query($sql)) { + $bookmarkList = ''; + + + $searchForm .= ''; + } else { + dol_print_error($db); + } +} // Execute hook printBookmarks $parameters = array('bookmarks'=>$bookmarkList); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 98ba6ca3cc2..56f7c41994b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5088,8 +5088,7 @@ class Form if ($selected) { $projet = new Project($this->db); $projet->fetch($selected); - //print ''.$projet->title.''; - $out .= $projet->getNomUrl(0, '', 1); + $out .= $projet->getNomUrl(1, '', 1); } else { $out .= " "; } diff --git a/htdocs/core/multicompany_page.php b/htdocs/core/multicompany_page.php new file mode 100644 index 00000000000..239e5c46392 --- /dev/null +++ b/htdocs/core/multicompany_page.php @@ -0,0 +1,147 @@ + + * + * This file is a modified version of datepicker.php from phpBSM to fix some + * bugs, to add new features and to dramatically increase speed. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/multicompany_page.php + * \brief File to return a page with the list of all entities user can switch to + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', 1); +} +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); + +require_once '../main.inc.php'; + +$action = GETPOST('action', 'aZ09'); +$entityid = GETPOST('entity', 'int'); +$backtourl = GETPOST('backtourl'); +if (empty($backtourl)) { + $backtourl = DOL_URL_ROOT; +} + +if (GETPOST('lang', 'aZ09')) { + $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php +} + +$langs->load("main"); + +$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); +$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); + + + +/* + * Actions + */ + +if (GETPOST('acction', 'aZ') == 'switchentity') { + if (is_object($mc)) { + $mc->switchEntity($entityid); + } + + header("Location: ".$backtourl); + exit(0); +} + + + +/* + * View + */ + +$title = $langs->trans("Multicompanies"); + +// URL http://mydolibarr/core/multicompany_page?dol_use_jmobile=1 can be used for tests +$head = ''."\n"; +$arrayofjs = array(); +$arrayofcss = array(); +top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); + + +print ''."\n"; +print '
    '; +//print '
    '; + + +if (empty($conf->multicompany->enabled)) { + $langs->load("admin"); + $bookmarkList .= '
    '.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("MultiCompany")).''; + $bookmarkList .= '

    '; +} else { + // Instantiate hooks of thirdparty module + $hookmanager->initHooks(array('multicompany')); + + // Define $bookmarks + $multicompanyList = ''; + $searchForm = ''; + + + if (is_object($mc)) { + $listofentities = $mc->getEntitiesList($user->login, false, true); + } + + foreach ($listofentities as $entityid => $entitycursor) { + $url = DOL_URL_ROOT.'/core/multicompany_page.php?action=switchentity&token='.newToken().'&entity='.((int) $entityid).($backtourl ? '&backtourl='.urlencode($backtourl) : ''); + $multicompanyList .= ''; + $multicompanyList .= dol_escape_htmltag($entitycursor); + $multicompanyList .= ''; + } + $multicompanyList .= '
    '; + + $searchForm .= ''; + + + // Execute hook printBookmarks + $parameters = array('multicompany'=>$multicompanyList); + $reshook = $hookmanager->executeHooks('printMultiCompanyEntities', $parameters); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) { + $multicompanyList .= $hookmanager->resPrint; + } else { + $multicompanyList = $hookmanager->resPrint; + } + + + print "\n"; + print "\n"; + print '
    '; + print ''; + print '
    '."\n"; + print $multicompanyList; + print '
    '."\n"; + print '
    '; + print "\n\n"; +} + +print '
    '; +print ''."\n"; + +$db->close(); diff --git a/htdocs/langs/en_US/bookmarks.lang b/htdocs/langs/en_US/bookmarks.lang index 87466cadcfa..d2378963a21 100644 --- a/htdocs/langs/en_US/bookmarks.lang +++ b/htdocs/langs/en_US/bookmarks.lang @@ -19,3 +19,4 @@ UseAnExternalHttpLinkOrRelativeDolibarrLink=Use an external/absolute link (https ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choose if the linked page should open in the current tab or a new tab BookmarksManagement=Bookmarks management BookmarksMenuShortCut=Ctrl + shift + m +NoBookmarks=No bookmarks defined diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 7141c1d38ae..ed07831fcba 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -89,11 +89,11 @@ IdProposal=Proposal ID IdProduct=Product ID PrParentLine=Proposal Parent Line LineBuyPriceHT=Buy Price Amount net of tax for line -SignPropal=Sign proposal +SignPropal=Accept proposal RefusePropal=Refuse proposal Sign=Sign +PropalAlreadySigned=Proposal already accepted PropalAlreadyRefused=Proposal already refused -PropalAlreadySigned=Proposal already signed -PropalSigned=Proposal signed +PropalSigned=Proposal accepted PropalRefused=Proposal refused ConfirmRefusePropal=Are you sure you want to refuse this commercial proposal? diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index aa823dc44d6..6d8b54d1954 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1183,7 +1183,7 @@ class Project extends CommonObject $label = ''; if ($option != 'nolink') { - $label = img_picto('', $this->picto).' '.$langs->trans("Project").''; + $label = img_picto('', $this->picto, 'class="pictofixedwidth"').' '.$langs->trans("Project").''; } if (isset($this->status)) { $label .= ' '.$this->getLibStatut(5); @@ -1252,7 +1252,7 @@ class Project extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip pictofixedwidth"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 65b12a91342..66b4af425e7 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -61,6 +61,7 @@ $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $refusepropal = GETPOST('refusepropal', 'alpha'); +$message = GETPOST('message', 'aZ09'); // Input are: // type ('invoice','order','contractline'), @@ -120,25 +121,33 @@ $creditor = $mysoc->name; $object = new Propal($db); $object->fetch(0, $ref); + /* * Actions */ if ($action == 'confirm_refusepropal') { + $db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql .= " SET fk_statut = ".((int) $object::STATUS_NOTSIGNED).", note_private = '".$object->note_private."', date_signature='".$db->idate(dol_now())."'"; + $sql .= " SET fk_statut = ".((int) $object::STATUS_NOTSIGNED).", note_private = '".$db->escape($object->note_private)."', date_signature='".$db->idate(dol_now())."'"; $sql .= " WHERE rowid = ".((int) $object->id); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); if (!$resql) { $error++; } + if (!$error) { $db->commit(); - setEventMessage("PropalRefused"); + + $message = 'refused'; + setEventMessages("PropalRefused", null, 'warning'); } else { $db->rollback(); } + $object->fetch(0, $ref); } @@ -367,7 +376,7 @@ if ($action == "dosign" && empty($cancel)) { success: function(response) { if(response == "success"){ console.log("Success on saving signature"); - window.location.replace("'.$_SERVER["SELF"].'?ref='.$ref.'"); + window.location.replace("'.$_SERVER["SELF"].'?ref='.$ref.'&message=signed"); }else{ console.error(response); } @@ -390,10 +399,18 @@ if ($action == "dosign" && empty($cancel)) { } else { if ($object->status == $object::STATUS_SIGNED) { print '
    '; - print ''.$langs->trans("PropalAlreadySigned").''; + if ($message == 'signed') { + print ''.$langs->trans("PropalSigned").''; + } else { + print ''.$langs->trans("PropalAlreadySigned").''; + } } elseif ($object->status == $object::STATUS_NOTSIGNED) { print '
    '; - print ''.$langs->trans("PropalAlreadyRefused").''; + if ($message == 'refused') { + print ''.$langs->trans("PropalRefused").''; + } else { + print ''.$langs->trans("PropalAlreadyRefused").''; + } } else { print ''; print ''; diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index f44bc0b1c99..6674ce9c6de 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -83,6 +83,21 @@ if (empty($endpoint_secret)) { exit(); } +if (!empty($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS)) { + // We set the user to use for all ipn actions in Dolibarr + $user = new User($db); + $user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS); + $user->getrights(); +} else { + print 'Error: Setup of module Stripe not complete for mode '.$service.'. The STRIPE_USER_ACCOUNT_FOR_ACTIONS is not defined.'; + http_response_code(400); // PHP 5.4 or greater + exit(); +} + + +// TODO Add a check on a security key + + /* * Actions @@ -110,10 +125,6 @@ try { $langs->load("main"); -// TODO Do we really need a user in setup just to have a name to fill an email topic when it is a technical system notification email -$user = new User($db); -$user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS); -$user->getrights(); if (!empty($conf->multicompany->enabled) && !empty($conf->stripeconnect->enabled) && is_object($mc)) { $sql = "SELECT entity"; @@ -276,11 +287,11 @@ if ($event->type == 'payout.created') { $ret = $mailfile->sendfile(); - http_response_code(200); // PHP 5.4 or greater + http_response_code(200); return 1; } else { $error++; - http_response_code(500); // PHP 5.4 or greater + http_response_code(500); return -1; } } elseif ($event->type == 'customer.source.created') { @@ -385,4 +396,4 @@ if ($event->type == 'payout.created') { // This event is deprecated. } -http_response_code(200); // PHP 5.4 or greater +http_response_code(200); From b1c799ee08bd1ec97412182fe56005f0ae894f0d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 30 Oct 2021 21:17:15 +0200 Subject: [PATCH 207/490] FIX #19241 Project - Fix display salary in overview --- htdocs/projet/element.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 9e14a53e7ea..22fe94a362a 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1,13 +1,13 @@ - * Copyright (C) 2004-2020 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2012-2016 Juanjo Menent - * Copyright (C) 2015-2019 Alexandre Spangaro - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Josep Lluís Amador - * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2021 Noé Cendrier +/* Copyright (C) 2001-2004 Rodolphe Quiedeville + * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2012-2016 Juanjo Menent + * Copyright (C) 2015-2021 Alexandre Spangaro + * Copyright (C) 2015 Marcos García + * Copyright (C) 2016 Josep Lluís Amador + * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 Noé Cendrier * * 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 @@ -590,8 +590,8 @@ $listofreferent = array( 'name'=>"Salaries", 'title'=>"ListSalariesAssociatedProject", 'class'=>'Salary', - 'table'=>'payment_salary', - 'datefieldname'=>'datev', + 'table'=>'salary', + 'datefieldname'=>'datesp', 'margin'=>'minus', 'disableamount'=>0, 'urlnew'=>DOL_URL_ROOT.'/salaries/card.php?action=create&projectid='.$id, @@ -816,7 +816,7 @@ foreach ($listofreferent as $key => $value) { } // Define $total_ht_by_line - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { $total_ht_by_line = $element->amount; } elseif ($tablename == 'fichinter') { $total_ht_by_line = $element->getAmount(); @@ -858,7 +858,7 @@ foreach ($listofreferent as $key => $value) { } // Define $total_ttc_by_line - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { $total_ttc_by_line = $element->amount; } elseif ($tablename == 'fichinter') { $total_ttc_by_line = $element->getAmount(); @@ -1075,7 +1075,7 @@ foreach ($listofreferent as $key => $value) { print ''; // if $key == 'project_task', we don't want details per user } elseif (in_array($tablename, array('payment_various'))) { print ''; // if $key == 'payment_various', we don't have any thirdparty - } elseif (in_array($tablename, array('expensereport_det', 'don', 'projet_task', 'stock_mouvement', 'payment_salary'))) { + } elseif (in_array($tablename, array('expensereport_det', 'don', 'projet_task', 'stock_mouvement', 'salary'))) { print $langs->trans("User"); } else { print $langs->trans("ThirdParty"); @@ -1233,8 +1233,8 @@ foreach ($listofreferent as $key => $value) { $date = $element->date; // No draft status on lines } elseif ($tablename == 'stock_mouvement') { $date = $element->datem; - } elseif ($tablename == 'payment_salary') { - $date = $element->datev; + } elseif ($tablename == 'salary') { + $date = $element->datesp; } elseif ($tablename == 'payment_various') { $date = $element->datev; } elseif ($tablename == 'chargesociales') { @@ -1292,7 +1292,7 @@ foreach ($listofreferent as $key => $value) { $tmpuser = new User($db); $tmpuser->fetch($expensereport->fk_user_author); print $tmpuser->getNomUrl(1, '', 48); - } elseif ($tablename == 'payment_salary') { + } elseif ($tablename == 'salary') { $tmpuser = new User($db); $tmpuser->fetch($element->fk_user); print $tmpuser->getNomUrl(1, '', 48); @@ -1320,7 +1320,7 @@ foreach ($listofreferent as $key => $value) { if (empty($value['disableamount'])) { $total_ht_by_line = null; $othermessage = ''; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { $total_ht_by_line = $element->amount; } elseif ($tablename == 'fichinter') { $total_ht_by_line = $element->getAmount(); @@ -1374,7 +1374,7 @@ foreach ($listofreferent as $key => $value) { // Amount inc tax if (empty($value['disableamount'])) { $total_ttc_by_line = null; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') { + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'salary') { $total_ttc_by_line = $element->amount; } elseif ($tablename == 'fichinter') { $total_ttc_by_line = $element->getAmount(); From 9142599ea5e80af74060ed6211f83f1ecd8dfeea Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 30 Oct 2021 21:18:52 +0200 Subject: [PATCH 208/490] copyright --- htdocs/projet/element.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 22fe94a362a..7e03c3738cc 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -6,7 +6,7 @@ * Copyright (C) 2015-2021 Alexandre Spangaro * Copyright (C) 2015 Marcos García * Copyright (C) 2016 Josep Lluís Amador - * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2021 Noé Cendrier * * This program is free software; you can redistribute it and/or modify From 54b81312b59b88e9d40497017f28eb93d667ff21 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 30 Oct 2021 22:49:32 +0200 Subject: [PATCH 209/490] FIX Ticket - Duplicate field project when we create ticket from project --- htdocs/core/class/html.formticket.class.php | 24 +++++++++++---------- htdocs/ticket/card.php | 19 ++++++++++------ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 8dcd4965c65..e2f9ba48687 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1,16 +1,17 @@ - * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2019 Frédéric France +/* Copyright (C) 2013-2015 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2021 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -351,12 +352,13 @@ class FormTicket } } - if (!empty($conf->projet->enabled) && !$this->ispublic) - { - $formproject = new FormProjets($this->db); - print '
    '; - print $formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); - print '
    '; + print $formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print '
    '; -print ""; +print ''; print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'p.fk_product_type', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Label', $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 6929c70a5ff..6dc40ab7477 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -45,6 +45,7 @@ $ref = GETPOST('ref', 'alpha'); $mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit'); $search_year = GETPOST('search_year', 'int'); $search_categ = GETPOST('search_categ', 'int'); +$notab = GETPOST('notab', 'int'); $error = 0; $mesg = ''; @@ -56,7 +57,7 @@ if (!empty($user->socid)) { } // Security check -$fieldvalue = (!empty($id) ? $id : $ref); +$fieldvalue = ($id > 0 ? $id : $ref); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $tmp = dol_getdate(dol_now()); @@ -65,6 +66,11 @@ if (empty($search_year)) { $search_year = $currentyear; } +$object = new Product($db); +if ($id > 0 || !empty($ref)) { + $result = $object->fetch($id, $ref); +} + $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -81,9 +87,10 @@ $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product $form = new Form($db); $htmlother = new FormOther($db); -$object = new Product($db); -if (!$id && empty($ref)) { +if (!($id > 0) && empty($ref) || $notab) { + $notab = 1; + llxHeader("", $langs->trans("ProductStatistics")); $type = GETPOST('type', 'int'); @@ -128,7 +135,7 @@ if (!$id && empty($ref)) { } -if ($result && (!empty($id) || !empty($ref))) { +if ($result && ($id > 0 || !empty($ref)) && empty($notab)) { $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -141,11 +148,11 @@ if ($result && (!empty($id) || !empty($ref))) { print dol_get_fiche_end(); } -if (empty($id) && empty($ref)) { +if ((!($id > 0) && empty($ref)) || $notab) { $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.$type : ''); + $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.((int) $type) : ''); $head[$h][1] = $langs->trans("Chart"); $head[$h][2] = 'chart'; $h++; @@ -158,7 +165,7 @@ if (empty($id) && empty($ref)) { $title = $langs->trans("ListProductByPopularity"); } - $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.$type : ''); + $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.((int) $type) : ''); $head[$h][1] = $langs->trans("ProductsPerPopularity"); $head[$h][2] = 'popularity'; $h++; @@ -167,21 +174,29 @@ if (empty($id) && empty($ref)) { } -if ($result || empty($id)) { +if ($result || !($id > 0)) { print ''; print ''; - print ''; + if (empty($id) || $notab) { + print ''; + } print '
    '; print ''; - if (empty($id)) { + if (!($id > 0) || $notab) { // Type - print ''; + // Product + print ''; + // Tag if ($conf->categorie->enabled) { print ''; } + } else { + print ''; } // Year @@ -220,7 +237,7 @@ if ($result || empty($id)) { } if ($mode == 'bynumber') { - print 'id).($type != '' ? '&type='.$type : '').'&mode=byunit&search_year='.$search_year.'">'; + print ''; } else { print ''; } @@ -238,7 +255,7 @@ if ($result || empty($id)) { } if ($mode == 'byunit') { - print 'id).($type != '' ? '&type='.$type : '').'&mode=bynumber&search_year='.$search_year.'">'; + print ''; } else { print ''; } @@ -256,9 +273,7 @@ if ($result || empty($id)) { } print '
    '; - //print '
    '.$langs->trans("Filter").'
    '.$langs->trans("ProductsAndServices").''; + print '
    '.$langs->trans("Type").''; $array = array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); print $form->selectarray('type', $array, $type); print '
    '.$langs->trans("ProductOrService").''; + print img_picto('', 'product', 'class="pictofixedwidth"'); + print $form->select_produits($id, 'id', '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, 'maxwidth500'); + print '
    '.$langs->trans("Categories").''; @@ -190,6 +205,8 @@ if ($result || empty($id)) { print $moreforfilter; print '
    '; - - // Generation des graphs + // Generation of graphs $dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]); if ($object->id > 0) { // We are on statistics for a dedicated product if (!file_exists($dir.'/'.$object->id)) { @@ -383,7 +398,7 @@ if ($result || empty($id)) { $px->SetShading(3); //print 'x '.$key.' '.$graphfiles[$key]['file']; - $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']); + $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.((int) $object->entity).'&file='.urlencode($graphfiles[$key]['file']).($notab ? '¬ab='.$notab : ''); $px->draw($dir."/".$graphfiles[$key]['file'], $url); $graphfiles[$key]['total'] = $px->total(); @@ -444,7 +459,9 @@ if ($result || empty($id)) { } else { $dategenerated = ($mesg ? ''.$mesg.'' : $langs->trans("ChartNotGenerated")); } - $linktoregenerate = 'id).((string) $type != '' ? '&type='.$type : '').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').''; + $linktoregenerate = ' 0 ? '&search_categ='.((int) $search_categ) : '').'">'; + $linktoregenerate .= img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh'); + $linktoregenerate .= ''; // Show graph print '
    '; @@ -478,7 +495,7 @@ if ($result || empty($id)) { } } -if (!$id) { +if (!($id > 0)) { print dol_get_fiche_end(); } From ed9f0c4ad951e4a79609c0396b67c2f99a09cf4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 13:42:08 +0100 Subject: [PATCH 217/490] Fix labels --- htdocs/core/modules/modHRM.class.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 9c5e509ecd3..b13e5b6bbba 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -200,58 +200,58 @@ class modHRM extends DolibarrModules $this->rights[$r][1] = 'Read skill/job/position'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'all'; - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read) + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->all->read) $r++; $this->rights[$r][0] = 4011; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/modify skill/job/position'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'all'; - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->all->write) $r++; $this->rights[$r][0] = 4012; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete skill/job/position'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'all'; - $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->all->delete) $r++; // Evaluation $this->rights[$r][0] = 4020; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read evaluation'; // Permission label + $this->rights[$r][1] = 'Read evaluations'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read) + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read) $r++; $this->rights[$r][0] = 4021; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/modify evaluation'; // Permission label + $this->rights[$r][1] = 'Create/modify your own evaluation'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->write) $r++; $this->rights[$r][0] = 4022; // Permission id (must not be already used) $this->rights[$r][1] = 'Validate evaluation'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'evaluation'; - $this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) + $this->rights[$r][4] = 'evaluation_advance'; + $this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->validate) $r++; $this->rights[$r][0] = 4023; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete evaluation'; // Permission label + $this->rights[$r][1] = 'Delete all evaluations'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'evaluation'; - $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->delete) $r++; // Comparison $this->rights[$r][0] = 4030; // Permission id (must not be already used) $this->rights[$r][1] = 'See comparison menu'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'compare'; - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) + $this->rights[$r][4] = 'compare_advance'; + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) $r++; } From 92f9f3179e83db0de114191d463cfcdfedb705c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 13:56:19 +0100 Subject: [PATCH 218/490] Update list.php --- htdocs/product/stock/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index a86bc83982b..8125e5d3cf3 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -195,6 +195,7 @@ $now = dol_now(); $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $title = $langs->trans("ListOfWarehouses"); +$totalarray = array(); // Build and execute select // -------------------------------------------------------------------- From 0e2e8fe27fb453b34da4fe0fb22a744bddef6fc4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:01:40 +0100 Subject: [PATCH 219/490] Update contact.php --- htdocs/compta/facture/contact.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 8395409cbd6..60fdeaf3e64 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -121,8 +121,7 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) if (empty($object->id)) { llxHeader(); $langs->load('errors'); - echo '
    '.$langs->trans("ErrorRecordNotFound"); - echo ' '.$langs->trans('GoBack').'
    '; + echo '
    '.$langs->trans("ErrorRecordNotFound").'
    '; llxFooter(); exit; } From 65d59405da76a97d906fa49e54432d946ea71af6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:01:56 +0100 Subject: [PATCH 220/490] Update document.php --- htdocs/compta/facture/document.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index e6cf3551738..33e651d833d 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -88,8 +88,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if (empty($object->id)) { llxHeader(); $langs->load('errors'); - echo '
    '; + echo '
    '.$langs->trans("ErrorRecordNotFound").'
    '; llxFooter(); exit; } From 8dfe4fe05fb49e58309a3d02b92b0133a74c5b9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:02:14 +0100 Subject: [PATCH 221/490] Update note.php --- htdocs/compta/facture/note.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 089d01b4a1f..8e2e8829d1a 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -67,8 +67,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, if (empty($object->id)) { llxHeader(); $langs->load('errors'); - echo '
    '; + echo '
    '.$langs->trans("ErrorRecordNotFound").'
    '; llxFooter(); exit; } From 3dcd1aa05d4f8bdde463a110bd3a4bfa71ec27dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:02:34 +0100 Subject: [PATCH 222/490] Update info.php --- htdocs/compta/facture/info.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 51b2ce8f4e3..820793c14d7 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -46,8 +46,7 @@ $ref = GETPOST("ref", 'alpha'); if (empty($object->id)) { llxHeader(); $langs->load('errors'); - echo '
    '; + echo '
    '.$langs->trans("ErrorRecordNotFound").'
    '; llxFooter(); exit; } From dfc869842264d8efb638f02dfe32501d71843702 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:16:18 +0100 Subject: [PATCH 223/490] Update replenish.php --- htdocs/product/stock/replenish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index d531a7df05c..329df47ef2e 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -581,7 +581,7 @@ print dol_get_fiche_head($head, 'replenish', '', -1, ''); print ''.$langs->trans("ReplenishmentStatusDesc").''."\n"; -$link = '
    '.$langs->trans("MenuNewWarehouse").''; +$link = ''.$langs->trans("MenuNewWarehouse").''; print info_admin($langs->trans("ErrorAtLeastOneWarehouseNeededForReplenish") .' '. $link, 0, 0, 'info', 'clearboth'); if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { From 7773f8f01733bd4444284ea2912661ae0e952348 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:20:30 +0100 Subject: [PATCH 224/490] Update replenish.php --- htdocs/product/stock/replenish.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 329df47ef2e..e536c8c52f7 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -580,9 +580,7 @@ print dol_get_fiche_head($head, 'replenish', '', -1, ''); print ''.$langs->trans("ReplenishmentStatusDesc").''."\n"; - -$link = ''.$langs->trans("MenuNewWarehouse").''; -print info_admin($langs->trans("ErrorAtLeastOneWarehouseNeededForReplenish") .' '. $link, 0, 0, 'info', 'clearboth'); +//$link = ''.$langs->trans("MenuNewWarehouse").''; if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."\n"; From 480ad63c5d7f9dccb5d01732280aca2c40144f38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:21:01 +0100 Subject: [PATCH 225/490] Update stocks.lang --- htdocs/langs/en_US/stocks.lang | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 03e0be4dec4..19655b2cc9e 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -256,4 +256,3 @@ AutofillWithExpected=Fill real quantity with expected quantity ShowAllBatchByDefault=By default, show batch details on product "stock" tab CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration FieldCannotBeNegative=Field "%s" cannot be negative -ErrorAtLeastOneWarehouseNeededForReplenish= Attention: You need to create at least one warehouse to use the replenish feature. From 13d3ff8ef70293905039691dfe8b56d07f750161 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:22:14 +0100 Subject: [PATCH 226/490] Update replenish.php --- htdocs/product/stock/replenish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index e536c8c52f7..1e348d01dee 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -359,7 +359,7 @@ $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product'; -$list_warehouse = empty($listofqualifiedwarehousesid) ? '0' :$listofqualifiedwarehousesid; +$list_warehouse = (empty($listofqualifiedwarehousesid) ? '0' : $listofqualifiedwarehousesid); $sql .= ' AND s.fk_entrepot IN ('.$db->sanitize($list_warehouse) .')'; //$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot AS ent ON s.fk_entrepot = ent.rowid AND ent.entity IN('.getEntity('stock').')'; From e6e440e573c32556dd3c28219be8e390d2d7e7eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 15:14:15 +0100 Subject: [PATCH 227/490] Fix #19257 error in the page Overview of a project --- htdocs/admin/stock.php | 20 ++++++++- htdocs/core/class/html.formprojet.class.php | 12 ++++- htdocs/langs/en_US/salaries.lang | 1 + htdocs/langs/en_US/stocks.lang | 1 + htdocs/projet/element.php | 48 ++++++++++---------- htdocs/salaries/card.php | 50 ++++++++++++++++++--- 6 files changed, 100 insertions(+), 32 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index a4a9e91e3ff..e1fc7fc1d3a 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -683,6 +683,8 @@ if ($conf->use_javascript_ajax) { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("SOCIETE_ASK_FOR_WAREHOUSE", $arrval, $conf->global->SOCIETE_ASK_FOR_WAREHOUSE); } +print ""; +print "\n"; print '
    '; print ''; @@ -693,6 +695,9 @@ if ($conf->use_javascript_ajax) { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL); } +print ""; +print "\n"; + print ''; print ''; print '"; print ''; print "\n"; +/* +print ''; +print ''; +print ''; +print "\n"; +*/ + print ''; print ''; // Owner From ad6f7e1a4887bad5ac91a257505d16d4af91309f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 16:31:15 +0100 Subject: [PATCH 232/490] Default target is same window for a link on app, external if not defined --- htdocs/bookmarks/card.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 289916a07c2..2637262a5e1 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -169,7 +169,11 @@ if ($action == 'create') { // Target print ''; // Owner From fb6a1d1f5119b73e227c17c825202e1a5e135244 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 16:56:38 +0100 Subject: [PATCH 233/490] FIX #19210 --- htdocs/core/lib/functions.lib.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d659c2b1916..eae8546a338 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2266,6 +2266,11 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = { global $conf, $langs; + // If date undefined or "", we return "" + if (dol_strlen($time) == 0) { + return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + } + if ($tzoutput === 'auto') { $tzoutput = (empty($conf) ? 'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey : 'tzserver')); } @@ -2289,7 +2294,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $user_date_tz = new DateTimeZone($offsettzstring); $user_dt = new DateTime(); $user_dt->setTimezone($user_date_tz); - $user_dt->setTimestamp(($tzoutput == 'tzuser' || empty($time)) ? dol_now() : $time); + $user_dt->setTimestamp($tzoutput == 'tzuser' ? dol_now() : (int) $time); $offsettz = $user_dt->getOffset(); } else { // old method (The 'tzuser' was processed like the 'tzuserrel') $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore @@ -2357,11 +2362,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $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) - } - // Clean format 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. From 682ad989186f864ca2c0c3a2c51acefcb382e629 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 17:06:37 +0100 Subject: [PATCH 234/490] Update security.lib.php --- htdocs/core/lib/security.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 852a87baa0b..475649701ae 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -489,12 +489,12 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (!$user->rights->fournisseur->commande->supprimer) { $deleteok = 0; } - } elseif ($feature == 'payment_supplier') { + } elseif ($feature == 'payment_supplier') { // Permission to delete a payment of an invoice is permission to edit an invoice. if (!$user->rights->fournisseur->facture->creer) { $deleteok = 0; } - } elseif ($feature == 'payment') { - if (!$user->rights->facture->supprimer) { + } elseif ($feature == 'payment') { // Permission to delete a payment of an invoice is permission to edit an invoice. + if (!$user->rights->facture->creer) { $deleteok = 0; } } elseif ($feature == 'banque') { From 0e4c113e7fcc167f9e7e60e51c316e35b7459595 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 17:11:23 +0100 Subject: [PATCH 235/490] Fix phpcs --- htdocs/core/class/html.formticket.class.php | 2 +- htdocs/ticket/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 46df923704d..ebfd3802cc2 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -406,7 +406,7 @@ class FormTicket } } - if($subelement != 'project') { + if ($subelement != 'project') { if (!empty($conf->projet->enabled) && !$this->ispublic) { $formproject = new FormProjets($this->db); print '
    '.$langs->trans("WarehouseAskWarehouseDuringPropal").'
    '.$langs->trans("WarehouseAskWarehouseDuringOrder").''; @@ -702,10 +707,23 @@ if ($conf->use_javascript_ajax) { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER); } -print "
    '.$langs->trans("WarehouseAskWarehouseDuringProject").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT); +} +print '
    '; print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc")); diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 9696dca7183..d485720dab8 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -505,7 +505,17 @@ class FormProjets } $linkedtothirdparty = false; - if (!in_array($table_element, array('don', 'expensereport_det', 'expensereport', 'loan', 'stock_mouvement', 'payment_salary', 'payment_various', 'chargesociales', 'entrepot'))) { + if (!in_array($table_element, array( + 'don', + 'expensereport_det', + 'expensereport', 'loan', + 'stock_mouvement', + 'payment_salary', + 'payment_various', + 'salary', + 'chargesociales', + 'entrepot') + )) { $linkedtothirdparty = true; } diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 504f0fbcc16..6397ed4c6d4 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -6,6 +6,7 @@ CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT=By default, leave empty the option "Autom Salary=Salary Salaries=Salaries NewSalary=New salary +AddSalary=Add salary NewSalaryPayment=New salary card AddSalaryPayment=Add salary payment SalaryPayment=Salary payment diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 19655b2cc9e..b373be27c35 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -63,6 +63,7 @@ RuleForWarehouse=Rule for warehouses WarehouseAskWarehouseOnThirparty=Set a warehouse on Third-parties WarehouseAskWarehouseDuringPropal=Set a warehouse on Commercial proposals WarehouseAskWarehouseDuringOrder=Set a warehouse on Sale orders +WarehouseAskWarehouseDuringProject=Set a warehouse on Projects UserDefaultWarehouse=Set a warehouse on Users MainDefaultWarehouse=Default warehouse MainDefaultWarehouseUser=Use a default warehouse for each user diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 7e03c3738cc..c805552d7a5 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -164,7 +164,7 @@ if ($id == '' && $ref == '') { exit(); } -$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +$mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $object = new Project($db); @@ -368,19 +368,19 @@ $listofreferent = array( 'class'=>'Entrepot', 'table'=>'entrepot', 'datefieldname'=>'date_entrepot', - 'urlnew'=>DOL_URL_ROOT.'/product/stock/card.php?action=create&projectid='.$id, + 'urlnew'=>DOL_URL_ROOT.'/product/stock/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'entrepot', 'buttonnew'=>'AddWarehouse', 'project_field'=>'fk_project', 'testnew'=>$user->rights->stock->creer, - 'test'=>$conf->stock->enabled && $user->rights->stock->lire), + 'test'=>$conf->stock->enabled && $user->rights->stock->lire && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)), 'propal'=>array( 'name'=>"Proposals", 'title'=>"ListProposalsAssociatedProject", 'class'=>'Propal', 'table'=>'propal', 'datefieldname'=>'datep', - 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'propal', 'buttonnew'=>'AddProp', 'testnew'=>$user->rights->propal->creer, @@ -391,7 +391,7 @@ $listofreferent = array( 'class'=>'Commande', 'table'=>'commande', 'datefieldname'=>'date_commande', - 'urlnew'=>DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'orders', 'buttonnew'=>'CreateOrder', 'testnew'=>$user->rights->commande->creer, @@ -403,7 +403,7 @@ $listofreferent = array( 'margin'=>'add', 'table'=>'facture', 'datefieldname'=>'datef', - 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'bills', 'buttonnew'=>'CreateBill', 'testnew'=>$user->rights->facture->creer, @@ -414,7 +414,7 @@ $listofreferent = array( 'class'=>'FactureRec', 'table'=>'facture_rec', 'datefieldname'=>'datec', - 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'bills', 'buttonnew'=>'CreateBill', 'testnew'=>$user->rights->facture->creer, @@ -425,7 +425,7 @@ $listofreferent = array( 'class'=>'SupplierProposal', 'table'=>'supplier_proposal', 'datefieldname'=>'date_valid', - 'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object + 'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'supplier_proposal', 'buttonnew'=>'AddSupplierProposal', 'testnew'=>$user->rights->supplier_proposal->creer, @@ -436,7 +436,7 @@ $listofreferent = array( 'class'=>'CommandeFournisseur', 'table'=>'commande_fournisseur', 'datefieldname'=>'date_commande', - 'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object + 'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'suppliers', 'buttonnew'=>'AddSupplierOrder', 'testnew'=>($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer), @@ -448,7 +448,7 @@ $listofreferent = array( 'margin'=>'minus', 'table'=>'facture_fourn', 'datefieldname'=>'datef', - 'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object + 'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'suppliers', 'buttonnew'=>'AddSupplierInvoice', 'testnew'=>($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer), @@ -459,7 +459,7 @@ $listofreferent = array( 'class'=>'Contrat', 'table'=>'contrat', 'datefieldname'=>'date_contrat', - 'urlnew'=>DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'contracts', 'buttonnew'=>'AddContract', 'testnew'=>$user->rights->contrat->creer, @@ -472,7 +472,7 @@ $listofreferent = array( 'datefieldname'=>'date_valid', 'disableamount'=>0, 'margin'=>'minus', - 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'interventions', 'buttonnew'=>'AddIntervention', 'testnew'=>$user->rights->ficheinter->creer, @@ -483,7 +483,7 @@ $listofreferent = array( 'class'=>'Expedition', 'table'=>'expedition', 'datefieldname'=>'date_valid', - 'urlnew'=>DOL_URL_ROOT.'/expedition/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/expedition/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'sendings', 'buttonnew'=>'CreateShipment', 'testnew'=>0, @@ -494,7 +494,7 @@ $listofreferent = array( 'class'=>'Mo', 'table'=>'mrp_mo', 'datefieldname'=>'date_valid', - 'urlnew'=>DOL_URL_ROOT.'/mrp/mo_card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/mrp/mo_card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'mrp', 'buttonnew'=>'CreateMO', 'testnew'=>'$user->rights->mrp->write', @@ -508,7 +508,7 @@ $listofreferent = array( 'datefieldname'=>'dated', 'margin'=>'minus', 'disableamount'=>1, - 'urlnew'=>DOL_URL_ROOT.'/deplacement/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/deplacement/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'trips', 'buttonnew'=>'AddTrip', 'testnew'=>$user->rights->deplacement->creer, @@ -521,7 +521,7 @@ $listofreferent = array( 'datefieldname'=>'date', 'margin'=>'minus', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'trips', 'buttonnew'=>'AddTrip', 'testnew'=>$user->rights->expensereport->creer, @@ -534,7 +534,7 @@ $listofreferent = array( 'table'=>'don', 'datefieldname'=>'datedon', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'donations', 'buttonnew'=>'AddDonation', 'testnew'=>$user->rights->don->creer, @@ -547,7 +547,7 @@ $listofreferent = array( 'table'=>'loan', 'datefieldname'=>'datestart', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'loan', 'buttonnew'=>'AddLoan', 'testnew'=>$user->rights->loan->write, @@ -560,7 +560,7 @@ $listofreferent = array( 'table'=>'chargesociales', 'datefieldname'=>'date_ech', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$id, + 'urlnew'=>DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'compta', 'buttonnew'=>'AddSocialContribution', 'testnew'=>$user->rights->tax->charges->lire, @@ -573,7 +573,7 @@ $listofreferent = array( 'table'=>'projet_task', 'datefieldname'=>'task_date', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id, + 'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'buttonnew'=>'AddTimeSpent', 'testnew'=>$user->rights->projet->creer, 'test'=>($conf->projet->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))), @@ -594,9 +594,9 @@ $listofreferent = array( 'datefieldname'=>'datesp', 'margin'=>'minus', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/salaries/card.php?action=create&projectid='.$id, + 'urlnew'=>DOL_URL_ROOT.'/salaries/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'salaries', - 'buttonnew'=>'AddSalaryPayment', + 'buttonnew'=>'AddSalary', 'testnew'=>$user->rights->salaries->write, 'test'=>$conf->salaries->enabled && $user->rights->salaries->read), 'variouspayment'=>array( @@ -607,7 +607,7 @@ $listofreferent = array( 'datefieldname'=>'datev', 'margin'=>'minus', 'disableamount'=>0, - 'urlnew'=>DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&projectid='.$id, + 'urlnew'=>DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'banks', 'buttonnew'=>'AddVariousPayment', 'testnew'=>$user->rights->banque->modifier, @@ -620,7 +620,7 @@ $listofreferent = array( 'table'=>'actioncomm', 'datefieldname'=>'datep', 'disableamount'=>1, - 'urlnew'=>DOL_URL_ROOT.'/comm/action/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/comm/action/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'agenda', 'buttonnew'=>'AddEvent', 'testnew'=>$user->rights->agenda->myactions->create, diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 486b4fd70ea..f5ebbcf0ec6 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -48,6 +48,9 @@ $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); + $accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0; $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); $confirm = GETPOST('confirm'); @@ -75,7 +78,6 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('salarycard', 'globalcard')); -$object = new Salary($db); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); @@ -97,6 +99,7 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } + restrictedArea($user, 'salaries', $object->id, 'salary', ''); @@ -104,9 +107,39 @@ restrictedArea($user, 'salaries', $object->id, 'salary', ''); * Actions */ -if ($cancel) { - header("Location: list.php"); - exit; +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + $error = 0; + + $backurlforlist = dol_buildpath('/salaries/list.php', 1); + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = dol_buildpath('/salaries/card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } + } + } + + if ($cancel) { + /*var_dump($cancel); + var_dump($backtopage);exit;*/ + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = ''; + } } // Link to a project @@ -404,8 +437,7 @@ llxHeader("", $title, $help_url); $form = new Form($db); if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); -if ($id) { - $object = new Salary($db); +if ($id > 0) { $result = $object->fetch($id); if ($result <= 0) { dol_print_error($db); @@ -439,6 +471,12 @@ if ($action == 'create') { print ''; print ''; print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } print load_fiche_titre($langs->trans("NewSalary"), '', 'salary'); From 41b8c92311f37172436886394bec319f8354d6f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 15:16:40 +0100 Subject: [PATCH 228/490] Update card.php --- htdocs/holiday/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 045c370de8e..e84fb79c7e3 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1541,7 +1541,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { //$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; + print '
    '; $MAXEVENT = 10; @@ -1550,7 +1550,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); - print '
    '; + print ''; } } } From 4f2cd2ba188b12d56063098264706fd0b82f4434 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 15:59:03 +0100 Subject: [PATCH 229/490] FIx #19227 --- htdocs/core/lib/functions.lib.php | 20 ++++++++++++++------ test/phpunit/SecurityTest.php | 4 ++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 084a4a4f25a..1c533f0e686 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -108,6 +108,10 @@ function getEntity($element, $shared = 1, $currentobject = null) { global $conf, $mc, $hookmanager, $object, $action; + if (! is_object($hookmanager)) { + $hookmanager = new HookManager($db); + } + // fix different element names (France to English) switch ($element) { case 'contrat': @@ -8151,16 +8155,20 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1) return 'Bad string syntax to evaluate: '.$s; } - // We block using of php exec or php file functions - $forbiddenphpstrings = array("exec(", "passthru(", "shell_exec(", "system(", "proc_open(", "popen(", "eval(", "dol_eval(", "executeCLI("); - $forbiddenphpstrings = array_merge($forbiddenphpstrings, array("fopen(", "file_put_contents(", "fputs(", "fputscsv(", "fwrite(", "fpassthru(", "unlink(", "mkdir(", "rmdir(", "symlink(", "touch(", "umask(")); - $forbiddenphpstrings = array_merge($forbiddenphpstrings, array('function(', '$$', 'call_user_func(')); + // We block use of php exec or php file functions + $forbiddenphpstrings = array('$$'); $forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_SESSION', '_COOKIE', '_GET', '_POST', '_REQUEST')); - $forbiddenphpregex = 'global\s+\$'; + + $forbiddenphpfunctions = array("exec", "passthru", "shell_exec", "system", "proc_open", "popen", "eval", "dol_eval", "executeCLI"); + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); + $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("function", "call_user_func")); + + $forbiddenphpregex = 'global\s+\$|\b('.implode('|', $forbiddenphpfunctions).')\b'; + do { $oldstringtoclean = $s; $s = str_ireplace($forbiddenphpstrings, '__forbiddenstring__', $s); - $s = preg_replace('/'.$forbiddenphpregex.'/', '__forbiddenstring__', $s); + $s = preg_replace('/'.$forbiddenphpregex.'/i', '__forbiddenstring__', $s); //$s = preg_replace('/\$[a-zA-Z0-9_\->\$]+\(/i', '', $s); // Remove $function( call and $mycall->mymethod( } while ($oldstringtoclean != $s); diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 81eff830b49..fe091b0fe47 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -874,6 +874,10 @@ class SecurityTest extends PHPUnit\Framework\TestCase print "result = ".$result."\n"; $this->assertContains('Bad string syntax to evaluate', $result); + $result=dol_eval('$a=exec ("ls")', 1, 1); + print "result = ".$result."\n"; + $this->assertContains('Bad string syntax to evaluate', $result); + $result=dol_eval('$a="test"; $$a;', 1, 0); print "result = ".$result."\n"; $this->assertContains('Bad string syntax to evaluate', $result); From d4107fcc4e324267ed872f7f4da07c123c01ba80 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 31 Oct 2021 16:14:13 +0100 Subject: [PATCH 230/490] Fix wrong column name --- htdocs/install/mysql/tables/llx_element_tag.key.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_element_tag.key.sql b/htdocs/install/mysql/tables/llx_element_tag.key.sql index fc1e3e7861d..e4af1c3871e 100644 --- a/htdocs/install/mysql/tables/llx_element_tag.key.sql +++ b/htdocs/install/mysql/tables/llx_element_tag.key.sql @@ -16,8 +16,8 @@ -- -- ============================================================================ -ALTER TABLE llx_element_tag ADD PRIMARY KEY pk_element_tag (fk_categorie, fk_socpeople); +ALTER TABLE llx_element_tag ADD PRIMARY KEY pk_element_tag (fk_categorie, fk_element); ALTER TABLE llx_element_tag ADD INDEX idx_element_tag_fk_categorie (fk_categorie); -ALTER TABLE llx_element_tag ADD INDEX idx_element_tag_fk_socpeople (fk_socpeople); +ALTER TABLE llx_element_tag ADD INDEX idx_element_tag_fk_element (fk_element); ALTER TABLE llx_element_tag ADD CONSTRAINT fk_element_tag_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); From 9989180c5fb6c3fe49a7f0753a26bbe27a59f9bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 16:25:29 +0100 Subject: [PATCH 231/490] Fix target is lost --- htdocs/bookmarks/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 1094eabf0c6..bfad54b361a 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -169,7 +169,7 @@ if ($action == 'create') { // Target print '
    '.$langs->trans("BehaviourOnClick").''; $liste = array(0=>$langs->trans("ReplaceWindow"), 1=>$langs->trans("OpenANewWindow")); - print $form->selectarray('target', $liste, 1); + print $form->selectarray('target', $liste, GETPOSTISSET('target') ? GETPOST('target', 'int') : 1); print ''.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'
    '.$langs->trans("BehaviourOnClick").''; $liste = array(0=>$langs->trans("ReplaceWindow"), 1=>$langs->trans("OpenANewWindow")); - print $form->selectarray('target', $liste, GETPOSTISSET('target') ? GETPOST('target', 'int') : 1, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); + $defaulttarget = 1; + if ($url && !preg_match('/^http/i', $url)) { + $defaulttarget = 0; + } + print $form->selectarray('target', $liste, GETPOSTISSET('target') ? GETPOST('target', 'int') : $defaulttarget, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); print ''.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'
    '; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index d59369a07ff..380d85be94c 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -200,7 +200,7 @@ if (empty($reshook)) { } // Link ticket to project - if(GETPOST('origin', 'alpha') == 'projet') { + if (GETPOST('origin', 'alpha') == 'projet') { $projectid = GETPOST('originid', 'int'); } else { $projectid = GETPOST('projectid', 'int'); From dbf330b49c252b4f57805b04ecf76daeacd2c340 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 17:17:21 +0100 Subject: [PATCH 236/490] Comment on test --- test/phpunit/DateLibTzFranceTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/phpunit/DateLibTzFranceTest.php b/test/phpunit/DateLibTzFranceTest.php index 4b63450c332..0db809be2f7 100644 --- a/test/phpunit/DateLibTzFranceTest.php +++ b/test/phpunit/DateLibTzFranceTest.php @@ -83,7 +83,10 @@ class DateLibTzFranceTest extends PHPUnit\Framework\TestCase global $conf,$user,$langs,$db; if (getServerTimeZoneString() != 'Europe/Paris' && getServerTimeZoneString() != 'Europe/Berlin') { - print "\n".__METHOD__." This PHPUnit test can be launched manually only onto a server with PHP timezone set to TZ=Europe/Paris, not a TZ=".getServerTimeZoneString().".\n"; die(1); + print "\n".__METHOD__." This PHPUnit test can be launched manually only onto a server with PHP timezone set to TZ=Europe/Paris, not a TZ=".getServerTimeZoneString().".\n"; + print "You can launch the test from command line with:\n"; + print "php -d date.timezone='Europe/Paris' phpunit DateLibTzFranceTest.php\n"; + die(1); } $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. From df5b2b67284950e5ab2c5ddea095efe946b1a3d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 17:36:56 +0100 Subject: [PATCH 237/490] Update viewcat.php --- htdocs/categories/viewcat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index d6b663a8804..5912d63c7cf 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -795,7 +795,7 @@ if ($type == Categorie::TYPE_CONTACT) { $permission = $user->rights->societe->creer; $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset); - if (!is_array($contacts) && $contacts < 0) { + if (is_numeric($contacts) && $contacts < 0) { dol_print_error($db, $object->error, $object->errors); } else { // Form to add record into a category From cee573cf96094cee86453f0553cb542573d502dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 17:42:43 +0100 Subject: [PATCH 238/490] Update ProductCombination.class.php --- 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 10318f11a46..336503056f9 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -509,7 +509,7 @@ class ProductCombination for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { if ($parent->multiprices[$i] != '' || isset($this->combination_price_levels[$i]->variation_price)) { - $new_type = !empty($parent->multiprices_base_type[$i]) ? $parent->multiprices_base_type[$i] : 'HT'; + $new_type = empty($parent->multiprices_base_type[$i]) ? 'HT' : $parent->multiprices_base_type[$i]; $new_min_price = $parent->multiprices_min[$i]; $variation_price = doubleval(!isset($this->combination_price_levels[$i]->variation_price) ? $this->variation_price : $this->combination_price_levels[$i]->variation_price); $variation_price_percentage = doubleval(!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage); From 8ce70aac5d9bec2161d2a73bd40f0dae0b3eb7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 31 Oct 2021 18:43:11 +0100 Subject: [PATCH 239/490] display spf info from dns --- htdocs/admin/mails.php | 15 +++++++++++++-- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 1283c5698d3..acfafcf9370 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -848,8 +848,19 @@ if ($action == 'edit') { $text .= ($text ? '

    ' : '').''.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD); } } - - + $companyemail = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'); + $dnsinfo = false; + if (!empty($companyemail)) { + $domain = array_pop(explode('@', $companyemail)); + $dnsinfo = dns_get_record($domain, DNS_TXT); + } + if (!empty($dnsinfo) && is_array($dnsinfo)) { + foreach ($dnsinfo as $info) { + if (strpos($info['txt'], 'v=spf1') !== false) { + $text .= ($text ? '

    ' : '').$langs->trans("ActualMailSPFRecordFound", $info['txt']); + } + } + } if ($text) { print info_admin($text); } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d9099f567fa..4ff9f693cf7 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -501,6 +501,7 @@ WarningPHPMailC=- Using the SMTP server of your own Email Service Provider to se WarningPHPMailD=Also, it is therefore recommended to change the sending method of e-mails to the value "SMTP". If you really want to keep the default "PHP" method to send emails, just ignore this warning, or remove it by setting the MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP constant to 1 in Home - Setup - Other. WarningPHPMail2=If your email SMTP provider need to restrict email client to some IP addresses (very rare), this is the IP address of the mail user agent (MUA) for your ERP CRM application: %s. WarningPHPMailSPF=If the domain name in your sender email address is protected by a SPF record (ask your domain name registar), you must add the following IPs in the SPF record of the DNS of your domain: %s. +ActualMailSPFRecordFound=Actual SPF record found : %s ClickToShowDescription=Click to show description DependsOn=This module needs the module(s) RequiredBy=This module is required by module(s) From 7d60cddaac4f6b2cee06fb7a63c99e79eca1d1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 31 Oct 2021 19:36:31 +0100 Subject: [PATCH 240/490] fix warning same test at line 65 --- htdocs/core/tpl/object_discounts.tpl.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index df565aea6f9..38e1967c11b 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -1,5 +1,6 @@ + * Copyright (C) 2021 Frédéric France * * 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 @@ -88,7 +89,7 @@ if ($absolute_discount > 0) { // Is there credit notes availables ? if ($absolute_creditnote > 0) { // If validated, we show link "add credit note to payment" - if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) { + if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) { $translationKey = !empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; $text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency".$conf->currency)).'.'; From 033d983f051900f0e6f00429af9c246d4a3afc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 31 Oct 2021 20:41:07 +0100 Subject: [PATCH 241/490] fix warning --- htdocs/knowledgemanagement/knowledgerecord_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index d4a702f26b8..c2e26fb7a86 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2021 Frédéric France * * 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 @@ -104,7 +104,7 @@ foreach ($object->fields as $key => $val) { // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach ($object->fields as $key => $val) { - if ($val['searchall']) { + if (!empty($val['searchall'])) { $fieldstosearchall['t.'.$key] = $val['label']; } } From af8f74103a0b9401c1906bb57f60aa07ca8515c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 31 Oct 2021 20:48:13 +0100 Subject: [PATCH 242/490] Update knowledgerecord_list.php --- htdocs/knowledgemanagement/knowledgerecord_list.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index c2e26fb7a86..aed45b1db26 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -444,6 +444,7 @@ print ''; foreach ($object->fields as $key => $val) { + $searchkey = empty($search[$key]) ? '' : $search[$key]; $cssforfield = (empty($val['css']) ? '' : $val['css']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; @@ -458,9 +459,9 @@ foreach ($object->fields as $key => $val) { print ''; } @@ -522,7 +523,7 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object From bc972554c6a254c3aee643cd43cd9dda48c3d156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 31 Oct 2021 21:13:15 +0100 Subject: [PATCH 243/490] replace reseved word rank --- .../install/mysql/migration/14.0.0-15.0.0.sql | 189 +++++++++--------- .../mysql/tables/llx_hrm_evaluationdet.sql | 23 +-- .../install/mysql/tables/llx_hrm_skilldet.sql | 14 +- .../mysql/tables/llx_hrm_skillrank.sql | 19 +- 4 files changed, 116 insertions(+), 129 deletions(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index d25f039fd42..3e71d0f6d65 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -157,24 +157,23 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (20, '2012', ' -- START GRH/HRM MODULE -CREATE TABLE llx_hrm_evaluation( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - ref varchar(128) DEFAULT '(PROV)' NOT NULL, - label varchar(255), - description text, - note_public text, - note_private text, - date_creation datetime NOT NULL, - tms timestamp, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - import_key varchar(14), - status smallint NOT NULL, - date_eval date, - fk_user integer NOT NULL, - fk_job integer NOT NULL - -- END MODULEBUILDER FIELDS +CREATE TABLE llx_hrm_evaluation +( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + label varchar(255), + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status smallint NOT NULL, + date_eval date, + fk_user integer NOT NULL, + fk_job integer NOT NULL ) ENGINE=innodb; ALTER TABLE llx_hrm_evaluation ADD INDEX idx_hrm_evaluation_rowid (rowid); ALTER TABLE llx_hrm_evaluation ADD INDEX idx_hrm_evaluation_ref (ref); @@ -193,19 +192,19 @@ create table llx_hrm_evaluation_extrafields ALTER TABLE llx_hrm_evaluation_extrafields ADD INDEX idx_evaluation_fk_object(fk_object); -CREATE TABLE llx_hrm_evaluationdet( +CREATE TABLE llx_hrm_evaluationdet +( -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - date_creation datetime NOT NULL, - tms timestamp, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - fk_skill integer NOT NULL, - fk_evaluation integer NOT NULL, - rank integer NOT NULL, - required_rank integer NOT NULL, - import_key varchar(14) - -- END MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + fk_skill integer NOT NULL, + fk_evaluation integer NOT NULL, + rankorder integer NOT NULL, + required_rank integer NOT NULL, + import_key varchar(14) ) ENGINE=innodb; ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_rowid (rowid); @@ -226,20 +225,18 @@ ALTER TABLE llx_hrm_evaluationdet_extrafields ADD INDEX idx_evaluationdet_fk_obj - -CREATE TABLE llx_hrm_job( - - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - label varchar(255) NOT NULL, - description text, - date_creation datetime NOT NULL, - tms timestamp, - deplacement varchar(255), - note_public text, - note_private text, - fk_user_creat integer, - fk_user_modif integer - +CREATE TABLE llx_hrm_job +( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + label varchar(255) NOT NULL, + description text, + date_creation datetime NOT NULL, + tms timestamp, + deplacement varchar(255), + note_public text, + note_private text, + fk_user_creat integer, + fk_user_modif integer ) ENGINE=innodb; ALTER TABLE llx_hrm_job ADD INDEX idx_hrm_job_rowid (rowid); @@ -259,23 +256,21 @@ ALTER TABLE llx_hrm_job_extrafields ADD INDEX idx_job_fk_object(fk_object); CREATE TABLE llx_hrm_job_user( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - -- ref varchar(128) NOT NULL, - description text, - date_creation datetime NOT NULL, - tms timestamp, - fk_contrat integer, - fk_user integer NOT NULL, - fk_job integer NOT NULL, - date_start date, - date_end date, - commentaire_abandon varchar(255), - note_public text, - note_private text, - fk_user_creat integer, - fk_user_modif integer - -- END MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + -- ref varchar(128) NOT NULL, + description text, + date_creation datetime NOT NULL, + tms timestamp, + fk_contrat integer, + fk_user integer NOT NULL, + fk_job integer NOT NULL, + date_start date, + date_end date, + commentaire_abandon varchar(255), + note_public text, + note_private text, + fk_user_creat integer, + fk_user_modif integer ) ENGINE=innodb; ALTER TABLE llx_hrm_job_user ADD INDEX idx_hrm_job_user_rowid (rowid); @@ -294,22 +289,21 @@ ALTER TABLE llx_hrm_job_user_extrafields ADD INDEX idx_position_fk_object(fk_obj -CREATE TABLE llx_hrm_skill( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - label varchar(255), - description text, - date_creation datetime NOT NULL, - tms timestamp, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - required_level integer NOT NULL, - date_validite integer NOT NULL, - temps_theorique double(24,8) NOT NULL, - skill_type integer NOT NULL, - note_public text, - note_private text - -- END MODULEBUILDER FIELDS +CREATE TABLE llx_hrm_skill +( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + label varchar(255), + description text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + required_level integer NOT NULL, + date_validite integer NOT NULL, + temps_theorique double(24,8) NOT NULL, + skill_type integer NOT NULL, + note_public text, + note_private text ) ENGINE=innodb; ALTER TABLE llx_hrm_skill ADD INDEX idx_hrm_skill_rowid (rowid); @@ -327,15 +321,14 @@ create table llx_hrm_skill_extrafields ALTER TABLE llx_hrm_skill_extrafields ADD INDEX idx_skill_fk_object(fk_object); -CREATE TABLE llx_hrm_skilldet( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - description text, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - fk_skill integer NOT NULL, - rank integer - -- END MODULEBUILDER FIELDS +CREATE TABLE llx_hrm_skilldet +( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + description text, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + fk_skill integer NOT NULL, + rankorder integer ) ENGINE=innodb; ALTER TABLE llx_hrm_skilldet ADD INDEX idx_hrm_skilldet_rowid (rowid); @@ -352,18 +345,17 @@ create table llx_hrm_skilldet_extrafields ALTER TABLE llx_hrm_skilldet_extrafields ADD INDEX idx_skilldet_fk_object(fk_object); -CREATE TABLE llx_hrm_skillrank( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - fk_skill integer NOT NULL, - rank integer NOT NULL, - fk_object integer NOT NULL, - date_creation datetime NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - objecttype varchar(128) NOT NULL - -- END MODULEBUILDER FIELDS +CREATE TABLE llx_hrm_skillrank +( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + fk_skill integer NOT NULL, + rankorder integer NOT NULL, + fk_object integer NOT NULL, + date_creation datetime NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + objecttype varchar(128) NOT NULL ) ENGINE=innodb; ALTER TABLE llx_hrm_skillrank ADD INDEX idx_hrm_skillrank_rowid (rowid); @@ -429,4 +421,3 @@ ALTER TABLE llx_socpeople DROP COLUMN googleplus; ALTER TABLE llx_socpeople DROP COLUMN youtube; ALTER TABLE llx_socpeople DROP COLUMN whatsapp; - \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql index 0509cc80146..4e1b3860ec8 100644 --- a/htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql +++ b/htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql @@ -16,17 +16,16 @@ -- along with this program. If not, see https://www.gnu.org/licenses/. -CREATE TABLE llx_hrm_evaluationdet( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - date_creation datetime NOT NULL, - tms timestamp, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - fk_skill integer NOT NULL, - fk_evaluation integer NOT NULL, - rank integer NOT NULL, - required_rank integer NOT NULL, +CREATE TABLE llx_hrm_evaluationdet +( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + fk_skill integer NOT NULL, + fk_evaluation integer NOT NULL, + rankorder integer NOT NULL, + required_rank integer NOT NULL, import_key varchar(14) - -- END MODULEBUILDER FIELDS ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet.sql index fba82645915..0257d886813 100644 --- a/htdocs/install/mysql/tables/llx_hrm_skilldet.sql +++ b/htdocs/install/mysql/tables/llx_hrm_skilldet.sql @@ -17,12 +17,10 @@ CREATE TABLE llx_hrm_skilldet( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - description text, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - fk_skill integer NOT NULL, - rank integer - -- END MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + description text, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + fk_skill integer NOT NULL, + rankorder integer ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_skillrank.sql b/htdocs/install/mysql/tables/llx_hrm_skillrank.sql index 5c4deb95938..4c4109ee7f7 100644 --- a/htdocs/install/mysql/tables/llx_hrm_skillrank.sql +++ b/htdocs/install/mysql/tables/llx_hrm_skillrank.sql @@ -15,16 +15,15 @@ -- along with this program. If not, see https://www.gnu.org/licenses/. -CREATE TABLE llx_hrm_skillrank( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - fk_skill integer NOT NULL, - rank integer NOT NULL, - fk_object integer NOT NULL, - date_creation datetime NOT NULL, +CREATE TABLE llx_hrm_skillrank +( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + fk_skill integer NOT NULL, + rankorder integer NOT NULL, + fk_object integer NOT NULL, + date_creation datetime NOT NULL, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - fk_user_creat integer NOT NULL, - fk_user_modif integer, + fk_user_creat integer NOT NULL, + fk_user_modif integer, objecttype varchar(128) NOT NULL - -- END MODULEBUILDER FIELDS ) ENGINE=innodb; From 9a68a97fc60c6c1869194d308ccc935a795803c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 31 Oct 2021 21:18:59 +0100 Subject: [PATCH 244/490] replace commentaire_abandon by abort_comment --- htdocs/hrm/class/position.class.php | 4 ++-- .../install/mysql/migration/14.0.0-15.0.0.sql | 2 +- .../install/mysql/tables/llx_hrm_job_user.sql | 20 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 2a0d04fe393..26298c31aa7 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -113,7 +113,7 @@ class Position extends CommonObject 'fk_job' => array('type'=>'integer:Job:/hrm/class/job.class.php', 'label'=>'Job', 'enabled'=>'1', 'position'=>56, 'notnull'=>1, 'visible'=>1,), 'date_start' => array('type'=>'date', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>51, 'notnull'=>1, 'visible'=>1,), 'date_end' => array('type'=>'date', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>52, 'notnull'=>0, 'visible'=>1,), - 'commentaire_abandon' => array('type'=>'varchar(255)', 'label'=>'AbandonmentComment', 'enabled'=>'1', 'position'=>502, 'notnull'=>0, 'visible'=>1,), + 'abort_comment' => array('type'=>'varchar(255)', 'label'=>'AbandonmentComment', 'enabled'=>'1', 'position'=>502, 'notnull'=>0, 'visible'=>1,), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>0,), 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), @@ -129,7 +129,7 @@ class Position extends CommonObject public $fk_job; public $date_start; public $date_end; - public $commentaire_abandon; + public $abort_comment; public $note_public; public $note_private; public $fk_user_creat; diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 3e71d0f6d65..6e751280a28 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -266,7 +266,7 @@ CREATE TABLE llx_hrm_job_user( fk_job integer NOT NULL, date_start date, date_end date, - commentaire_abandon varchar(255), + abort_comment varchar(255), note_public text, note_private text, fk_user_creat integer, diff --git a/htdocs/install/mysql/tables/llx_hrm_job_user.sql b/htdocs/install/mysql/tables/llx_hrm_job_user.sql index ce9620623dd..6124f84e1e6 100644 --- a/htdocs/install/mysql/tables/llx_hrm_job_user.sql +++ b/htdocs/install/mysql/tables/llx_hrm_job_user.sql @@ -17,17 +17,17 @@ CREATE TABLE llx_hrm_job_user( -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, -- ref varchar(128) NOT NULL, - description text, - date_creation datetime NOT NULL, - tms timestamp, - fk_contrat integer, - fk_user integer NOT NULL, - fk_job integer NOT NULL, - date_start datetime, - date_end datetime, - commentaire_abandon varchar(255), + description text, + date_creation datetime NOT NULL, + tms timestamp, + fk_contrat integer, + fk_user integer NOT NULL, + fk_job integer NOT NULL, + date_start datetime, + date_end datetime, + abort_comment varchar(255), note_public text, note_private text, fk_user_creat integer, From 445fea18bbf9482912525fce42b35e98c35e44ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 31 Oct 2021 22:20:02 +0100 Subject: [PATCH 245/490] fix scrutinizer dol_set_focus returns void --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 2e06d89c39c..79ae03cbe4f 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -817,7 +817,7 @@ if ($action == 'create' || $action == 'adduserldap') { print dol_get_fiche_head('', '', '', 0, ''); - print dol_set_focus('#lastname'); + dol_set_focus('#lastname'); print '
    '; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $searchkey, $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { - print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); + print $object->showInputField($val, $key, $searchkey, '', '', 'search_', 'maxwidth125', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
    '; print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -469,9 +470,9 @@ foreach ($object->fields as $key => $val) { print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
    '; } elseif ($key == 'lang') { - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + print $formadmin->select_language($searchkey, 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); } else { - print ''; + print ''; } print '
    '; From 270ddfda1f20c4589d236d70fcf65df32872eca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 31 Oct 2021 22:24:25 +0100 Subject: [PATCH 246/490] fix scrutinizer --- htdocs/core/lib/geturl.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 70eca219e03..be7e1ffa80b 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -251,7 +251,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = dol_syslog("getURLContent request=".$request); if (!empty($conf->global->MAIN_GETURLCONTENT_OUTPUT_RESPONSE)) { // This may contains binary data, so we dont output reponse by default. - dol_syslog("getURLContent response =".response); + dol_syslog("getURLContent response =".$response); } dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it From 75eff571d9e8b0be3cc25257b470bf82047e7593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 31 Oct 2021 22:27:39 +0100 Subject: [PATCH 247/490] fix unknown function --- htdocs/core/modules/societe/mod_codeclient_elephant.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index c44b290bb0e..67edcb94b8b 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -132,7 +132,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode // Parametrage du prefix customers $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; @@ -140,7 +140,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode // Parametrage du prefix suppliers $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= '
    '.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).' 
    '.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).'
    '; From e02565190a028ed129d88cb8e837b3b84d3c82bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 01:10:30 +0100 Subject: [PATCH 248/490] replace function each deprecated in php 7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Warning This function has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged. Avertissement Cette fonctionnalité est OBSOLÈTE à partir de PHP 7.2.0 et a été SUPPRIMÉE à partir de PHP 8.0.0. --- htdocs/includes/printipp/http_class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/includes/printipp/http_class.php b/htdocs/includes/printipp/http_class.php index 30bb33d663b..27a3d0cb584 100644 --- a/htdocs/includes/printipp/http_class.php +++ b/htdocs/includes/printipp/http_class.php @@ -366,7 +366,9 @@ class http_class $content_length = 0; foreach ($this->arguments["BodyStream"] as $argument) { - list ($type, $value) = each ($argument); + // list ($type, $value) = each ($argument); + $type = key($argument); + $value = current($argument); reset ($argument); if ($type == "Data") { @@ -420,7 +422,9 @@ class http_class } foreach ($this->arguments["BodyStream"] as $argument) { - list ($type, $value) = each ($argument); + // list ($type, $value) = each ($argument); + $type = key($argument); + $value = current($argument); reset ($argument); if ($type == "Data") { From d5130f25418e367b53cd015891b7d743211f3370 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Nov 2021 02:16:29 +0100 Subject: [PATCH 249/490] Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop FIX #19013 --- htdocs/adherents/card.php | 14 ++--- htdocs/ticket/card.php | 85 +++++++++++++++------------- htdocs/ticket/class/ticket.class.php | 19 +++++-- 3 files changed, 68 insertions(+), 50 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index cf0d82b2c7b..5b53437a212 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1788,13 +1788,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; - // Birth Date - print ''; - - // Public - print ''; - - // Categories + // Tags / Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { print ''; print ''; } + // Birth Date + print ''; + + // Public + print ''; + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 581ca8601e8..3dbd1ad8aa7 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -618,7 +618,7 @@ if (empty($reshook)) { if ($ret > 0) { $log_action = $langs->trans('TicketInitialMessageModified')." \n"; // include the Diff class - dol_include_once('/ticket/class/utils_diff.class.php'); + include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php'; // output the result of comparing two files as plain text $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); @@ -1048,11 +1048,11 @@ if ($action == 'create' || $action == 'presend') { print '
    '.$langs->trans("DateOfBirth").''.dol_print_date($object->birth, 'day').'
    '.$langs->trans("Public").''.yn($object->public).'
    '.$langs->trans("Categories").''; @@ -1802,6 +1796,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
    '.$langs->trans("DateOfBirth").''.dol_print_date($object->birth, 'day').'
    '.$langs->trans("Public").''.yn($object->public).'
    '; + print '
    '; print $langs->trans("AssignedTo"); if ($object->fk_statut < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) { - print ''.img_edit($langs->trans('Modify'), '').''.img_edit($langs->trans('Modify'), '').''; } - print '
    '; + print '
    '; print '
    '; - if ($object->fk_user_assign > 0) { + if (GETPOST('set', 'alpha') != "assign_ticket" && $object->fk_user_assign > 0) { $userstat->fetch($object->fk_user_assign); print $userstat->getNomUrl(-1); } @@ -1063,30 +1063,30 @@ if ($action == 'create' || $action == 'presend') { print ''; print ''; print ''; - print ' '; + //print ' '; print $form->select_dolusers($user->id, 'fk_user_assign', 1); - print ' '; + print ' '; print ''; } print '
    '; - print ''; // Timing (Duration sum of linked fichinter) - if ($conf->ficheinter->enabled) { + if (!empty($conf->ficheinter->enabled)) { $object->fetchObjectLinked(); $num = count($object->linkedObjects); $timing = 0; + $foundinter = 0; if ($num) { foreach ($object->linkedObjects as $objecttype => $objects) { if ($objecttype = "fichinter") { foreach ($objects as $fichinter) { + $foundinter++; $timing += $fichinter->duration; } } } } - print ''; } + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print ''; if ($action != 'progression' && $object->fk_statut < $object::STATUS_CLOSED && !$user->socid) { print ''; } print '
    '; print $langs->trans('Progression').''; print ''.img_edit($langs->trans('Modify')).'
    '; - print '
    '; + print ''; if ($user->rights->ticket->write && $action == 'progression') { print '
    '; print ''; print ''; print ''; - print ''; - print ' '; + print ''; + print ' '; print '
    '; } else { print($object->progress > 0 ? $object->progress : '0').'%'; @@ -1095,32 +1095,53 @@ if ($action == 'create' || $action == 'presend') { print '
    '; - + print '
    '; print $form->textwithpicto($langs->trans("TicketDurationAuto"), $langs->trans("TicketDurationAutoInfos"), 1); print ''; - print convertSecondToTime($timing, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + print $foundinter ? convertSecondToTime($timing, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY) : ''; print '
    '; + + + // Fin colonne gauche et début colonne droite + print '
    '; + + print '
    '; + print ''; + print ''; + print ''; + + print '
    '; + // Categories if ($conf->categorie->enabled) { + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + + print ''; + print ''; - print ''; - - print '"; - } - + + print '"; + } + print ''; print ''; - foreach ($this->params as $item) { + foreach ($this->items as $item) { $out .= $this->generateLineOutput($item, $editMode); } $out .= ''; @@ -117,13 +117,13 @@ class formSetup public function saveConfFromPost($noMessageInUpdate = false) { - if (empty($this->params)) { + if (empty($this->items)) { return null; } $this->db->begin(); $error = 0; - foreach ($this->params as $item) { + foreach ($this->items as $item) { $res = $item->setValueFromPost(); if ($res > 0) { $item->saveConfValue(); @@ -234,7 +234,7 @@ class formSetup $item->cssClass = $params['css']; } - $this->params[$item->confKey] = $item; + $this->items[$item->confKey] = $item; return true; } @@ -247,7 +247,7 @@ class formSetup public function exportItemsAsParamsArray() { $arrayofparameters = array(); - foreach ($this->params as $key => $item) { + foreach ($this->items as $key => $item) { $arrayofparameters[$item->confKey] = array( 'type' => $item->getType(), 'enabled' => $item->enabled @@ -265,8 +265,8 @@ class formSetup public function reloadConfs() { - if (!array($this->params)) { return false; } - foreach ($this->params as $item) { + if (!array($this->items)) { return false; } + foreach ($this->items as $item) { $item->reloadValueFromConf(); } @@ -294,8 +294,8 @@ class formSetup // try to get rank from target column, this will override item->rank if (!empty($targetItemKey)) { - if (isset($this->params[$targetItemKey])) { - $targetItem = $this->params[$targetItemKey]; + if (isset($this->items[$targetItemKey])) { + $targetItem = $this->items[$targetItemKey]; $item->rank = $targetItem->rank; // $targetItem->rank will be increase after if ($targetItem->rank >= 0 && $insertAfterTarget) { $item->rank++; @@ -303,7 +303,7 @@ class formSetup } // calc new rank for each item to make place for new item - foreach ($this->params as $fItem) { + foreach ($this->items as $fItem) { if ($item->rank <= $fItem->rank) { $fItem->rank = $fItem->rank + 1; $this->setItemMaxRank($fItem->rank); // set new max rank if needed @@ -311,8 +311,8 @@ class formSetup } } - $this->params[$item->confKey] = $item; - return $this->params[$item->confKey]; + $this->items[$item->confKey] = $item; + return $this->items[$item->confKey]; } /** @@ -322,7 +322,7 @@ class formSetup public function sortingItems() { // Sorting - return uasort($this->params, array($this, 'itemSort')); + return uasort($this->items, array($this, 'itemSort')); } /** @@ -331,7 +331,7 @@ class formSetup */ public function getCurentItemMaxRank($cache = true) { - if (empty($this->params)) { + if (empty($this->items)) { return 0; } @@ -340,7 +340,7 @@ class formSetup } $this->maxItemRank = 0; - foreach ($this->params as $item) { + foreach ($this->items as $item) { $this->maxItemRank = max($this->maxItemRank, $item->rank); } @@ -367,10 +367,10 @@ class formSetup */ public function getLineRank($itemKey) { - if (!isset($this->params[$itemKey]->rank)) { + if (!isset($this->items[$itemKey]->rank)) { return -1; } - return $this->params[$itemKey]->rank; + return $this->items[$itemKey]->rank; } diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 527ea8eb32d..417c28f30a2 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -265,7 +265,7 @@ if ($action == 'edit') { print ''; print '
    '; } else { - if (!empty($formSetup->params)) { + if (!empty($formSetup->items)) { print $formSetup->generateOutput(); $setupnotempty++; From 12b046cb68a41ace480a519d366f3243b03144d6 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 2 Nov 2021 14:11:36 +0100 Subject: [PATCH 287/490] Fix class name --- htdocs/core/class/html.formsetup.class.php | 20 +++++++++---------- htdocs/modulebuilder/template/admin/setup.php | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 8f9d3af0528..6f2ec2acfb6 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -19,7 +19,7 @@ /** * This class help you create setup render */ -class formSetup +class FormSetup { /** @@ -27,7 +27,7 @@ class formSetup */ public $db; - /** @var formSetupItem[] */ + /** @var FormSetupItem[] */ public $items = array(); /** @@ -147,7 +147,7 @@ class formSetup } /** - * @param formSetupItem $item the setup item + * @param FormSetupItem $item the setup item * @param bool $editMode Display as edit mod * @return string the html output for an setup item */ @@ -223,7 +223,7 @@ class formSetup //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), */ - $item = new formSetupItem($confKey); + $item = new FormSetupItem($confKey); $item->setTypeFromTypeString($params['type']); if (!empty($params['enabled'])) { @@ -280,11 +280,11 @@ class formSetup * @param $confKey the conf key used in database * @param string $targetItemKey target item used to place the new item beside * @param bool $insertAfterTarget insert before or after target item ? - * @return formSetupItem the new setup item created + * @return FormSetupItem the new setup item created */ public function newItem($confKey, $targetItemKey = false, $insertAfterTarget = false) { - $item = new formSetupItem($confKey); + $item = new FormSetupItem($confKey); // set item rank if not defined as last item if (empty($item->rank)) { @@ -377,11 +377,11 @@ class formSetup /** * uasort callback function to Sort params items * - * @param formSetupItem $a formSetup item - * @param formSetupItem $b formSetup item + * @param FormSetupItem $a formSetup item + * @param FormSetupItem $b formSetup item * @return int Return compare result */ - public function itemSort(formSetupItem $a, formSetupItem $b) + public function itemSort(FormSetupItem $a, FormSetupItem $b) { if (empty($a->rank)) { $a->rank = 0; @@ -399,7 +399,7 @@ class formSetup /** * This class help to create item for class formSetup */ -class formSetupItem +class FormSetupItem { /** * @var DoliDB Database handler. diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 417c28f30a2..206cca0ff52 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -79,7 +79,7 @@ $type = 'myobject'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; -$formSetup = new formSetup($db); +$formSetup = new FormSetup($db); // Hôte From 98929f2dbac85245debf9f05670f3ba5947dbfea Mon Sep 17 00:00:00 2001 From: BadPixxel Date: Tue, 2 Nov 2021 14:16:55 +0100 Subject: [PATCH 288/490] FIX: Status propagation from Parent Product toSell or toBuy Status propagation should be done only when parent is updated. Otherwise, any modification made on the parent will overwrite the specific configuration made at the child level. --- htdocs/variants/class/ProductCombination.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index b7fc3d620f5..4245f2039c9 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -488,8 +488,14 @@ class ProductCombination $child->price_autogen = $parent->price_autogen; $child->weight = $parent->weight; - $child->status = $parent->status; - + // Only when Parent Status are updated + if ($parent->oldcopy && ($parent->status != $parent->oldcopy->status)) { + $child->status = $parent->status; + } + if ($parent->oldcopy && ($parent->status_buy != $parent->oldcopy->status_buy)) { + $child->status_buy = $parent->status_buy; + } + if ($this->variation_weight) { // If we must add a delta on weight $child->weight = ($child->weight ? $child->weight : 0) + $this->variation_weight; } From 5c10cd5ba9df55220a1f218da5333ec444e01b61 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 2 Nov 2021 13:20:41 +0000 Subject: [PATCH 289/490] Fixing style errors. --- htdocs/variants/class/ProductCombination.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 4245f2039c9..e1fab396cb8 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -490,12 +490,12 @@ class ProductCombination $child->weight = $parent->weight; // Only when Parent Status are updated if ($parent->oldcopy && ($parent->status != $parent->oldcopy->status)) { - $child->status = $parent->status; - } + $child->status = $parent->status; + } if ($parent->oldcopy && ($parent->status_buy != $parent->oldcopy->status_buy)) { - $child->status_buy = $parent->status_buy; - } - + $child->status_buy = $parent->status_buy; + } + if ($this->variation_weight) { // If we must add a delta on weight $child->weight = ($child->weight ? $child->weight : 0) + $this->variation_weight; } From 82b7f0e9e45e7b85b544ed8a8d9ca60cdb0dfabc Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 2 Nov 2021 15:21:14 +0100 Subject: [PATCH 290/490] FIX second approval back in stable feature as is the setting for minimum amount (last part from PR#14286) --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 72ba5be84ee..00bc994096f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -999,7 +999,7 @@ class CommandeFournisseur extends CommonOrder if (empty($secondlevel)) { // standard or first level approval $sql .= " date_approve='".$this->db->idate($now)."',"; $sql .= " fk_user_approve = ".$user->id; - if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { if (empty($this->user_approve_id2)) { $movetoapprovestatus = false; // second level approval not done $comment = ' (first level)'; From 126fbf9f631a3ff7d226e8719d0c3b12a8c2dc20 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:46:04 +0100 Subject: [PATCH 291/490] Change date format to be equal to mass stock transfert --- htdocs/product/stock/tpl/stockcorrection.tpl.php | 2 +- htdocs/product/stock/tpl/stocktransfer.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 05d628902fb..e1a5e734016 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -155,7 +155,7 @@ print ''; print ''; -print ''; +print ''; print ''; print '
    '; - print '
    '; + print ''; + print ''; @@ -1130,7 +1151,7 @@ if ($action == 'create' || $action == 'presend') { if ($user->rights->ticket->write && $action == 'categories') { $cate_arbo = $form->select_all_categories(Categorie::TYPE_TICKET, '', 'parent', 64, 0, 1); - if (count($cate_arbo)) { + if (is_array($cate_arbo)) { // Categories print '"; } @@ -1155,27 +1176,15 @@ if ($action == 'create' || $action == 'presend') { print $form->showCategories($object->id, Categorie::TYPE_TICKET, 1); print ""; } + + print '
    '; print $langs->trans("Categories"); if ($action != 'categories' && !$user->socid) { print ''.img_edit($langs->trans('Modify')).''; print ''; @@ -1146,7 +1167,7 @@ if ($action == 'create' || $action == 'presend') { } print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print ''; + print ''; print ''; print "
    '; } - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
    '; - - - // Fin colonne gauche et début colonne droite - print '
    '; - // View Original message $actionobject->viewTicketOriginalMessage($user, $action, $object); // Classification of ticket - print '
    '; - print ''; - print ''; - print ''; - print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; @@ -1184,11 +1193,11 @@ if ($action == 'create' || $action == 'presend') { print ''; print ''; @@ -1198,7 +1207,7 @@ if ($action == 'create' || $action == 'presend') { print ''; // Type print ''; @@ -1206,15 +1215,15 @@ if ($action == 'create' || $action == 'presend') { // Group print ''; print ''; print ''; // Severity print ''; print ''; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index ed134296e76..2265bb2fb66 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1258,12 +1258,12 @@ class Ticket extends CommonObject /** * Return status label of object * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label */ public function getLibStatut($mode = 0) { - return $this->libStatut($this->fk_statut, $mode); + return $this->libStatut($this->fk_statut, $mode, 0, $this->progress); } @@ -1274,9 +1274,10 @@ class Ticket extends CommonObject * @param string $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @param int $notooltip 1=No tooltip + * @param int $progress Progression (0 to 100) * @return string Label */ - public function LibStatut($status, $mode = 0, $notooltip = 0) + public function LibStatut($status, $mode = 0, $notooltip = 0, $progress = 0) { // phpcs:enable global $langs; @@ -1312,7 +1313,15 @@ class Ticket extends CommonObject $params = array('tooltip' => 'no'); } - return dolGetStatus($langs->transnoentitiesnoconv($labelStatus), $langs->transnoentitiesnoconv($labelStatusShort), '', $statusType, $mode, '', $params); + $labelStatus = $langs->transnoentitiesnoconv($labelStatus); + $labelStatusShort = $langs->transnoentitiesnoconv($labelStatusShort); + + if ($status == self::STATUS_IN_PROGRESS && $progress > 0) { + $labelStatus .= ' ('.round($progress).'%)'; + $labelStatusShort .= ' ('.round($progress).'%)'; + } + + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode, '', $params); } From e4613b3104c06862d6b25b97f7732a4f3e709716 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Nov 2021 02:28:41 +0100 Subject: [PATCH 250/490] FIX sql error when values for natural_search is an array --- htdocs/ticket/list.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 141cafa17fd..1bac8af0e92 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -383,15 +383,16 @@ foreach ($search as $key => $val) { $sql .= natural_search($key, join(',', $newarrayofstatus), 2); } continue; - } - if ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project') { + } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project') { if ($search[$key] > 0) { $sql .= natural_search($key, $search[$key], 2); } continue; } + $mode_search = ((!empty($object->fields[$key]) && ($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))) ? 1 : 0); - if ($search[$key] != '') { + // $search[$key] can be an array of values, or a string. We add filter if array not empty or if it is a string. + if ((is_array($search[$key]) && !empty($search[$key])) || (!is_array($search[$key]) && $search[$key] != '')) { $sql .= natural_search($key, $search[$key], $mode_search); } } From 3c69fb0ea3f866bf6b3449aed13bffcf866dd00c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Nov 2021 02:35:15 +0100 Subject: [PATCH 251/490] Update mails.php --- htdocs/admin/mails.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index acfafcf9370..90036b752b0 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -850,13 +850,13 @@ if ($action == 'edit') { } $companyemail = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'); $dnsinfo = false; - if (!empty($companyemail)) { + if (!empty($companyemail) && function_exists('dns_get_record')) { $domain = array_pop(explode('@', $companyemail)); $dnsinfo = dns_get_record($domain, DNS_TXT); } if (!empty($dnsinfo) && is_array($dnsinfo)) { foreach ($dnsinfo as $info) { - if (strpos($info['txt'], 'v=spf1') !== false) { + if (strpos($info['txt'], 'v=spf') !== false) { $text .= ($text ? '

    ' : '').$langs->trans("ActualMailSPFRecordFound", $info['txt']); } } From 1b336456ce3ae58f7fd522f6a6529773623a39b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Nov 2021 02:44:14 +0100 Subject: [PATCH 252/490] Code comment --- htdocs/core/class/ldap.class.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index e2ce33cc45f..4e0c2bd83ca 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -292,12 +292,12 @@ class Ldap } - /** - * Simply closes the connection set up earlier. - * Returns true if OK, false if there was an error. + * Simply closes the connection set up earlier. Returns true if OK, false if there was an error. + * This method seems a duplicate/alias of unbind(). * * @return boolean true or false + * @see unbind() */ public function close() { @@ -349,16 +349,21 @@ class Ldap } /** - * Unbind du serveur ldap. + * Unbind of LDAP server (close connection). * * @return boolean true or false + * @see close() */ public function unbind() { - if (!$this->result = @ldap_unbind($this->connection)) { - return false; - } else { + $this->result = true; + if ($this->connection) { + $this->result = @ldap_unbind($this->connection); + } + if ($this->result) { return true; + } else { + return false; } } From 3e46d5812915c8497ec28aaa8de9980ffe53e0a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Nov 2021 03:14:54 +0100 Subject: [PATCH 253/490] FIX Type of field progression in ticket must be integer --- .../install/mysql/migration/14.0.0-15.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_ticket.sql | 2 +- htdocs/ticket/class/ticket.class.php | 2 +- htdocs/ticket/list.php | 27 +++++++++---------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 6e751280a28..02a18f69a40 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -87,6 +87,9 @@ ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0; ALTER TABLE llx_holiday ADD COLUMN date_approve DATETIME DEFAULT NULL; ALTER TABLE llx_holiday ADD COLUMN fk_user_approve integer DEFAULT NULL; +ALTER TABLE llx_ticket MODIFY COLUMN progress integer; + + ALTER TABLE llx_emailcollector_emailcollectoraction MODIFY COLUMN actionparam TEXT; ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN lang varchar(6); diff --git a/htdocs/install/mysql/tables/llx_ticket.sql b/htdocs/install/mysql/tables/llx_ticket.sql index c053e787dfa..d891a65d502 100644 --- a/htdocs/install/mysql/tables/llx_ticket.sql +++ b/htdocs/install/mysql/tables/llx_ticket.sql @@ -29,7 +29,7 @@ CREATE TABLE llx_ticket message text, fk_statut integer, resolution integer, - progress varchar(100), + progress integer DEFAULT 0, -- progression 0 - 100 or null timing varchar(20), type_code varchar(32), category_code varchar(32), diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 2265bb2fb66..43bb2cd5835 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -271,7 +271,7 @@ class Ticket extends CommonObject 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1), 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,), 'email_msgid' => array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'help'=>'EmailMsgIDDesc'), - 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>"", 'isameasure'=>2), + 'progress' => array('type'=>'integer', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>"", 'isameasure'=>2, 'csslist'=>'width50'), 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>'$conf->global->TICKET_ENABLE_RESOLUTION', 'position'=>550, 'notnull'=>1), 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'SolvedClosed', 9 => 'Deleted')), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 1bac8af0e92..96ac7aab8be 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -334,20 +334,18 @@ $title = $langs->trans('TicketList'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) { - $sql .= "t.".$key.", "; -} +$sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } } // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql = preg_replace('/, $/', '', $sql); +$sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -424,7 +422,6 @@ if ($search_dateclose_end) { $sql .= " AND t.date_close <= '".$db->idate($search_dateclose_end)."'"; } - if (!$user->socid && ($mode == "mine" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) { $sql .= " AND (t.fk_user_assign = ".((int) $user->id); if (empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) { @@ -675,8 +672,6 @@ $arrayofmassactions = array( ); if ($user->rights->ticket->write) { $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close"); -} -if ($user->rights->ticket->write) { $arrayofmassactions['reopen'] = img_picto('', 'folder-open', 'class="pictofixedwidth"').$langs->trans("ReOpen"); } if ($user->rights->ticket->delete) { @@ -768,18 +763,22 @@ print '
    '; if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) { - print ''; + print ''; } else { // Button to edit Properties if ($object->fk_statut < $object::STATUS_NEED_MORE_INFO && $user->rights->ticket->write) { - print ''.img_edit($langs->trans('Modify')).''; + print ' '.img_edit($langs->trans('Modify')).''; } } print '
    '; - print $langs->trans('TicketChangeType'); + print $langs->trans('Type'); print ''; $formticket->selectTypesTickets($object->type_code, 'update_value_type', '', 2); print '
    '; - print $langs->trans('TicketChangeCategory'); + print $langs->trans('TicketCategory'); print ''; - $formticket->selectGroupTickets($object->category_code, 'update_value_category', '', 2); + $formticket->selectGroupTickets($object->category_code, 'update_value_category', '', 2, 0, 0, 0, 'maxwidth500'); print '
    '; - print $langs->trans('TicketChangeSeverity'); + print $langs->trans('TicketSeverity'); print ''; $formticket->selectSeveritiesTickets($object->severity_code, 'update_value_severity', '', 2); print '
    '; foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'fk_statut') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - if ($key == 'type_code') { + if ($key == 'progress') { + print ''; + } elseif ($key == 'type_code') { print ''; @@ -873,18 +872,18 @@ print ''."\n"; // -------------------------------------------------------------------- print ''; foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'fk_statut' || $key == 'severity_code') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, '', $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } $totalarray = array( From 2f7e246ab366735fbd199047cbde4cb82db59c1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Nov 2021 03:18:12 +0100 Subject: [PATCH 254/490] Merge --- htdocs/includes/printipp/http_class.php | 954 +++++++++++------------- 1 file changed, 446 insertions(+), 508 deletions(-) diff --git a/htdocs/includes/printipp/http_class.php b/htdocs/includes/printipp/http_class.php index 30bb33d663b..553152b5c90 100644 --- a/htdocs/includes/printipp/http_class.php +++ b/htdocs/includes/printipp/http_class.php @@ -4,7 +4,7 @@ /* ==================================================================== * GNU Lesser General Public License * Version 2.1, February 1999 - * + * * Class http_class - Basic http client with "Basic" and Digest/MD5 * authorization mechanism. * handle ipv4/v6 addresses, Unix sockets, http and https @@ -31,13 +31,13 @@ * This class is intended to implement a subset of Hyper Text Transfer Protocol * (HTTP/1.1) on client side (currently: POST operation), with file streaming * capability. - * + * * It can perform Basic and Digest authentication. - * + * * References needed to debug / add functionnalities: * - RFC 2616 * - RFC 2617 - * + * * * Class and Function List: * Function list: @@ -66,58 +66,55 @@ ************************/ class httpException extends Exception { - protected $errno; + protected $errno; - public function __construct ($msg, $errno = null) - { - parent::__construct ($msg); - $this->errno = $errno; - } + public function __construct($msg, $errno = null) + { + parent::__construct($msg); + $this->errno = $errno; + } - public function getErrorFormatted () - { - return sprintf ("[http_class]: %s -- "._(" file %s, line %s"), - $this->getMessage (), $this->getFile (), $this->getLine ()); - } + public function getErrorFormatted() + { + return sprintf("[http_class]: %s -- "._(" file %s, line %s"), + $this->getMessage(), $this->getFile(), $this->getLine()); + } - public function getErrno () - { - return $this->errno; - } + public function getErrno() + { + return $this->errno; + } } function error2string($value) { - $level_names = array( - E_ERROR => 'E_ERROR', - E_WARNING => 'E_WARNING', - E_PARSE => 'E_PARSE', - E_NOTICE => 'E_NOTICE', - E_CORE_ERROR => 'E_CORE_ERROR', - E_CORE_WARNING => 'E_CORE_WARNING', - E_COMPILE_ERROR => 'E_COMPILE_ERROR', - E_COMPILE_WARNING => 'E_COMPILE_WARNING', - E_USER_ERROR => 'E_USER_ERROR', - E_USER_WARNING => 'E_USER_WARNING', - E_USER_NOTICE => 'E_USER_NOTICE' - ); - if(defined('E_STRICT')) { - $level_names[E_STRICT]='E_STRICT'; - } - $levels=array(); - if(($value&E_ALL)==E_ALL) - { - $levels[]='E_ALL'; - $value&=~E_ALL; - } - foreach($level_names as $level=>$name) - { - if(($value&$level)==$level) - { - $levels[]=$name; - } - } - return implode(' | ',$levels); + $level_names = array( + E_ERROR => 'E_ERROR', + E_WARNING => 'E_WARNING', + E_PARSE => 'E_PARSE', + E_NOTICE => 'E_NOTICE', + E_CORE_ERROR => 'E_CORE_ERROR', + E_CORE_WARNING => 'E_CORE_WARNING', + E_COMPILE_ERROR => 'E_COMPILE_ERROR', + E_COMPILE_WARNING => 'E_COMPILE_WARNING', + E_USER_ERROR => 'E_USER_ERROR', + E_USER_WARNING => 'E_USER_WARNING', + E_USER_NOTICE => 'E_USER_NOTICE' + ); + if (defined('E_STRICT')) { + $level_names[E_STRICT]='E_STRICT'; + } + $levels=array(); + if (($value&E_ALL)==E_ALL) { + $levels[]='E_ALL'; + $value&=~E_ALL; + } + foreach ($level_names as $level=>$name) { + if (($value&$level)==$level) { + $levels[]=$name; + } + } + return implode(' | ', $levels); } /*********************** @@ -127,486 +124,427 @@ function error2string($value) ************************/ class http_class { - // variables declaration - public $debug; - public $html_debug; - public $timeout = 30; // time waiting for connection, seconds - public $data_timeout = 30; // time waiting for data, milliseconds - public $data_chunk_timeout = 1; // time waiting between data chunks, millisecond - public $force_multipart_form_post; - public $username; - public $password; - public $request_headers = array (); - public $request_body = "Not a useful information"; - public $status; - public $window_size = 1024; // chunk size of data - public $with_exceptions = 0; // compatibility mode for old scripts - public $port; - public $host; - private $default_port = 631; - private $headers; - private $reply_headers = array (); - private $reply_body = array (); - private $connection; - private $arguments; - private $bodystream = array (); - private $last_limit; - private $connected; - private $nc = 1; - private $user_agent = "PRINTIPP/0.81+CVS"; - private $readed_bytes = 0; + // variables declaration + public $debug; + public $html_debug; + public $timeout = 30; // time waiting for connection, seconds + public $data_timeout = 30; // time waiting for data, milliseconds + public $data_chunk_timeout = 1; // time waiting between data chunks, millisecond + public $force_multipart_form_post; + public $username; + public $password; + public $request_headers = array (); + public $request_body = "Not a useful information"; + public $status; + public $window_size = 1024; // chunk size of data + public $with_exceptions = 0; // compatibility mode for old scripts + public $port; + public $host; + private $default_port = 631; + private $headers; + private $reply_headers = array (); + private $reply_body = array (); + private $connection; + private $arguments; + private $bodystream = array (); + private $last_limit; + private $connected; + private $nc = 1; + private $user_agent = "PRINTIPP/0.81+CVS"; + private $readed_bytes = 0; - public function __construct () - { - true; - } + public function __construct() + { + true; + } - /********************* - * - * Public functions - * - **********************/ + /********************* + * + * Public functions + * + **********************/ - public function GetRequestArguments ($url, &$arguments) - { - $this->arguments = array (); - $this->arguments["URL"] = $arguments["URL"] = $url; - $this->arguments["RequestMethod"] = $arguments["RequestMethod"] = "POST"; - $this->headers["Content-Length"] = 0; - $this->headers["Content-Type"] = "application/octet-stream"; - $this->headers["Host"] = $this->host; - $this->headers["User-Agent"] = $this->user_agent; - //$this->headers["Expect"] = "100-continue"; - } + public function GetRequestArguments($url, &$arguments) + { + $this->arguments = array (); + $this->arguments["URL"] = $arguments["URL"] = $url; + $this->arguments["RequestMethod"] = $arguments["RequestMethod"] = "POST"; + $this->headers["Content-Length"] = 0; + $this->headers["Content-Type"] = "application/octet-stream"; + $this->headers["Host"] = $this->host; + $this->headers["User-Agent"] = $this->user_agent; + //$this->headers["Expect"] = "100-continue"; + } - public function Open ($arguments) - { - $this->connected = false; - $url = $arguments["URL"]; - $port = $this->default_port; - #$url = split (':', $url, 2); - $url = preg_split ('#:#', $url, 2); - $transport_type = $url[0]; - $unix = false; - switch ($transport_type) - { - case 'http': - $transport_type = 'tcp://'; - break; + public function Open($arguments) + { + $this->connected = false; + $url = $arguments["URL"]; + $port = $this->default_port; + // $url = split (':', $url, 2); + $url = preg_split('#:#', $url, 2); + $transport_type = $url[0]; + $unix = false; + switch ($transport_type) { + case 'http': + $transport_type = 'tcp://'; + break; - case 'https': - $transport_type = 'tls://'; - break; + case 'https': + $transport_type = 'tls://'; + break; - case 'unix': - $transport_type = 'unix://'; - $port = 0; - $unix = true; - break; + case 'unix': + $transport_type = 'unix://'; + $port = 0; + $unix = true; + break; - default: - $transport_type = 'tcp://'; - break; - } - $url = $url[1]; - if (!$unix) - { - #$url = split ("/", preg_replace ("#^/{1,}#", '', $url), 2); - $url = preg_split ("#/#", preg_replace ("#^/{1,}#", '', $url), 2); - $url = $url[0]; - $port = $this->port; - $error = sprintf (_("Cannot resolve url: %s"), $url); - $ip = gethostbyname ($url); - $ip = @gethostbyaddr ($ip); - if (!$ip) - { - return $this->_HttpError ($error, E_USER_WARNING); - } - if (strstr ($url, ":")) // we got an ipv6 address - { - if (!strstr ($url, "[")) // it is not escaped - { - $url = sprintf ("[%s]", $url); - } - } - } - $this->connection = @fsockopen ($transport_type.$url, $port, $errno, $errstr, $this->timeout); - $error = - sprintf (_('Unable to connect to "%s%s port %s": %s'), $transport_type, - $url, $port, $errstr); - if (!$this->connection) - { - return $this->_HttpError ($error, E_USER_WARNING); - } - $this->connected = true; - return array (true, "success"); - } + default: + $transport_type = 'tcp://'; + break; + } + $url = $url[1]; + if (!$unix) { + // $url = split ("/", preg_replace ("#^/{1,}#", '', $url), 2); + $url = preg_split("#/#", preg_replace("#^/{1,}#", '', $url), 2); + $url = $url[0]; + $port = $this->port; + $error = sprintf(_("Cannot resolve url: %s"), $url); + $ip = gethostbyname($url); + $ip = @gethostbyaddr($ip); + if (!$ip) { + return $this->_HttpError($error, E_USER_WARNING); + } + if (strstr($url, ":")) { // we got an ipv6 address + if (!strstr($url, "[")) { // it is not escaped + $url = sprintf("[%s]", $url); + } + } + } + $this->connection = @fsockopen($transport_type.$url, $port, $errno, $errstr, $this->timeout); + $error = + sprintf(_('Unable to connect to "%s%s port %s": %s'), $transport_type, + $url, $port, $errstr); + if (!$this->connection) { + return $this->_HttpError($error, E_USER_WARNING); + } + $this->connected = true; + return array (true, "success"); + } - public function SendRequest ($arguments) - { - $error = - sprintf (_('Streaming request failed to %s'), $arguments['RequestURI']); - $result = self::_StreamRequest ($arguments); - if (!$result[0]) - { - return $this->_HttpError ($error." ".$result[1], E_USER_WARNING); - } - self::_ReadReply (); - if (!preg_match ('#http/1.1 401 unauthorized#', $this->status)) - { - return array (true, "success"); - } - $headers = array_keys ($this->reply_headers); - $error = _("need authentication but no mechanism provided"); - if (!in_array ("www-authenticate", $headers)) - { - return $this->_HttpError ($error, E_USER_WARNING); - } - #$authtype = split (' ', $this->reply_headers["www-authenticate"]); - $authtype = preg_split ('# #', $this->reply_headers["www-authenticate"]); - $authtype = strtolower ($authtype[0]); - switch ($authtype) - { - case 'basic': - $pass = base64_encode ($this->user.":".$this->password); - $arguments["Headers"]["Authorization"] = "Basic ".$pass; - break; + public function SendRequest($arguments) + { + $error = + sprintf(_('Streaming request failed to %s'), $arguments['RequestURI']); + $result = self::_StreamRequest($arguments); + if (!$result[0]) { + return $this->_HttpError($error." ".$result[1], E_USER_WARNING); + } + self::_ReadReply(); + if (!preg_match('#http/1.1 401 unauthorized#', $this->status)) { + return array (true, "success"); + } + $headers = array_keys($this->reply_headers); + $error = _("need authentication but no mechanism provided"); + if (!in_array("www-authenticate", $headers)) { + return $this->_HttpError($error, E_USER_WARNING); + } + // $authtype = split (' ', $this->reply_headers["www-authenticate"]); + $authtype = preg_split('# #', $this->reply_headers["www-authenticate"]); + $authtype = strtolower($authtype[0]); + switch ($authtype) { + case 'basic': + $pass = base64_encode($this->user.":".$this->password); + $arguments["Headers"]["Authorization"] = "Basic ".$pass; + break; - case 'digest': - $arguments["Headers"]["Authorization"] = self::_BuildDigest (); - break; + case 'digest': + $arguments["Headers"]["Authorization"] = self::_BuildDigest(); + break; - default: - $error = - sprintf (_("need '%s' authentication mechanism, but have not"), - $authtype[0]); - return $this->_HttpError ($error, E_USER_WARNING); - break; - } - self::Close (); - self::Open ($arguments); + default: + $error = + sprintf(_("need '%s' authentication mechanism, but have not"), + $authtype[0]); + return $this->_HttpError($error, E_USER_WARNING); + break; + } + self::Close(); + self::Open($arguments); - $error = sprintf(_('Streaming request failed to %s after a try to authenticate'), $arguments['RequestURI']); - $result = self::_StreamRequest ($arguments); - if (!$result[0]) - { - return $this->_HttpError ($error.": ".$result[1], E_USER_WARNING); - } - self::_ReadReply (); - return array (true, "success"); - } + $error = sprintf(_('Streaming request failed to %s after a try to authenticate'), $arguments['RequestURI']); + $result = self::_StreamRequest($arguments); + if (!$result[0]) { + return $this->_HttpError($error.": ".$result[1], E_USER_WARNING); + } + self::_ReadReply(); + return array (true, "success"); + } - public function ReadReplyHeaders (&$headers) - { - $headers = $this->reply_headers; - } + public function ReadReplyHeaders(&$headers) + { + $headers = $this->reply_headers; + } - public function ReadReplyBody (&$body, $chunk_size) - { - $body = substr ($this->reply_body, $this->last_limit, $chunk_size); - $this->last_limit += $chunk_size; - } + public function ReadReplyBody(&$body, $chunk_size) + { + $body = substr($this->reply_body, $this->last_limit, $chunk_size); + $this->last_limit += $chunk_size; + } - public function Close () - { - if (!$this->connected) - { - return; - } - fclose ($this->connection); - } + public function Close() + { + if (!$this->connected) { + return; + } + fclose($this->connection); + } - /********************* - * - * Private functions - * - *********************/ + /********************* + * + * Private functions + * + *********************/ - private function _HttpError ($msg, $level, $errno = null) - { - $trace = ''; - $backtrace = debug_backtrace(); - foreach ($backtrace as $trace) - { - $trace .= sprintf ("in [file: '%s'][function: '%s'][line: %s];\n", $trace['file'], $trace['function'],$trace['line']); - } - $msg = sprintf ( '%s\n%s: [errno: %s]: %s', - $trace, error2string ($level), $errno, $msg); - if ($this->with_exceptions) - { - throw new httpException ($msg, $errno); - } - else - { - trigger_error ($msg, $level); - return array (false, $msg); - } - } + private function _HttpError($msg, $level, $errno = null) + { + $trace = ''; + $backtrace = debug_backtrace(); + foreach ($backtrace as $trace) { + $trace .= sprintf("in [file: '%s'][function: '%s'][line: %s];\n", $trace['file'], $trace['function'], $trace['line']); + } + $msg = sprintf( '%s\n%s: [errno: %s]: %s', + $trace, error2string($level), $errno, $msg); + if ($this->with_exceptions) { + throw new httpException($msg, $errno); + } else { + trigger_error($msg, $level); + return array (false, $msg); + } + } - private function _streamString ($string) - { - $success = fwrite ($this->connection, $string); - if (!$success) - { - return false; - } - return true; - } + private function _streamString($string) + { + $success = fwrite($this->connection, $string); + if (!$success) { + return false; + } + return true; + } - private function _StreamRequest ($arguments) - { - $this->status = false; - $this->reply_headers = array (); - $this->reply_body = ""; - if (!$this->connected) - { - return $this->_HttpError (_("not connected"), E_USER_WARNING); - } - $this->arguments = $arguments; - $content_length = 0; - foreach ($this->arguments["BodyStream"] as $argument) - { - list ($type, $value) = each ($argument); - reset ($argument); - if ($type == "Data") - { - $length = strlen ($value); - } - elseif ($type == "File") - { - if (is_readable ($value)) - { - $length = filesize ($value); - } - else - { - $length = 0; - return $this->_HttpError (sprintf (_("%s: file is not readable"), $value), E_USER_WARNING); - } - } - else - { - $length = 0; - return $this->_HttpError (sprintf(_("%s: not a valid argument for content"), $type), E_USER_WARNING); - } - $content_length += $length; - } - $this->request_body = sprintf (_("%s Bytes"), $content_length); - $this->headers["Content-Length"] = $content_length; - $this->arguments["Headers"] = array_merge ($this->headers, $this->arguments["Headers"]); - if ($this->arguments["RequestMethod"] != "POST") - { - return $this->_HttpError (sprintf(_("%s: method not implemented"), $arguments["RequestMethod"]), E_USER_WARNING); - } - $string = sprintf ("POST %s HTTP/1.1\r\n", $this->arguments["RequestURI"]); - $this->request_headers[$string] = ''; - if (!$this->_streamString ($string)) - { - return $this->_HttpError (_("Error while puts POST operation"), E_USER_WARNING); - } - foreach ($this->arguments["Headers"] as $header => $value) - { - $string = sprintf ("%s: %s\r\n", $header, $value); - $this->request_headers[$header] = $value; - if (!$this->_streamString ($string)) - { - return $this->_HttpError (_("Error while puts HTTP headers"), E_USER_WARNING); - } - } - $string = "\r\n"; - if (!$this->_streamString ($string)) - { - return $this->_HttpError (_("Error while ends HTTP headers"), E_USER_WARNING); - } - foreach ($this->arguments["BodyStream"] as $argument) - { - list ($type, $value) = each ($argument); - reset ($argument); - if ($type == "Data") - { - $streamed_length = 0; - while ($streamed_length < strlen ($value)) - { - $string = substr ($value, $streamed_length, $this->window_size); - if (!$this->_streamString ($string)) - { - return $this->_HttpError (_("error while sending body data"), E_USER_WARNING); - } - $streamed_length += $this->window_size; - } - } - elseif ($type == "File") - { - if (is_readable ($value)) - { - $file = fopen ($value, 'rb'); - while (!feof ($file)) - { - if (gettype ($block = @fread ($file, $this->window_size)) != "string") - { - return $this->_HttpError (_("cannot read file to upload"), E_USER_WARNING); - } - if (!$this->_streamString ($block)) - { - return $this->_HttpError (_("error while sending body data"), E_USER_WARNING); - } - } - } - } - } - return array (true, "success"); - } + private function _StreamRequest($arguments) + { + $this->status = false; + $this->reply_headers = array (); + $this->reply_body = ""; + if (!$this->connected) { + return $this->_HttpError(_("not connected"), E_USER_WARNING); + } + $this->arguments = $arguments; + $content_length = 0; + foreach ($this->arguments["BodyStream"] as $argument) { + // list ($type, $value) = each ($argument); + $type = key($argument); + $value = current($argument); + reset($argument); + if ($type == "Data") { + $length = strlen($value); + } elseif ($type == "File") { + if (is_readable($value)) { + $length = filesize($value); + } else { + $length = 0; + return $this->_HttpError(sprintf(_("%s: file is not readable"), $value), E_USER_WARNING); + } + } else { + $length = 0; + return $this->_HttpError(sprintf(_("%s: not a valid argument for content"), $type), E_USER_WARNING); + } + $content_length += $length; + } + $this->request_body = sprintf(_("%s Bytes"), $content_length); + $this->headers["Content-Length"] = $content_length; + $this->arguments["Headers"] = array_merge($this->headers, $this->arguments["Headers"]); + if ($this->arguments["RequestMethod"] != "POST") { + return $this->_HttpError(sprintf(_("%s: method not implemented"), $arguments["RequestMethod"]), E_USER_WARNING); + } + $string = sprintf("POST %s HTTP/1.1\r\n", $this->arguments["RequestURI"]); + $this->request_headers[$string] = ''; + if (!$this->_streamString($string)) { + return $this->_HttpError(_("Error while puts POST operation"), E_USER_WARNING); + } + foreach ($this->arguments["Headers"] as $header => $value) { + $string = sprintf("%s: %s\r\n", $header, $value); + $this->request_headers[$header] = $value; + if (!$this->_streamString($string)) { + return $this->_HttpError(_("Error while puts HTTP headers"), E_USER_WARNING); + } + } + $string = "\r\n"; + if (!$this->_streamString($string)) { + return $this->_HttpError(_("Error while ends HTTP headers"), E_USER_WARNING); + } + foreach ($this->arguments["BodyStream"] as $argument) { + // list ($type, $value) = each ($argument); + $type = key($argument); + $value = current($argument); + reset($argument); + if ($type == "Data") { + $streamed_length = 0; + while ($streamed_length < strlen($value)) { + $string = substr($value, $streamed_length, $this->window_size); + if (!$this->_streamString($string)) { + return $this->_HttpError(_("error while sending body data"), E_USER_WARNING); + } + $streamed_length += $this->window_size; + } + } elseif ($type == "File") { + if (is_readable($value)) { + $file = fopen($value, 'rb'); + while (!feof($file)) { + if (gettype($block = @fread($file, $this->window_size)) != "string") { + return $this->_HttpError(_("cannot read file to upload"), E_USER_WARNING); + } + if (!$this->_streamString($block)) { + return $this->_HttpError(_("error while sending body data"), E_USER_WARNING); + } + } + } + } + } + return array (true, "success"); + } - private function _ReadReply () - { - if (!$this->connected) - { - return array (false, _("not connected")); - } - $this->reply_headers = array (); - $this->reply_body = ""; - $headers = array (); - $body = ""; - while (!feof ($this->connection)) - { - $line = fgets ($this->connection, 1024); - if (strlen (trim($line)) == 0) - { - break; - } // \r\n => end of headers - if (preg_match ('#^[[:space:]]#', $line)) - { - $headers[-1] .= sprintf(' %s', trim ($line)); - continue; - } - $headers[] = trim ($line); - } - $this->status = isset ($headers[0]) ? strtolower ($headers[0]) : false; - foreach ($headers as $header) - { - $header = preg_split ("#: #", $header); - $header[0] = strtolower ($header[0]); - if ($header[0] !== "www-authenticate") - { - $header[1] = isset ($header[1]) ? strtolower ($header[1]) : ""; - } - if (!isset ($this->reply_headers[$header[0]])) - { - $this->reply_headers[$header[0]] = $header[1]; - } - } - self::_ReadStream (); - return true; - } + private function _ReadReply() + { + if (!$this->connected) { + return array (false, _("not connected")); + } + $this->reply_headers = array (); + $this->reply_body = ""; + $headers = array (); + $body = ""; + while (!feof($this->connection)) { + $line = fgets($this->connection, 1024); + if (strlen(trim($line)) == 0) { + break; + } // \r\n => end of headers + if (preg_match('#^[[:space:]]#', $line)) { + $headers[-1] .= sprintf(' %s', trim($line)); + continue; + } + $headers[] = trim($line); + } + $this->status = isset($headers[0]) ? strtolower($headers[0]) : false; + foreach ($headers as $header) { + $header = preg_split("#: #", $header); + $header[0] = strtolower($header[0]); + if ($header[0] !== "www-authenticate") { + $header[1] = isset($header[1]) ? strtolower($header[1]) : ""; + } + if (!isset($this->reply_headers[$header[0]])) { + $this->reply_headers[$header[0]] = $header[1]; + } + } + self::_ReadStream(); + return true; + } - private function _ReadStream () - { - if (! array_key_exists ("content-length", $this->reply_headers)) - { - stream_set_blocking($this->connection, 0); - $this->reply_body = stream_get_contents($this->connection); - return true; - } - stream_set_blocking($this->connection, 1); - $content_length = $this->reply_headers["content-length"]; - $this->reply_body = stream_get_contents($this->connection,$content_length); - return true; - } + private function _ReadStream() + { + if (! array_key_exists("content-length", $this->reply_headers)) { + stream_set_blocking($this->connection, 0); + $this->reply_body = stream_get_contents($this->connection); + return true; + } + stream_set_blocking($this->connection, 1); + $content_length = $this->reply_headers["content-length"]; + $this->reply_body = stream_get_contents($this->connection, $content_length); + return true; + } - private function _BuildDigest () - { - $auth = $this->reply_headers["www-authenticate"]; - #list ($head, $auth) = split (" ", $auth, 2); - list ($head, $auth) = preg_split ("# #", $auth, 2); - #$auth = split (", ", $auth); - $auth = preg_split ("#, #", $auth); - foreach ($auth as $sheme) - { - #list ($sheme, $value) = split ('=', $sheme); - list ($sheme, $value) = preg_split ('#=#', $sheme); - $fields[$sheme] = trim (trim ($value), '"'); - } - $nc = sprintf ('%x', $this->nc); - $prepend = ""; - while ((strlen ($nc) + strlen ($prepend)) < 8) - $prependi .= "0"; - $nc = $prepend.$nc; - $cnonce = "printipp"; - $username = $this->user; - $password = $this->password; - $A1 = $username.":".$fields["realm"].":".$password; - if (array_key_exists ("algorithm", $fields)) - { - $algorithm = strtolower ($fields["algorithm"]); - switch ($algorithm) - { - case "md5": - break; + private function _BuildDigest() + { + $auth = $this->reply_headers["www-authenticate"]; + // list ($head, $auth) = split (" ", $auth, 2); + list ($head, $auth) = preg_split("# #", $auth, 2); + // $auth = split (", ", $auth); + $auth = preg_split("#, #", $auth); + foreach ($auth as $sheme) { + // list ($sheme, $value) = split ('=', $sheme); + list ($sheme, $value) = preg_split('#=#', $sheme); + $fields[$sheme] = trim(trim($value), '"'); + } + $nc = sprintf('%x', $this->nc); + $prepend = ""; + while ((strlen($nc) + strlen($prepend)) < 8) + $prependi .= "0"; + $nc = $prepend.$nc; + $cnonce = "printipp"; + $username = $this->user; + $password = $this->password; + $A1 = $username.":".$fields["realm"].":".$password; + if (array_key_exists("algorithm", $fields)) { + $algorithm = strtolower($fields["algorithm"]); + switch ($algorithm) { + case "md5": + break; - case "md5-sess": - $A1 = - $username.":".$fields["realm"].":".$password.":". - $fields['nonce'].":".$cnonce; - break; + case "md5-sess": + $A1 = + $username.":".$fields["realm"].":".$password.":". + $fields['nonce'].":".$cnonce; + break; - default: - return $this->_HttpError( - sprintf (_("digest Authorization: algorithm '%s' not implemented"), - $algorithm), - E_USER_WARNING); - return false; - break; - } - } - $A2 = "POST:".$this->arguments["RequestURI"]; - if (array_key_exists ("qop", $fields)) - { - $qop = strtolower ($fields["qop"]); - #$qop = split (" ", $qop); - $qop = preg_split ("# #", $qop); - if (in_array ("auth", $qop)) - { - $qop = "auth"; - } - else - { - self::_HttpError( - sprintf (_("digest Authorization: algorithm '%s' not implemented"), - $qop), - E_USER_WARNING); - return false; - } - } - $response = md5 (md5 ($A1).":".$fields["nonce"].":".md5 ($A2)); - if (isset ($qop) && ($qop == "auth")) - { - $response = - md5 (md5 ($A1).":".$fields["nonce"].":".$nc.":".$cnonce.":".$qop. - ":".$A2); - } - $auth_scheme = - sprintf - ('Digest username="%s", realm="%s", nonce="%s", uri="%s", response="%s"', - $username, $fields["realm"], $fields['nonce'], - $this->arguments["RequestURI"], $response); - if (isset ($algorithm)) - { - $auth_scheme .= sprintf (', algorithm="%s"', $algorithm); - } - if (isset ($qop)) - { - $auth_scheme .= sprintf (', cnonce="%s"', $cnonce); - } - if (array_key_exists ("opaque", $fields)) - { - $auth_scheme .= sprintf (', opaque="%s"', $fields['opaque']); - } - if (isset ($qop)) - { - $auth_scheme .= sprintf (', qop="%s"', $qop); - } - $auth_scheme .= sprintf (', nc=%s', $nc); - $this->nc++; - return $auth_scheme; - } + default: + return $this->_HttpError( + sprintf(_("digest Authorization: algorithm '%s' not implemented"), + $algorithm), + E_USER_WARNING); + return false; + break; + } + } + $A2 = "POST:".$this->arguments["RequestURI"]; + if (array_key_exists("qop", $fields)) { + $qop = strtolower($fields["qop"]); + // $qop = split (" ", $qop); + $qop = preg_split("# #", $qop); + if (in_array("auth", $qop)) { + $qop = "auth"; + } else { + self::_HttpError( + sprintf(_("digest Authorization: algorithm '%s' not implemented"), + $qop), + E_USER_WARNING); + return false; + } + } + $response = md5(md5($A1).":".$fields["nonce"].":".md5($A2)); + if (isset($qop) && ($qop == "auth")) { + $response = + md5(md5($A1).":".$fields["nonce"].":".$nc.":".$cnonce.":".$qop. + ":".$A2); + } + $auth_scheme = + sprintf('Digest username="%s", realm="%s", nonce="%s", uri="%s", response="%s"', + $username, $fields["realm"], $fields['nonce'], + $this->arguments["RequestURI"], $response); + if (isset($algorithm)) { + $auth_scheme .= sprintf(', algorithm="%s"', $algorithm); + } + if (isset($qop)) { + $auth_scheme .= sprintf(', cnonce="%s"', $cnonce); + } + if (array_key_exists("opaque", $fields)) { + $auth_scheme .= sprintf(', opaque="%s"', $fields['opaque']); + } + if (isset($qop)) { + $auth_scheme .= sprintf(', qop="%s"', $qop); + } + $auth_scheme .= sprintf(', nc=%s', $nc); + $this->nc++; + return $auth_scheme; + } } From 3e1fa44657b90bd2212072f8f8e9543eee2cb619 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Nov 2021 03:23:38 +0100 Subject: [PATCH 255/490] Fix phpdoc --- htdocs/core/lib/functions.lib.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2a48858c9f6..408a771e1ed 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4500,7 +4500,7 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss * This function must be called when a blocking technical error is encountered. * However, one must try to call it only within php pages, classes must return their error through their property "error". * - * @param DoliDB? $db Database handler + * @param DoliDB|string $db Database handler * @param string|string[] $error String or array of errors strings to show * @param array $errors Array of errors * @return void @@ -5193,16 +5193,16 @@ function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0) * Function to format a value into an amount for visual output * Function used into PDF and HTML pages * - * @param float $amount Amount to format - * @param integer $form Type of format, HTML or not (not by default) - * @param Translate? $outlangs Object langs for output - * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before beeing inserted into database or after a computation, so this parameter should be useless. - * @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT) - * @param int $forcerounding Force the number of decimal to forcerounding decimal (-1=do not force) - * @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency) - * @return string Chaine avec montant formate + * @param float $amount Amount to format + * @param integer $form Type of format, HTML or not (not by default) + * @param Translate|string $outlangs Object langs for output + * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before beeing inserted into database or after a computation, so this parameter should be useless. + * @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT) + * @param int $forcerounding Force the number of decimal to forcerounding decimal (-1=do not force) + * @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency) + * @return string String with formated amount * - * @see price2num() Revert function of price + * @see price2num() Revert function of price */ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code = '') { From 7d07da527d2c2a93a0d3a938ed2dff3c8f8e4801 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Nov 2021 03:30:22 +0100 Subject: [PATCH 256/490] Debug v15 --- htdocs/core/db/DoliDB.class.php | 17 +++++++++-------- htdocs/hrm/compare.php | 5 ++++- htdocs/takepos/invoice.php | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 29ced10dc35..a30fa5f4f7e 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -318,14 +318,14 @@ abstract class DoliDB implements Database /** * Return first result from query as object * Note : This method executes a given SQL query and retrieves the first row of results as an object. It should only be used with SELECT queries - * Dont add LIMIT to your query, it will be added by this method - * @param string $sql the sql query string - * @return bool| object - * @deprecated + * Dont add LIMIT to your query, it will be added by this method. + * + * @param string $sql The sql query string + * @return bool|object Result of fetch_object */ public function getRow($sql) { - $sql .= ' LIMIT 1;'; + $sql .= ' LIMIT 1'; $res = $this->query($sql); if ($res) { @@ -338,9 +338,10 @@ abstract class DoliDB implements Database /** * return all results from query as an array of objects * Note : This method executes a given SQL query and retrieves all row of results as an array of objects. It should only be used with SELECT queries - * be carefull with this method use it only with some limit of results to avoid performences loss - * @param string $sql the sql query string - * @return bool| array + * be carefull with this method use it only with some limit of results to avoid performences loss. + * + * @param string $sql The sql query string + * @return bool|array Result * @deprecated */ public function getRows($sql) diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index 13b83af9737..07097443628 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -256,10 +256,13 @@ $fk_usergroup1 = GETPOST('fk_usergroup1'); update_note_public($desc); + $invoice->update_note($desc, '_public'); } else foreach ($invoice->lines as $line) { if ($line->id == $idline) { $result = $invoice->updateline($line->id, $desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); From cb8e1ce8f034903e5d3c5010abc326f776eb16a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 09:20:22 +0100 Subject: [PATCH 257/490] fix warning --- htdocs/core/actions_addupdatedelete.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 6fd84f4eda3..dff83eb508c 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -110,7 +110,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { } // Validation of fields values - if ($conf->global->MAIN_FEATURE_LEVEL >= 2 || !empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { + if (getDolGlobalInt('MAIN_FEATURE_LEVEL') >= 2 || !empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) { if (!$object->validateField($object->fields, $key, $value)) { $error++; From aaadeb1b9db153e2664f9030efbbb1a737995325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 09:27:32 +0100 Subject: [PATCH 258/490] fix change sql --- htdocs/hrm/class/skilldet.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/skilldet.class.php b/htdocs/hrm/class/skilldet.class.php index 1fb90b907db..c3acdd0982e 100644 --- a/htdocs/hrm/class/skilldet.class.php +++ b/htdocs/hrm/class/skilldet.class.php @@ -104,7 +104,7 @@ class Skilldet extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'rank' => array('type'=>'integer', 'label'=>'rank', 'enabled'=>'1', 'position'=>2, 'notnull'=>0, 'visible'=>2,), + 'rankorder' => array('type'=>'integer', 'label'=>'rank', 'enabled'=>'1', 'position'=>2, 'notnull'=>0, 'visible'=>2,), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>0,), From f99a11b876324d5b87c0bd1401f470d4d62fc380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 09:28:51 +0100 Subject: [PATCH 259/490] Update evaluationdet.class.php --- htdocs/hrm/class/evaluationdet.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php index a268f1b30be..115571bb6ba 100644 --- a/htdocs/hrm/class/evaluationdet.class.php +++ b/htdocs/hrm/class/evaluationdet.class.php @@ -111,7 +111,7 @@ class Evaluationline extends CommonObject 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), 'fk_skill' => array('type'=>'integer:Skill:hrm/class/skill.class.php:1', 'label'=>'Skill', 'enabled'=>'1', 'position'=>3, 'notnull'=>1, 'visible'=>1, 'index'=>1,), 'fk_evaluation' => array('type'=>'integer:Evaluation:hrm/class/evaluation.class.php:1', 'label'=>'Evaluation', 'enabled'=>'1', 'position'=>3, 'notnull'=>1, 'visible'=>1, 'index'=>1,), - 'rank' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>'1', 'position'=>4, 'notnull'=>1, 'visible'=>1,), + 'rankorder' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>'1', 'position'=>4, 'notnull'=>1, 'visible'=>1,), 'required_rank' => array('type'=>'integer', 'label'=>'requiredRank', 'enabled'=>'1', 'position'=>5, 'notnull'=>1, 'visible'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), ); From 39777d4cc5a589c2028bfb56d1a4f00296d36f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 09:37:07 +0100 Subject: [PATCH 260/490] fix error --- htdocs/core/modules/printing/modules_printing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index 41a87cb2704..1bbf78df022 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -69,7 +69,7 @@ class PrintingDriver $listoffiles = array(); $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); foreach ($dirmodels as $dir) { - $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\modules.php', '', 'name', SORT_ASC, 0); + $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '.modules.php', '', 'name', SORT_ASC, 0); if (!empty($tmpfiles)) { $listoffiles = array_merge($listoffiles, $tmpfiles); } From b992deb08444b8a620af8773e6a2c741e119964e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 09:44:43 +0100 Subject: [PATCH 261/490] fix warnings --- htdocs/core/modules/printing/printipp.modules.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index f290b2b4e90..02ba610961d 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -1,6 +1,6 @@ + * Copyright (C) 2014-2021 Frederic France * * 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 @@ -108,10 +108,10 @@ class printing_printipp extends PrintingDriver global $conf; $this->db = $db; - $this->host = $conf->global->PRINTIPP_HOST; - $this->port = $conf->global->PRINTIPP_PORT; - $this->user = $conf->global->PRINTIPP_USER; - $this->password = $conf->global->PRINTIPP_PASSWORD; + $this->host = getDolGlobalString('PRINTIPP_HOST'); + $this->port = getDolGlobalString('PRINTIPP_PORT'); + $this->user = getDolGlobalString('PRINTIPP_USER'); + $this->password = getDolGlobalString('PRINTIPP_PASSWORD'); $this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text'); $this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text'); $this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"'); @@ -159,8 +159,8 @@ class printing_printipp extends PrintingDriver $ipp->setCopies($obj->copy); } else { if (!empty($conf->global->PRINTIPP_URI_DEFAULT)) { - dol_syslog("Will use default printer conf->global->PRINTIPP_URI_DEFAULT = ".$conf->global->PRINTIPP_URI_DEFAULT); - $ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT); + dol_syslog("Will use default printer conf->global->PRINTIPP_URI_DEFAULT = ".getDolGlobalString('PRINTIPP_URI_DEFAULT')); + $ipp->setPrinterURI(getDolGlobalString('PRINTIPP_URI_DEFAULT')); } else { $this->errors[] = 'NoDefaultPrinterDefined'; $error++; From 4c016cc3be9fe59716d703c415648728711bc192 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 1 Nov 2021 10:11:43 +0100 Subject: [PATCH 262/490] integrate fix from V14 --- htdocs/core/class/html.formsetup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 219308bd5e6..a7df249e44c 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -447,7 +447,7 @@ class formSetupItem * because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist * to be sure we can manage evolution easily * @param string $type possible values based on old module builder setup : 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' - * @deprecated yes this method came deprecated because it exists only for manage setup convertion + * @deprecated yes this setTypeFromTypeString came deprecated because it exists only for manage setup convertion * @return bool */ public function setTypeFromTypeString($type) @@ -521,7 +521,7 @@ class formSetupItem foreach ($ways as $way) { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; } - $out.= '
      ' . implode(' ', $toprint) . '
    '; + $out.='
      ' . implode(' ', $toprint) . '
    '; } elseif (preg_match('/thirdparty_type/', $this->type)) { if ($this->fieldValue==2) { $out.= $this->langs->trans("Prospect"); From 3508aa92d6bcc20d6f7e2d5fefe15cef6ceaacd4 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 1 Nov 2021 10:24:19 +0100 Subject: [PATCH 263/490] Fix : uk and index on element_tag table --- htdocs/install/mysql/tables/llx_element_tag.key.sql | 4 +--- htdocs/install/mysql/tables/llx_element_tag.sql | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_element_tag.key.sql b/htdocs/install/mysql/tables/llx_element_tag.key.sql index e4af1c3871e..d3a0b38afa9 100644 --- a/htdocs/install/mysql/tables/llx_element_tag.key.sql +++ b/htdocs/install/mysql/tables/llx_element_tag.key.sql @@ -16,8 +16,6 @@ -- -- ============================================================================ -ALTER TABLE llx_element_tag ADD PRIMARY KEY pk_element_tag (fk_categorie, fk_element); -ALTER TABLE llx_element_tag ADD INDEX idx_element_tag_fk_categorie (fk_categorie); -ALTER TABLE llx_element_tag ADD INDEX idx_element_tag_fk_element (fk_element); +ALTER TABLE llx_element_tag ADD UNIQUE INDEX idx_element_tag_uk (fk_categorie, fk_element); ALTER TABLE llx_element_tag ADD CONSTRAINT fk_element_tag_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); diff --git a/htdocs/install/mysql/tables/llx_element_tag.sql b/htdocs/install/mysql/tables/llx_element_tag.sql index 937137727e7..d43ced98130 100644 --- a/htdocs/install/mysql/tables/llx_element_tag.sql +++ b/htdocs/install/mysql/tables/llx_element_tag.sql @@ -18,6 +18,7 @@ create table llx_element_tag ( + rowid integer AUTO_INCREMENT PRIMARY KEY, fk_categorie integer NOT NULL, fk_element integer NOT NULL, import_key varchar(14) From ea641b707d17a0ca44c2aefc4838453e0e7eee9f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 1 Nov 2021 10:32:37 +0100 Subject: [PATCH 264/490] Factoring --- htdocs/core/class/html.formsetup.class.php | 141 ++++++++++++++------- 1 file changed, 95 insertions(+), 46 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index a7df249e44c..df99b6cdbbb 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -191,7 +191,7 @@ class formSetup $arrayofparameters = array(); foreach ($this->params as $key => $item) { $arrayofparameters[$item->confKey] = array( - 'type' => $item->type, + 'type' => $item->getType(), 'enabled' => $item->enabled ); } @@ -356,57 +356,15 @@ class formSetupItem } elseif ($this->type == 'yesno') { $out.= $this->form->selectyesno($this->confKey, $this->fieldValue, 1); } elseif (preg_match('/emailtemplate:/', $this->type)) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($this->db); - - $tmp = explode(':', $this->type); - $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang - //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); - $arrayOfMessageName = array(); - if (is_array($formmail->lines_model)) { - foreach ($formmail->lines_model as $modelMail) { - //var_dump($modelmail); - $moreonlabel = ''; - if (!empty($arrayOfMessageName[$modelMail->label])) { - $moreonlabel = ' (' . $this->langs->trans("SeveralLangugeVariatFound") . ')'; - } - // The 'label' is the key that is unique if we exclude the language - $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\(|\)/', '', $modelMail->label)) . $moreonlabel; - } - } - $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + $out.= $this->generateInputFieldEmailTemplate(); } elseif (preg_match('/category:/', $this->type)) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - $formother = new FormOther($this->db); - - $tmp = explode(':', $this->type); - $out.= img_picto('', 'category', 'class="pictofixedwidth"'); - $out.= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + $out.=$this->generateInputFieldCategories(); } elseif (preg_match('/thirdparty_type/', $this->type)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($this->db); $out.= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey); } elseif ($this->type == 'securekey') { - $out.= ''; - if (!empty($conf->use_javascript_ajax)) { - $out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"'); - } - if (!empty($conf->use_javascript_ajax)) { - $out.= "\n".''; - } + $out.= $this->generateInputFieldSecureKey(); } elseif ($this->type == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $selected = (empty($this->fieldValue) ? '' : $this->fieldValue); @@ -430,6 +388,7 @@ class formSetupItem $out.= "\n"; return $out; } + /** * generate input field for html * @return string @@ -442,6 +401,96 @@ class formSetupItem return $doleditor->Create(1); } + /** + * generate input field for categories + * @return string + */ + public function generateInputFieldCategories() + { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($this->db); + + $tmp = explode(':', $this->type); + $out= img_picto('', 'category', 'class="pictofixedwidth"'); + $out.= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + return $out; + } + + /** + * generate input field for email template selector + * @return string + */ + public function generateInputFieldEmailTemplate() + { + global $conf, $user; + $out = ''; + if (preg_match('/emailtemplate:/', $this->type)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); + + $tmp = explode(':', $this->type); + $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang + $arrayOfMessageName = array(); + if (is_array($formmail->lines_model)) { + foreach ($formmail->lines_model as $modelMail) { + $moreonlabel = ''; + if (!empty($arrayOfMessageName[$modelMail->label])) { + $moreonlabel = ' (' . $this->langs->trans("SeveralLangugeVariatFound") . ')'; + } + // The 'label' is the key that is unique if we exclude the language + $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\(|\)/', '', $modelMail->label)) . $moreonlabel; + } + } + $out .= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + } + + return $out; + } + + + /** + * generate input field for secure key + * @return string + */ + public function generateInputFieldSecureKey() + { + global $conf; + $out = ''; + if (!empty($conf->use_javascript_ajax)) { + $out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"'); + } + if (!empty($conf->use_javascript_ajax)) { + $out .= "\n" . ''; + } + return $out; + } + + /** + * get the type : used for old module builder setup conf style conversion and tests + * because this two class will quickly evolve it's important to not set or get directly $this->type (will be protected) so this method exist + * to be sure we can manage evolution easily + * + * @return string + */ + public function getType() + { + return $this->type; + } + /** * set the type from string : used for old module builder setup conf style conversion and tests * because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist From 960319fd8a988f6141de7c3a74e20179440002b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Nov 2021 10:33:54 +0100 Subject: [PATCH 265/490] dol_htmlentities is better for future than htmlentities --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 42257707ea2..74c7a6d272f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1474,7 +1474,7 @@ if ($id > 0) { print ''; print ''; if ($backtopage) { - print ''; + print ''; } if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; From 772c3eb43ab784f9154bd57cab7b180a89dc2148 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 1 Nov 2021 11:13:44 +0100 Subject: [PATCH 266/490] Works on ldap password hash type --- htdocs/admin/ldap.php | 15 ++++++++++++--- htdocs/core/class/ldap.class.php | 13 +++++-------- htdocs/langs/en_US/ldap.lang | 2 ++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 4010d724c1a..1b93ada1119 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2005-2021 Regis Houssin * Copyright (C) 2006-2020 Laurent Destailleur * Copyright (C) 2011-2013 Juanjo Menent * @@ -29,10 +29,11 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formldap.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page -$langs->load("admin"); +$langs->loadLangs(array("admin", "ldap")); if (!$user->admin) { accessforbidden(); @@ -99,6 +100,9 @@ if (empty($reshook)) { if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) { $error++; } + if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("'LDAP_PASSWORD_HASH_TYPE'", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + $error++; + } if (!$error) { $db->commit(); @@ -129,7 +133,7 @@ if (!function_exists("ldap_connect")) { $form = new Form($db); - +$formldap = new FormLdap($db); print ''; print ''; @@ -251,6 +255,11 @@ $arraylist['1'] = $langs->trans("Yes"); print $form->selectarray('usetls', $arraylist, $conf->global->LDAP_SERVER_USE_TLS); print '
    '; +// Password hash type +print ''; + print ''; print ''; print "\n"; diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index e2ce33cc45f..0815874d71c 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -159,8 +159,6 @@ class Ldap $this->attr_mobile = $conf->global->LDAP_FIELD_MOBILE; } - - // Connection handling methods ------------------------------------------- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -218,8 +216,9 @@ class Ldap // Upgrade connexion to TLS, if requested by the configuration if (!empty($conf->global->LDAP_SERVER_USE_TLS)) { // For test/debug - //ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7); - //ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3); + ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7); + ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3); + ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); $resulttls = ldap_start_tls($this->connection); if (!$resulttls) { @@ -291,8 +290,6 @@ class Ldap return $return; } - - /** * Simply closes the connection set up earlier. * Returns true if OK, false if there was an error. @@ -906,10 +903,10 @@ class Ldap return -3; } - $search = ldap_search($this->connection, $dn, $filter); + $search = @ldap_search($this->connection, $dn, $filter); // Only one entry should ever be returned - $entry = ldap_first_entry($this->connection, $search); + $entry = @ldap_first_entry($this->connection, $search); if (!$entry) { $this->ldapErrorCode = -1; diff --git a/htdocs/langs/en_US/ldap.lang b/htdocs/langs/en_US/ldap.lang index 8b6f0864215..b13e454159d 100644 --- a/htdocs/langs/en_US/ldap.lang +++ b/htdocs/langs/en_US/ldap.lang @@ -25,3 +25,5 @@ ContactSynchronized=Contact synchronized ForceSynchronize=Force synchronizing Dolibarr -> LDAP ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility. PasswordOfUserInLDAP=Password of user in LDAP +LDAPPasswordHashType=Password hash type +LDAPPasswordHashTypeExample=Type of password hash used on the server \ No newline at end of file From 55243dedb69c29a0ac3b54db9a1739d021b192f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 13:32:19 +0100 Subject: [PATCH 267/490] fix typo --- htdocs/core/actions_addupdatedelete.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index dff83eb508c..fd13c61efd2 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -110,7 +110,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { } // Validation of fields values - if (getDolGlobalInt('MAIN_FEATURE_LEVEL') >= 2 || !empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 || !empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) { if (!$object->validateField($object->fields, $key, $value)) { $error++; From 18918d4e9d26be41029b5680c9fc831ca99dc4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 13:34:13 +0100 Subject: [PATCH 268/490] Update actions_addupdatedelete.inc.php --- htdocs/core/actions_addupdatedelete.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index fd13c61efd2..10d25b2aa09 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -226,7 +226,7 @@ if ($action == 'update' && !empty($permissiontoadd)) { } // Validation of fields values - if ($conf->global->MAIN_FEATURE_LEVEL >= 2 || !empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 || !empty($conf->global->MAIN_ACTIVATE_VALIDATION_RESULT)) { if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) { if (!$object->validateField($object->fields, $key, $value)) { $error++; From d7c0d87aeb0eb5cab544c97856c4127df5239912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 13:35:25 +0100 Subject: [PATCH 269/490] Update mod_facture_fournisseur_tulip.php --- .../modules/supplier_invoice/mod_facture_fournisseur_tulip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 5fc2737957f..e6838b9c4c4 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -104,7 +104,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $texte .= ''; $texte .= ''; - if ($conf->global->MAIN_FEATURE_LEVEL >= 2) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // Parametrage du prefix des replacement $texte .= ''; $texte .= ''; From 8bfb6562284d6c3cd4eb151af82d03ff4f3dd468 Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Mon, 1 Nov 2021 13:47:52 +0100 Subject: [PATCH 270/490] Update card.php Load $usergroup->members is not necessary and wastes resources --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 429de7fd1a6..8a211501382 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1945,7 +1945,7 @@ if ($action == 'create' || $action == 'adduserldap') { $exclude = array(); $usergroup = new UserGroup($db); - $groupslist = $usergroup->listGroupsForUser($object->id); + $groupslist = $usergroup->listGroupsForUser($object->id, false); if (!empty($groupslist)) { foreach ($groupslist as $groupforuser) { From d40e9bb3046b30ec3e47a9844ec838e905514873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 13:52:06 +0100 Subject: [PATCH 271/490] remove old field field skype has been removed --- htdocs/adherents/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index fe21b8577ef..4936fadd326 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -314,7 +314,7 @@ if (!empty($search_categ) || !empty($catid)) { } $sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,"; $sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; -$sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; +$sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,"; $sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; $sql .= " d.note_private, d.note_public,"; $sql .= " s.nom,"; From 5be40b926b6198e638dba1e796c2114417cd75c9 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:56:24 +0100 Subject: [PATCH 272/490] Clean function not use anymore --- .../class/fournisseur.commande.class.php | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 787d9ee321b..9cf3c74e967 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2274,50 +2274,6 @@ class CommandeFournisseur extends CommonOrder return $ret; } - /** - * Return array of the lines that are waiting to be dispatched - * - * @return array Array of lines - */ - public function getNotCompletlyDispatchedLines() - { - $ret = array(); - - $sql = "SELECT supplierOrderDet.fk_product as product_id, supplierOrderDet.qty as qty_ordered, supplierOrderDet.fk_commande,"; - $sql .= " dispatch.rowid as dispatchedlineid, sum(dispatch.qty) as qty_dispatched"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as supplierOrderDet"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as dispatch ON supplierOrderDet.rowid = dispatch.fk_commandefourndet"; - $sql .= " WHERE supplierOrderDet.fk_commande = ".((int) $this->id); - $sql .= " GROUP BY supplierOrderDet.fk_product"; - - $resql = $this->db->query($sql); - - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - - while ($i < $num) { - $objp = $this->db->fetch_object($resql); - - if ($objp) { - // If product not completly dispatched - if (is_null($objp->qty_dispatched) OR ($objp->qty_dispatched < $objp->qty_ordered)) { - $ret[] = array( - 'product_id' => $objp->product_id, - 'qty_ordered' => $objp->qty_ordered, - 'qty_dispatched' => $objp->qty_dispatched, - ); - } - } - $i++; - } - } else { - dol_print_error($this->db, 'Failed to execute request to get not completly dispatched lines'); - } - - return $ret; - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set a delivery in database for this supplier order From 7b88f1da3fea112919f0c61bf9cb894323cbfbab Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:56:55 +0100 Subject: [PATCH 273/490] Change to have number of item dispached on number of total item --- htdocs/core/lib/fourn.lib.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index e81bdb5e9d0..7fc903db72b 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -157,12 +157,24 @@ function ordersupplier_prepare_head($object) if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { $langs->load("stocks"); - $nbLineToDispatch = count($object->getNotCompletlyDispatchedLines()); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderDispatch"); - if ($nbLineToDispatch > 0) { - $head[$h][1] .= ''.$nbLineToDispatch.''; + + //If dispach process running we add the number of item to dispatch into the head + if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') { + $lines = $object->fetch_lines(); + $dispachedLines = $object->getDispachedLines(1); + $sumQtyAllreadyDispatched = 0; + for ($line = 0 ; $line < count($dispachedLines) ; $line++) { + $sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty']; + } + $sumQtyOrdered = 0; + for ($line = 0 ; $line < count($object->lines) ; $line++) { + $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; + } + $head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.''; } + $head[$h][2] = 'dispatch'; $h++; } From 85372a70836d2d9cdb003cc490bd8fa17c73fc46 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 1 Nov 2021 18:57:35 +0000 Subject: [PATCH 274/490] Fixing style errors. --- htdocs/core/lib/fourn.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 7fc903db72b..27ebc98635d 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -159,22 +159,22 @@ function ordersupplier_prepare_head($object) $langs->load("stocks"); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderDispatch"); - + //If dispach process running we add the number of item to dispatch into the head if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') { $lines = $object->fetch_lines(); $dispachedLines = $object->getDispachedLines(1); $sumQtyAllreadyDispatched = 0; - for ($line = 0 ; $line < count($dispachedLines) ; $line++) { + for ($line = 0 ; $line < count($dispachedLines); $line++) { $sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty']; } $sumQtyOrdered = 0; - for ($line = 0 ; $line < count($object->lines) ; $line++) { + for ($line = 0 ; $line < count($object->lines); $line++) { $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; - } + } $head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.''; } - + $head[$h][2] = 'dispatch'; $h++; } From 85776f7529dbc3d969e827a82d6fcf1c1b168159 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Mon, 1 Nov 2021 20:08:00 +0100 Subject: [PATCH 275/490] Avoid function calls in a FOR loop test part --- htdocs/core/lib/fourn.lib.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 27ebc98635d..25bbd52e413 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -162,14 +162,17 @@ function ordersupplier_prepare_head($object) //If dispach process running we add the number of item to dispatch into the head if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') { - $lines = $object->fetch_lines(); + $object->fetch_lines(); + $nbLinesOrdered = count($object->lines); $dispachedLines = $object->getDispachedLines(1); + $nbDispachedLines = count($dispachedLines); + $sumQtyAllreadyDispatched = 0; - for ($line = 0 ; $line < count($dispachedLines); $line++) { + for ($line = 0 ; $line < $nbDispachedLines; $line++) { $sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty']; } $sumQtyOrdered = 0; - for ($line = 0 ; $line < count($object->lines); $line++) { + for ($line = 0 ; $line < $nbLinesOrdered; $line++) { $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; } $head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.''; From f73f3cd55f271a43d8bdca2e9d8dae9911b4caee Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 2 Nov 2021 04:50:29 +0100 Subject: [PATCH 276/490] typo --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index ddaf1d320c3..313dd5d8fbe 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -295,7 +295,7 @@ function societe_prepare_head(Societe $object) // Notifications if (!empty($conf->notification->enabled)) { $nbNotif = 0; - // Enable caching of thirdrparty count notifications + // Enable caching of thirdparty count notifications require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; $cachekey = 'count_notifications_thirdparty_'.$object->id; $dataretrieved = dol_getcache($cachekey); From fb0002a38ee7efdbbf35791f4bbeb2098aa1097e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 2 Nov 2021 04:51:18 +0100 Subject: [PATCH 277/490] Factorize user rights --- htdocs/societe/paymentmodes.php | 61 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 9cb0eadecf5..18d560f6d9f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1,12 +1,13 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2018 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Peter Fontaine - * Copyright (C) 2015-2016 Marcos García - * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018 -2021Thibault FOUCART +/* Copyright (C) 2002-2004 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013 Peter Fontaine + * Copyright (C) 2015-2016 Marcos García + * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2018-2021 Thibault FOUCART + * Copyright (C) 2021 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 @@ -41,7 +42,6 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $langs->loadLangs(array("companies", "commercial", "banks", "bills", 'paypal', 'stripe', 'withdrawals')); - // Security check $socid = GETPOST("socid", "int"); if ($user->socid) { @@ -70,6 +70,10 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartybancard', 'globalcard')); +$permissiontoread = $user->rights->societe->lire; +$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_builddoc.inc.php + +$permissiontoaddupdatepaymentinformation = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $permissiontoadd) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->societe->addupdate_thirdparty_payment_information->write))); if (!empty($conf->stripe->enabled)) { $service = 'StripeTest'; @@ -455,7 +459,6 @@ if (empty($reshook)) { $id = $socid; $upload_dir = $conf->societe->multidir_output[$object->entity]; - $permissiontoadd = $user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; $id = $savid; @@ -703,7 +706,7 @@ if (empty($companybankaccount->socid)) { $companybankaccount->socid = $object->id; } -if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) { +if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoadd) { print ''; print ''; $actionforadd = 'update'; @@ -713,7 +716,7 @@ if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->soc print ''; print ''; } -if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer) { +if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoadd) { print ''; print ''; $actionforadd = 'add'; @@ -787,12 +790,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } if (!empty($conf->stripe->enabled)) { - $permissiontowrite = $user->rights->societe->creer; // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - $out.= '
    '; + print ''; + print ''; $formTicket->selectTypesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print '
    '.$langs->trans("LDAPServerUseTLSExample").'
    '.$langs->trans("LDAPPasswordHashType").''; +print $formldap->selectLdapPasswordHashType(getDolGlobalString('LDAP_PASSWORD_HASH_TYPE'), 'LDAP_PASSWORD_HASH_TYPE'); +print ''.$langs->trans("LDAPPasswordHashTypeExample").'
    '.$langs->trans("ForANonAnonymousAccess").'
    '.$form->textwithpicto('', $tooltip, 1, 1).'
    '.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
    '; - print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoadd, 'string', '', 0, 2, 'socid'); print ''; - print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); + print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoadd, 'string', '', null, null, '', 2, '', 'socid'); if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') { $connect = ''; if (!empty($stripeacc)) { @@ -849,14 +851,13 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { - $permissiontowrite = $user->rights->societe->creer; $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) // Stripe customer key 'cu_....' stored into llx_societe_account print '
    '; - print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoadd, 'string', '', 0, 2, 'socid'); print ''; - print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); + print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoadd, 'string', '', null, null, '', 2, '', 'socid'); if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') { $connect = ''; @@ -1061,7 +1062,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $hookmanager->resPrint; // Action column print ''; - if ($user->rights->societe->creer) { + if ($permissiontoadd) { if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) { print ''.$langs->trans("CreateCardOnStripe").''; } @@ -1214,7 +1215,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $hookmanager->resPrint; // Action column print ''; - if ($user->rights->societe->creer) { + if ($permissiontoadd) { print ''; print img_picto($langs->trans("Delete"), 'delete'); print ''; @@ -1288,7 +1289,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $rib_list = $object->get_all_rib(); if (is_array($rib_list)) { - print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
    '; // You can use div-table-responsive-no-min if you don't need reserved height for your table print ''; print ''; @@ -1446,7 +1447,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // Edit/Delete print ''; print ''; print ''; + print ''; } print ''; print ''; print ''; print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; - } print ''; $total = 0; @@ -657,8 +655,26 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print price($sign * $multicurrency_remaintopay); } print ''; - } - + + print '"; + } + print ''; print '"; - // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) { - print '"; - } - print "\n"; $total += $objp->total_ht; $total_ttc += $objp->total_ttc; @@ -730,6 +723,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; + print ''; } print ''; print ''; print ''; print ''; // Autofilled - if (!empty($conf->multicurrency->enabled)) { - print ''; - } print "\n"; } print "
    '; - if ($user->rights->societe->creer) { + if ($permissiontoadd) { print ''; print img_picto($langs->trans("Modify"), 'edit'); print ''; @@ -1486,10 +1487,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' */ $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed = $user->rights->societe->lire; - $delallowed = $user->rights->societe->creer; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $permissiontoread, $permissiontoadd, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); // Show direct download link if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { @@ -1536,7 +1535,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // Edit BAN -if ($socid && $action == 'edit' && $user->rights->societe->creer) { +if ($socid && $action == 'edit' && $permissiontoadd) { print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1655,7 +1654,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) { } // Edit Card -if ($socid && $action == 'editcard' && $user->rights->societe->creer) { +if ($socid && $action == 'editcard' && $permissiontoadd) { print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1698,7 +1697,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer) { // Create BAN -if ($socid && $action == 'create' && $user->rights->societe->creer) { +if ($socid && $action == 'create' && $permissiontoadd) { print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1813,7 +1812,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) { } // Create Card -if ($socid && $action == 'createcard' && $user->rights->societe->creer) { +if ($socid && $action == 'createcard' && $permissiontoadd) { print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1857,10 +1856,10 @@ if ($socid && $action == 'createcard' && $user->rights->societe->creer) { print $form->buttonsSaveCancel("Add"); } -if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) { +if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoadd) { print ''; } -if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer) { +if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoadd) { print ''; } From 155eae1772e6f2fa647b8d31704bc20cc4a1e1f3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 2 Nov 2021 04:52:16 +0100 Subject: [PATCH 278/490] Add advanced right to add / update thirdparty payment information --- htdocs/core/modules/modSociete.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index c3eba65673b..a177f367c23 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -197,6 +197,13 @@ class modSociete extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'export'; + $r++; + $this->rights[$r][0] = 130; + $this->rights[$r][1] = 'Modify thirdparty information payment'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'addupdate_thirdparty_payment_information'; // Visible if option MAIN_USE_ADVANCED_PERMS is on + $this->rights[$r][5] = 'write'; + // 262 : Restrict access to sales representative $r++; $this->rights[$r][0] = 262; From b128fb5ad9887c949ab321f49bd216ff884ffe53 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 2 Nov 2021 04:55:20 +0100 Subject: [PATCH 279/490] Add advanced right to add / update thirdparty payment information --- htdocs/societe/paymentmodes.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 07f0193359c..fa4b6069430 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -706,7 +706,7 @@ if (empty($companybankaccount->socid)) { $companybankaccount->socid = $object->id; } -if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoadd) { +if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoaddupdatepaymentinformation) { print '
    '; print ''; $actionforadd = 'update'; @@ -716,7 +716,7 @@ if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoadd) print ''; print ''; } -if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoadd) { +if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoaddupdatepaymentinformation) { print ''; print ''; $actionforadd = 'add'; @@ -792,9 +792,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (!empty($conf->stripe->enabled)) { // Stripe customer key 'cu_....' stored into llx_societe_account print '
    '; - print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoadd, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; - print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoadd, 'string', '', null, null, '', 2, '', 'socid'); + print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') { $connect = ''; if (!empty($stripeacc)) { @@ -855,9 +855,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // Stripe customer key 'cu_....' stored into llx_societe_account print '
    '; - print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoadd, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; - print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoadd, 'string', '', null, null, '', 2, '', 'socid'); + print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') { $connect = ''; @@ -1062,7 +1062,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $hookmanager->resPrint; // Action column print ''; - if ($permissiontoadd) { + if ($permissiontoaddupdatepaymentinformation) { if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) { print ''.$langs->trans("CreateCardOnStripe").''; } @@ -1215,7 +1215,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $hookmanager->resPrint; // Action column print ''; - if ($permissiontoadd) { + if ($permissiontoaddupdatepaymentinformation) { print ''; print img_picto($langs->trans("Delete"), 'delete'); print ''; @@ -1449,7 +1449,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // Edit/Delete print ''; - if ($permissiontoadd) { + if ($permissiontoaddupdatepaymentinformation) { print ''; print img_picto($langs->trans("Modify"), 'edit'); print ''; @@ -1490,7 +1490,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $permissiontoread, $permissiontoadd, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $permissiontoread, $permissiontoaddupdatepaymentinformation, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); // Show direct download link if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { @@ -1537,7 +1537,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // Edit BAN -if ($socid && $action == 'edit' && $permissiontoadd) { +if ($socid && $action == 'edit' && $permissiontoaddupdatepaymentinformation) { print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1656,7 +1656,7 @@ if ($socid && $action == 'edit' && $permissiontoadd) { } // Edit Card -if ($socid && $action == 'editcard' && $permissiontoadd) { +if ($socid && $action == 'editcard' && $permissiontoaddupdatepaymentinformation) { print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1699,7 +1699,7 @@ if ($socid && $action == 'editcard' && $permissiontoadd) { // Create BAN -if ($socid && $action == 'create' && $permissiontoadd) { +if ($socid && $action == 'create' && $permissiontoaddupdatepaymentinformation) { print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1814,7 +1814,7 @@ if ($socid && $action == 'create' && $permissiontoadd) { } // Create Card -if ($socid && $action == 'createcard' && $permissiontoadd) { +if ($socid && $action == 'createcard' && $permissiontoaddupdatepaymentinformation) { print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1858,10 +1858,10 @@ if ($socid && $action == 'createcard' && $permissiontoadd) { print $form->buttonsSaveCancel("Add"); } -if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoadd) { +if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoaddupdatepaymentinformation) { print ''; } -if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoadd) { +if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoaddupdatepaymentinformation) { print ''; } From 8992276e25bc1fab93059730c01b8d2cfbdcb9e9 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 2 Nov 2021 05:18:32 +0100 Subject: [PATCH 280/490] Hidden button without specific advancedright --- htdocs/societe/paymentmodes.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index fa4b6069430..b278c7c6da3 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1282,8 +1282,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // List of bank accounts - - $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create'); + if ($permissiontoaddupdatepaymentinformation) { + $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '&action=create'); + } print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank'); From 13123c3370d352625dccdb54f1ecaba87e74a491 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 2 Nov 2021 05:31:51 +0100 Subject: [PATCH 281/490] Permission language key --- htdocs/langs/en_US/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 7ffbe0328c1..9e5cefe79a3 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -762,6 +762,7 @@ Permission121=Read third parties linked to user Permission122=Create/modify third parties linked to user Permission125=Delete third parties linked to user Permission126=Export third parties +Permission130=Create/modify third parties payment information Permission141=Read all projects and tasks (also private projects for which I am not a contact) Permission142=Create/modify all projects and tasks (also private projects for which I am not a contact) Permission144=Delete all projects and tasks (also private projects i am not contact for) From 5bb6185e64359d476954359076e64473d13591e6 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Tue, 2 Nov 2021 12:37:39 +0100 Subject: [PATCH 282/490] add_substitution --- htdocs/core/lib/functions.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 084a4a4f25a..5eb0bd7d62c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7212,7 +7212,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if ($object->id > 0) { $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)) : ''); $substitutionarray['__ONLINE_PAYMENT_URL__'] = $paymenturl; - + + if (is_object($object) && $object->element == 'propal') { + $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref); + } if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') { $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element); } else { From b56eaf91e892f39252b1d431fd71eb082002fa85 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 2 Nov 2021 20:53:00 +0800 Subject: [PATCH 283/490] Update paiement.php --- htdocs/fourn/facture/paiement.php | 53 +++++++++++++------------------ 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 1dd6f0a0f12..cdd73b5ef70 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -555,14 +555,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.$langs->trans('MulticurrencyAmountTTC').''.$langs->trans('MulticurrencyAlreadyPaid').''.$langs->trans('MulticurrencyRemainderToPay').''.$langs->trans('MulticurrencyPaymentAmount').''.$langs->trans('AmountTTC').''.$langs->trans('AlreadyPaid').''.$langs->trans('RemainderToPay').''.$langs->trans('PaymentAmount').''.$langs->trans('MulticurrencyPaymentAmount').'
    '; + // Add remind multicurrency amount + $namef = 'multicurrency_amount_'.$objp->facid; + $nameRemain = 'multicurrency_remain_'.$objp->facid; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { + if ($action != 'add_paiement') { + if (!empty($conf->use_javascript_ajax)) { + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + } + print ''; + print ''; + } else { + print ''; + print ''; + } + } + print "'.price($sign * $objp->total_ttc).''.price($sign * $objp->am); @@ -690,29 +706,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print "'; - - // Add remind multicurrency amount - $namef = 'multicurrency_amount_'.$objp->facid; - $nameRemain = 'multicurrency_remain_'.$objp->facid; - - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - if ($action != 'add_paiement') { - if (!empty($conf->use_javascript_ajax)) { - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); - } - print ''; - print ''; - } else { - print ''; - print ''; - } - } - print "
       '.price($sign * $total_ttc).''.price($sign * $totalrecu); @@ -742,9 +736,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'
    \n"; From b98efd7e44085ff4f7bb0e9ac056139994bb7c4a Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 2 Nov 2021 13:55:12 +0100 Subject: [PATCH 284/490] Add rank item management and add Hook --- htdocs/core/class/html.formsetup.class.php | 258 ++++++++++++++++-- htdocs/modulebuilder/template/admin/setup.php | 27 +- 2 files changed, 248 insertions(+), 37 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index df99b6cdbbb..cbf8cbd37ba 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -30,6 +30,9 @@ class formSetup /** @var formSetupItem[] */ public $params = array(); + /** + * @var int + */ public $setupNotEmpty = 0; /** @var Translate */ @@ -38,6 +41,9 @@ class formSetup /** @var Form */ public $form; + /** @var int */ + protected $maxItemRank; + /** * Constructor * @@ -63,29 +69,81 @@ class formSetup */ public function generateOutput($editMode = false) { + global $hookmanager, $action; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $out = ''; - if ($editMode) { - $out .= ''; + $parameters = array( + 'editMode' => $editMode + ); + $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutput', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ' '; - $out.= ' '; - $out.= ''; - $out.= ''; + if ($reshook > 0) { + return $hookmanager->resPrint; + } else { + $out = ''; + if ($editMode) { + $out .= ''; + } - $out.= ''; + $out .= '
    '.$this->langs->trans("Parameter").''.$this->langs->trans("Value").'
    '; + $out .= ''; + $out .= ''; + $out .= ' '; + $out .= ' '; + $out .= ''; + $out .= ''; + + // Sort items before render + $this->sortingItems(); + + $out .= ''; + foreach ($this->params as $item) { + $out .= $this->generateLineOutput($item, $editMode); + } + $out .= ''; + + $out .= '
    ' . $this->langs->trans("Parameter") . '' . $this->langs->trans("Value") . '
    '; + return $out; + } + } + + /** + * @param bool $noMessageInUpdate display event message on errors and success + * @return void|null + */ + public function saveConfFromPost($noMessageInUpdate = false) + { + + if (empty($this->params)) { + return null; + } + + $this->db->begin(); + $error = 0; foreach ($this->params as $item) { - $out.= $this->generateLineOutput($item, $editMode); + $res = $item->setValueFromPost(); + if ($res > 0) { + $item->saveConfValue(); + } elseif ($res < 0) { + $error++; + break; + } } - $out.= '
    '; - return $out; + if (!$error) { + $this->db->commit(); + if (empty($noMessageInUpdate)) { + setEventMessages($this->langs->trans("SetupSaved"), null); + } + } else { + $this->db->rollback(); + if (empty($noMessageInUpdate)) { + setEventMessages($this->langs->trans("SetupNotSaved"), null, 'errors'); + } + } } /** @@ -209,25 +267,133 @@ class formSetup if (!array($this->params)) { return false; } foreach ($this->params as $item) { - $item->reloadConf(); + $item->reloadValueFromConf(); } return true; } - /** * Create a new item + * the tagret is useful with hooks : that allow externals modules to add setup items on good place * @param $confKey the conf key used in database + * @param string $targetItemKey target item used to place the new item beside + * @param bool $insertAfterTarget insert before or after target item ? * @return formSetupItem the new setup item created */ - public function newItem($confKey) + public function newItem($confKey, $targetItemKey = false, $insertAfterTarget = false) { $item = new formSetupItem($confKey); + + // set item rank if not defined as last item + if (empty($item->rank)) { + $item->rank = $this->getCurentItemMaxRank() + 1; + $this->setItemMaxRank($item->rank); // set new max rank if needed + } + + // try to get rank from target column, this will override item->rank + if (!empty($targetItemKey)) { + if (isset($this->params[$targetItemKey])) { + $targetItem = $this->params[$targetItemKey]; + $item->rank = $targetItem->rank; // $targetItem->rank will be increase after + if ($targetItem->rank >= 0 && $insertAfterTarget) { + $item->rank++; + } + } + + // calc new rank for each item to make place for new item + foreach ($this->params as $fItem) { + if ($item->rank <= $fItem->rank) { + $fItem->rank = $fItem->rank + 1; + $this->setItemMaxRank($fItem->rank); // set new max rank if needed + } + } + } + $this->params[$item->confKey] = $item; return $this->params[$item->confKey]; } + + /** + * Sort items according to rank + * @return bool + */ + public function sortingItems() + { + // Sorting + return uasort($this->params, array($this, 'itemSort')); + } + + /** + * @param bool $cache To use cache or not + * @return int + */ + public function getCurentItemMaxRank($cache = true) + { + if (empty($this->params)) { + return 0; + } + + if ($cache && $this->maxItemRank > 0) { + return $this->maxItemRank; + } + + $this->maxItemRank = 0; + foreach ($this->params as $item) { + $this->maxItemRank = max($this->maxItemRank, $item->rank); + } + + return $this->maxItemRank; + } + + + /** + * set new max rank if needed + * @param int $rank the item rank + * @return int|void + */ + public function setItemMaxRank($rank) + { + $this->maxItemRank = max($this->maxItemRank, $rank); + } + + + /** + * get item position rank from item key + * + * @param string $itemKey the item key + * @return int rank on success and -1 on error + */ + public function getLineRank($itemKey) + { + if (!isset($this->params[$itemKey]->rank)) { + return -1; + } + return $this->params[$itemKey]->rank; + } + + + /** + * uasort callback function to Sort params items + * + * @param formSetupItem $a formSetup item + * @param formSetupItem $b formSetup item + * @return int Return compare result + */ + public function itemSort(formSetupItem $a, formSetupItem $b) + { + if (empty($a->rank)) { + $a->rank = 0; + } + if (empty($b->rank)) { + $b->rank = 0; + } + if ($a->rank == $b->rank) { + return 0; + } + return ($a->rank < $b->rank) ? -1 : 1; + } } /** @@ -243,6 +409,9 @@ class formSetupItem /** @var Translate */ public $langs; + /** @var int */ + public $entity; + /** @var Form */ public $form; @@ -267,6 +436,9 @@ class formSetupItem /** @var bool|string set this var to override field output */ public $fieldOutputOverride = false; + /** @var int $rank */ + public $rank = 0; + /** * @var string $errors */ @@ -294,6 +466,7 @@ class formSetupItem $this->db = $db; $this->form = new Form($this->db); $this->langs = $langs; + $this->entity = $conf->entity; $this->confKey = $confKey; $this->fieldValue = $conf->global->{$this->confKey}; @@ -303,12 +476,58 @@ class formSetupItem * reload conf value from databases * @return null */ - public function reloadConf() + public function reloadValueFromConf() { global $conf; $this->fieldValue = $conf->global->{$this->confKey}; } + + /** + * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php + * @return int -1 if KO, 1 if OK + */ + public function saveConfValue() + { + // Modify constant only if key was posted (avoid resetting key to the null value) + if ($this->type != 'title') { + $result = dolibarr_set_const($this->db, $this->confKey, $this->fieldValue, 'chaine', 0, '', $this->entity); + if ($result < 0) { + return -1; + } else { + return 1; + } + } + } + + + /** + * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php + * @return int -1 if KO, 0 nothing to do , 1 if OK + */ + public function setValueFromPost() + { + // Modify constant only if key was posted (avoid resetting key to the null value) + if ($this->type != 'title') { + if (preg_match('/category:/', $this->type)) { + if (GETPOST($this->confKey, 'int') == '-1') { + $val_const = ''; + } else { + $val_const = GETPOST($this->confKey, 'int'); + } + } else { + $val_const = GETPOST($this->confKey, 'alpha'); + } + + // TODO add value check with class validate + $this->fieldValue = $val_const; + + return 1; + } + + return 0; + } + /** * Get help text or generate it * @return int|string @@ -596,6 +815,7 @@ class formSetupItem return $out; } + /* * METHODS FOR SETTING DISPLAY TYPE */ diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 007e9d84b12..527ea8eb32d 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -60,6 +60,9 @@ require_once '../lib/mymodule.lib.php'; // Translations $langs->loadLangs(array("admin", "mymodule@mymodule")); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('mymodulesetup', 'globalsetup')); + // Access control if (!$user->admin) { accessforbidden(); @@ -74,22 +77,10 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; -$arrayofparameters = array( - 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1), - 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1), - //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), - //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), - //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), - //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), - //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), -); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; $formSetup = new formSetup($db); -$formSetup->addItemsFromParamsArray($arrayofparameters); - // Hôte $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); @@ -131,11 +122,10 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); * Actions */ -if ((float) DOL_VERSION >= 6) { - // TODO Add save setup by formSetup - $arrayofparameters = $formSetup->exportItemsAsParamsArray(); - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; - $formSetup->reloadConfs(); +if ((float) DOL_VERSION >= 15) { + if ($action == 'update') { + $formSetup->saveConfFromPost(); + } } if ($action == 'updateMask') { @@ -275,8 +265,9 @@ if ($action == 'edit') { print ''; print '
    '; } else { - if (!empty($arrayofparameters)) { + if (!empty($formSetup->params)) { print $formSetup->generateOutput(); + $setupnotempty++; print '
    '; print ''.$langs->trans("Modify").''; From 899f0bee9a191a699104ee60dad8b35bb5aa639f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 2 Nov 2021 12:59:38 +0000 Subject: [PATCH 285/490] Fixing style errors. --- htdocs/fourn/facture/paiement.php | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index cdd73b5ef70..76e15127098 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -655,26 +655,26 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print price($sign * $multicurrency_remaintopay); } print '
    '; - // Add remind multicurrency amount - $namef = 'multicurrency_amount_'.$objp->facid; - $nameRemain = 'multicurrency_remain_'.$objp->facid; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - if ($action != 'add_paiement') { - if (!empty($conf->use_javascript_ajax)) { - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); - } - print ''; - print ''; - } else { - print ''; - print ''; - } - } - print "'; + // Add remind multicurrency amount + $namef = 'multicurrency_amount_'.$objp->facid; + $nameRemain = 'multicurrency_remain_'.$objp->facid; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { + if ($action != 'add_paiement') { + if (!empty($conf->use_javascript_ajax)) { + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + } + print ''; + print ''; + } else { + print ''; + print ''; + } + } + print "'.price($sign * $objp->total_ttc).''.price($sign * $objp->am); From bbe71c9c32d792a3fd0cfe56b37394d9af6f4942 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 2 Nov 2021 14:07:36 +0100 Subject: [PATCH 286/490] Rename var --- htdocs/core/class/html.formsetup.class.php | 36 +++++++++---------- htdocs/modulebuilder/template/admin/setup.php | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index cbf8cbd37ba..8f9d3af0528 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -28,7 +28,7 @@ class formSetup public $db; /** @var formSetupItem[] */ - public $params = array(); + public $items = array(); /** * @var int @@ -100,7 +100,7 @@ class formSetup $this->sortingItems(); $out .= '
    '.$langs->trans("MovementLabel").''; print ''; print ''.$langs->trans("InventoryCode").''.$langs->trans("InventoryCode").'
    '; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 27c9b2acb21..711e5a0c9ac 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -130,7 +130,7 @@ print '
    '.$langs->trans("MovementLabel").''; print ''; print ''.$langs->trans("InventoryCode").''.$langs->trans("InventoryCode").'
    '; From 0c1d4c9d5104717bc9957ac0cde20bba21872881 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:48:12 +0100 Subject: [PATCH 292/490] No need of escape htmltag thanks to GETPOST before --- htdocs/product/stock/tpl/stocktransfer.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 711e5a0c9ac..b71e1e8b248 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -124,11 +124,11 @@ if (!empty($conf->productbatch->enabled) && } // Label -$valformovementlabel = (GETPOST("label") ?GETPOST("label") : $langs->trans("MovementTransferStock", $productref)); +$valformovementlabel = (GETPOST("label") ? GETPOST("label") : $langs->trans("MovementTransferStock", $productref)); print ''; print ''.$langs->trans("MovementLabel").''; print ''; -print ''; +print ''; print ''; print ''.$langs->trans("InventoryCode").''; print ''; From 49d955b7948a1c730c519402f5c003fb5f2dfb5d Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:53:57 +0100 Subject: [PATCH 293/490] Uniformization of the table code as the line above --- htdocs/product/stock/tpl/stockcorrection.tpl.php | 5 ++++- htdocs/product/stock/tpl/stocktransfer.tpl.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index e1a5e734016..e4dfd8b5d7c 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -155,7 +155,10 @@ print ''.$langs->trans("MovementLabel").''; print ''; print ''; print ''; -print ''.$langs->trans("InventoryCode").''; +print ''.$langs->trans("InventoryCode").''; +print ''; +print ''; +print ''; print ''; print ''; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index b71e1e8b248..31a3103c3eb 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -130,7 +130,10 @@ print ''.$langs->trans("MovementLabel").''; print ''; print ''; print ''; -print ''.$langs->trans("InventoryCode").''; +print ''.$langs->trans("InventoryCode").''; +print ''; +print ''; +print ''; print ''; print ''; From d91c24233c33525d89ec4c0557fc74770464cd8e Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 2 Nov 2021 16:43:09 +0100 Subject: [PATCH 294/490] NEW: Can show Paid button if invoice or supplier invoice has no payments with global INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS and SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS --- htdocs/compta/facture/card.php | 13 ++++++++----- htdocs/fourn/facture/card.php | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ba505f33d67..b02c48ff79b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4091,10 +4091,10 @@ if ($action == 'create') { } // Confirmation du classement paye - if ($action == 'paid' && $resteapayer <= 0) { + if ($action == 'paid' && ($resteapayer <= 0 || (!empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $resteapayer == $object->total_ttc))) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', "yes", 1); } - if ($action == 'paid' && $resteapayer > 0) { + if ($action == 'paid' && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) || $resteapayer != $object->total_ttc)) { $close = array(); // Code $i = 0; @@ -5450,14 +5450,17 @@ if ($action == 'create') { } // Classify paid - if (($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))) - || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) + if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment && ( + ($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && ($resteapayer <= 0 || (!empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $object->total_ttc == $resteapayer))) || + ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0) || + ($object->type == Facture::TYPE_DEPOSIT && $object->total_ttc > 0 && ($resteapayer == 0 || (!empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $object->total_ttc == $resteapayer))) + ) ) { print ''.$langs->trans('ClassifyPaid').''; } // Classify 'closed not completely paid' (possible if validated and not yet filed paid) - if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && $usercanissuepayment) { + if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) || $resteapayer != $object->total_ttc) && $usercanissuepayment) { if ($totalpaye > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice print ''.$langs->trans('ClassifyPaidPartially').''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ee1f768b60b..507c046a6a4 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2563,11 +2563,11 @@ if ($action == 'create') { } // Confirmation set paid - if ($action == 'paid' && $resteapayer <= 0) { + if ($action == 'paid' && ($resteapayer <= 0 || (!empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $resteapayer == $object->total_ttc))) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', 0, 1); } - if ($action == 'paid' && $resteapayer > 0) { + if ($action == 'paid' && $resteapayer > 0 && (empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) || $resteapayer != $object->total_ttc)) { $close = array(); // Code $i = 0; @@ -3496,14 +3496,17 @@ if ($action == 'create') { } // Classify paid - if (($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && (($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $resteapayer >= 0))) - || ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && empty($discount->id)) + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && ( + ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT && ($resteapayer <= 0 || (!empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $object->total_ttc == $resteapayer))) || + ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $resteapayer >= 0) || + ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->total_ttc > 0 && ($resteapayer == 0 || (!empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $object->total_ttc == $resteapayer))) + ) ) { print ''.$langs->trans('ClassifyPaid').''; } // Classify 'closed not completely paid' (possible if validated and not yet filed paid) - if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0) { + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) || $object->total_ttc != $resteapayer)) { if ($totalpaye > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice print ''.$langs->trans('ClassifyPaidPartially').''; From b02c89bd8b7e68090c52142ef33e42d8c39be7d7 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 2 Nov 2021 23:07:46 +0100 Subject: [PATCH 295/490] Add link year subscription list in subscription by year stats page --- htdocs/adherents/stats/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index ed79978552f..de9a5b3d9d9 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -196,7 +196,7 @@ foreach ($data as $val) { print ''; print ''; //print ''; - print $year; + print ''.$year.''; //print ''; print ''; print ''.$val['nb'].''; From d334fe1292b1abfe4b2ec1083f504e5b1f852bf1 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 3 Nov 2021 13:12:33 +0100 Subject: [PATCH 296/490] Fix Bad count of subscription by year If --- htdocs/core/boxes/box_members_subscriptions_by_year.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index be835511c6b..b6c146312bc 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -111,7 +111,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($result); - $year = dol_print_date($this->db->jdate($objp->dateh), "%Y", 'gmt'); + $year = dol_print_date($this->db->jdate($objp->dateh), "%Y"); $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; $tot += $objp->subscription; From a359c7a681dfa27c3d57969ea02cdabd13e4b259 Mon Sep 17 00:00:00 2001 From: Vincent Dieltiens Date: Wed, 3 Nov 2021 14:22:08 +0100 Subject: [PATCH 297/490] Handle case where credit note has no source invoice --- htdocs/fourn/facture/card.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) mode change 100644 => 100755 htdocs/fourn/facture/card.php diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php old mode 100644 new mode 100755 index ee1f768b60b..5de5942a542 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2721,8 +2721,12 @@ if ($action == 'create') { } if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $facusing = new FactureFournisseur($db); - $facusing->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; + if ($object->fk_facture_source > 0) { + $facusing->fetch($object->fk_facture_source); + print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; + } else { + print ' ('.$langs->transnoentities("NoInvoiceToCorrect").')'; + } } $facidavoir = $object->getListIdAvoirFromInvoice(); From a4c4732d5d10588dd6877360a6db1e51be046d33 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 3 Nov 2021 16:18:03 +0100 Subject: [PATCH 298/490] NEW: for developpers add hook for moreHTMLRef in dol_banner_tab --- htdocs/core/class/hookmanager.class.php | 3 ++- htdocs/core/lib/functions.lib.php | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 40610ce5d6f..691c20e10f8 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -229,7 +229,8 @@ class HookManager 'showLinkToObjectBlock', 'setContentSecurityPolicy', 'setHtmlTitle', - 'completeTabsHead' + 'completeTabsHead', + 'formDolBanner' ) )) { $hooktype = 'addreplace'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 408a771e1ed..8912c41152a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1845,7 +1845,7 @@ function dol_get_fiche_end($notab = 0) */ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $onlybanner = 0, $morehtmlright = '') { - global $conf, $form, $user, $langs; + global $conf, $form, $user, $langs, $hookmanager; $error = 0; @@ -2116,6 +2116,17 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $morehtmlref .= '
    '; } + $parameters=array('morehtmlref'=>$morehtmlref); + $reshook = $hookmanager->executeHooks('formDolBanner', $parameters, $object, ''); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } elseif (empty($reshook)) { + $morehtmlref .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $morehtmlref = $hookmanager->resPrint; + } + + print '
    '; print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright); print '
    '; From 054d98b942299ab8cb8d238c66047e5009cd6831 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 3 Nov 2021 16:31:35 +0100 Subject: [PATCH 299/490] fix ref --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8912c41152a..c71b3ad0802 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2117,7 +2117,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } $parameters=array('morehtmlref'=>$morehtmlref); - $reshook = $hookmanager->executeHooks('formDolBanner', $parameters, $object, ''); + $reshook = $hookmanager->executeHooks('formDolBanner', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } elseif (empty($reshook)) { From 973f408b6e3caa54a862b887f759279d214d487b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 3 Nov 2021 20:35:57 +0100 Subject: [PATCH 300/490] Fix default enddate subscription must be in futur --- htdocs/adherents/subscription.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 1316a337610..839680c3874 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,8 +943,10 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0) { - $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd') { + $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + } else { + $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); } } print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); From 0e91b32e990e764fade7abec6e03ea6d7a605b9c Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 3 Nov 2021 20:40:09 +0100 Subject: [PATCH 301/490] Update subscription.php --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 839680c3874..11b3aed8f00 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,7 +943,7 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd') { + if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); From f9db196512ac5b405780368bc2ea2667e43db5a3 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 3 Nov 2021 22:31:45 +0100 Subject: [PATCH 302/490] Update subscription.php --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 11b3aed8f00..f38562da5a0 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,7 +943,7 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { + if ($object->datefin > 0 && dol_now() < dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); From 586005ff2e5daf46870bb62c908052aa947cd28c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 3 Nov 2021 21:43:30 +0000 Subject: [PATCH 303/490] Fixing style errors. --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index f38562da5a0..e8a703a6efb 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -944,7 +944,7 @@ if ($rowid > 0) { if (!$datefrom) { $datefrom = $object->datevalid; if ($object->datefin > 0 && dol_now() < dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { - $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); } From 3fb0e3c5ad4789209478f43ff65716edc358c93c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 3 Nov 2021 22:56:15 +0100 Subject: [PATCH 304/490] NEW add html.formldap.class.php --- htdocs/adherents/ldap.php | 4 +- htdocs/adherents/type_ldap.php | 4 +- htdocs/admin/ldap.php | 67 ++---- htdocs/admin/ldap_groups.php | 4 +- htdocs/admin/ldap_members_types.php | 2 +- htdocs/admin/ldap_users.php | 4 +- htdocs/contact/ldap.php | 4 +- htdocs/core/class/conf.class.php | 21 +- htdocs/core/class/html.formldap.class.php | 196 ++++++++++++++++++ htdocs/core/class/ldap.class.php | 19 +- htdocs/core/login/functions_ldap.php | 2 +- ...interface_50_modLdap_Ldapsynchro.class.php | 44 ++-- htdocs/langs/en_US/ldap.lang | 4 +- htdocs/user/card.php | 2 +- htdocs/user/group/ldap.php | 4 +- htdocs/user/ldap.php | 4 +- 16 files changed, 293 insertions(+), 92 deletions(-) create mode 100644 htdocs/core/class/html.formldap.class.php diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 4b64290f107..70624983815 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -158,13 +158,13 @@ print dol_get_fiche_end(); */ print '
    '; -if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') { +if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { print ''; } print "
    \n"; -if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') { +if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { print "
    \n"; } diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index 43902a5e1bf..d7650a8de2b 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -124,13 +124,13 @@ print dol_get_fiche_end(); print '
    '; -if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) { +if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print ''.$langs->trans("ForceSynchronize").''; } print "
    \n"; -if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) { +if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print "
    \n"; } diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 167c48d84c0..99c86f783fc 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -100,7 +100,7 @@ if (empty($reshook)) { if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) { $error++; } - if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("'LDAP_PASSWORD_HASH_TYPE'", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("LDAP_PASSWORD_HASH_TYPE", 'aZ09'), 'chaine', 0, '', $conf->entity)) { $error++; } @@ -150,13 +150,9 @@ print "\n"; // Synchro utilisateurs/groupes active print ''.$langs->trans("LDAPDnSynchroActive").''; -$arraylist = array(); -$arraylist['0'] = $langs->trans("No"); -$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr"); -$arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP"); -print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE); +print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_SYNCHRO_ACTIVE'), 'activesynchro'); print ''.$langs->trans("LDAPDnSynchroActiveExample").''; -if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) { +if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && empty($conf->global->LDAP_USER_DN)) { print '
    '.$langs->trans("LDAPSetupNotComplete").''; } print ''; @@ -164,32 +160,21 @@ print ''; // Synchro contact active if (!empty($conf->societe->enabled)) { print ''.$langs->trans("LDAPDnContactActive").''; - $arraylist = array(); - $arraylist['0'] = $langs->trans("No"); - $arraylist['1'] = $langs->trans("DolibarrToLDAP"); - print $form->selectarray('activecontact', $arraylist, $conf->global->LDAP_CONTACT_ACTIVE); + print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_CONTACT_ACTIVE'), 'activecontact', array(Ldap::SYNCHRO_LDAP_TO_DOLIBARR)); print ''.$langs->trans("LDAPDnContactActiveExample").''; } // Synchro member active if (!empty($conf->adherent->enabled)) { print ''.$langs->trans("LDAPDnMemberActive").''; - $arraylist = array(); - $arraylist['0'] = $langs->trans("No"); - $arraylist['1'] = $langs->trans("DolibarrToLDAP"); - $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')'; - print $form->selectarray('activemembers', $arraylist, $conf->global->LDAP_MEMBER_ACTIVE); + print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_ACTIVE'), 'activemembers', array(), 2); print ''.$langs->trans("LDAPDnMemberActiveExample").''; } // Synchro member type active if (!empty($conf->adherent->enabled)) { print ''.$langs->trans("LDAPDnMemberTypeActive").''; - $arraylist = array(); - $arraylist['0'] = $langs->trans("No"); - $arraylist['1'] = $langs->trans("DolibarrToLDAP"); - $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')'; - print $form->selectarray('activememberstypes', $arraylist, $conf->global->LDAP_MEMBER_TYPE_ACTIVE); + print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE'), 'activememberstypes', array(), 2); print ''.$langs->trans("LDAPDnMemberTypeActiveExample").''; } @@ -206,53 +191,39 @@ print "\n"; // Type print ''.$langs->trans("Type").''; -$arraylist = array(); -$arraylist['activedirectory'] = 'Active Directory'; -$arraylist['openldap'] = 'OpenLdap'; -$arraylist['egroupware'] = 'Egroupware'; -print $form->selectarray('type', $arraylist, $conf->global->LDAP_SERVER_TYPE); +print $formldap->selectLdapServerType(getDolGlobalString('LDAP_SERVER_TYPE'), 'type'); print ' '; // Version print ''.$langs->trans("Version").''; -$arraylist = array(); -$arraylist['3'] = 'Version 3'; -$arraylist['2'] = 'Version 2'; -print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION', $arraylist, $conf->global->LDAP_SERVER_PROTOCOLVERSION); +print $formldap->selectLdapServerProtocolVersion(getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION'), 'LDAP_SERVER_PROTOCOLVERSION'); print ''.$langs->trans("LDAPServerProtocolVersion").''; // Serveur primaire print ''; print $langs->trans("LDAPPrimaryServer").''; -print ''; +print ''; print ''.$langs->trans("LDAPServerExample").''; // Serveur secondaire print ''; print $langs->trans("LDAPSecondaryServer").''; -print ''; +print ''; print ''.$langs->trans("LDAPServerExample").''; // Port print ''.$langs->trans("LDAPServerPort").''; -if (!empty($conf->global->LDAP_SERVER_PORT)) { - print ''; -} else { - print ''; -} +print ''; print ''.$langs->trans("LDAPServerPortExample").''; // DNserver print ''.$langs->trans("LDAPServerDn").''; -print ''; +print ''; print ''.$langs->trans("LDAPServerDnExample").''; // Utiliser TLS print ''.$langs->trans("LDAPServerUseTLS").''; -$arraylist = array(); -$arraylist['0'] = $langs->trans("No"); -$arraylist['1'] = $langs->trans("Yes"); -print $form->selectarray('usetls', $arraylist, $conf->global->LDAP_SERVER_USE_TLS); +print $form->selectyesno('usetls', getDolGlobalInt('LDAP_SERVER_USE_TLS'), 1); print ''.$langs->trans("LDAPServerUseTLSExample").''; // Password hash type @@ -267,7 +238,7 @@ print "\n"; // DNAdmin print ''; print ''.$langs->trans("LDAPAdminDn").''; -print ''; +print ''; print ''.$langs->trans("LDAPAdminDnExample").''; // Pass @@ -276,7 +247,7 @@ print ''.$langs->trans("LDAPPassword").''; if (!empty($conf->global->LDAP_ADMIN_PASS)) { print ''; // je le met en visible pour test } else { - print ''; + print ''; } print ''.$langs->trans('Password').' (ex: secret)'; @@ -306,17 +277,17 @@ if (function_exists("ldap_connect")) { if ($result > 0) { // Test ldap connect and bind print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPTCPConnectOK", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT).''; + print ''.$langs->trans("LDAPTCPConnectOK", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT')).''; print '
    '; if (!empty($conf->global->LDAP_ADMIN_DN) && !empty($conf->global->LDAP_ADMIN_PASS)) { if ($result == 2) { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPBindOK", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; + print ''.$langs->trans("LDAPBindOK", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; print '
    '; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPBindKO", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; + print ''.$langs->trans("LDAPBindKO", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; print '
    '; print $langs->trans("Error").' '.$ldap->error; print '
    '; @@ -342,7 +313,7 @@ if (function_exists("ldap_connect")) { $ldap->unbind(); } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPTCPConnectKO", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT).''; + print ''.$langs->trans("LDAPTCPConnectKO", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT')).''; print '
    '; print $langs->trans("Error").' '.$ldap->error; print '
    '; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 82ee85b9a20..5723183735e 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -218,7 +218,7 @@ print ''; /* * Test de la connexion */ -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $butlabel = $langs->trans("LDAPTestSynchroGroup"); $testlabel = 'testgroup'; $key = $conf->global->LDAP_KEY_GROUPS; @@ -226,7 +226,7 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { $objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); -} elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { +} elseif (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { $butlabel = $langs->trans("LDAPTestSearch"); $testlabel = 'testsearchgroup'; $key = $conf->global->LDAP_KEY_GROUPS; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 05572dc8bbf..7933b59d5e0 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -188,7 +188,7 @@ print ''; /* * Test de la connexion */ -if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { +if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $butlabel = $langs->trans("LDAPTestSynchroMemberType"); $testlabel = 'testmembertype'; $key = $conf->global->LDAP_KEY_MEMBERS_TYPES; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index 33bec1cb2e8..f395eb88fb4 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -405,7 +405,7 @@ print ''; /* * Test de la connexion */ -if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'dolibarr2ldap') { +if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $butlabel = $langs->trans("LDAPTestSynchroUser"); $testlabel = 'testuser'; $key = getDolGlobalString('LDAP_KEY_USERS'); @@ -413,7 +413,7 @@ if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'dolibarr2ldap') { $objectclass = getDolGlobalString('LDAP_USER_OBJECT_CLASS'); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); -} elseif (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'ldap2dolibarr') { +} elseif (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { $butlabel = $langs->trans("LDAPTestSearch"); $testlabel = 'testsearchuser'; $key = getDolGlobalString('LDAP_KEY_USERS'); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index d29aab0386b..92b9c1ad337 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -136,13 +136,13 @@ print dol_get_fiche_end(); */ print '
    '; -if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') { +if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { print ''.$langs->trans("ForceSynchronize").''; } print "
    \n"; -if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') { +if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { print "
    \n"; } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 044dc192426..cf54151d2d6 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -775,8 +775,8 @@ class Conf $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400; } if (isset($this->commande)) { - $this->bank->rappro = new stdClass(); - $this->bank->cheque = new stdClass(); + $this->bank->rappro = new stdClass(); + $this->bank->cheque = new stdClass(); $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400; $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400; } @@ -845,6 +845,23 @@ class Conf } } + // For backward compatibility + if (!empty($this->global->LDAP_SYNCHRO_ACTIVE)) { + if ($this->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { + $this->global->LDAP_SYNCHRO_ACTIVE = 1; + } else if ($this->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { + $this->global->LDAP_SYNCHRO_ACTIVE = 2; + } + } + // For backward compatibility + if (!empty($this->global->LDAP_MEMBER_ACTIVE) && $this->global->LDAP_MEMBER_ACTIVE == 'ldap2dolibarr') { + $this->global->LDAP_MEMBER_ACTIVE = 2; + } + // For backward compatibility + if (!empty($this->global->LDAP_MEMBER_TYPE_ACTIVE) && $this->global->LDAP_MEMBER_TYPE_ACTIVE == 'ldap2dolibarr') { + $this->global->LDAP_MEMBER_TYPE_ACTIVE = 2; + } + if (!empty($this->global->MAIN_TZUSERINPUTKEY)) { $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel' } diff --git a/htdocs/core/class/html.formldap.class.php b/htdocs/core/class/html.formldap.class.php new file mode 100644 index 00000000000..acee0bbbea7 --- /dev/null +++ b/htdocs/core/class/html.formldap.class.php @@ -0,0 +1,196 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/html.formldap.class.php + * \ingroup core + * \brief File of class with ldap html predefined components + */ +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + +/** + * Class to manage generation of HTML components for ldap module + */ +class FormLdap +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var string[] Array of error strings + */ + public $errors = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $form; + + if (!is_object($form)) { + $form = new Form($this->db); + } + + $langs->loadLangs(array("admin", "ldap")); + + $this->db = $db; + } + + /** + * Return list of types of hash + * + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $showempty Add an empty field + * @return string HTML select string + */ + public function selectLdapPasswordHashType($selected = 'md5', $htmlname = 'ldaphashtype', $showempty = 0) + { + global $form; + + if (empty($selected)) { + $selected = 'md5'; + } + if (empty($htmlname)) { + $htmlname = 'ldaphashtype'; + } + + $arraylist = array( + "pbkdf2sha256" => "PBKDF2_SHA256", + "ssha512" => "SSHA512", + "ssha256" => "SSHA256", + "ssha" => "SSHA", + "sha" => "SHA", + "md5" => "MD5", + "smd5" => "SMD5", + "cryptmd5" => "CRYPT-MD5", + "cryptsha512" => "CRYPT-SHA512", + "cryptsha256" => "CRYPT-SHA256", + "crypt" => "CRYPT", + "clear" => "CLEAR" + ); + + return $form->selectarray($htmlname, $arraylist, $selected, $showempty); + } + + /** + * Return list of type of synchronization + * + * @param int $selected Preselected type + * @param string $htmlname Name of field in form + * @param array $exclude Exclude values from the list + * @param int $scriptonly Add warning if synchro only work with a script (0 = disable, 1 = Dolibarr2ldap, 2 = ldap2dolibarr, 3 = all) + * @param int $showempty Add an empty field + * @return string HTML select string + */ + public function selectLdapDnSynchroActive($selected = 0, $htmlname = 'activesynchro', $exclude = array(), $scriptonly = 0, $showempty = 0) + { + global $langs, $form; + + if (empty($selected)) { + $selected = Ldap::SYNCHRO_NONE; + } + if (empty($htmlname)) { + $htmlname = 'activesynchro'; + } + + $dolibarr2ldaplabel = $langs->trans("DolibarrToLDAP") . (($scriptonly == 1 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPExportScriptOnly").")" : ""); + $ldap2dolibarrlabel = $langs->trans("LDAPToDolibarr") . (($scriptonly == 2 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPImportScriptOnly").")" : ""); + + $arraylist = array( + Ldap::SYNCHRO_NONE => $langs->trans("No"), + Ldap::SYNCHRO_DOLIBARR_TO_LDAP => $dolibarr2ldaplabel, + Ldap::SYNCHRO_LDAP_TO_DOLIBARR => $ldap2dolibarrlabel + ); + + if (is_array($exclude) && !empty($exclude)) { + foreach($exclude as $value) { + if (array_key_exists($value, $arraylist)) { + unset($arraylist[$value]); + } + } + } + + return $form->selectarray($htmlname, $arraylist, $selected, $showempty); + } + + /** + * Return list of ldap server types + * + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $showempty Add an empty field + * @return string HTML select string + */ + public function selectLdapServerType($selected = 'openldap', $htmlname = 'type', $showempty = 0) + { + global $form; + + if (empty($selected)) { + $selected = 'openldap'; + } + if (empty($htmlname)) { + $htmlname = 'type'; + } + + $arraylist = array( + 'activedirectory' => 'Active Directory', + 'openldap' => 'OpenLdap', + 'egroupware' => 'Egroupware' + ); + + return $form->selectarray($htmlname, $arraylist, $selected, $showempty); + } + + /** + * Return list of ldap server protocol version + * + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $showempty Add an empty field + * @return string HTML select string + */ + public function selectLdapServerProtocolVersion($selected = '3', $htmlname = 'ldapprotocolversion', $showempty = 0) + { + global $form; + + if (empty($selected)) { + $selected = '3'; + } + if (empty($htmlname)) { + $htmlname = 'ldapprotocolversion'; + } + + $arraylist = array( + '3' => 'Version 3', + '2' => 'Version 2' + ); + + return $form->selectarray($htmlname, $arraylist, $selected, $showempty); + } +} diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index a1921ea2217..bd0ccbee5ac 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -122,6 +122,21 @@ class Ldap */ public $result; + /** + * No Ldap synchronization + */ + const SYNCHRO_NONE = 0; + + /** + * Dolibarr to Ldap synchronization + */ + const SYNCHRO_DOLIBARR_TO_LDAP = 1; + + /** + * Ldap to Dolibarr synchronization + */ + const SYNCHRO_LDAP_TO_DOLIBARR = 2; + /** * Constructor @@ -230,7 +245,7 @@ class Ldap dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING); $this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection); $connected = 0; - $this->close(); + $this->unbind(); } } @@ -279,7 +294,7 @@ class Ldap } if (!$connected) { - $this->close(); + $this->unbind(); } } } diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 2d55ca2815b..5ae3af3f008 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -181,7 +181,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) } // ldap2dolibarr synchronisation - if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { // ldap2dolibarr synchronisation + if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { // ldap2dolibarr synchronization dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr"); // On charge les attributs du user ldap diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index d4db5ebccfc..24df646efd6 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -81,7 +81,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers // Users if ($action == 'USER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -98,7 +98,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -177,7 +177,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -212,7 +212,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } elseif ($action == 'USER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -229,7 +229,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } /*} elseif ($action == 'USER_SETINGROUP') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -263,7 +263,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USER_REMOVEFROMGROUP') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -298,7 +298,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } elseif ($action == 'USERGROUP_CREATE') { // Groupes dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -320,7 +320,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USERGROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -353,7 +353,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USERGROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -439,7 +439,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } elseif ($action == 'MEMBER_CREATE') { // Members dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -450,7 +450,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->add($dn, $info, $user); // For member type - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { if ($object->typeid > 0) { require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; $membertype = new AdherentType($this->db); @@ -482,7 +482,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { // If status field is setup to be synchronized if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) { $ldap = new Ldap(); @@ -503,7 +503,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_SUBSCRIPTION') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { // If subscriptions fields are setup to be synchronized if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE || $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT @@ -528,7 +528,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -557,7 +557,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent); // For member type - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; /* @@ -616,7 +616,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { // If password field is setup to be synchronized if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) { $ldap = new Ldap(); @@ -637,7 +637,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_RESILIATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { // If status field is setup to be synchronized if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) { $ldap = new Ldap(); @@ -658,7 +658,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -669,7 +669,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->delete($dn); // For member type - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { if ($object->typeid > 0) { require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; @@ -706,7 +706,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } elseif ($action == 'MEMBER_TYPE_CREATE') { // Members types dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -728,7 +728,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_TYPE_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -765,7 +765,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_TYPE_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); diff --git a/htdocs/langs/en_US/ldap.lang b/htdocs/langs/en_US/ldap.lang index b13e454159d..19dd29e0a51 100644 --- a/htdocs/langs/en_US/ldap.lang +++ b/htdocs/langs/en_US/ldap.lang @@ -26,4 +26,6 @@ ForceSynchronize=Force synchronizing Dolibarr -> LDAP ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility. PasswordOfUserInLDAP=Password of user in LDAP LDAPPasswordHashType=Password hash type -LDAPPasswordHashTypeExample=Type of password hash used on the server \ No newline at end of file +LDAPPasswordHashTypeExample=Type of password hash used on the server +SupportedForLDAPExportScriptOnly=Only supported by an ldap export script +SupportedForLDAPImportScriptOnly=Only supported by an ldap import script \ No newline at end of file diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e3a72384050..da4cbf5fac0 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -731,7 +731,7 @@ if ($action == 'create' || $action == 'adduserldap') { print "
    "; - if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) { + if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) { // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set $ldap = new Ldap(); $result = $ldap->connect_bind(); diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index d8d1995a847..e3a01f27731 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -147,13 +147,13 @@ print dol_get_fiche_end(); */ print '
    '; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print ''.$langs->trans("ForceSynchronize").''; } print "
    \n"; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print "
    \n"; } diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 8e12bf1b461..66199e9b3f6 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -153,13 +153,13 @@ print dol_get_fiche_end(); */ print '
    '; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print ''.$langs->trans("ForceSynchronize").''; } print "
    \n"; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print "
    \n"; } From 3f426abc290f6198d836fed5a357982b177c7034 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 4 Nov 2021 10:56:55 +0100 Subject: [PATCH 305/490] Qual: If hidden option BANK_CAN_RECONCILIATE_CASHACCOUNT is activated, show Account Statements tab on Cash Accounts --- htdocs/core/lib/bank.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 30a3d21de90..554d435c471 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2021 Ferran Marcet * * 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 @@ -66,7 +67,7 @@ function bank_prepare_head(Account $object) $head[$h][2] = 'graph'; $h++; - if ($object->courant != Account::TYPE_CASH) { + if ($object->courant != Account::TYPE_CASH || !empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) { $nbReceipts = 0; // List of all standing receipts From dd8d4e9e983c5650f31db1386fdb698ee668f315 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 4 Nov 2021 12:10:19 +0100 Subject: [PATCH 306/490] Fix missing return status --- htdocs/core/db/DoliDB.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 8f2a9dc315e..af470ac62d6 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -308,7 +308,7 @@ abstract class DoliDB implements Database * Note : This method executes a given SQL query and retrieves the first row of results as an object. It should only be used with SELECT queries * Dont add LIMIT to your query, it will be added by this method * @param string $sql the sql query string - * @return bool| object + * @return bool|int|object false on failure, 0 on empty, object on success */ public function getRow($sql) { @@ -317,7 +317,13 @@ abstract class DoliDB implements Database $res = $this->query($sql); if ($res) { - return $this->fetch_object($res); + $obj = $this->fetch_object($res); + if(!$obj){ + return 0; + } + else{ + return $obj; + } } return false; From 58ae45a88bd29fb66eeeb24f5d95b54e92cd2ffa Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 4 Nov 2021 13:57:47 +0100 Subject: [PATCH 307/490] fix DocumentPreview on holiday documents --- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/holiday/document.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index ffa441c0527..6f0a79d9383 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1373,7 +1373,7 @@ class FormFile } // Preview link if (!$editline) { - print $this->showPreview($file, $modulepart, $filepath, 0, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); + print $this->showPreview($file, $modulepart, $filepath, 0, 'entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); } print "\n"; diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index 6986d75d630..b11b795723c 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -349,7 +349,7 @@ if ($object->id) { $permissiontoadd = $user->rights->holiday->write; $permtoedit = $user->rights->holiday->write; $param = '&id='.$object->id; - $relativepathwithnofile = $modulepart.'/'.dol_sanitizeFileName($object->ref).'/'; + $relativepathwithnofile = dol_sanitizeFileName($object->ref).'/'; $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__'; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; From 4af8a4e9fd8c84a8c3443c8066db1cfc28cdc275 Mon Sep 17 00:00:00 2001 From: Vincent Dieltiens Date: Fri, 5 Nov 2021 12:10:28 +0100 Subject: [PATCH 308/490] Add EXPENSEREPORT_FILE_IS_REQUIRED global var to force user to join a file for each line of an expense report --- htdocs/expensereport/card.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index b711a65d25a..f15f8c74743 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -118,6 +118,7 @@ $permissiontoadd = $user->rights->expensereport->creer; // Used by the include o $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); $projectRequired = $conf->projet->enabled && ! empty($conf->global->EXPENSEREPORT_PROJECT_IS_REQUIRED); +$fileRequired = !empty($conf->global->EXPENSEREPORT_FILE_IS_REQUIRED); if ($object->id > 0) { // Check current user can read this expense report @@ -1157,6 +1158,12 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Project")), null, 'errors'); } + // If no file associated + if ($fileRequired && $fk_ecm_files == 0) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); + } + if (!$error) { $type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees From 3959d12a39bf5022c6436b493b6de4be77f754fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 12:42:42 +0100 Subject: [PATCH 309/490] Update DoliDB.class.php --- htdocs/core/db/DoliDB.class.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index af470ac62d6..68e29f22481 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -312,17 +312,15 @@ abstract class DoliDB implements Database */ public function getRow($sql) { - $sql .= ' LIMIT 1;'; + $sql .= ' LIMIT 1'; $res = $this->query($sql); - if ($res) - { + if ($res) { $obj = $this->fetch_object($res); - if(!$obj){ - return 0; - } - else{ + if ($obj) { return $obj; + } else { + return 0; } } From 19b9412c1357299940c14be206bf464fc774cd61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 12:49:33 +0100 Subject: [PATCH 310/490] FIX #19305 --- htdocs/core/modules/modPropale.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 007e92e4277..12835530bf9 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -156,7 +156,8 @@ class modPropale extends DolibarrModules $this->rights[$r][1] = 'Close commercial proposals'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'cloturer'; + $this->rights[$r][4] = 'propal_advance'; + $this->rights[$r][5] = 'close'; $r++; $this->rights[$r][0] = 27; // id de la permission From 02200b98103803826a1b6737bd6bc355ce77b8e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 13:10:44 +0100 Subject: [PATCH 311/490] Update card.php --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 5de5942a542..c986bdd56db 100755 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2725,7 +2725,7 @@ if ($action == 'create') { $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } else { - print ' ('.$langs->transnoentities("NoInvoiceToCorrect").')'; + print ' ('.$langs->transnoentities("CorrectInvoiceNotFound").')'; } } From bc7b035846a33b21000614751b33c413408bd646 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 13:11:54 +0100 Subject: [PATCH 312/490] Update card.php --- htdocs/fourn/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c986bdd56db..da8672c9518 100755 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1,4 +1,4 @@ - * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles @@ -2725,7 +2725,7 @@ if ($action == 'create') { $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } else { - print ' ('.$langs->transnoentities("CorrectInvoiceNotFound").')'; + print ' ('.$langs->transnoentities("CorrectedInvoiceNotFound").')'; } } From 15bc4a7d6b4b0a7a9c943b12989f3950b3fb5aad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 13:18:37 +0100 Subject: [PATCH 313/490] Update index.php --- htdocs/adherents/stats/index.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index de9a5b3d9d9..7bf395e9bcc 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -195,9 +195,7 @@ foreach ($data as $val) { } print ''; print ''; - //print ''; - print ''.$year.''; - //print ''; + print ''.$year.''; print ''; print ''.$val['nb'].''; print ''.price(price2num($val['total'], 'MT'), 1).''; From 2b6d296e63a0d3e7f80cb41416129c9da646154e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 13:58:11 +0100 Subject: [PATCH 314/490] Rename var --- htdocs/compta/facture/card.php | 10 +++++----- htdocs/fourn/facture/card.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b02c48ff79b..509ab85634d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4091,10 +4091,10 @@ if ($action == 'create') { } // Confirmation du classement paye - if ($action == 'paid' && ($resteapayer <= 0 || (!empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $resteapayer == $object->total_ttc))) { + if ($action == 'paid' && ($resteapayer <= 0 || (!empty($conf->global->INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) && $resteapayer == $object->total_ttc))) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', "yes", 1); } - if ($action == 'paid' && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) || $resteapayer != $object->total_ttc)) { + if ($action == 'paid' && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) || $resteapayer != $object->total_ttc)) { $close = array(); // Code $i = 0; @@ -5451,16 +5451,16 @@ if ($action == 'create') { // Classify paid if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment && ( - ($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && ($resteapayer <= 0 || (!empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $object->total_ttc == $resteapayer))) || + ($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && ($resteapayer <= 0 || (!empty($conf->global->INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) && $object->total_ttc == $resteapayer))) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0) || - ($object->type == Facture::TYPE_DEPOSIT && $object->total_ttc > 0 && ($resteapayer == 0 || (!empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $object->total_ttc == $resteapayer))) + ($object->type == Facture::TYPE_DEPOSIT && $object->total_ttc > 0 && ($resteapayer == 0 || (!empty($conf->global->INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) && $object->total_ttc == $resteapayer))) ) ) { print ''.$langs->trans('ClassifyPaid').''; } // Classify 'closed not completely paid' (possible if validated and not yet filed paid) - if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) || $resteapayer != $object->total_ttc) && $usercanissuepayment) { + if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) || $resteapayer != $object->total_ttc) && $usercanissuepayment) { if ($totalpaye > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice print ''.$langs->trans('ClassifyPaidPartially').''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d5e27b62d4b..a6cf0cb232d 100755 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2563,11 +2563,11 @@ if ($action == 'create') { } // Confirmation set paid - if ($action == 'paid' && ($resteapayer <= 0 || (!empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $resteapayer == $object->total_ttc))) { + if ($action == 'paid' && ($resteapayer <= 0 || (!empty($conf->global->SUPPLIER_INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) && $resteapayer == $object->total_ttc))) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', 0, 1); } - if ($action == 'paid' && $resteapayer > 0 && (empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) || $resteapayer != $object->total_ttc)) { + if ($action == 'paid' && $resteapayer > 0 && (empty($conf->global->SUPPLIER_INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) || $resteapayer != $object->total_ttc)) { $close = array(); // Code $i = 0; @@ -3501,16 +3501,16 @@ if ($action == 'create') { // Classify paid if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && ( - ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT && ($resteapayer <= 0 || (!empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $object->total_ttc == $resteapayer))) || + ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT && ($resteapayer <= 0 || (!empty($conf->global->SUPPLIER_INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) && $object->total_ttc == $resteapayer))) || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $resteapayer >= 0) || - ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->total_ttc > 0 && ($resteapayer == 0 || (!empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) && $object->total_ttc == $resteapayer))) + ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->total_ttc > 0 && ($resteapayer == 0 || (!empty($conf->global->SUPPLIER_INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) && $object->total_ttc == $resteapayer))) ) ) { print ''.$langs->trans('ClassifyPaid').''; } // Classify 'closed not completely paid' (possible if validated and not yet filed paid) - if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->SUPPLIER_INVOICE_CAN_FORCE_PAID_WHEN_NO_PAIEMENTS) || $object->total_ttc != $resteapayer)) { + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->SUPPLIER_INVOICE_CAN_ADD_PAYMENT_EVEN_IF_ALREADY_PAID) || $object->total_ttc != $resteapayer)) { if ($totalpaye > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice print ''.$langs->trans('ClassifyPaidPartially').''; From 9d7f7e2090fa84ebece603aefa7fb34e7952bdb5 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 5 Nov 2021 14:03:56 +0100 Subject: [PATCH 315/490] Better condition --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index e8a703a6efb..05e55206c02 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,7 +943,7 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0 && dol_now() < dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { + if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) < dol_now()) { $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); From 897b00faf02fb5e803f33f7c0f9196b8701fcfda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 14:23:19 +0100 Subject: [PATCH 316/490] Clean code --- htdocs/admin/bank.php | 6 ++---- htdocs/admin/modules.php | 2 +- htdocs/admin/prelevement.php | 2 +- htdocs/admin/syslog.php | 4 +--- htdocs/admin/translation.php | 2 +- htdocs/comm/propal/card.php | 2 +- htdocs/core/class/html.formadmin.class.php | 2 +- htdocs/core/class/infobox.class.php | 2 +- htdocs/core/class/translate.class.php | 2 +- htdocs/core/get_info.php | 4 ++-- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/core/lib/project.lib.php | 10 +--------- htdocs/exports/export.php | 1 - htdocs/main.inc.php | 14 ++++---------- htdocs/societe/admin/societe.php | 2 +- htdocs/societe/paymentmodes.php | 2 +- htdocs/stripe/admin/stripe.php | 11 +---------- htdocs/theme/eldy/main_menu_fa_icons.inc.php | 2 +- 18 files changed, 23 insertions(+), 51 deletions(-) diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 6580db4e8f3..e1e468b0cec 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -275,8 +275,7 @@ print '

    '; /* * Document templates generators */ -//if (! empty($conf->global->MAIN_FEATURES_LEVEL)) -//{ + print load_fiche_titre($langs->trans("BankAccountModelModule"), '', ''); // Load array def with activated templates @@ -466,8 +465,7 @@ print '

    '; /* * Document templates generators */ -//if (! empty($conf->global->MAIN_FEATURES_LEVEL)) -//{ + print load_fiche_titre($langs->trans("Other"), '', ''); print "\n"; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 9c2b91ec586..2cbb14bb2dd 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -542,7 +542,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= '
    '; $moreforfilter .= $form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), $langs->trans('Origin'), 0, 0, '', 0, 0, 0, '', 'maxwidth200', 1); $moreforfilter .= '
    '; - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) { $array_version = array('stable'=>$langs->transnoentitiesnoconv("Stable")); if ($conf->global->MAIN_FEATURES_LEVEL < 0) { $array_version['deprecated'] = $langs->trans("Deprecated"); diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 207642fe8e3..88a02e90457 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -297,7 +297,7 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; if ($modulequalified) { diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 10b3d1bd47b..2f272cd986f 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -187,8 +187,6 @@ if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY) && $user->entity) { } -//print "conf->global->MAIN_FEATURES_LEVEL = ".$conf->global->MAIN_FEATURES_LEVEL."

    \n"; - // Output mode print load_fiche_titre($langs->trans("SyslogOutput"), '', ''); @@ -207,7 +205,7 @@ foreach ($syslogModules as $moduleName) { $moduleactive = (int) $module->isActive(); //print $moduleName." = ".$moduleactive." - ".$module->getName()." ".($moduleactive == -1)."
    \n"; - if (($moduleactive == -1) && empty($conf->global->MAIN_FEATURES_LEVEL)) { + if (($moduleactive == -1) && getDolGlobalInt('MAIN_FEATURES_LEVEL') == 0) { continue; // Some modules are hidden if not activable and not into debug mode (end user must not see them) } diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index f07623ed5d0..e9a6eaeb390 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -556,7 +556,7 @@ if ($mode == 'searchkey') { print ''.img_edit_add($langs->trans("TranslationOverwriteKey")).''; } - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) { $transifexlangfile = '$'; // $ means 'All' //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key; $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c046281f18e..896448d7b9a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2679,7 +2679,7 @@ if ($action == 'create') { $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); // Show online signature link - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + $useonlinesignature = 1; // Replace this with 1 when feature to make online signature is ok if ($object->statut != Propal::STATUS_DRAFT && $useonlinesignature) { print '
    '; diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 13619fe5aa3..4196fb32b68 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -304,7 +304,7 @@ class FormAdmin if (preg_match('/\.lib/i', $filelib)) { continue; } - if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') == 0 && in_array($file, $expdevmenu)) { continue; } diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index adde51c4974..0cd34e13193 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -37,7 +37,7 @@ class InfoBox { global $conf; - if (empty($conf->global->MAIN_FEATURES_LEVEL) || $conf->global->MAIN_FEATURES_LEVEL < 2) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { return array( 0 => 'Home', 1 => 'UsersHome', diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index b535d2b3585..e741adc84b5 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -589,7 +589,7 @@ class Translate } /* Disabled. There is too many cases where translation of $newstr is not defined is normal (like when output with setEventMessage an already translated string) - if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { dol_syslog(__METHOD__." MAIN_FEATURES_LEVEL=DEVELOP: missing translation for key '".$newstr."' in ".$_SERVER["PHP_SELF"], LOG_DEBUG); }*/ diff --git a/htdocs/core/get_info.php b/htdocs/core/get_info.php index 4927be6a005..ee21aac0de3 100644 --- a/htdocs/core/get_info.php +++ b/htdocs/core/get_info.php @@ -83,8 +83,8 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { $appli .= " ".DOL_VERSION; } -if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { - $appli .= "
    ".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL; +if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) { + $appli .= "
    ".$langs->trans("LevelOfFeature").': '.getDolGlobalInt('MAIN_FEATURES_LEVEL'); } $logouttext = ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c71b3ad0802..25dec3e47bb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4537,7 +4537,7 @@ function dol_print_error($db = '', $error = '', $errors = null) if ($_SERVER['DOCUMENT_ROOT']) { // Mode web $out .= $langs->trans("DolibarrHasDetectedError").".
    \n"; - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0) { $out .= "You use an experimental or develop level of features, so please do NOT report any bugs or vulnerability, except if problem is confirmed after moving option MAIN_FEATURES_LEVEL back to 0.
    \n"; } $out .= $langs->trans("InformationToHelpDiagnose").":
    \n"; @@ -4545,7 +4545,7 @@ function dol_print_error($db = '', $error = '', $errors = null) $out .= "".$langs->trans("Date").": ".dol_print_date(time(), 'dayhourlog')."
    \n"; $out .= "".$langs->trans("Dolibarr").": ".DOL_VERSION." - https://www.dolibarr.org
    \n"; if (isset($conf->global->MAIN_FEATURES_LEVEL)) { - $out .= "".$langs->trans("LevelOfFeature").": ".dol_htmlentities($conf->global->MAIN_FEATURES_LEVEL, ENT_COMPAT)."
    \n"; + $out .= "".$langs->trans("LevelOfFeature").": ".getDolGlobalInt('MAIN_FEATURES_LEVEL')."
    \n"; } if (function_exists("phpversion")) { $out .= "".$langs->trans("PHP").": ".phpversion()."
    \n"; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index c66bcdfc2d8..e9e06708f7c 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -471,14 +471,6 @@ function project_timesheet_prepare_head($mode, $fuser = null) $h++; } - /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perline.php".($param?'?'.$param:''); - $head[$h][1] = $langs->trans("InputDetail"); - $head[$h][2] = 'inputperline'; - $h++; - }*/ - complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet'); complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet', 'remove'); @@ -517,7 +509,7 @@ function project_admin_prepare_head() $head[$h][2] = 'attributes_task'; $h++; - if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { $langs->load("members"); $head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php'; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index c0a48b97222..93e20b06afe 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -151,7 +151,6 @@ $sqlusedforexport = ''; $head = array(); $upload_dir = $conf->export->dir_temp.'/'.$user->id; -//$usefilters=($conf->global->MAIN_FEATURES_LEVEL > 1); $usefilters = 1; // Security check diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c1f3231c737..25bc42046a9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -523,7 +523,6 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (invalid token), so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING); //print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers. setEventMessages('SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry', null, 'warnings'); - //if ($conf->global->MAIN_FEATURES_LEVEL >= 1) setEventMessages('Unset POST and GET params by CSRF protection in main.inc.php (Token provided was not generated by the previous page).'."
    \n".'$_SERVER[REQUEST_URI] = '.$_SERVER['REQUEST_URI'].' $_SERVER[REQUEST_METHOD] = '.$_SERVER['REQUEST_METHOD'].' GETPOST(token) = '.GETPOST('token', 'alpha').' $_SESSION[token] = '.$_SESSION['token'], null, 'warnings'); if (isset($_POST['id'])) $savid = ((int) $_POST['id']); unset($_POST); //unset($_POST['action']); unset($_POST['massaction']); @@ -1437,8 +1436,8 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print ''."\n"; // Do not index print ''."\n"; // Scale for mobile device print ''."\n"; - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { - print ''."\n"; + if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) { + print ''."\n"; } // Favicon $favicon = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png'; @@ -1628,11 +1627,6 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } else { print ''."\n"; } - /*if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED')) - { - if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print ''."\n"; - else print ''."\n"; - }*/ if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) { print ''."\n"; } else { @@ -1842,8 +1836,8 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead $appli .= " ".DOL_VERSION; } - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { - $appli .= "
    ".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL; + if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) { + $appli .= "
    ".$langs->trans("LevelOfFeature").': '.getDolGlobalInt('MAIN_FEATURES_LEVEL'); } $logouttext = ''; diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 536eb0546cc..2f272ceca1c 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -833,7 +833,7 @@ print ''; print ''; if (!empty($conf->expedition->enabled)) { - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { // Visible on experimental only because seems to not be implemented everywhere (only on proposal) + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0) { // Visible on experimental only because seems to not be implemented everywhere (only on proposal) print ''; print ''; print ''; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 7d0c9b154c4..995558ae2f5 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -848,7 +848,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } } - if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { $permissiontowrite = $user->rights->societe->creer; $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 0bb351bf977..06f417e48df 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -356,7 +356,7 @@ print img_picto('', 'bank_account').' '; $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS, 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); print ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // What is this for ? +if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // What is this for ? print ''; } -// Warehouse for automatic decrement -//if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // warehouse to reduce stock for online payment -//{ -// print ''; -//} - print ''; } // Ref supplier if (!empty($arrayfields['f.ref_supplier']['checked'])) { print ''; } // Type @@ -1006,7 +1006,7 @@ if ($resql) { // Label if (!empty($arrayfields['f.label']['checked'])) { print ''; } // Date invoice @@ -1037,11 +1037,11 @@ if ($resql) { } // Project if (!empty($arrayfields['p.ref']['checked'])) { - print ''; + print ''; } // Thirpdarty if (!empty($arrayfields['s.nom']['checked'])) { - print ''; + print ''; } // Town if (!empty($arrayfields['s.town']['checked'])) { @@ -1096,13 +1096,13 @@ if ($resql) { if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Amount tax 1 print ''; } if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Amount tax 2 print ''; } if (!empty($arrayfields['f.total_ttc']['checked'])) { From 09d9d1ac4242a626d253fe4b02c6fe2d667b1958 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:38:44 +0100 Subject: [PATCH 324/490] Add missing unique key --- .../install/mysql/migration/14.0.0-15.0.0.sql | 2 ++ .../tables/llx_c_partnership_type.key.sql | 19 +++++++++++++++++++ .../mysql/tables/llx_c_partnership_type.sql | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 htdocs/install/mysql/tables/llx_c_partnership_type.key.sql diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 02a18f69a40..2c460d4ab88 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -80,6 +80,8 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, -- v15 +ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code); + ALTER TABLE llx_c_holiday_types CHANGE COLUMN newByMonth newbymonth double(8,5) DEFAULT 0 NOT NULL; ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql b/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql new file mode 100644 index 00000000000..c4aa0c04b0a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2021 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code); diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.sql b/htdocs/install/mysql/tables/llx_c_partnership_type.sql index 23d5a89e16c..d2a4a3b7549 100644 --- a/htdocs/install/mysql/tables/llx_c_partnership_type.sql +++ b/htdocs/install/mysql/tables/llx_c_partnership_type.sql @@ -30,6 +30,6 @@ create table llx_c_partnership_type entity integer DEFAULT 1 NOT NULL, code varchar(32) NOT NULL, label varchar(64) NOT NULL, - active tinyint DEFAULT 1 NOT NULL + active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; From e8a2fc33c31fce90c5c51563a0ea3021e2caa2de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:47:03 +0100 Subject: [PATCH 325/490] Fix visiblity of dictionnary for MAIN_USE_EXPENSE_IK --- htdocs/admin/dict.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 4a5a09a3461..035d44cf3b2 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -509,8 +509,8 @@ $tabcond[30] = !empty($conf->label->enabled); $tabcond[32] = (!empty($conf->holiday->enabled) || !empty($conf->hrm->enabled)); $tabcond[33] = !empty($conf->hrm->enabled); $tabcond[34] = !empty($conf->hrm->enabled); -$tabcond[35] = !empty($conf->expensereport->enabled); -$tabcond[36] = !empty($conf->expensereport->enabled); +$tabcond[35] = !empty($conf->expensereport->enabled) && !empty($conf->global->MAIN_USE_EXPENSE_IK); +$tabcond[36] = !empty($conf->expensereport->enabled) && !empty($conf->global->MAIN_USE_EXPENSE_IK); $tabcond[37] = !empty($conf->product->enabled); $tabcond[38] = !empty($conf->socialnetworks->enabled); $tabcond[39] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)); From 22345225190627b3b1a44c5a9d121db2af9931aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 13:51:31 +0100 Subject: [PATCH 326/490] Debug module parnership. Add the type of partnership. --- htdocs/admin/dict.php | 2 +- htdocs/core/lib/modulebuilder.lib.php | 4 +- .../install/mysql/migration/14.0.0-15.0.0.sql | 2 + .../install/mysql/tables/llx_partnership.sql | 1 + htdocs/modulebuilder/index.php | 29 +- .../template/class/myobject.class.php | 6 +- .../partnership/class/partnership.class.php | 18 +- .../class/partnership_type.class.php | 562 ++++++++++++++++++ 8 files changed, 609 insertions(+), 15 deletions(-) create mode 100644 htdocs/partnership/class/partnership_type.class.php diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 035d44cf3b2..35fd58980b1 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2107,7 +2107,7 @@ if ($id) { if ($iserasable) { print ''; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index a5589679b50..d44da05fa38 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -17,8 +17,8 @@ */ /** - * \file htdocs/core/lib/memory.lib.php - * \brief Set of function for memory/cache management + * \file htdocs/core/lib/modulebuilder.lib.php + * \brief Set of function for modulebuilder management */ diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 2c460d4ab88..960b8010d51 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -82,6 +82,8 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code); +ALTER TABLE llx_partnership ADD COLUMN fk_type integer DEFAULT 0 NOT NULL; + ALTER TABLE llx_c_holiday_types CHANGE COLUMN newByMonth newbymonth double(8,5) DEFAULT 0 NOT NULL; ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_partnership.sql b/htdocs/install/mysql/tables/llx_partnership.sql index 6ab312f8875..47ee7f3a48b 100644 --- a/htdocs/install/mysql/tables/llx_partnership.sql +++ b/htdocs/install/mysql/tables/llx_partnership.sql @@ -20,6 +20,7 @@ CREATE TABLE llx_partnership( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, ref varchar(128) DEFAULT '(PROV)' NOT NULL, status smallint NOT NULL DEFAULT '0', + fk_type integer DEFAULT 0 NOT NULL, fk_soc integer, fk_member integer, date_partnership_start date NOT NULL, diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index cab90270d64..9239413d951 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -262,6 +262,7 @@ if ($dirins && $action == 'initmodule' && $modulename) { // Delete some files related to Object (because the previous dolCopyDir has copied everything) dol_delete_file($destdir.'/myobject_card.php'); + dol_delete_file($destdir.'/myobject_contact.php'); dol_delete_file($destdir.'/myobject_note.php'); dol_delete_file($destdir.'/myobject_document.php'); dol_delete_file($destdir.'/myobject_agenda.php'); @@ -337,6 +338,14 @@ if ($dirins && $action == 'initmodule' && $modulename) { setEventMessages('ModuleInitialized', null); $module = $modulename; $modulename = ''; + + clearstatcache(true); + if (function_exists('opcache_invalidate')) { + opcache_reset(); // remove the include cache hell ! + } + + header("Location: ".$_SERVER["PHP_SELF"].'?module='.$modulename); + exit; } } @@ -953,7 +962,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', if ($notnull) { $string .= ", 'notnull'=>".$notnull; } - if ($fieldname == 'ref') { + if ($fieldname == 'ref' || $fieldname == 'code') { $string .= ", 'showoncombobox'=>1"; } $string .= ", 'position'=>".$position; @@ -1417,6 +1426,14 @@ if ($dirins && $action == 'confirm_deletemodule') { if ($result > 0) { setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null); + + clearstatcache(true); + if (function_exists('opcache_invalidate')) { + opcache_reset(); // remove the include cache hell ! + } + + header("Location: ".$_SERVER["PHP_SELF"].'?module=deletemodule'); + exit; } else { setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings'); } @@ -1757,6 +1774,10 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') { $loadclasserrormessage = $e->getMessage()."
    \n"; $loadclasserrormessage .= 'File: '.$e->getFile()."
    \n"; $loadclasserrormessage .= 'Line: '.$e->getLine()."
    \n"; + } catch (Exception $e) { + $loadclasserrormessage = $e->getMessage()."
    \n"; + $loadclasserrormessage .= 'File: '.$e->getFile()."
    \n"; + $loadclasserrormessage .= 'Line: '.$e->getLine()."
    \n"; } if (class_exists($class)) { @@ -1771,6 +1792,7 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') { $error++; } $langs->load("errors"); + print ''; print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
    '; print $loadclasserrormessage; } @@ -2423,8 +2445,8 @@ if ($module == 'initmodule') { print ''.$langs->trans("EnterNameOfObjectDesc").'

    '; print '
    '; - print ' '.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'
    '; - print ' '.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'
    '; + print '
    '; + print '
    '; print ''; print '
    '; print '
    '; @@ -2633,6 +2655,7 @@ if ($module == 'initmodule') { print '


    '; + clearstatcache(true); if (function_exists('opcache_invalidate')) { opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell ! } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 8e316d014d5..6e5d6efcff4 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -767,7 +767,7 @@ class MyObject extends CommonObject if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } - if ($add_save_lastsearch_values) { + if ($url && $add_save_lastsearch_values) { $url .= '&save_lastsearch_values=1'; } } @@ -784,13 +784,13 @@ class MyObject extends CommonObject $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } - if ($option == 'nolink') { + if ($option == 'nolink' || empty($url)) { $linkstart = ''; - if ($option == 'nolink') { + if ($option == 'nolink' || empty($url)) { $linkend = ''; } else { $linkend = ''; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index f2b15735762..b378435e546 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2021 NextGestion +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2021 NextGestion * * 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 @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + /** * Class for Partnership */ @@ -105,7 +106,7 @@ class Partnership extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), - //'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnershiptype.class.php', 'label' => 'Type', 'default' => 1, 'enabled' => 1, 'visible' => 1, 'position' => 20), + 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php', 'label' => 'Type', 'enabled' => 1, 'visible' => 1, 'position' => 20), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -366,14 +367,15 @@ class Partnership extends CommonObject return -1; } - $sql = 'SELECT p.rowid, p.ref, p.fk_soc, p.fk_member, p.status'; + $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status'; $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation'; $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif'; $sql .= ', p.note_private, p.note_public'; $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel'; $sql .= ', p.import_key, p.model_pdf'; - + $sql .= ', pt.code as type_code, pt.label as type_label'; $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid'; if ($id) { $sql .= " WHERE p.rowid=".((int) $id); @@ -400,8 +402,12 @@ class Partnership extends CommonObject if ($obj) { $this->id = $obj->rowid; $this->entity = $obj->entity; - $this->rowid = $obj->rowid; $this->ref = $obj->ref; + + $this->fk_type = $obj->fk_type; + $this->type_code = $obj->type_code; + $this->type_label = $obj->type_label; + $this->fk_soc = $obj->fk_soc; $this->fk_member = $obj->fk_member; $this->status = $obj->status; diff --git a/htdocs/partnership/class/partnership_type.class.php b/htdocs/partnership/class/partnership_type.class.php new file mode 100644 index 00000000000..6916d95e4f3 --- /dev/null +++ b/htdocs/partnership/class/partnership_type.class.php @@ -0,0 +1,562 @@ + + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018-2019 Thibault Foucart + * Copyright (C) 2021 Waël Almoman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/partnership/class/partnership_type.class.php + * \ingroup partnership + * \brief File of class to manage partnership types + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + + +/** + * Class to manage partnership type + */ +class PartnershipType extends CommonObject +{ + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'c_partnership_type'; + + /** + * @var string ID to identify managed object + */ + public $element = 'partnership_type'; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'generic'; + + /** + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + public $ismultientitymanaged = 1; + + /** + * @var string Partnership code + */ + public $code; + + /** + * @var string Partnership type label + */ + public $label; + + + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1), + 'code' =>array('type'=>'varchar(32)', 'label'=>'Code', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20, 'showoncombobox'=>1), + 'label' =>array('type'=>'varchar(64)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25, 'showoncombobox'=>1), + 'active' =>array('type'=>'integer', 'label'=>'Active', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30), + ); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } + + // Example to show how to set values of fields definition dynamically + /*if ($user->rights->mymodule->myobject->read) { + $this->fields['myfield']['visible'] = 1; + $this->fields['myfield']['noteditable'] = 0; + }*/ + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); + } + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + $resultcreate = $this->createCommon($user, $notrigger); + + //$resultvalidate = $this->validate($user, $notrigger); + + return $resultcreate; + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } + return $result; + } + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = "SELECT "; + $sql .= $this->getFieldList('t'); + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")"; + } else { + $sql .= " WHERE 1 = 1"; + } + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key." = ".((int) $value); + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")"; + } else { + $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIPTYPE_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIPTYPE_CANCEL'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'PARTNERSHIPTYPE_REOPEN'); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } + + $result = ''; + + $label = img_picto('', $this->picto).' '.$langs->trans("PartnershipType").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
    '; + $label .= ''.$langs->trans('Code').': '.$this->code; + $label .= '
    '.$langs->trans('Label').': '.$this->label; + + //$url = dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$this->id; + $url = ''; + + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($url && $add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } + } + + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + if ($option == 'nolink' || empty($url)) { + $linkstart = ''; + if ($option == 'nolink' || empty($url)) { + $linkend = ''; + } else { + $linkend = ''; + } + + $result .= $linkstart; + + if (empty($this->showphoto_on_popup)) { + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if (!empty($filename)) { + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + $result .= '
    No photo
    '; + } else { + $result .= '
    No photo
    '; + } + + $result .= ''; + } else { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } + } + + if ($withpicto != 2) { + $result .= $this->ref; + } + + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action, $hookmanager; + $hookmanager->initHooks(array('myobjectdao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + + return $result; + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLabelStatus($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("mymodule@mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); + } + + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_CANCELED) { + $statusType = 'status6'; + } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = "SELECT rowid, date_creation as datec, tms as datem,"; + $sql .= " fk_user_creat, fk_user_modif"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " WHERE t.rowid = ".((int) $id); + + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + // Set here init that are not commonf fields + // $this->property1 = ... + // $this->property2 = ... + + $this->initAsSpecimenCommon(); + } +} From 3b7c385c6c5ee621586a78e775ccf943c0699b50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 13:53:30 +0100 Subject: [PATCH 327/490] Fix syntax error --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 3ba436cf28c..1b051a6081f 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -979,7 +979,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $outputlangs->load("dict"); $line = ''; - $reg = aray(); + $reg = array(); $dims = $pdf->getPageDimensions(); From 98ba48c0e76f7585701e1d5bf9017d7cc797e87e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 15:58:46 +0100 Subject: [PATCH 328/490] Look and feel v15 --- htdocs/modulebuilder/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 9239413d951..ef777569ee5 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1724,8 +1724,8 @@ print load_fiche_titre($text, '', 'title_setup'); print ''.$langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').'
    '; -print $textforlistofdirs; -print '
    '; +//print $textforlistofdirs; +//print '
    '; //var_dump($listofmodules); @@ -1750,7 +1750,7 @@ if ($message) { } //print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
    '; -$infomodulesfound = '
    '.$form->textwithpicto(''.$langs->trans("ModuleBuilderDesc3", count($listofmodules)).'', $langs->trans("ModuleBuilderDesc4", $FILEFLAG)).'
    '; +$infomodulesfound = '
    '.$form->textwithpicto(''.$langs->trans("ModuleBuilderDesc3", count($listofmodules)).'', $langs->trans("ModuleBuilderDesc4", $FILEFLAG).'
    '.$textforlistofdirs).'
    '; // Load module descriptor From 6d10facf5bda1e5d0a04893a334625134e865153 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 16:04:37 +0100 Subject: [PATCH 329/490] Debug v15 --- htdocs/modulebuilder/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index ef777569ee5..1ab03743747 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3355,7 +3355,8 @@ if ($module == 'initmodule') { } } else { print '
    '; print ''; print ''; From ed9806576aa61063fe6ea9bf7da9ddb146137dd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 16:07:16 +0100 Subject: [PATCH 330/490] Trans --- htdocs/langs/en_US/modulebuilder.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 5d6b51d5fe4..e479438769d 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -98,7 +98,7 @@ MenusDefDescTooltip=The menus provided by your module/application are defined in DictionariesDefDescTooltip=The dictionaries provided by your module/application are defined into the array $this->dictionaries into the module descriptor file. You can edit manually this file or use the embedded editor.

    Note: Once defined (and module re-activated), dictionaries are also visible into the setup area to administrator users on %s. PermissionsDefDescTooltip=The permissions provided by your module/application are defined into the array $this->rights into the module descriptor file. You can edit manually this file or use the embedded editor.

    Note: Once defined (and module re-activated), permissions are visible into the default permissions setup %s. HooksDefDesc=Define in the module_parts['hooks'] property, in the module descriptor, the context of hooks you want to manage (list of contexts can be found by a search on 'initHooks(' in core code).
    Edit the hook file to add code of your hooked functions (hookable functions can be found by a search on 'executeHooks' in core code). -TriggerDefDesc=Define in the trigger file the code you want to execute for each business event executed. +TriggerDefDesc=Define in the trigger file the code that you want to execute when a business event external to your module is executed (events recorded by other modules). SeeIDsInUse=See IDs in use in your installation SeeReservedIDsRangeHere=See range of reserved IDs ToolkitForDevelopers=Toolkit for Dolibarr developers From 969fe16442a098490142eb0d2622377622933e3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 16:51:18 +0100 Subject: [PATCH 331/490] Debug mass actions of partnership module --- htdocs/core/actions_massactions.inc.php | 1 + htdocs/langs/en_US/partnership.lang | 1 + .../partnership/class/partnership.class.php | 22 ++++---- .../class/partnershiputils.class.php | 4 +- htdocs/partnership/partnership_card.php | 8 +-- htdocs/partnership/partnership_list.php | 56 +++++++++++++++++-- 6 files changed, 69 insertions(+), 23 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 00bfe865aaa..8ccff0eb017 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1556,6 +1556,7 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == } } +// Approve for leave only if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $confirm == 'yes')) && $permissiontoapprove) { $db->begin(); diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index f5b9ebcde24..0eb73c17920 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -58,6 +58,7 @@ ManagePartnership=Manage partnership BacklinkNotFoundOnPartnerWebsite=Backlink not found on partner website ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership? PartnershipType=Partnership type +PartnershipRefApproved=Partnership %s approved # # Template Mail diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index b378435e546..4981dde2b45 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -67,7 +67,7 @@ class Partnership extends CommonObject const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; // Validate (no more draft) - const STATUS_ACCEPTED = 2; // Approved + const STATUS_APPROVED = 2; // Approved const STATUS_REFUSED = 3; // Refused const STATUS_CANCELED = 9; @@ -707,13 +707,13 @@ class Partnership extends CommonObject } /** - * Accept object + * Approve object * * @param User $user User making status change * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if OK, 0=Nothing done, >0 if KO */ - public function accept($user, $notrigger = 0) + public function approve($user, $notrigger = 0) { global $conf, $langs; @@ -722,7 +722,7 @@ class Partnership extends CommonObject $error = 0; // Protection - if ($this->status == self::STATUS_ACCEPTED) { + if ($this->status == self::STATUS_APPROVED) { dol_syslog(get_class($this)."::accept action abandonned: already acceptd", LOG_WARNING); return 0; } @@ -751,7 +751,7 @@ class Partnership extends CommonObject // Accept $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($num)."',"; - $sql .= " status = ".self::STATUS_ACCEPTED; + $sql .= " status = ".self::STATUS_APPROVED; // if (!empty($this->fields['date_validation'])) { // $sql .= ", date_validation = '".$this->db->idate($now)."'"; // } @@ -818,7 +818,7 @@ class Partnership extends CommonObject // Set new ref and current status if (!$error) { $this->ref = $num; - $this->status = self::STATUS_ACCEPTED; + $this->status = self::STATUS_APPROVED; } if (!$error) { @@ -893,7 +893,7 @@ class Partnership extends CommonObject public function cancel($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_ACCEPTED) { + if ($this->status != self::STATUS_APPROVED) { return 0; } @@ -928,7 +928,7 @@ class Partnership extends CommonObject return -1; }*/ - return $this->setStatusCommon($user, self::STATUS_ACCEPTED, $notrigger, 'PARTNERSHIP_REOPEN'); + return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN'); } /** @@ -1073,18 +1073,18 @@ class Partnership extends CommonObject //$langs->load("partnership"); $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->labelStatus[self::STATUS_ACCEPTED] = $langs->transnoentitiesnoconv('Accepted'); + $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved'); $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused'); $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->labelStatusShort[self::STATUS_ACCEPTED] = $langs->transnoentitiesnoconv('Accepted'); + $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved'); $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused'); $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); } $statusType = 'status'.$status; - if ($status == self::STATUS_ACCEPTED) { + if ($status == self::STATUS_APPROVED) { $statusType = 'status4'; } if ($status == self::STATUS_REFUSED) { diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 0588b9e5df2..35b8a3b01e5 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -101,7 +101,7 @@ class PartnershipUtils $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; $sql .= " WHERE fk_member > 0"; $sql .= " AND (d.datefin < '".$this->db->idate($datetotest)."' AND dty.subscription = 1)"; - $sql .= " AND p.status = ".((int) $partnership::STATUS_ACCEPTED); // Only accepted not yet canceled + $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled $sql .= $this->db->order('d.rowid', 'ASC'); // Limit is managed into loop later @@ -262,7 +262,7 @@ class PartnershipUtils $sql .= " WHERE 1 = 1"; $sql .= " AND p.".$fk_partner." > 0"; - $sql .= " AND p.status = ".((int) $partnership::STATUS_ACCEPTED); // Only accepted not yet canceled + $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. $sql .= $this->db->order('p.rowid', 'ASC'); // Limit is managed into loop later diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index 72787042e0e..0f32eb94580 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -153,7 +153,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'confirm_accept' && $confirm == 'yes' && $permissiontoadd) { - $result = $object->accept($user); + $result = $object->approve($user); if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -590,9 +590,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Cancel if ($permissiontoadd) { - if ($object->status == $object::STATUS_ACCEPTED) { + if ($object->status == $object::STATUS_APPROVED) { print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); - } elseif ($object->status > $object::STATUS_ACCEPTED) { + } elseif ($object->status > $object::STATUS_APPROVED) { // print ''.$langs->trans("Re-Open").''."\n"; print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken(), '', $permissiontoadd); } @@ -600,7 +600,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Refuse if ($permissiontoadd) { - if ($object->status != $object::STATUS_DRAFT && $object->status != $object::STATUS_ACCEPTED && $object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) { + if ($object->status != $object::STATUS_DRAFT && $object->status != $object::STATUS_APPROVED && $object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) { print dolGetButtonAction($langs->trans('Refuse'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=refuse&token='.newToken(), '', $permissiontoadd); } } diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index ef3b55ae44b..2703d431e1a 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -29,8 +29,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - -// load partnership libraries require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; // for other modules @@ -158,6 +156,8 @@ if ($user->socid > 0) { // Protection if external user * Actions */ +$error = 0; + if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; @@ -200,6 +200,43 @@ if (empty($reshook)) { $uploaddir = $conf->partnership->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Validate and approve + if (!$error && $massaction == 'approve' && $permissiontoadd) { + $objecttmp = new Partnership($db); + + $db->begin(); + $error = 0; + $result = 0; + + foreach ($toselect as $checked) { + if ($objecttmp->fetch($checked)) { + if ($objecttmp->status == $objecttmp::STATUS_DRAFT) { + //$objecttmp->date = dol_now(); + $result = $objecttmp->validate($user); + } + + if ($result >= 0 && $objecttmp->status == $objecttmp::STATUS_VALIDATED) { + $result = $objecttmp->approve($user); + if ($result > 0) { + setEventMessages($langs->trans("PartnershipRefApproved", $objecttmp->ref), null); + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + } + } + } + + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } + } + // Cancel partnership if ($massaction == 'cancel' && $permissiontoadd) { $db->begin(); @@ -208,9 +245,14 @@ if (empty($reshook)) { $nbok = 0; foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); + var_dump($objecttmp->status); if ($result > 0) { - $result = $objecttmp->cancel($user, 3); - if ($result <= 0) { + $result = $objecttmp->cancel($user, 0); + var_dump($result); + if ($result == 0) { + setEventMessages($langs->trans('StatusOfRefMustBe', $objecttmp->ref, $objecttmp->LibStatut($objecttmp::STATUS_APPROVED)), null, 'warnings'); + $error++; + } elseif ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; @@ -432,7 +474,9 @@ $param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( -'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"), + //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), + 'approve'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove"), + 'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"), //'generate_doc'=>img_picto('', 'pdf').$langs->trans("ReGeneratePDF"), //'builddoc'=>img_picto('', 'pdf').$langs->trans("PDFMerge"), 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendMail"), @@ -440,7 +484,7 @@ $arrayofmassactions = array( if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('prevalidate', 'presend', 'predelete'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); From 424727546550d4f653e58176d9e03f74b61cf0a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:27:37 +0100 Subject: [PATCH 332/490] css --- htdocs/index.php | 8 ++++---- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 1884d9a823a..b9ac604ca95 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -539,9 +539,9 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $openedDashBoard .= '
    '; if (!empty($board->labelShort)) { - $infoName = ''.$board->labelShort.''; + $infoName = ''.$board->labelShort.''; } else { - $infoName = $board->label; + $infoName = ''.$board->label.''; } $textLateTitle = $langs->trans("NActionsLate", $board->nbtodolate); @@ -563,7 +563,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $nbtodClass = 'badge badge-info'; } - $openedDashBoard .= ' '.$infoName.' : '.$board->nbtodo.''; + $openedDashBoard .= ' '.$infoName.''.$board->nbtodo.''; if ($textLate) { if ($board->url_late) { $openedDashBoard .= ''; @@ -576,7 +576,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $openedDashBoard .= ''."\n"; if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) { - $openedDashBoard .= ''.$langs->trans('Total').' : '.price($board->total).''; + $openedDashBoard .= ''.$langs->trans('Total').' '.price($board->total).''; } $openedDashBoard .= '
    '."\n"; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d2e3c43a3aa..31bc0e036b6 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1086,7 +1086,7 @@ select.flat.selectlimit { max-width: 62px; } .selectlimit, .marginrightonly { - margin-right: 10px !important; + margin-: 10px !important; } .marginleftonly { margin-: 10px !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 4acf119eff7..06598624da2 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1170,7 +1170,7 @@ select.flat.selectlimit { max-width: 62px; } .selectlimit, .marginrightonly { - margin-right: 10px !important; + margin-: 10px !important; } .marginleftonly { margin-: 10px !important; From 1934a3767651f836b3eabe3b228f7d8cf1f732dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:35:43 +0100 Subject: [PATCH 333/490] Escape to avoid false positive, even if it should be useless. --- htdocs/core/class/commonobject.class.php | 7 +------ htdocs/core/class/fileupload.class.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 91446f38070..812353591ed 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7874,11 +7874,6 @@ abstract class CommonObject $out .= ($display_type=='card' ? '' : ''); - /*for($ii = 0; $ii < ($colspan - 1); $ii++) - { - $out .='
    '; - }*/ - if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) { $out .= ($display_type=='card' ? '' : ''); } else { @@ -8887,7 +8882,7 @@ abstract class CommonObject $sql = "SELECT ".$objectline->getFieldList('l'); $sql .= " FROM ".MAIN_DB_PREFIX.$objectline->table_element." as l"; - $sql .= " WHERE l.fk_".$this->element." = ".((int) $this->id); + $sql .= " WHERE l.fk_".$this->db->escape($this->element)." = ".((int) $this->id); if ($morewhere) { $sql .= $morewhere; } diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 45bc622b9db..ea8618c8b92 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -222,7 +222,7 @@ class FileUpload protected function setFileDeleteUrl($file) { $file->delete_url = $this->options['script_url'] - .'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element; + .'?file='.urlencode($file->name).'&fk_element='.urlencode($this->fk_element).'&element='.urlencode($this->element); $file->delete_type = $this->options['delete_type']; if ($file->delete_type !== 'DELETE') { $file->delete_url .= '&_method=DELETE'; From 66f85d674db5967808806cacea45cc5945d27df7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:43:17 +0100 Subject: [PATCH 334/490] Fix warning scrutinizer --- htdocs/core/class/ldap.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 1d31c0cfc86..4af22683b2c 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -181,6 +181,8 @@ class Ldap $connected = 0; $this->bind = 0; + $this->error = 0; + $this->connectedServer = ''; // Check parameters if (count($this->server) == 0 || empty($this->server[0])) { @@ -229,7 +231,7 @@ class Ldap dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING); $this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection); $connected = 0; - $this->close(); + $this->unbind(); } } @@ -278,7 +280,9 @@ class Ldap } if (!$connected) { - $this->close(); + $this->unbind(); + } else { + $this->connectedServer = $host; } } } @@ -291,7 +295,7 @@ class Ldap $return = -1; dol_syslog(get_class($this)."::connect_bind return=".$return.' - '.$this->error, LOG_WARNING); } - $this->connectedServer = $host; + return $return; } From 68295073720d52307b3c8040269dfbf6bab28be8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:44:34 +0100 Subject: [PATCH 335/490] Fix missing $db --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 25dec3e47bb..602460e0e6d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -106,7 +106,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) */ function getEntity($element, $shared = 1, $currentobject = null) { - global $conf, $mc, $hookmanager, $object, $action; + global $conf, $mc, $hookmanager, $object, $action, $db; if (! is_object($hookmanager)) { $hookmanager = new HookManager($db); From 2e499c2d17326353b6a4417c70175f199e995739 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:46:08 +0100 Subject: [PATCH 336/490] Fix unknown property --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 602460e0e6d..0ad85cc6c49 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -144,10 +144,10 @@ function getEntity($element, $shared = 1, $currentobject = null) $reshook = $hookmanager->executeHooks('hookGetEntity', $parameters, $currentobject, $action); // Note that $action and $object may have been modified by some hooks if (is_numeric($reshook)) { - if ($reshook == 0 && !empty($hookmanager->resprints)) { - $out .= ','.$hookmanager->resprints; // add + if ($reshook == 0 && !empty($hookmanager->resPrint)) { + $out .= ','.$hookmanager->resPrint; // add } elseif ($reshook == 1) { - $out = $hookmanager->resprints; // replace + $out = $hookmanager->resPrint; // replace } } From 5613ec71d60b2c64f4444609c69bbd8aa2f85738 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:48:01 +0100 Subject: [PATCH 337/490] Fix syntax --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a6cf0cb232d..7ad7d434f46 100755 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1,4 +1,4 @@ - * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles From eaf2c6e89cf762cc31c7efab842607ab07ee2023 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:49:31 +0100 Subject: [PATCH 338/490] Fix $action not defined --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0ad85cc6c49..53ec09f943b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1845,7 +1845,7 @@ function dol_get_fiche_end($notab = 0) */ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $onlybanner = 0, $morehtmlright = '') { - global $conf, $form, $user, $langs, $hookmanager; + global $conf, $form, $user, $langs, $hookmanager, $action; $error = 0; From 5d4cf586d60a8ebdae04b03a7d6ddf1e0f696c1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:51:30 +0100 Subject: [PATCH 339/490] Fix duplicate call --- scripts/company/sync_contacts_dolibarr2ldap.php | 1 - scripts/members/sync_members_dolibarr2ldap.php | 1 - scripts/members/sync_members_types_dolibarr2ldap.php | 1 - scripts/user/sync_groups_dolibarr2ldap.php | 1 - scripts/user/sync_users_dolibarr2ldap.php | 1 - 5 files changed, 5 deletions(-) diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index e161a813ec7..ccaabb1afda 100755 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -154,7 +154,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { dol_print_error($db); } diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index 66c245cf3eb..74a5c4db210 100755 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -163,7 +163,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { dol_print_error($db); } diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php index 3d592673296..3ec2c9d0d90 100755 --- a/scripts/members/sync_members_types_dolibarr2ldap.php +++ b/scripts/members/sync_members_types_dolibarr2ldap.php @@ -121,7 +121,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { print $ldap->error; } diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index dd0476bbfca..7d9ed2f307e 100755 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -112,7 +112,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { dol_print_error($db); } diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index 26b1363d5a1..abe0b9fbcf4 100755 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -111,7 +111,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { dol_print_error($db); } From f5edd25f6dfefcc6e090c603bb69af074c190cad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:14:49 +0100 Subject: [PATCH 340/490] Clean code --- .../class/ProductCombination.class.php | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 5e396fba8db..bb6372fd5eb 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -1061,37 +1061,33 @@ class ProductCombinationLevel */ public function fetchAll($fk_product_attribute_combination, $fk_price_level = 0) { + $result = array(); $sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination); - if (!empty($fk_price_level)) { $sql .= ' AND fk_price_level = '.intval($fk_price_level); } - $combination_price_levels = $this->db->getRows($sql); - - if (!is_array($combination_price_levels)) { - return -1; - } - - $result = array(); - - if (!empty($combination_price_levels)) { - // For more simple usage set level as array key - foreach ($combination_price_levels as $k => $row) { - $productCombinationLevel = new ProductCombinationLevel($this->db); - $productCombinationLevel->fetchFormObj($row); - $result[$row->fk_price_level] = $productCombinationLevel; + $res = $this->db->query($sql); + if ($res) { + if ($this->db->num_rows($res) > 0) { + while ($obj = $this->db->fetch_object($res)) { + $productCombinationLevel = new ProductCombinationLevel($this->db); + $productCombinationLevel->fetchFormObj($obj); + $result[$obj->fk_price_level] = $productCombinationLevel; + } } + } else { + return -1; } return $result; } /** - * assign vars form an stdclass like sql obj + * Assign vars form an stdclass like sql obj * * @param int $obj Object resultset * @return int <0 KO, >0 OK From 142e9473c5af94978048f70149e097a72b27d307 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:28:59 +0100 Subject: [PATCH 341/490] Responsive --- htdocs/admin/barcode.php | 152 +++++++++++++++++-------------- htdocs/variants/combinations.php | 40 +++++--- 2 files changed, 109 insertions(+), 83 deletions(-) diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index c370c07b73b..2fbfed35536 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -176,6 +176,71 @@ foreach ($dirbarcode as $reldir) { } } + + +// Select barcode numbering module +if ($conf->product->enabled) { + print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', ''); + + print '
    '; + print '
    '.$langs->trans("AskForPreferredShippingMethod").' 
    '; print $langs->trans("BankAccountForBankTransfer").''; print img_picto('', 'bank_account').' '; @@ -446,15 +446,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code print '
    '; -// print $langs->trans("ONLINE_PAYMENT_WAREHOUSE").''; -// print $formproduct->selectWarehouses($conf->global->ONLINE_PAYMENT_WAREHOUSE, 'ONLINE_PAYMENT_WAREHOUSE', '', 1, $disabled); -// print '
    '; print $langs->trans("CSSUrlForPaymentForm").''; print ''; diff --git a/htdocs/theme/eldy/main_menu_fa_icons.inc.php b/htdocs/theme/eldy/main_menu_fa_icons.inc.php index a9e5e80c009..f193af733c9 100644 --- a/htdocs/theme/eldy/main_menu_fa_icons.inc.php +++ b/htdocs/theme/eldy/main_menu_fa_icons.inc.php @@ -53,7 +53,7 @@ div.mainmenu.bank::before { content: "\f19c"; } -global->MAIN_FEATURES_LEVEL == 2) { ?> + /* TESTING USAGE OF SVG WITHOUT FONT */ div.mainmenu.cashdesk { line-height: 26px; From 61d97ccd22abfc9fd60bce6741b7cf4e1d2047bf Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Fri, 5 Nov 2021 16:02:24 +0100 Subject: [PATCH 317/490] NEW : redirect after connection in login page --- htdocs/core/lib/security2.lib.php | 5 +++++ htdocs/core/tpl/login.tpl.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index ab47bc02899..d6546e64cfd 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -224,6 +224,11 @@ if (!function_exists('dol_loginfunction')) { $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $moreloginextracontent = $hookmanager->resPrint; + //Redirect after connection + $parameters = array('entity' => GETPOST('entity', 'int')); + $reshook = $hookmanager->executeHooks('redirectAfterConnection', $parameters); // Note that $action and $object may have been modified by some hooks. + $php_self = $hookmanager->resPrint; + // Login $login = (!empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin)); $password = $demopassword; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 0a4bb149986..9f2f2f68712 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -57,7 +57,7 @@ if (!empty($conf->dol_use_jmobile)) { $conf->use_javascript_ajax = 1; } -$php_self = dol_escape_htmltag($_SERVER['PHP_SELF']); +$php_self = empty($php_self) ? dol_escape_htmltag($_SERVER['PHP_SELF']) : $php_self; $php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''; if (!preg_match('/mainmenu=/', $php_self)) { $php_self .= (preg_match('/\?/', $php_self) ? '&' : '?').'mainmenu=home'; From 77864f2c2c45678f167c891e106d9912bf738edf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Nov 2021 19:07:28 +0100 Subject: [PATCH 318/490] NEW Can set value for EHLO smtp command in MAIL_SMTP_USE_FROM_FOR_HELO --- htdocs/core/class/smtps.class.php | 77 ++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index c287aae1c2f..dbaaacc2d18 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -464,20 +464,26 @@ class SMTPs $host = 'tls://'.$host; } - $hosth = $host; + $hosth = $host; // so for example 'localhost' or 'smtp-relay.gmail.com' if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { - // If the from to is 'aaa ', we will keep 'ccc.com' - $hosth = $this->getFrom('addr'); - $hosth = preg_replace('/^.*.*$/', '', $hosth); - $hosth = preg_replace('/.*@/', '', $hosth); + if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name + $hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO; + } else { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from. + // So if the from to is 'aaa ', we will keep 'ccc.com' + $hosth = $this->getFrom('addr'); + $hosth = preg_replace('/^.*.*$/', '', $hosth); + $hosth = preg_replace('/.*@/', '', $hosth); + } } if ($_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) { if ($usetls) { /* - The following dialog illustrates how a client and server can start a TLS STARTTLS session + The following dialog illustrates how a client and server can start a TLS STARTTLS session: S: C: S: 220 mail.imc.org SMTP service ready @@ -494,6 +500,39 @@ class SMTPs S: 250-server-domain.com S: 250 AUTH LOGIN C: + S: 250 OK + C: RCPT TO: + S: 250 OK + C: DATA + S: 354 Send message, end with a "." on a line by itself + C: + S . + S: 250 OK, message accepted for delivery: queued as 12345 + C: QUIT + S: 221 Bye */ if (!$_retVal = $this->socket_send_str('STARTTLS', 220)) { $this->_setErr(131, 'STARTTLS connection is not supported.'); @@ -517,10 +556,10 @@ class SMTPs $this->_setErr(132, 'STARTTLS connection failed.'); return $_retVal; } - // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time + // Most servers expect a 2nd pass of EHLO after TLS is established to get another time // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. - if (!$_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) { - $this->_setErr(126, '"'.$hosth.'" does not support authenticated connections.'); + if (! $_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) { + $this->_setErr(126, '"'.$hosth.'" does not support authenticated connections. Error after sending EHLO '.$hosth); return $_retVal; } } @@ -560,7 +599,7 @@ class SMTPs $this->_setErr(130, 'Invalid Authentication Credentials.'); } } else { - $this->_setErr(126, '"'.$host.'" does not support authenticated connections.'); + $this->_setErr(126, '"'.$host.'" does not support authenticated connections. Error after sending EHLO '.$hosth); } return $_retVal; @@ -603,11 +642,17 @@ class SMTPs $hosth = $host; if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { - // If the from to is 'aaa ', we will keep 'ccc.com' - $hosth = $this->getFrom('addr'); - $hosth = preg_replace('/^.*.*$/', '', $hosth); - $hosth = preg_replace('/.*@/', '', $hosth); + if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name + $hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO; + } else { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from. + // If the from to is 'aaa ', we will keep 'ccc.com' + $hosth = $this->getFrom('addr'); + $hosth = preg_replace('/^.*.*$/', '', $hosth); + $hosth = preg_replace('/.*@/', '', $hosth); + } } $_retVal = $this->socket_send_str('HELO '.$hosth, '250'); From 65105a3e05b26a8c6959da65394ed38fb909df42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Nov 2021 19:27:50 +0100 Subject: [PATCH 319/490] Better log --- htdocs/core/class/ldap.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index e2ce33cc45f..48618a83dd9 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -261,7 +261,7 @@ class Ldap } // Try in anonymous if (!$this->bind) { - dol_syslog(get_class($this)."::connect_bind try bind on ".$host, LOG_DEBUG); + dol_syslog(get_class($this)."::connect_bind try bind anonymously on ".$host, LOG_DEBUG); $result = $this->bind(); if ($result) { $this->bind = $this->result; From fc70adb2e74f53dbcf3746b94731dc55ae4df8c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Nov 2021 20:40:26 +0100 Subject: [PATCH 320/490] Fix ref suffix for patnership into PSHIP --- .../core/modules/partnership/mod_partnership_standard.php | 2 +- htdocs/partnership/partnership_card.php | 4 ++-- htdocs/partnership/partnership_list.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php index fefcafa2350..d5a2bb326b2 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php @@ -36,7 +36,7 @@ class mod_partnership_standard extends ModeleNumRefPartnership */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $prefix = 'PARTNERSHIP'; + public $prefix = 'PSHIP'; /** * @var string Error code (or message) diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index 99cdb74e264..72787042e0e 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -232,7 +232,7 @@ if (empty($reshook)) { // Actions to send emails $triggersendname = 'PARTNERSHIP_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO'; - $trackid = 'partnership'.$object->id; + $trackid = 'pship'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; if (!empty($id) && !empty(GETPOST('confirm'))) { @@ -664,7 +664,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $modelmail = 'partnership_send'; $defaulttopic = 'InformationMessage'; $diroutput = $conf->partnership->dir_output; - $trackid = 'partnership'.$object->id; + $trackid = 'pship'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index a5c52609d74..ef3b55ae44b 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -464,7 +464,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort $topicmail = "SendPartnershipRef"; $modelmail = "partnership_send"; $objecttmp = new Partnership($db); -$trackid = 'partnership'.$object->id; +$trackid = 'pship'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { From ccc1d4d1fa1871d7b5680376427dbd95a43ef513 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:24:25 +0100 Subject: [PATCH 321/490] Fix warning --- htdocs/core/lib/pdf.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 4821bfde2b9..3ba436cf28c 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -979,6 +979,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $outputlangs->load("dict"); $line = ''; + $reg = aray(); $dims = $pdf->getPageDimensions(); @@ -1273,6 +1274,7 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos // Fix bug of some HTML editors that replace links ]*src=")([^"]*)(&)([^"]*")/', '\1\2&\4', $labelproductservice, -1, $nbrep); //var_dump($labelproductservice);exit; From 713db0e61355924009116566e720c8e90bc8b7e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:26:44 +0100 Subject: [PATCH 322/490] Removed function pdf_getTotalQty (duplicate with pdf_getlineqty) --- htdocs/core/lib/pdf.lib.php | 42 ------------------------------------- 1 file changed, 42 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1a8d15a4fc4..c8334edc705 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2214,48 +2214,6 @@ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0) return $result; } -/** - * Return total quantity of products and/or services - * - * @param Object $object Object - * @param string $type Type - * @param Translate $outputlangs Object langs for output - * @return integer - * @deprecated Not used by Dolibarr core, so will be removed. - */ -function pdf_getTotalQty($object, $type, $outputlangs) -{ - global $hookmanager; - - $total = 0; - $nblines = count($object->lines); - - // Loop on each lines - for ($i = 0; $i < $nblines; $i++) { - if ($object->lines[$i]->special_code != 3) { - if ($type == 'all') { - $total += $object->lines[$i]->qty; - } elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) { - $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) { - $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - } - $hidedetails = ''; - $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); - $action = ''; - $reshook = $hookmanager->executeHooks('pdf_getTotalQty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - return $hookmanager->resPrint; - } elseif ($type == 0 && $object->lines[$i]->product_type == 0) { - $total += $object->lines[$i]->qty; - } elseif ($type == 1 && $object->lines[$i]->product_type == 1) { - $total += $object->lines[$i]->qty; - } - } - } - - return $total; -} - /** * Return linked objects to use for document generation. * Warning: To save space, this function returns only one link per link type (all links are concated on same record string). This function is used by pdf_writeLinkedObjects From 11bb7428cedf682dd322f1494b545e80d7c5f3f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:34:08 +0100 Subject: [PATCH 323/490] Clean code --- htdocs/fourn/facture/list.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 6c133c9b5a1..7dbead5536b 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -975,13 +975,13 @@ if ($resql) { // Ref if (!empty($arrayfields['f.ref']['checked'])) { print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; if ($user->admin) { - print ''.img_delete().''; + print ''.img_delete().''; } //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin print '
    '; - print ' '.$langs->trans("NoTrigger"); + print ' '.$langs->trans("TriggersFile"); + print ' : '.$langs->trans("FileNotYetGenerated").''; print ''.img_picto('Generate', 'generate', 'class="paddingleft"').'
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); + + foreach ($dirbarcodenum as $dirroot) { + $dir = dol_buildpath($dirroot, 0); + + $handle = @opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^mod_barcode_product_.*php$/', $file)) { + $file = substr($file, 0, dol_strlen($file) - 4); + + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + } + + $modBarCode = new $file(); + + print ''; + print ''; + print '\n"; + + if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM) && $conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") { + print ''; + } else { + print ''; + } + print ''; + print "\n"; + } + } + closedir($handle); + } + } + print "
    '.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
    '.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; + print $modBarCode->info($langs); + print ''.$modBarCode->getExample($langs)."'; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + $s = $modBarCode->getToolTip($langs, null, -1); + print $form->textwithpicto('', $s, 1); + print '
    \n"; + print '
    '; +} + + /* * CHOIX ENCODAGE */ @@ -189,6 +254,7 @@ if (empty($conf->use_javascript_ajax)) { print ''; } +print '
    '; print ''; print ''; print ''; @@ -211,8 +277,9 @@ if ($resql) { while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; + print '
    '.$langs->trans("Name").'
    '; - print $obj->label; + print '
    '; + print dol_escape_htmltag($obj->label); print "\n"; print $langs->trans('BarcodeDesc'.$obj->encoding); //print "L'EAN se compose de 8 caracteres, 7 chiffres plus une cle de controle.
    "; @@ -270,6 +337,7 @@ if ($resql) { } } print "
    \n"; +print '
    '; if (empty($conf->use_javascript_ajax)) { print $form->buttonsSaveCancel("Save", ''); @@ -287,6 +355,7 @@ print "
    "; print ''; print ""; +print '
    '; print ''; print ''; print ''; @@ -304,7 +373,9 @@ if (!isset($_SERVER['WINDIR'])) { $langs->load("errors"); print '
    '.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).''; } - print ''; + print ''; + print ''; + print ''; } // Module products @@ -313,7 +384,9 @@ if (!empty($conf->product->enabled)) { print ''; print ''; + print ''; + print ''; + print ''; } // Module thirdparty @@ -322,10 +395,14 @@ if (!empty($conf->societe->enabled)) { print ''; print ''; + print ''; + print ''; + print ''; } print "
    '.$langs->trans("Parameter").'
     
    '.$langs->trans("SetDefaultBarcodeTypeProducts").''; print $formbarcode->selectBarcodeType($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE, "PRODUIT_DEFAULT_BARCODE_TYPE", 1); - print '
     
    '.$langs->trans("SetDefaultBarcodeTypeThirdParties").''; print $formbarcode->selectBarcodeType($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY, "GENBARCODE_BARCODETYPE_THIRDPARTY", 1); - print '
     
    \n"; +print '
    '; + print '
    '; print ''; print "
    "; @@ -334,71 +411,6 @@ print '
    '; print '
    '; - -// Select barcode numbering module -if ($conf->product->enabled) { - print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', ''); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); - - foreach ($dirbarcodenum as $dirroot) { - $dir = dol_buildpath($dirroot, 0); - - $handle = @opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (preg_match('/^mod_barcode_product_.*php$/', $file)) { - $file = substr($file, 0, dol_strlen($file) - 4); - - try { - dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) { - dol_syslog($e->getMessage(), LOG_ERR); - } - - $modBarCode = new $file(); - - print ''; - print ''; - print '\n"; - - if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM) && $conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") { - print ''; - } else { - print ''; - } - print ''; - print "\n"; - } - } - closedir($handle); - } - } - print "
    '.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
    '.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; - print $modBarCode->info($langs); - print ''.$modBarCode->getExample($langs)."'; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - $s = $modBarCode->getToolTip($langs, null, -1); - print $form->textwithpicto('', $s, 1); - print '
    \n"; -} - -//print ''; - -print "
    "; - // End of page llxFooter(); $db->close(); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index d70419060f5..1569fcabb39 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -194,14 +194,11 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $bulkaction = $massaction; $error = 0; - - $db->begin(); foreach ($toselect as $prodid) { // need create new of Product to prevent rename dir behavior $prodstatic = new Product($db); - if ($prodstatic->fetch($prodid) < 0) { continue; } @@ -209,33 +206,50 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( if ($bulkaction == 'on_sell') { $prodstatic->status = 1; $res = $prodstatic->update($prodstatic->id, $user); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } elseif ($bulkaction == 'on_buy') { $prodstatic->status_buy = 1; $res = $prodstatic->update($prodstatic->id, $user); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } elseif ($bulkaction == 'not_sell') { $prodstatic->status = 0; $res = $prodstatic->update($prodstatic->id, $user); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } elseif ($bulkaction == 'not_buy') { $prodstatic->status_buy = 0; $res = $prodstatic->update($prodstatic->id, $user); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } elseif ($bulkaction == 'delete') { $res = $prodstatic->delete($user, $prodstatic->id); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } else { break; } - - if ($res <= 0) { - $error++; - break; - } } if ($error) { $db->rollback(); - - if ($prodstatic->error) { - setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); - } else { + if (empty($prodstatic->error)) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); } } else { @@ -834,7 +848,7 @@ if (!empty($id) || !empty($ref)) { $aaa .= ' '; $aaa .= ' '; $aaa .= ''; - $aaa .= ''; + $aaa .= ''; } $massactionbutton = $aaa; From 9fd57279855a097354c80ea58ca73800c657e722 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:47:27 +0100 Subject: [PATCH 342/490] Try to fix some regressions --- htdocs/accountancy/customer/list.php | 13 ++++++++----- htdocs/accountancy/supplier/list.php | 21 +++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index abf5a8d4c2e..c07f4854b84 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -413,6 +413,9 @@ if ($result) { if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); } + if ($search_label) { + $param .= '&search_label='.urlencode($search_label); + } if ($search_desc) { $param .= '&search_desc='.urlencode($search_desc); } @@ -491,7 +494,7 @@ if ($result) { $searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; - print ''; + print "\n"; print ''; print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder); @@ -539,7 +542,7 @@ if ($result) { $thirdpartystatic->email = $objp->email; $thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->tva_intra = $objp->tva_intra; - $thirdpartystatic->code_compta = $objp->company_code_sell; + $thirdpartystatic->code_compta_company = $objp->company_code_sell; $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; @@ -558,7 +561,7 @@ if ($result) { $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; $facture_static->type = $objp->ftype; - $facture_static->date = $objp->datef; + $facture_static->date = $db->jdate($objp->datef); $facture_static_det->id = $objp->rowid; $facture_static_det->total_ht = $objp->total_ht; @@ -634,7 +637,7 @@ if ($result) { // Ref Invoice print ''.$facture_static->getNomUrl(1).''; - print ''.dol_print_date($db->jdate($facture_static->date), 'day').''; + print ''.dol_print_date($facture_static->date, 'day').''; // Ref Product print ''; @@ -728,7 +731,7 @@ if ($result) { // Column with checkbox print ''; - if (!empty($suggestedid) && $suggestedaccountingaccountfor<>'') { + if (!empty($suggestedid) && $suggestedaccountingaccountfor <> '') { $ischecked=1; } elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { $ischecked = 0; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 20230c7cfad..b7e914c381a 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -291,7 +291,7 @@ if (strlen(trim($search_ref))) { $sql .= natural_search("p.ref", $search_ref); } if (strlen(trim($search_label))) { - $sql .= natural_search("f.libelle", $search_label); + $sql .= natural_search(array("p.label", "f.libelle"), $search_label); } if (strlen(trim($search_desc))) { $sql .= natural_search("l.description", $search_desc); @@ -546,7 +546,7 @@ if ($result) { $thirdpartystatic->email = $objp->email; $thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->tva_intra = $objp->tva_intra; - $thirdpartystatic->code_compta_fournisseur = $objp->company_code_buy; + $thirdpartystatic->code_compta_company = $objp->company_code_buy; $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; @@ -566,10 +566,11 @@ if ($result) { $facturefourn_static->id = $objp->facid; $facturefourn_static->type = $objp->ftype; $facturefourn_static->label = $objp->invoice_label; + $facturefourn_static->date = $db->jdate($objp->datef); $facturefourn_static_det->id = $objp->rowid; $facturefourn_static_det->total_ht = $objp->total_ht; - $facturefourn_static_det->tva_tx_line = $objp->tva_tx_line; + $facturefourn_static_det->tva_tx = $objp->tva_tx_line; $facturefourn_static_det->vat_src_code = $objp->vat_src_code; $facturefourn_static_det->product_type = $objp->type_l; $facturefourn_static_det->desc = $objp->description; @@ -608,6 +609,9 @@ if ($result) { if (empty($code_buy_l) && empty($code_buy_p)) { $code_buy_p_notset = 'color:red'; } + /*if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber' && empty($code_sell_p_notset)) { + $code_sell_p_notset = 'color:orange'; + }*/ // $code_buy_l is now default code of product/service // $code_buy_p is now code of product/service @@ -626,15 +630,15 @@ if ($result) { print ''; */ - print ''.dol_print_date($db->jdate($facturefourn_static_det->datef), 'day').''; + print ''.dol_print_date($facturefourn_static->date, 'day').''; // Ref Product print ''; if ($product_static->id > 0) { print $product_static->getNomUrl(1); } - if ($product_static->product_label) { - print '
    '.$product_static->product_label.''; + if ($product_static->label) { + print '
    '.$product_static->label.''; } print ''; @@ -650,11 +654,12 @@ if ($result) { print ''; // Vat rate + $code_vat_differ=''; if ($objp->vat_tx_l != $objp->vat_tx_p && ! empty($objp->vat_tx_l)) { // Note: having a vat rate of 0 is often the normal case when sells is intra b2b or to export $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; } print ''; - print vatrate($facturefourn_static_det->tva_tx_line.($facturefourn_static_det->vat_src_code ? ' ('.$facturefourn_static_det->vat_src_code.')' : '')); + print vatrate($facturefourn_static_det->tva_tx.($facturefourn_static_det->vat_src_code ? ' ('.$facturefourn_static_det->vat_src_code.')' : '')); print ''; // Thirdparty @@ -671,7 +676,7 @@ if ($result) { // Found accounts print ''; - $s = '1. '.(($facturefourn_static_det->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; + $s = '1. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountbydefaultfor == 'eec') { $shelp .= $langs->trans("SaleEEC"); From 47451432a743abe22270c6d803f38b4673c8dfef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:49:58 +0100 Subject: [PATCH 343/490] Fix warning --- htdocs/admin/defaultvalues.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 026a4315c83..9c80b1f7fa8 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -350,17 +350,15 @@ if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { $disabled = ' disabled="disabled"'; } print ''; -print "\n"; -print ''; +print ''."\n"; +print ''."\n"; -$result=$object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity))); +$result = $object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity))); -if (!is_array($result) && $result<0) { +if (!is_array($result) && $result < 0) { setEventMessages($object->error, $object->errors, 'errors'); -} elseif (count($result)>0) { - foreach ($result as $key=>$defaultvalue) { - print "\n"; - +} elseif (is_array($result) && count($result) > 0) { + foreach ($result as $key => $defaultvalue) { print ''; // Page @@ -378,11 +376,6 @@ if (!is_array($result) && $result<0) { // Value if ($mode != 'focus' && $mode != 'mandatory') { print ''; - /*print ''; - print ''; - print ''; - print ''; - */ if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) print dol_escape_htmltag($defaultvalue->value); else print ''; print ''; @@ -405,8 +398,6 @@ if (!is_array($result) && $result<0) { print ''; print "\n"; - print "\n"; - $i++; } } From 5085db36a7e6fba0d8a2f6dbce9fee0f501eb704 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:54:59 +0100 Subject: [PATCH 344/490] Clean code --- .../accountancy/class/accountancyexport.class.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 2c4dbfd51cd..07d28b7abdb 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -87,11 +87,11 @@ class AccountancyExport * * @param DoliDb $db Database handler */ - public function __construct(DoliDB &$db) + public function __construct(DoliDB $db) { global $conf; - $this->db = &$db; + $this->db = $db; $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n"); } @@ -928,17 +928,18 @@ class AccountancyExport $date_validation = dol_print_date($line->date_validation, '%Y%m%d'); $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d'); + $refInvoice = ''; if ($line->doc_type == 'customer_invoice') { // Customer invoice require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $invoice = new Facture($db); + $invoice = new Facture($this->db); $invoice->fetch($line->fk_doc); $refInvoice = $invoice->ref; } elseif ($line->doc_type == 'supplier_invoice') { // Supplier invoice require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $invoice = new FactureFournisseur($db); + $invoice = new FactureFournisseur($this->db); $invoice->fetch($line->fk_doc); $refInvoice = $invoice->ref_supplier; @@ -1054,17 +1055,18 @@ class AccountancyExport $date_validation = dol_print_date($line->date_validation, '%Y%m%d'); $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d'); + $refInvoice = ''; if ($line->doc_type == 'customer_invoice') { // Customer invoice require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $invoice = new Facture($db); + $invoice = new Facture($this->db); $invoice->fetch($line->fk_doc); $refInvoice = $invoice->ref; } elseif ($line->doc_type == 'supplier_invoice') { // Supplier invoice require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $invoice = new FactureFournisseur($db); + $invoice = new FactureFournisseur($this->db); $invoice->fetch($line->fk_doc); $refInvoice = $invoice->ref_supplier; From 1d09ffa4c6f7cd63292ccd636e26718c268c263b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:59:11 +0100 Subject: [PATCH 345/490] Fix scrutinizer --- htdocs/admin/hrm.php | 10 ++++++---- htdocs/admin/mails.php | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index 8eb2f93c13c..c006688fca1 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -79,10 +79,12 @@ if ($action == 'update') { if (!empty($max_rank)) { $static_skill = new Skill($db); $TAllSkills = $static_skill->fetchAll(); - foreach ($TAllSkills as &$skill) { - if (empty($skill->lines)) $skill->fetchLines(); - if (count($skill->lines) < $conf->global->HRM_MAXRANK) { - $skill->createSkills(count($skill->lines) + 1); + if (is_array($TAllSkills)) { + foreach ($TAllSkills as &$skill) { + if (empty($skill->lines)) $skill->fetchLines(); + if (count($skill->lines) < $conf->global->HRM_MAXRANK) { + $skill->createSkills(count($skill->lines) + 1); + } } } } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 90036b752b0..d60b4e4ddc6 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -851,8 +851,11 @@ if ($action == 'edit') { $companyemail = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'); $dnsinfo = false; if (!empty($companyemail) && function_exists('dns_get_record')) { - $domain = array_pop(explode('@', $companyemail)); - $dnsinfo = dns_get_record($domain, DNS_TXT); + $arrayofemailparts = explode('@', $companyemail); + if (count($arrayofemailparts) == 2) { + $domain = $arrayofemailparts[1]; + $dnsinfo = dns_get_record($domain, DNS_TXT); + } } if (!empty($dnsinfo) && is_array($dnsinfo)) { foreach ($dnsinfo as $info) { From 29bf662cc4431c1c2503bcfcb5526fd7f7332b57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 19:01:44 +0100 Subject: [PATCH 346/490] Fix warnings --- htdocs/adherents/class/adherent_type.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 90b34e604be..cdf021cfa68 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -90,7 +90,7 @@ class AdherentType extends CommonObject public $subscription; /** - * @var float amount for subscription + * @var float|string Amount for subscription (null or '' means not defined) */ public $amount; From c3fb8416a58e0d0327c658541ec0b4932731029b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 20:40:02 +0100 Subject: [PATCH 347/490] reponsive --- htdocs/contrat/list.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index cee0faf95aa..ca544e94a1b 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -492,7 +492,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $url = DOL_URL_ROOT.'/contrat/card.php?action=create'; if (!empty($socid)) { - $url .= '&socid='.$socid; + $url .= '&socid='.((int) $socid); } $newcardbutton = dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer); @@ -795,11 +795,12 @@ while ($i < min($num, $limit)) { print ''; } + // Ref thirdparty if (!empty($arrayfields['c.ref_customer']['checked'])) { - print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''; + print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''; } if (!empty($arrayfields['c.ref_supplier']['checked'])) { - print ''.$obj->ref_supplier.''; + print ''.dol_escape_htmltag($obj->ref_supplier).''; } if (!empty($arrayfields['s.nom']['checked'])) { print ''; @@ -810,7 +811,7 @@ while ($i < min($num, $limit)) { print ''; } if (!empty($arrayfields['s.email']['checked'])) { - print ''.$obj->email.''; + print ''.dol_print_email($obj->email).''; } // Town if (!empty($arrayfields['s.town']['checked'])) { From a386d637b3cd5c062187a9910be580abd020eb9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 20:43:04 +0100 Subject: [PATCH 348/490] Clean code --- htdocs/contrat/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index ca544e94a1b..110afee0cd5 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -319,7 +319,7 @@ if ($sall) { } if ($search_user > 0) { $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user); -} +}tdoverflowmax200 // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -600,11 +600,11 @@ if (!empty($arrayfields['s.email']['checked'])) { } // Town if (!empty($arrayfields['s.town']['checked'])) { - print ''; + print ''; } // Zip if (!empty($arrayfields['s.zip']['checked'])) { - print ''; + print ''; } // State if (!empty($arrayfields['state.nom']['checked'])) { @@ -797,7 +797,7 @@ while ($i < min($num, $limit)) { // Ref thirdparty if (!empty($arrayfields['c.ref_customer']['checked'])) { - print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''; + print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''; } if (!empty($arrayfields['c.ref_supplier']['checked'])) { print ''.dol_escape_htmltag($obj->ref_supplier).''; From c7cb5213bd321873f9e1eb477c9e09321e6c07e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 20:43:26 +0100 Subject: [PATCH 349/490] Clean code --- htdocs/contrat/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 110afee0cd5..0cfa0b2bf16 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -319,7 +319,7 @@ if ($sall) { } if ($search_user > 0) { $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user); -}tdoverflowmax200 +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks From 2fc05a4c1cdd0541e51b90e960d7d23e5501110e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 00:37:42 +0100 Subject: [PATCH 350/490] Add test virus file --- test/phpunit/testvirus.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/phpunit/testvirus.txt diff --git a/test/phpunit/testvirus.txt b/test/phpunit/testvirus.txt new file mode 100644 index 00000000000..a2463df6d64 --- /dev/null +++ b/test/phpunit/testvirus.txt @@ -0,0 +1 @@ +X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* \ No newline at end of file From d591a83085c93346e969054c6967350648d68755 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 00:57:00 +0100 Subject: [PATCH 351/490] css --- htdocs/admin/tools/dolibarr_import.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 29bfe5c12a4..77dea6f23ab 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -207,6 +207,9 @@ if (in_array($type, array('mysql', 'mysqli'))) { //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
    '.$langs->trans("UnHidePassword").''; //else print '
    '.$langs->trans("HidePassword").''; print '
    '; + + print '
    '; + print ''; } From bbd3293c3c5c13dc6b9e9f98947bce37d626439b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 01:42:38 +0100 Subject: [PATCH 352/490] Data ref --- htdocs/install/mysql/data/llx_c_availability.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_availability.sql b/htdocs/install/mysql/data/llx_c_availability.sql index 2e06d1de8b3..7291c399da0 100644 --- a/htdocs/install/mysql/data/llx_c_availability.sql +++ b/htdocs/install/mysql/data/llx_c_availability.sql @@ -27,6 +27,8 @@ delete from llx_c_availability; INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (1, 'AV_NOW', 'Immediate', 1, 10); -INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (2, 'AV_1W', '1 week', 1, 20); -INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (3, 'AV_2W', '2 weeks', 1, 30); -INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (4, 'AV_3W', '3 weeks', 1, 40); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (2, 'AV_1W', '1 week', 1, 20); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (3, 'AV_2W', '2 weeks', 1, 30); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (4, 'AV_3W', '3 weeks', 1, 40); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (5, 'AV_4W', '4 weeks', 1, 50); + From 2ea248e705fdb8986b27e72ee46666caec7c5cc2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 02:09:20 +0100 Subject: [PATCH 353/490] Clean code --- htdocs/hrm/core/tpl/objectline_view.tpl.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/hrm/core/tpl/objectline_view.tpl.php b/htdocs/hrm/core/tpl/objectline_view.tpl.php index 9be74a5f38f..9dd0e0099ab 100644 --- a/htdocs/hrm/core/tpl/objectline_view.tpl.php +++ b/htdocs/hrm/core/tpl/objectline_view.tpl.php @@ -57,11 +57,6 @@ $domData .= ' data-id="'.$line->id.'"'; $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; -$sign = 1; -if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && in_array($object->element, array('facture', 'invoice_supplier')) && $object->type == $object::TYPE_CREDIT_NOTE) { - $sign = -1; -} - $coldisplay = 0; ?> From e8b3875e2e79b4c30681e86a5ab7ab9ed988fb21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 02:57:21 +0100 Subject: [PATCH 354/490] FIX bad sign of amount stored for multicurrency columns on credit notes --- htdocs/compta/facture/card.php | 19 ++++++++------- htdocs/compta/facture/class/facture.class.php | 23 ++++++++++--------- .../fourn/class/fournisseur.facture.class.php | 23 ++++++++++--------- .../install/mysql/migration/13.0.0-14.0.0.sql | 20 ++++++++++++++++ htdocs/langs/en_US/bills.lang | 2 ++ htdocs/theme/eldy/global.inc.php | 2 +- 6 files changed, 58 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ed4f3d873e9..d9be7ff3f1c 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3845,13 +3845,14 @@ if ($action == 'create') { $totalpaye = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); - // print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." + //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." // selleruserrevenuestamp=".$selleruserevenustamp; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); + $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); // Multicurrency @@ -5089,7 +5090,7 @@ if ($action == 'create') { print ''; print $langs->trans('RemainderToPay'); if ($resteapayeraffiche < 0) { - print ' ('.$langs->trans('ExcessReceived').')'; + print ' ('.$langs->trans('NegativeIfExcessReceived').')'; } print ''; print ''; @@ -5117,23 +5118,25 @@ if ($action == 'create') { print ' :'.price($retainedWarranty).' '; } } else { // Credit note + + $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentneutral'; // Total already paid back print ''; - print $langs->trans('AlreadyPaidBack'); - print ' :'.price($sign * $totalpaye).' '; + print ''.$langs->trans('AlreadyPaidBack').''; + print ''.price($sign * $totalpaye).' '; // Billed - print ''.$langs->trans("Billed").' :'.price($sign * $object->total_ttc).' '; + print ''.$langs->trans("Billed").''.price($sign * $object->total_ttc).' '; // Remainder to pay back print ''; - print $langs->trans('RemainderToPayBack'); + print ''.$langs->trans('RemainderToPayBack'); if ($resteapayeraffiche > 0) { - print ' ('.$langs->trans('ExcessPaid').')'; + print ' ('.$langs->trans('NegativeIfExcessRefunded').')'; } - print ' :'; + print ''; print ''.price($sign * $resteapayeraffiche).''; print ' '; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a28838756d9..f8f246924e3 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3296,8 +3296,8 @@ class Facture extends CommonInvoice $this->line->desc = $desc; $this->line->ref_ext = $ref_ext; - $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; @@ -3306,11 +3306,11 @@ class Facture extends CommonInvoice $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; - $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative - $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative - $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative + $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative + $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative $this->line->fk_product = $fk_product; $this->line->product_type = $product_type; @@ -3337,10 +3337,11 @@ class Facture extends CommonInvoice // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht_devise) : $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise + + $this->line->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ht) : $multicurrency_total_ht); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_tva) : $multicurrency_total_tva); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ttc) : $multicurrency_total_ttc); // For credit note and if qty is negative, total is negative if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2601c610e15..851dcf645a5 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1957,8 +1957,8 @@ class FactureFournisseur extends CommonInvoice $this->line->desc = $desc; $this->line->ref_supplier = $ref_supplier; - $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; @@ -1967,11 +1967,11 @@ class FactureFournisseur extends CommonInvoice $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; - $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); - $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax1) : $total_localtax1); - $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax2) : $total_localtax2); - $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative + $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative + $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative $this->line->fk_product = $fk_product; $this->line->product_type = $type; @@ -1992,10 +1992,11 @@ class FactureFournisseur extends CommonInvoice // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht_devise) : $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise + + $this->line->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ht) : $multicurrency_total_ht); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_tva) : $multicurrency_total_tva); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ttc) : $multicurrency_total_ttc); // For credit note and if qty is negative, total is negative if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 03110b4425e..ac032d3541d 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -87,6 +87,26 @@ DELETE FROM llx_user_param where param = 'MAIN_THEME' and value in ('auguria', ' -- For v14 +--Fix bad sign on multicompany column for customer invoice lines +UPDATE llx_facturedet SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and subprice > 0) OR (multicurrency_subprice > 0 and subprice < 0)); +UPDATE llx_facturedet SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facturedet SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facturedet SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicompany column for customer invoices +UPDATE llx_facture SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facture SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicurrency column for supplier invoice lines +UPDATE llx_facture_fourn_det SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and pu_ht > 0) OR (multicurrency_subprice > 0 and pu_ht < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and tva > 0) OR (multicurrency_total_tva > 0 and tva < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicompany column for customer invoices +UPDATE llx_facture_fourn SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture_fourn SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facture_fourn SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); + + UPDATE llx_c_ticket_type set label = 'Issue or bug' WHERE code = 'ISSUE'; INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('PROBLEM', '22', 'Problem', 0, 0, NULL); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index a835ec8475d..6078942f574 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -236,9 +236,11 @@ Abandoned=Abandoned RemainderToPay=Remaining unpaid RemainderToTake=Remaining amount to take RemainderToPayBack=Remaining amount to refund +NegativeIfExcessRefunded=negative if excess refunded Rest=Pending AmountExpected=Amount claimed ExcessReceived=Excess received +NegativeIfExcessReceived=negative if excess received ExcessPaid=Excess paid EscompteOffered=Discount offered (payment before term) EscompteOfferedShort=Discount diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 4da2d71dfd7..39c62b2685f 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1195,7 +1195,7 @@ select.flat.selectlimit { } /* Styles for amount on card */ -table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaintopay { +table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaintopay, table.paymenttable td.amountremaintopayback { padding-top: 0px; padding-bottom: 0px; } From cd4f59bb2a5777536598ea3e45afd6f54a6f7b87 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:01:18 +0100 Subject: [PATCH 355/490] FIX bad sign of amount stored for multicurrency columns on credit notes --- htdocs/install/mysql/migration/repair.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 59f04fdb2ca..5208a733769 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -501,6 +501,25 @@ UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS -- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL; +--Fix bad sign on multicompany column for customer invoice lines +UPDATE llx_facturedet SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and subprice > 0) OR (multicurrency_subprice > 0 and subprice < 0)); +UPDATE llx_facturedet SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facturedet SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facturedet SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicompany column for customer invoices +UPDATE llx_facture SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facture SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicurrency column for supplier invoice lines +UPDATE llx_facture_fourn_det SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and pu_ht > 0) OR (multicurrency_subprice > 0 and pu_ht < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and tva > 0) OR (multicurrency_total_tva > 0 and tva < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicompany column for customer invoices +UPDATE llx_facture_fourn SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture_fourn SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facture_fourn SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); + UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NULL AND fk_prev_id IS NULL; From be1ca6ebab44388d5b29ff3c27344ebaaf461458 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:21:15 +0100 Subject: [PATCH 356/490] Clean code --- .../core/class/commondocgenerator.class.php | 123 +++++++++--------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 7183605ae10..a92179e7b6a 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -399,7 +399,7 @@ abstract class CommonDocGenerator $sumpayed = $sumdeposit = $sumcreditnote = ''; $already_payed_all = 0; - $remain_to_pay = 0; + if ($object->element == 'facture') { $invoice_source = new Facture($this->db); if ($object->fk_facture_source > 0) { @@ -409,7 +409,6 @@ abstract class CommonDocGenerator $sumdeposit = $object->getSumDepositsUsed(); $sumcreditnote = $object->getSumCreditNotesUsed(); $already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote; - $remain_to_pay = $sumpayed - $sumdeposit - $sumcreditnote; if ($object->fk_account > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -421,76 +420,76 @@ abstract class CommonDocGenerator $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); $resarray = array( - $array_key.'_id'=>$object->id, - $array_key.'_ref'=>$object->ref, - $array_key.'_ref_ext'=>$object->ref_ext, - $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), - $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), - $array_key.'_source_invoice_ref'=>$invoice_source->ref, - // Dates - $array_key.'_hour'=>dol_print_date($date, 'hour'), - $array_key.'_date'=>dol_print_date($date, 'day'), - $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), - $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), - $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), - $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), - $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), - $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), - $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), - $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), + $array_key.'_id'=>$object->id, + $array_key.'_ref'=>$object->ref, + $array_key.'_ref_ext'=>$object->ref_ext, + $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), + $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), + $array_key.'_source_invoice_ref'=>$invoice_source->ref, + // Dates + $array_key.'_hour'=>dol_print_date($date, 'hour'), + $array_key.'_date'=>dol_print_date($date, 'day'), + $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), + $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), + $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), + $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), + $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), + $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), + $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), + $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), - $array_key.'_payment_mode_code'=>$object->mode_reglement_code, - $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), - $array_key.'_payment_term_code'=>$object->cond_reglement_code, - $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), + $array_key.'_payment_mode_code'=>$object->mode_reglement_code, + $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), + $array_key.'_payment_term_code'=>$object->cond_reglement_code, + $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), - $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), + $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), - $array_key.'_bank_iban'=>$bank_account->iban, - $array_key.'_bank_bic'=>$bank_account->bic, - $array_key.'_bank_label'=>$bank_account->label, - $array_key.'_bank_number'=>$bank_account->number, - $array_key.'_bank_proprio'=>$bank_account->proprio, + $array_key.'_bank_iban'=>$bank_account->iban, + $array_key.'_bank_bic'=>$bank_account->bic, + $array_key.'_bank_label'=>$bank_account->label, + $array_key.'_bank_number'=>$bank_account->number, + $array_key.'_bank_proprio'=>$bank_account->proprio, - $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), - $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), - $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), - $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), - $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), + $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), + $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), + $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), + $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), + $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), - $array_key.'_total_ht'=>price2num($object->total_ht), - $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), - $array_key.'_total_localtax1'=>price2num($object->total_localtax1), - $array_key.'_total_localtax2'=>price2num($object->total_localtax2), - $array_key.'_total_ttc'=>price2num($object->total_ttc), + $array_key.'_total_ht'=>price2num($object->total_ht), + $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), + $array_key.'_total_localtax1'=>price2num($object->total_localtax1), + $array_key.'_total_localtax2'=>price2num($object->total_localtax2), + $array_key.'_total_ttc'=>price2num($object->total_ttc), - $array_key.'_multicurrency_code' => $object->multicurrency_code, - $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), - $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), - $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), - $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), - $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), - $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), - $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), + $array_key.'_multicurrency_code' => $object->multicurrency_code, + $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), + $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), + $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), + $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), + $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), + $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), + $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), - $array_key.'_note_private'=>$object->note, - $array_key.'_note_public'=>$object->note_public, - $array_key.'_note'=>$object->note_public, // For backward compatibility + $array_key.'_note_private'=>$object->note, + $array_key.'_note_public'=>$object->note_public, + $array_key.'_note'=>$object->note_public, // For backward compatibility - // Payments - $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), - $array_key.'_already_payed'=>price2num($sumpayed), - $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), - $array_key.'_already_deposit'=>price2num($sumdeposit), - $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), - $array_key.'_already_creditnote'=>price2num($sumcreditnote), + // Payments + $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), + $array_key.'_already_payed'=>price2num($sumpayed), + $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), + $array_key.'_already_deposit'=>price2num($sumdeposit), + $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), + $array_key.'_already_creditnote'=>price2num($sumcreditnote), - $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), - $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), + $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), - // Remain to pay with all know information (except open direct debit requests) - $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $remain_to_pay, 'MT'), 0, $outputlangs), - $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $remain_to_pay, 'MT') + // Remain to pay with all known information (except open direct debit requests) + $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $already_payed_all, 'MT') ); if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { From a94b2b4f7e9ffe4ae0ecf99c72e27ffefd53d7c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:21:15 +0100 Subject: [PATCH 357/490] Clean code --- .../core/class/commondocgenerator.class.php | 123 +++++++++--------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 641c2f80902..d65ecc1325d 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -398,7 +398,7 @@ abstract class CommonDocGenerator $sumpayed = $sumdeposit = $sumcreditnote = ''; $already_payed_all = 0; - $remain_to_pay = 0; + if ($object->element == 'facture') { $invoice_source = new Facture($this->db); if ($object->fk_facture_source > 0) { @@ -408,7 +408,6 @@ abstract class CommonDocGenerator $sumdeposit = $object->getSumDepositsUsed(); $sumcreditnote = $object->getSumCreditNotesUsed(); $already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote; - $remain_to_pay = $sumpayed - $sumdeposit - $sumcreditnote; if ($object->fk_account > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -420,76 +419,76 @@ abstract class CommonDocGenerator $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); $resarray = array( - $array_key.'_id'=>$object->id, - $array_key.'_ref'=>$object->ref, - $array_key.'_ref_ext'=>$object->ref_ext, - $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), - $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), - $array_key.'_source_invoice_ref'=>$invoice_source->ref, - // Dates - $array_key.'_hour'=>dol_print_date($date, 'hour'), - $array_key.'_date'=>dol_print_date($date, 'day'), - $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), - $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), - $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), - $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), - $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), - $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), - $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), - $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), + $array_key.'_id'=>$object->id, + $array_key.'_ref'=>$object->ref, + $array_key.'_ref_ext'=>$object->ref_ext, + $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), + $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), + $array_key.'_source_invoice_ref'=>$invoice_source->ref, + // Dates + $array_key.'_hour'=>dol_print_date($date, 'hour'), + $array_key.'_date'=>dol_print_date($date, 'day'), + $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), + $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), + $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), + $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), + $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), + $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), + $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), + $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), - $array_key.'_payment_mode_code'=>$object->mode_reglement_code, - $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), - $array_key.'_payment_term_code'=>$object->cond_reglement_code, - $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), + $array_key.'_payment_mode_code'=>$object->mode_reglement_code, + $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), + $array_key.'_payment_term_code'=>$object->cond_reglement_code, + $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), - $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), + $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), - $array_key.'_bank_iban'=>$bank_account->iban, - $array_key.'_bank_bic'=>$bank_account->bic, - $array_key.'_bank_label'=>$bank_account->label, - $array_key.'_bank_number'=>$bank_account->number, - $array_key.'_bank_proprio'=>$bank_account->proprio, + $array_key.'_bank_iban'=>$bank_account->iban, + $array_key.'_bank_bic'=>$bank_account->bic, + $array_key.'_bank_label'=>$bank_account->label, + $array_key.'_bank_number'=>$bank_account->number, + $array_key.'_bank_proprio'=>$bank_account->proprio, - $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), - $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), - $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), - $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), - $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), + $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), + $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), + $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), + $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), + $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), - $array_key.'_total_ht'=>price2num($object->total_ht), - $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), - $array_key.'_total_localtax1'=>price2num($object->total_localtax1), - $array_key.'_total_localtax2'=>price2num($object->total_localtax2), - $array_key.'_total_ttc'=>price2num($object->total_ttc), + $array_key.'_total_ht'=>price2num($object->total_ht), + $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), + $array_key.'_total_localtax1'=>price2num($object->total_localtax1), + $array_key.'_total_localtax2'=>price2num($object->total_localtax2), + $array_key.'_total_ttc'=>price2num($object->total_ttc), - $array_key.'_multicurrency_code' => $object->multicurrency_code, - $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), - $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), - $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), - $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), - $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), - $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), - $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), + $array_key.'_multicurrency_code' => $object->multicurrency_code, + $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), + $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), + $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), + $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), + $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), + $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), + $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), - $array_key.'_note_private'=>$object->note, - $array_key.'_note_public'=>$object->note_public, - $array_key.'_note'=>$object->note_public, // For backward compatibility + $array_key.'_note_private'=>$object->note, + $array_key.'_note_public'=>$object->note_public, + $array_key.'_note'=>$object->note_public, // For backward compatibility - // Payments - $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), - $array_key.'_already_payed'=>price2num($sumpayed), - $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), - $array_key.'_already_deposit'=>price2num($sumdeposit), - $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), - $array_key.'_already_creditnote'=>price2num($sumcreditnote), + // Payments + $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), + $array_key.'_already_payed'=>price2num($sumpayed), + $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), + $array_key.'_already_deposit'=>price2num($sumdeposit), + $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), + $array_key.'_already_creditnote'=>price2num($sumcreditnote), - $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), - $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), + $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), - // Remain to pay with all know information (except open direct debit requests) - $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $remain_to_pay, 'MT'), 0, $outputlangs), - $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $remain_to_pay, 'MT') + // Remain to pay with all known information (except open direct debit requests) + $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $already_payed_all, 'MT') ); if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { From d026c721cf8f59933f8b66d3230af3f7896c08d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:27:27 +0100 Subject: [PATCH 358/490] Update security2.lib.php --- htdocs/core/lib/security2.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index d6546e64cfd..2edb2e629de 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -215,17 +215,17 @@ if (!function_exists('dol_loginfunction')) { } // Execute hook getLoginPageOptions (for table) - $parameters = array('entity' => GETPOST('entity', 'int')); + $parameters = array('entity' => GETPOST('entity', 'int'), 'switchentity' => GETPOST('switchentity', 'int')); $reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $morelogincontent = $hookmanager->resPrint; // Execute hook getLoginPageExtraOptions (eg for js) - $parameters = array('entity' => GETPOST('entity', 'int')); + $parameters = array('entity' => GETPOST('entity', 'int'), 'switchentity' => GETPOST('switchentity', 'int')); $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $moreloginextracontent = $hookmanager->resPrint; //Redirect after connection - $parameters = array('entity' => GETPOST('entity', 'int')); + $parameters = array('entity' => GETPOST('entity', 'int'), 'switchentity' => GETPOST('switchentity', 'int')); $reshook = $hookmanager->executeHooks('redirectAfterConnection', $parameters); // Note that $action and $object may have been modified by some hooks. $php_self = $hookmanager->resPrint; From e8e0768eec34e01f6e10f11bfb8a8144cec0a199 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:47:16 +0100 Subject: [PATCH 359/490] Fix phpcs --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e18d0c081c2..81a5413182e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7227,7 +7227,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if ($object->id > 0) { $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)) : ''); $substitutionarray['__ONLINE_PAYMENT_URL__'] = $paymenturl; - + if (is_object($object) && $object->element == 'propal') { $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref); } From b34fb95f4f8163ebc7287587803502054f4fba8f Mon Sep 17 00:00:00 2001 From: Gerhard Stephan Date: Mon, 8 Nov 2021 10:59:04 +0100 Subject: [PATCH 360/490] Load product data optional fields to the line -> enables to use "line_options_{extrafield}" --- htdocs/core/class/commondocgenerator.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a92179e7b6a..e5a2ef4c9db 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -559,6 +559,15 @@ abstract class CommonDocGenerator $resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs); } + // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" + if (isset($line->fk_product) && $line->fk_product > 0) + { + $tmpproduct = new Product($this->db); + $result = $tmpproduct->fetch($line->fk_product); + foreach($tmpproduct->array_options as $key=>$label) + $resarray["line_".$key] = $label; + } + return $resarray; } From 3ff880aa74c12f389135cdad31b0726bf0084b84 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 11:40:40 +0100 Subject: [PATCH 361/490] Avoid virus detection --- test/phpunit/testvirus.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/phpunit/testvirus.txt b/test/phpunit/testvirus.txt index a2463df6d64..4a130462173 100644 --- a/test/phpunit/testvirus.txt +++ b/test/phpunit/testvirus.txt @@ -1 +1,2 @@ -X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* \ No newline at end of file +# Remove this line and replace the ABC with X50 to get a file that is detected by antiviruses. +ABC!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* \ No newline at end of file From 0a3a0862ffaf4c63396f4d96f765238e9f3e92cf Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 8 Nov 2021 13:33:24 +0100 Subject: [PATCH 362/490] fixes to be pure markdown --- SECURITY.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 427b1cc7ae2..9c28e2874b9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -12,8 +12,7 @@ This file contains some policies about the security reports on Dolibarr ERP CRM ## Reporting a Vulnerability -To report a vulnerability, please use GitHub security advisory at https://github.com/Dolibarr/dolibarr/security/advisories/new (if you have permissions) or alternatively send an email to security@dolibarr.org (for everybody) - +To report a vulnerability, please use GitHub security advisory at [https://github.com/Dolibarr/dolibarr/security/advisories/new](https://github.com/Dolibarr/dolibarr/security/advisories/new) (if you have permissions) or alternatively send an email to security@dolibarr.org (for everybody) ## Hunting vulnerabilities on Dolibarr @@ -23,7 +22,7 @@ If you believe you've found a security bug in our service, we are happy to work Any type of denial of service attacks is strictly forbidden, as well as any interference with network equipment and Dolibarr infrastructure. -We recommand to install Dolibarr ERP CRM on your own server (as most Open Source software, download and use is free: https://www.dolibarr.org/download) to get access on every side of application. +We recommand to install Dolibarr ERP CRM on your own server (as most Open Source software, download and use is free: [https://www.dolibarr.org/download](https://www.dolibarr.org/download)) to get access on every side of application. ### User Agent @@ -31,8 +30,7 @@ If you try to find bug on Dolibarr, we recommend to append to your user-agent he ### Account access -You can install the web application yourself on your own platform/server so you get full access to application and sources. Download the zip of the files to put into your own web server virtual host from https://www.dolibarr.org/download - +You can install the web application yourself on your own platform/server so you get full access to application and sources. Download the zip of the files to put into your own web server virtual host from [https://www.dolibarr.org/download](https://www.dolibarr.org/download) ## Eligibility and Responsible Disclosure @@ -46,7 +44,6 @@ You must avoid tests that could cause degradation or interruption of our service You must not leak, manipulate, or destroy any user data of third parties to find your vulnerability. - ## Scope for qualified vulnerabilities ONLY vulnerabilities discovered, when the following setup on test platform is used, are "valid": @@ -64,7 +61,6 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us Scope is the web application (back office) and the APIs. - ## Qualifying vulnerabilities for reporting * Remote code execution (RCE) @@ -81,7 +77,6 @@ Scope is the web application (back office) and the APIs. * Software version disclosure (for non admin users only) * Stack traces or path disclosure (for non admin users only) - ## Non-qualifying vulnerabilities for reporting * "Self" XSS @@ -99,4 +94,3 @@ Scope is the web application (back office) and the APIs. * Software version or private IP disclosure when logged user is admin * Stack traces or path disclosure when logged user is admin * Any vulnerabilities due to a configuration different than the one defined into chapter "Scope for qualified vulnerabilities". - From d06d6c51cd7ca5802bcac3047386e9011e0fb14a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 8 Nov 2021 13:44:46 +0100 Subject: [PATCH 363/490] MD041 - First line in a file should be a top-level heading --- htdocs/modulebuilder/template/core/boxes/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/boxes/README.md b/htdocs/modulebuilder/template/core/boxes/README.md index b641e7136bc..3989bca5847 100644 --- a/htdocs/modulebuilder/template/core/boxes/README.md +++ b/htdocs/modulebuilder/template/core/boxes/README.md @@ -1 +1 @@ -Directory where widgets files are stored. \ No newline at end of file +# Directory where widgets files are stored From 85a3bbba3d9fc491b16ba761ce82afdef42b7af8 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 8 Nov 2021 13:51:03 +0100 Subject: [PATCH 364/490] Translations --- .../mailings/mailinglist_mymodule_myobject.modules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index dc797b99a94..b50f4acf741 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -55,9 +55,9 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets /** - * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings + * Displays the filter form that appears in the mailing recipient selection page * - * @return string Retourne zone select + * @return string Return select zone */ public function formFilter() { @@ -83,7 +83,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets /** - * Renvoie url lien vers fiche de la source du destinataire du mailing + * Returns url link to file of the source of the recipient of the mailing * * @param int $id ID * @return string Url lien @@ -115,7 +115,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets } $sql .= " ORDER BY email"; - // Stocke destinataires dans target + // Store recipients in target $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); From 39b8916215623e9d19d477d8ebe10e554510408e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 14:01:15 +0100 Subject: [PATCH 365/490] css --- htdocs/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index b9ac604ca95..be439300291 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -561,9 +561,11 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $nbtodClass = ''; if ($board->nbtodo > 0) { $nbtodClass = 'badge badge-info'; + } else { + $nbtodClass = 'opacitymedium'; } - $openedDashBoard .= ' '.$infoName.''.$board->nbtodo.''; + $openedDashBoard .= ''.$infoName.''.$board->nbtodo.''; if ($textLate) { if ($board->url_late) { $openedDashBoard .= ''; From c858c7bf53ff4f7be7dbef8b5a7f305ce090515e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 14:05:07 +0100 Subject: [PATCH 366/490] Trans shorter --- htdocs/langs/en_US/ticket.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 0134b96b935..d38358eb74d 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -318,7 +318,7 @@ BoxTicketLastXDays=Number of new tickets by days the last %s days BoxTicketLastXDayswidget = Number of new tickets by days the last X days BoxNoTicketLastXDays=No new tickets the last %s days BoxNumberOfTicketByDay=Number of new tickets by day -BoxNewTicketVSClose=Number of today's new tickets versus today's closed tickets +BoxNewTicketVSClose=Number of tickets versus closed tickets (today) TicketCreatedToday=Ticket created today TicketClosedToday=Ticket closed today KMFoundForTicketGroup=We found topics and FAQs that may answers your question, thanks to check them before submitting the ticket From c464a1cfd22385b70e94c2b8818034ac1f11cc47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 14:37:21 +0100 Subject: [PATCH 367/490] Fix colors --- htdocs/core/class/dolgraph.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index e52ab780195..59213e9066e 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -107,10 +107,12 @@ class DolGraph global $conf; global $theme_bordercolor, $theme_datacolor, $theme_bgcolor; + // Some default values for the case it is not defined into the theme later. $this->bordercolor = array(235, 235, 224); $this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220)); $this->bgcolor = array(235, 235, 224); + // Load color of the theme $color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php'; if (is_readable($color_file)) { include $color_file; @@ -1415,13 +1417,13 @@ class DolGraph $color = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ', 0.9)'; $bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')'; } else { // We do not use a 'group by' - if (!empty($this->bordercolor[$i]) && is_array($this->datacolor[$i])) { + if (!empty($this->datacolor[$i]) && is_array($this->datacolor[$i])) { $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ', 0.9)'; } else { $color = $this->datacolor[$i]; } if (!empty($this->bordercolor[$i]) && is_array($this->bordercolor[$i])) { - $color = 'rgb(' . $this->bordercolor[$i][0] . ', ' . $this->bordercolor[$i][1] . ', ' . $this->bordercolor[$i][2] . ', 0.9)'; + $bordercolor = 'rgb(' . $this->bordercolor[$i][0] . ', ' . $this->bordercolor[$i][1] . ', ' . $this->bordercolor[$i][2] . ', 0.9)'; } else { if ($type != 'horizontalBar') { $bordercolor = $color; From f4b2a6ec9235545f84b5f58ade7fbc7eaa769de6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 14:51:14 +0100 Subject: [PATCH 368/490] Fix negative colors for bars --- htdocs/core/class/dolgraph.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 59213e9066e..a93ed92e8f5 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1431,6 +1431,14 @@ class DolGraph $bordercolor = $this->bordercolor[$i]; } } + + // For negative colors, we invert border and background + $tmp = str_replace('#', '', $color); + if (strpos($tmp, '-') !== false) { + $foundnegativecolor++; + $bordercolor = str_replace('-', '', $color); + $color = '#FFFFFF'; // If $val is '-123' + } } if ($i > 0) { $this->stringtoshow .= ', '; From c1a2e7b12e1706f02dd9f5df50256cc7f0c1fc2b Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 8 Nov 2021 17:51:19 +0100 Subject: [PATCH 369/490] FIX: project task list: extrafields could not be displayed --- htdocs/projet/tasks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index d61dffeee3c..03816ff91df 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -135,6 +135,7 @@ if ($object->usage_bill_time) { } // Extra fields +$extrafieldsobjectkey = $taskstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -774,7 +775,6 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print ''; - $extrafieldsobjectkey = $taskstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Action column From 86365271254fa9bcc8933bc944bbc3155cf17a9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 17:53:18 +0100 Subject: [PATCH 370/490] Clean code --- .../boxes/box_graph_invoices_permonth.php | 10 ++----- .../box_graph_invoices_supplier_permonth.php | 28 +++++-------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 18ffe022610..65498ab6362 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -146,9 +146,6 @@ class box_graph_invoices_permonth extends ModeleBoxes $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png"; // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$endyear.'.png'; - if ($mode == 'supplier') { - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$endyear.'.png'; - } $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); @@ -189,10 +186,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png"; // default value for customer mode - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.'.png'; - if ($mode == 'supplier') { - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$endyear.'.png'; - } + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.'.png'; $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); @@ -251,7 +245,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $stringtoshow .= ' '.$langs->trans("AmountOfBillsByMonthHT"); $stringtoshow .= '
    '; $stringtoshow .= $langs->trans("Year").' '; - $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; if ($shownb && $showtot) { diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 3d8cb88938d..4ba27c74b1a 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -125,9 +125,6 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); - if (empty($year)) { - $year = $nowarray['year']; - } if (empty($endyear)) { $endyear = $nowarray['year']; } @@ -143,12 +140,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if ($shownb) { $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); - $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; + $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$endyear.".png"; // default value for customer mode - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; - if ($mode == 'supplier') { - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$year.'.png'; - } + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$endyear.'.png'; $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); @@ -186,12 +180,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if ($showtot) { $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); - $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png"; + $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$endyear.".png"; // default value for customer mode - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png'; - if ($mode == 'supplier') { - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$year.'.png'; - } + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$endyear.'.png'; $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); @@ -273,17 +264,12 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes } $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); } else { - $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength'=>500, 'text' => $mesg); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover left"', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' ); } } From bd9d3bb4aba43dbdd0edb7e092c68562880d6bf9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 18:10:35 +0100 Subject: [PATCH 371/490] Clean code --- htdocs/includes/odtphp/odf.php | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index a7416258a57..80183843b36 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -79,7 +79,7 @@ class Odf // Create tmp direcoty (will be deleted in destructor) if (!file_exists($this->tmpdir)) { - $result=mkdir($this->tmpdir); + $result = mkdir($this->tmpdir); } // Load zip proxy @@ -329,6 +329,7 @@ class Odf $tempHtml = $html; while (strlen($tempHtml) > 0) { + $matches = array(); // Check if the string includes a html tag if (preg_match_all('/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/', $tempHtml, $matches)) { $tagOffset = strpos($tempHtml, $matches[0][0]); @@ -342,6 +343,7 @@ class Odf $tempHtml = substr($tempHtml, $tagOffset); } // Extract the attribute data from the html tag + $explodedAttributes = array(); preg_match_all('/([0-9A-Za-z]+(?:="[0-9A-Za-z\:\-\s\,\;\#]*")?)+/', $matches[2][0], $explodedAttributes); $explodedAttributes = array_filter($explodedAttributes[0]); $attributes = array(); @@ -447,32 +449,6 @@ class Odf return $value; } - /** - * Evaluating php codes inside the ODT and output the buffer (print, echo) inplace of the code - * - * @return int 0 - */ - public function phpEval() - { - preg_match_all('/[\{\<]\?(php)?\s+(?P.+)\?[\}\>]/iU', $this->contentXml, $matches); // detecting all {?php code ?} or - $nbfound=count($matches['content']); - for ($i=0; $i < $nbfound; $i++) { - try { - $ob_output = ''; // flush the output for each code. This var will be filled in by the eval($code) and output buffering : any print or echo or output will be redirected into this variable - $code = $matches['content'][$i]; - ob_start(); - eval($code); - $ob_output = ob_get_contents(); // send the content of the buffer into $ob_output - $this->contentXml = str_replace($matches[0][$i], $ob_output, $this->contentXml); - ob_end_clean(); - } catch (Exception $e) { - ob_end_clean(); - $this->contentXml = str_replace($matches[0][$i], 'ERROR: there was a problem while evaluating this portion of code, please fix it: '.$e, $this->contentXml); - } - } - return 0; - } - /** * Assign a template variable as a picture * @@ -515,10 +491,12 @@ IMG; // Search all possible rows in the document $reg1 = "#]*>(.*)#smU"; + $matches = array(); preg_match_all($reg1, $this->contentXml, $matches); for ($i = 0, $size = count($matches[0]); $i < $size; $i++) { // Check if the current row contains a segment row.* $reg2 = '#\[!--\sBEGIN\s(row.[\S]*)\s--\](.*)\[!--\sEND\s\\1\s--\]#sm'; + $matches2 = array(); if (preg_match($reg2, $matches[0][$i], $matches2)) { $balise = str_replace('row.', '', $matches2[1]); // Move segment tags around the row @@ -665,6 +643,7 @@ IMG; } // $reg = "#\[!--\sBEGIN\s$segment\s--\]<\/text:p>(.*)\[!--\sEND\s$segment\s--\]#sm"; $reg = "#\[!--\sBEGIN\s$segment\s--\](.*)\[!--\sEND\s$segment\s--\]#sm"; + $m = array(); if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) { throw new OdfException("'".$segment."' segment not found in the document. The tag [!-- BEGIN xxx --] or [!-- END xxx --] is not present into content file."); } @@ -1005,6 +984,7 @@ IMG; public function getvalue($valuename) { $searchreg="/\\[".$valuename."\\](.*)\\[\\/".$valuename."\\]/"; + $matches = array(); preg_match($searchreg, $this->contentXml, $matches); $this->contentXml = preg_replace($searchreg, "", $this->contentXml); return $matches[1]; From 6e01f1702e2642a52787ce23b59a2550d1c444e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 18:45:00 +0100 Subject: [PATCH 372/490] Fix css --- htdocs/projet/stats/index.php | 6 +++++- htdocs/projet/tasks/stats/index.php | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index c5acc20bfe6..878b80165d5 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -302,7 +302,9 @@ print $form->selectarray('year', $arrayyears, $year, 0); print ''; print ''; print ''; + print ''; + print '

    '; print '
    '; @@ -369,10 +371,12 @@ $stringtoshow .= ''; print $stringtoshow; +print '
    '; -print ''; print '
    '; +print dol_get_fiche_end(); + // End of page llxFooter(); $db->close(); diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index 60cbdf37072..5fd6b47407c 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -172,7 +172,9 @@ print $form->selectarray('year', $arrayyears, $year, 0); print ''; print ''; print ''; + print ''; + print '

    '; @@ -190,13 +192,13 @@ foreach ($data_all_year as $val) { $oldyear--; print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; + print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; print '0'; print ''; } print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$year.''; + print ' 0 ? '&userid='.$userid : '').'">'.$year.''; print ''.$val['nb'].''; print ''; $oldyear = $year; @@ -220,8 +222,11 @@ print $stringtoshow; print ''; + print '
    '; +print dol_get_fiche_end(); + // End of page llxFooter(); $db->close(); From 69ea6c5b7a82284c9d06f527cd641f2b61980d1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 18:49:30 +0100 Subject: [PATCH 373/490] css --- htdocs/theme/md/style.css.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 06598624da2..42de9b1c6f1 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1987,7 +1987,7 @@ div.fichehalfleft { print "float: ".$left.";\n"; } ?> browser->layout != 'phone') { - print "width: calc(50% - 10px);\n"; + print "width: calc(50% - 14px);\n"; } ?> } div.fichehalfright { @@ -1995,7 +1995,7 @@ div.fichehalfright { print "float: ".$right.";\n"; } ?> browser->layout != 'phone') { - print "width: calc(50% - 10px);\n"; + print "width: calc(50% - 14px);\n"; } ?> } div.fichehalfright { From 6e1213128faeb28fb21e3f159d8b8eef9cd52275 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 18:53:19 +0100 Subject: [PATCH 374/490] Look and feel v15 --- htdocs/contrat/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 0cfa0b2bf16..4c8c9c7aae5 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -810,8 +810,9 @@ while ($i < min($num, $limit)) { } print ''; } + // Email if (!empty($arrayfields['s.email']['checked'])) { - print ''.dol_print_email($obj->email).''; + print ''.dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).''; } // Town if (!empty($arrayfields['s.town']['checked'])) { From 13e8e3d33c8a31e989f30615e5919de0487374c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 19:15:02 +0100 Subject: [PATCH 375/490] Look and feel v15 --- htdocs/core/class/html.formother.class.php | 1 - htdocs/theme/md/style.css.php | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 99ee1b6af9b..ebe28237cc4 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -542,7 +542,6 @@ class FormOther $resql_usr = $this->db->query($sql_usr); if ($resql_usr) { $userstatic = new User($this->db); - $showstatus = 1; while ($obj_usr = $this->db->fetch_object($resql_usr)) { $userstatic->id = $obj_usr->rowid; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 42de9b1c6f1..b750ac21b1e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1521,11 +1521,11 @@ table[summary="list_of_modules"] .fa-cog { } /* Set a width. Note: add also a max-width, for example maxwidth500, that will be used in priority */ -.widthcentpercentminusx { +select.widthcentpercentminusx, span.widthcentpercentminusx:not(.select2-selection), input.widthcentpercentminusx { width: calc(100% - 50px) !important; display: inline-block; } -.widthcentpercentminusxx { +select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-selection), input.widthcentpercentminusxx { width: calc(100% - 70px) !important; display: inline-block; } @@ -3829,11 +3829,12 @@ div.liste_titre_bydiv { border-top-color: var(--colortopbordertitle1); border-top-style: solid; - box-shadow: none; border-collapse: collapse; display: table; padding: 2px 0px 2px 0; - width: calc(100% - 1px); + box-shadow: none; + /*width: calc(100% - 1px); 1px more, i don't know why so i remove */ + width: calc(100%); } tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr, tagtr.liste_titre { From ebdcff3b49e6bc76c8e519f784864b15fe6465eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 20:07:03 +0100 Subject: [PATCH 376/490] FIX filter for export of accounting documents --- htdocs/compta/accounting-files.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 2c94cea750c..791da74b030 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -610,8 +610,12 @@ if (!empty($date_start) && !empty($date_stop)) { echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; foreach ($listofchoices as $choice => $val) { print ''; } From d28edae46009f9ca0f01042946e0fcf905b10263 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 20:11:32 +0100 Subject: [PATCH 377/490] Fix idate must be jdate --- htdocs/compta/accounting-files.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 791da74b030..15096e28b4f 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -348,8 +348,8 @@ if (($action == 'searchfiles' || $action == 'dl')) { $nofile = array(); $nofile['id'] = $objd->id; $nofile['entity'] = $objd->entity; - $nofile['date'] = $db->idate($objd->date); - $nofile['date_due'] = $db->idate($objd->date_due); + $nofile['date'] = $db->jdate($objd->date); + $nofile['date_due'] = $db->jdate($objd->date_due); $nofile['paid'] = $objd->paid; $nofile['amount_ht'] = $objd->total_ht; $nofile['amount_ttc'] = $objd->total_ttc; @@ -368,8 +368,8 @@ if (($action == 'searchfiles' || $action == 'dl')) { foreach ($files as $key => $file) { $file['id'] = $objd->id; $file['entity'] = $objd->entity; - $file['date'] = $db->idate($objd->date); - $file['date_due'] = $db->idate($objd->date_due); + $file['date'] = $db->jdate($objd->date); + $file['date_due'] = $db->jdate($objd->date_due); $file['paid'] = $objd->paid; $file['amount_ht'] = $objd->total_ht; $file['amount_ttc'] = $objd->total_ttc; From 9f8e21bc2cd3f0a2e6edffdd33a53c162a9b9a23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 20:39:52 +0100 Subject: [PATCH 378/490] Fix filter on dates --- htdocs/compta/accounting-files.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 15096e28b4f..a06dd8dacaf 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -57,12 +57,12 @@ $date_start = GETPOST('date_start', 'alpha'); $date_startDay = GETPOST('date_startday', 'int'); $date_startMonth = GETPOST('date_startmonth', 'int'); $date_startYear = GETPOST('date_startyear', 'int'); -$date_start = ($date_startDay ? dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear, 'tzuserrel') : dol_stringtotime($date_start)); +$date_start = dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear, 'tzuserrel'); $date_stop = GETPOST('date_stop', 'alpha'); $date_stopDay = GETPOST('date_stopday', 'int'); $date_stopMonth = GETPOST('date_stopmonth', 'int'); $date_stopYear = GETPOST('date_stopyear', 'int'); -$date_stop = ($date_stopDay ? dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel') : dol_stringtotime($date_stop)); +$date_stop = dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel'); $action = GETPOST('action', 'aZ09'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -460,7 +460,7 @@ if ($result && $action == "dl" && !$error) { $log .= ','.$langs->transnoentitiesnoconv("Country"); $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; - $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; + $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip'; dol_delete_file($zipname); @@ -608,7 +608,7 @@ if (!empty($date_start) && !empty($date_stop)) { print '
    '."\n"; print ''; - echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); + echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel'); print ''; print ''; @@ -745,19 +745,19 @@ if (!empty($date_start) && !empty($date_stop)) { print ''.$data['paid'].''; // Total ET - print ''.price($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'])."\n"; + print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."\n"; // Total IT - print ''.price($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'])."\n"; + print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."\n"; // Total VAT - print ''.price($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'])."\n"; + print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."\n"; - print ''.$data['thirdparty_name']."\n"; + print ''.dol_escape_htmltag($data['thirdparty_name'])."\n"; print ''.$data['thirdparty_code']."\n"; print ''.$data['country_code']."\n"; - print ''.$data['vatnum']."\n"; + print ''.dol_escape_htmltag($data['vatnum'])."\n"; if ($data['sens']) { $totalET_credit += $data['amount_ht']; From d611b99d958a0404c9d97e3193cdbc43a609d4f7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 9 Nov 2021 03:01:48 +0100 Subject: [PATCH 379/490] GNU version 3 --- dev/initdemo/sftpget_and_loaddump.php | 2 +- dev/initdemo/updatedemo.php | 2 +- dev/translation/sanity_check_en_langfiles.php | 2 +- dev/translation/strip_language_file.php | 2 +- htdocs/accountancy/class/lettering.class.php | 2 +- htdocs/admin/expensereport_ik.php | 2 +- htdocs/admin/expensereport_rules.php | 2 +- htdocs/compta/bank/account_statement_document.php | 2 +- htdocs/compta/bank/document.php | 2 +- htdocs/fourn/commande/dispatch.php | 11 +++++------ htdocs/holiday/month_report.php | 2 +- htdocs/install/mysql/data/llx_c_units.sql | 2 +- htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql | 2 +- htdocs/install/mysql/tables/llx_c_exp_tax_range.sql | 2 +- .../mysql/tables/llx_c_ticket_category.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_ticket_category.sql | 2 +- .../mysql/tables/llx_c_ticket_resolution.key.sql | 2 +- .../install/mysql/tables/llx_c_ticket_resolution.sql | 2 +- .../mysql/tables/llx_c_ticket_severity.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_ticket_severity.sql | 2 +- htdocs/install/mysql/tables/llx_c_ticket_type.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_ticket_type.sql | 2 +- htdocs/install/mysql/tables/llx_c_units.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_units.sql | 2 +- htdocs/install/mysql/tables/llx_expensereport_ik.sql | 2 +- .../install/mysql/tables/llx_expensereport_rules.sql | 2 +- .../install/mysql/tables/llx_facturedet_rec.key.sql | 2 +- .../install/mysql/tables/llx_ticket_extrafields.sql | 2 +- htdocs/loan/calcmens.php | 5 ++--- htdocs/public/ticket/create_ticket.php | 2 +- 30 files changed, 35 insertions(+), 37 deletions(-) diff --git a/dev/initdemo/sftpget_and_loaddump.php b/dev/initdemo/sftpget_and_loaddump.php index 7d781fe5b0c..63b5ac65054 100755 --- a/dev/initdemo/sftpget_and_loaddump.php +++ b/dev/initdemo/sftpget_and_loaddump.php @@ -4,7 +4,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/dev/initdemo/updatedemo.php b/dev/initdemo/updatedemo.php index 4dd98451823..4ee2032c7cf 100755 --- a/dev/initdemo/updatedemo.php +++ b/dev/initdemo/updatedemo.php @@ -4,7 +4,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 39db0a55764..840f09a0adb 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -6,7 +6,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/dev/translation/strip_language_file.php b/dev/translation/strip_language_file.php index 3467b648457..f0a0397cd6e 100755 --- a/dev/translation/strip_language_file.php +++ b/dev/translation/strip_language_file.php @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 1dd4c4df3e5..f722a716b79 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -6,7 +6,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index d32ef64aebc..900754ef4b4 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index bddaf58475a..77fb8f24f82 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -6,7 +6,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 0a979e01d39..f36d455dc74 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -8,7 +8,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 7dce00005f3..389c8195f37 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -7,7 +7,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 170785c0118..547abd33b4b 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -10,19 +10,18 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2019-2020 Christophe Battarel * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * or see https://www.gnu.org/ */ /** diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 1bb58ca98b0..ad9b0295b2d 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -6,7 +6,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/data/llx_c_units.sql b/htdocs/install/mysql/data/llx_c_units.sql index 59692793fe2..475020aabaf 100644 --- a/htdocs/install/mysql/data/llx_c_units.sql +++ b/htdocs/install/mysql/data/llx_c_units.sql @@ -6,7 +6,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql b/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql index 15d89c4747c..90c60d87b97 100644 --- a/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql +++ b/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql @@ -5,7 +5,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql b/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql index e80eeb15d50..0d996df7033 100644 --- a/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql +++ b/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql @@ -5,7 +5,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.key.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.key.sql index 3afa9b5be1d..d5917ce1f5d 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_category.key.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_category.key.sql @@ -2,7 +2,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.sql index 57bd15f2c23..8477b455796 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_category.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_category.sql @@ -3,7 +3,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_resolution.key.sql b/htdocs/install/mysql/tables/llx_c_ticket_resolution.key.sql index ac3690b70bb..472a4f4ca30 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_resolution.key.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_resolution.key.sql @@ -2,7 +2,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_resolution.sql b/htdocs/install/mysql/tables/llx_c_ticket_resolution.sql index 2f6d0d1d3da..d935d9556a4 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_resolution.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_resolution.sql @@ -2,7 +2,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_severity.key.sql b/htdocs/install/mysql/tables/llx_c_ticket_severity.key.sql index a564f0059d2..fbe3e9e7de1 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_severity.key.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_severity.key.sql @@ -2,7 +2,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_severity.sql b/htdocs/install/mysql/tables/llx_c_ticket_severity.sql index b9f565c4395..c87c258faa6 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_severity.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_severity.sql @@ -2,7 +2,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_type.key.sql b/htdocs/install/mysql/tables/llx_c_ticket_type.key.sql index 7a4374e35fa..c912c3da835 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_type.key.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_type.key.sql @@ -2,7 +2,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_type.sql b/htdocs/install/mysql/tables/llx_c_ticket_type.sql index 462d1a71535..3c476ff848b 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_type.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_type.sql @@ -2,7 +2,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_units.key.sql b/htdocs/install/mysql/tables/llx_c_units.key.sql index d3e1d40e50a..93c8b9600d2 100644 --- a/htdocs/install/mysql/tables/llx_c_units.key.sql +++ b/htdocs/install/mysql/tables/llx_c_units.key.sql @@ -4,7 +4,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_c_units.sql b/htdocs/install/mysql/tables/llx_c_units.sql index ef77703ae6e..7b2424a8f54 100644 --- a/htdocs/install/mysql/tables/llx_c_units.sql +++ b/htdocs/install/mysql/tables/llx_c_units.sql @@ -5,7 +5,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_expensereport_ik.sql b/htdocs/install/mysql/tables/llx_expensereport_ik.sql index 839fbac8e9a..d2b1fd80815 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_ik.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_ik.sql @@ -5,7 +5,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_expensereport_rules.sql b/htdocs/install/mysql/tables/llx_expensereport_rules.sql index ae8f9b09496..1892ead3500 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_rules.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_rules.sql @@ -4,7 +4,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_facturedet_rec.key.sql b/htdocs/install/mysql/tables/llx_facturedet_rec.key.sql index 2580c33a7ab..616df5ec148 100644 --- a/htdocs/install/mysql/tables/llx_facturedet_rec.key.sql +++ b/htdocs/install/mysql/tables/llx_facturedet_rec.key.sql @@ -5,7 +5,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/install/mysql/tables/llx_ticket_extrafields.sql b/htdocs/install/mysql/tables/llx_ticket_extrafields.sql index 31f82064461..5131150649a 100644 --- a/htdocs/install/mysql/tables/llx_ticket_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_ticket_extrafields.sql @@ -2,7 +2,7 @@ -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or +-- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index 19763c0a924..cc6debab86c 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . */ /** diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index e621feb6653..00eff71da78 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -4,7 +4,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, From 33e40c12c8e5552f568f8c70f620b53f2dfa168a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 9 Nov 2021 14:12:28 +0100 Subject: [PATCH 380/490] FIX close cash with some terminals in TakePOS --- htdocs/takepos/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 344955a9167..f3b9991061e 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -732,6 +732,7 @@ $( document ).ready(function() { if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".$conf->entity." AND "; + $sql .= " posnumber = ".$_SESSION["takeposterminal"]." AND "; $sql .= " date(date_creation) = CURDATE()"; $resql = $db->query($sql); if ($resql) { @@ -918,6 +919,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".$conf->entity." AND "; +$sql .= " posnumber = ".$_SESSION["takeposterminal"]." AND "; $sql .= " date(date_creation) = CURDATE()"; $resql = $db->query($sql); if ($resql) From 1e20e082fe355d822a98ccc467767ea02171e571 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 9 Nov 2021 18:36:04 +0100 Subject: [PATCH 381/490] FIX lost superadmin grade after edit user card ! --- htdocs/user/card.php | 8 ++++++-- htdocs/user/class/user.class.php | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 8622e293906..cfa89120053 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -450,11 +450,15 @@ if (empty($reshook)) { // Do we update also ->entity ? if (!empty($conf->multicompany->enabled)) { // If multicompany is not enabled, we never update the entity of a user. if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $object->entity = 1; // all users are in master entity + if (GETPOST('superadmin', 'int') === 1) { + $object->entity = 0; + } else { + $object->entity = 1; // all users are in master entity + } } else { // A user should not be able to move a user into another entity. Only superadmin should be able to do this. if ($user->entity == 0 && $user->admin) { - if (GETPOST("superadmin")) { + if (GETPOST('superadmin', 'int')) { // We try to set the user as superadmin. $object->entity = 0; } else { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 9540f082a4c..09bb34ddef3 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1773,7 +1773,9 @@ class User extends CommonObject $sql .= ", salaryextra= ".($this->salaryextra != '' ? "'".$this->db->escape($this->salaryextra)."'" : "null"); } $sql .= ", weeklyhours= ".($this->weeklyhours != '' ? "'".$this->db->escape($this->weeklyhours)."'" : "null"); - $sql .= ", entity = ".((int) $this->entity); + if (!empty($user->admin) && empty($user->entity) && $user->id != $this->id) { + $sql .= ", entity = ".((int) $this->entity); // entity flag can be set/unset only by an another superadmin user + } $sql .= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null'); $sql .= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null'); $sql .= ", fk_warehouse = ".($this->fk_warehouse > 0 ? $this->fk_warehouse : "null"); From 5649e865c3e6cefa8e324769d663c1225a1125ef Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 9 Nov 2021 18:38:29 +0100 Subject: [PATCH 382/490] FIX wrong check --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index cfa89120053..dec885e11eb 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -450,7 +450,7 @@ if (empty($reshook)) { // Do we update also ->entity ? if (!empty($conf->multicompany->enabled)) { // If multicompany is not enabled, we never update the entity of a user. if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - if (GETPOST('superadmin', 'int') === 1) { + if (GETPOST('superadmin', 'int')) { $object->entity = 0; } else { $object->entity = 1; // all users are in master entity From cea3d93b91c3eaa829f34ae73aa9ee2d8bed676a Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 9 Nov 2021 20:51:27 +0100 Subject: [PATCH 383/490] Fix wrong sign in test --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 05e55206c02..d9ab62336a1 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,7 +943,7 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) < dol_now()) { + if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > dol_now()) { $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); From e5d40bf464894bb815a7032590f72373fd0afbf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Nov 2021 12:06:39 +0100 Subject: [PATCH 384/490] error display --- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index c7b74abfc39..4e82aa12686 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -128,7 +128,7 @@ if (GETPOST('cancel', 'alpha')) { if ($action == "reopen") { $result = $object->setStatut($object::STATUS_DRAFT, null, '', 'CASHFENCE_REOPEN'); if ($result < 0) { - dol_print_error($db, $object->error, $object->error); + setEventMessages($object->error, $object->error, 'errors'); } $action = 'view'; From 005254ad3438ce400c6136d88b56eb0b0f626e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Nov 2021 12:21:03 +0100 Subject: [PATCH 385/490] Update cashcontrol_card.php --- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 4e82aa12686..2cb658f135f 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -356,7 +356,7 @@ if ($action == "create" || $action == "start" || $action == 'close') { } elseif ($syear && $smonth && $sday) { $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; } else { - dol_print_error('', 'Year not defined'); + setEventMessages($langs->trans('Year not defined'), null, 'errors'); } $resql = $db->query($sql); From 06e6479a123c74b11cf732814077e485b8cb184a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Nov 2021 12:24:53 +0100 Subject: [PATCH 386/490] Update cashcontrol_card.php --- htdocs/compta/cashcontrol/cashcontrol_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 2cb658f135f..1950cdb5392 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -312,7 +312,7 @@ if ($action == "create" || $action == "start" || $action == 'close') { } elseif ($syear && $smonth && $sday) { $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; } else { - dol_print_error('', 'Year not defined'); + setEventMessages($langs->trans('YearNotDefined'), null, 'errors'); } $resql = $db->query($sql); @@ -356,7 +356,7 @@ if ($action == "create" || $action == "start" || $action == 'close') { } elseif ($syear && $smonth && $sday) { $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; } else { - setEventMessages($langs->trans('Year not defined'), null, 'errors'); + setEventMessages($langs->trans('YearNotDefined'), null, 'errors'); } $resql = $db->query($sql); From c9517db43badbc80b514d35625358cad2efe63a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Nov 2021 12:26:28 +0100 Subject: [PATCH 387/490] Update cashdesk.lang --- htdocs/langs/en_US/cashdesk.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 22d5afed2fc..5792e015040 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -133,3 +133,4 @@ SplitSale=Split sale PrintWithoutDetailsButton=Add "Print without details" button PrintWithoutDetailsLabelDefault=Line label by default on printing without details PrintWithoutDetails=Print without details +YearNotDefined=Year is not defined From 0afaf080ee0bb5f94458427eb2bfe24f66b79c5c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 10 Nov 2021 14:53:17 +0100 Subject: [PATCH 388/490] FIX bug if multicompany disabled avoid bad constantes --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 56f7c41994b..fb0bba95ac4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1926,7 +1926,7 @@ class Form $sql .= " WHERE u.entity IS NOT NULL"; } } else { - if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= " ON ug.fk_user = u.rowid"; $sql .= " WHERE ug.entity = ".$conf->entity; From 285bd67d90d60743124bf7f81e6f699b3a0c6b21 Mon Sep 17 00:00:00 2001 From: Gerhard Stephan Date: Wed, 10 Nov 2021 15:16:36 +0100 Subject: [PATCH 389/490] Added -Propal- as a missing class name to the commondocgenerator.class.php --- htdocs/core/class/commondocgenerator.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index e5a2ef4c9db..544a08198f8 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -492,7 +492,7 @@ abstract class CommonDocGenerator $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $already_payed_all, 'MT') ); - if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { + if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Propal', 'Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { $resarray[$array_key.'_total_discount_ht_locale'] = price($object->getTotalDiscount(), 0, $outputlangs); $resarray[$array_key.'_total_discount_ht'] = price2num($object->getTotalDiscount()); } else { @@ -538,7 +538,7 @@ abstract class CommonDocGenerator // Note that this added fields does not match a field into database in Dolibarr (Dolibarr manage discount on lines not as a global property of object) $resarray['object_total_up'] = $totalUp; $resarray['object_total_up_locale'] = price($resarray['object_total_up'], 0, $outputlangs); - if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { + if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Propal', 'Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { $totalDiscount = $object->getTotalDiscount(); } else { $totalDiscount = 0; From 7c5810dee61f7416521e3e157dfc9e5d06824702 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 10 Nov 2021 14:19:14 +0000 Subject: [PATCH 390/490] Fixing style errors. --- htdocs/core/class/commondocgenerator.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 544a08198f8..a0f3f311ed4 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -560,14 +560,13 @@ abstract class CommonDocGenerator } // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" - if (isset($line->fk_product) && $line->fk_product > 0) - { + if (isset($line->fk_product) && $line->fk_product > 0) { $tmpproduct = new Product($this->db); $result = $tmpproduct->fetch($line->fk_product); - foreach($tmpproduct->array_options as $key=>$label) + foreach ($tmpproduct->array_options as $key=>$label) $resarray["line_".$key] = $label; } - + return $resarray; } From 6a216e520f202142e93c4f9f21099ef527cd9003 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 11 Nov 2021 11:06:05 +0100 Subject: [PATCH 391/490] block deletion of items not free to delete (is_deletable) --- htdocs/core/actions_massactions.inc.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 8ccff0eb017..7c24257594f 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1295,7 +1295,14 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction .= '
    '.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'

    '; + $TMsg[] = '
    '.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'

    '; + continue; + } + + if ($objecttmp->is_erasable() <= 0) { + $langs->load("errors"); + $nbignored++; + $TMsg[] = '
    '.$langs->trans('ErrorRecordHasChildren').' '.$objecttmp->ref.'

    '; continue; } From 28e14ac336f16610449c3de73c84934d6c97f845 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 11 Nov 2021 13:28:33 +0100 Subject: [PATCH 392/490] fix permission on supplier_order document upload --- htdocs/supplier_proposal/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index a8b85fc25b5..884519a4f9a 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -75,7 +75,7 @@ if ($object->id > 0) { $upload_dir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($object->ref); } - +$permissiontoadd = $user->rights->supplier_proposal->creer; /* * Actions From bbd97c6e16a42d3e57c4df7c7680d95236a90df6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 13:36:04 +0100 Subject: [PATCH 393/490] Code comment --- htdocs/core/db/DoliDB.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 1aecd205da3..1ebea289470 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -233,7 +233,7 @@ abstract class DoliDB implements Database * Define sort criteria of request * * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb' - * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'; + * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'. Note: If the quantity fo sortorder values is lower than sortfield, we used the last value for missing values. * @return string String to provide syntax of a sort sql string */ public function order($sortfield = null, $sortorder = null) From fd3fd9d945f51a14146df69be9e60baf2f755946 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 13:46:58 +0100 Subject: [PATCH 394/490] Fix getpost --- htdocs/compta/bank/transfer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 9665a8a2b1f..f728dc74f4e 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -61,8 +61,8 @@ if ($action == 'add') { $dateo = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $label = GETPOST('label', 'alpha'); - $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); - $amountto = price2num(GETPOST('amountto', 'alpha'), 'MT'); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT', 2); + $amountto = price2num(GETPOST('amountto', 'alpha'), 'MT', 2); if (!$label) { $error++; From 0443302c3d5fb814eb6e813c1bafe27393730c08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 13:49:21 +0100 Subject: [PATCH 395/490] FIX calculation of balance in conciliation page on desc sorting. --- htdocs/compta/bank/bankentries_list.php | 13 ++++++------- htdocs/core/lib/functions.lib.php | 8 +++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 8628e287bd0..00a61a7ce7e 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -178,7 +178,6 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); - /* * Actions */ @@ -270,13 +269,15 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' if (!$error) { $param = 'action=reconcile&contextpage=banktransactionlist&id='.$id.'&search_account='.$id; - $param .= '&search_conciliated='.urlencode($search_conciliated); if ($page) { $param .= '&page='.urlencode($page); } if ($offset) { $param .= '&offset='.urlencode($offset); } + if ($search_conciliated != '' && $search_conciliated != '-1') { + $param .= '&search_conciliated='.urlencode($search_conciliated); + } if ($search_thirdparty_user) { $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); } @@ -419,7 +420,6 @@ $banklinestatic = new AccountLine($db); $now = dol_now(); - // Must be before button action $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { @@ -757,7 +757,7 @@ if ($resql) { // Confirmation delete if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteTransaction'); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid", 'int'), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); } // Lines of title fields @@ -1200,7 +1200,7 @@ if ($resql) { $objforbalance = $db->fetch_object($resqlforbalance); if ($objforbalance) { // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show - if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { + if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) { $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount); } else { // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show @@ -1285,8 +1285,7 @@ if ($resql) { } } - - if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { + if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) { $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc) $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT'); } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 81a5413182e..54a44753513 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5378,13 +5378,16 @@ function price2num($amount, $rounding = '', $option = 0) if ($thousand != ',' && $thousand != '.') { $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users } + $amount = str_replace(' ', '', $amount); // To avoid spaces $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . $amount = str_replace($dec, '.', $amount); + + $amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example. } //print ' XX'.$amount.' '.$rounding; - // Now, make a rounding if required + // Now, $amount is a real PHP float number. We make a rounding if required. if ($rounding) { $nbofdectoround = ''; if ($rounding == 'MU') { @@ -5424,9 +5427,12 @@ function price2num($amount, $rounding = '', $option = 0) if ($thousand != ',' && $thousand != '.') { $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users } + $amount = str_replace(' ', '', $amount); // To avoid spaces $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . $amount = str_replace($dec, '.', $amount); + + $amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example. } return $amount; From 28aa17e4fd5d17511f1646021ebf98b397990903 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 13:49:21 +0100 Subject: [PATCH 396/490] FIX calculation of balance in conciliation page on desc sorting. --- htdocs/compta/bank/bankentries_list.php | 13 ++++++------- htdocs/core/lib/functions.lib.php | 8 +++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 14aeee29d69..84938f24dbc 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -175,7 +175,6 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); - /* * Actions */ @@ -266,13 +265,15 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' if (!$error) { $param = 'action=reconcile&contextpage=banktransactionlist&id='.$id.'&search_account='.$id; - $param .= '&search_conciliated='.urlencode($search_conciliated); if ($page) { $param .= '&page='.urlencode($page); } if ($offset) { $param .= '&offset='.urlencode($offset); } + if ($search_conciliated != '' && $search_conciliated != '-1') { + $param .= '&search_conciliated='.urlencode($search_conciliated); + } if ($search_thirdparty_user) { $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); } @@ -415,7 +416,6 @@ $banklinestatic = new AccountLine($db); $now = dol_now(); - // Must be before button action $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { @@ -748,7 +748,7 @@ if ($resql) { // Confirmation delete if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteTransaction'); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid", 'int'), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); } // Lines of title fields @@ -1189,7 +1189,7 @@ if ($resql) { $objforbalance = $db->fetch_object($resqlforbalance); if ($objforbalance) { // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show - if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { + if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) { $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount); } else { // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show @@ -1274,8 +1274,7 @@ if ($resql) { } } - - if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { + if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) { $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc) $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT'); } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index eae8546a338..07ff2930f0f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5329,13 +5329,16 @@ function price2num($amount, $rounding = '', $option = 0) if ($thousand != ',' && $thousand != '.') { $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users } + $amount = str_replace(' ', '', $amount); // To avoid spaces $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . $amount = str_replace($dec, '.', $amount); + + $amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example. } //print ' XX'.$amount.' '.$rounding; - // Now, make a rounding if required + // Now, $amount is a real PHP float number. We make a rounding if required. if ($rounding) { $nbofdectoround = ''; if ($rounding == 'MU') { @@ -5375,9 +5378,12 @@ function price2num($amount, $rounding = '', $option = 0) if ($thousand != ',' && $thousand != '.') { $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users } + $amount = str_replace(' ', '', $amount); // To avoid spaces $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . $amount = str_replace($dec, '.', $amount); + + $amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example. } return $amount; From 9cb094b46638fe37b8028084214a6525650686c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 14:37:25 +0100 Subject: [PATCH 397/490] Fix error method not defined --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 7c24257594f..80ba0b671eb 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1299,7 +1299,7 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' continue; } - if ($objecttmp->is_erasable() <= 0) { + if (method_exists($objecttmp, 'is_erasable') && $objecttmp->is_erasable() <= 0) { $langs->load("errors"); $nbignored++; $TMsg[] = '
    '.$langs->trans('ErrorRecordHasChildren').' '.$objecttmp->ref.'

    '; From da2f3e7b406fdcfa76be9651b7d54a7ad6c1b51f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 14:55:59 +0100 Subject: [PATCH 398/490] Code comment --- htdocs/core/class/commondocgenerator.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a92179e7b6a..e5d8db4cb53 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -516,8 +516,9 @@ abstract class CommonDocGenerator // Add vat by rates if (is_array($object->lines) && count($object->lines) > 0) { $totalUp = 0; + // Set substitution keys for different VAT rates foreach ($object->lines as $line) { - // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward compatibility + // $line->tva_tx format depends on database field accuracy, no reliable. This is kept for backward compatibility if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) { $resarray[$array_key.'_total_vat_'.$line->tva_tx] = 0; } From c6ecf87a8a8ee583cb99264f70c03d0e9778a189 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:02:51 +0100 Subject: [PATCH 399/490] Update commondocgenerator.class.php --- htdocs/core/class/commondocgenerator.class.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a0f3f311ed4..0f962a9ca09 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -559,14 +559,6 @@ abstract class CommonDocGenerator $resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs); } - // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" - if (isset($line->fk_product) && $line->fk_product > 0) { - $tmpproduct = new Product($this->db); - $result = $tmpproduct->fetch($line->fk_product); - foreach ($tmpproduct->array_options as $key=>$label) - $resarray["line_".$key] = $label; - } - return $resarray; } From 66f1dd854584717bfbaa95002e3d933da8abc20f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:12:31 +0100 Subject: [PATCH 400/490] Fix avoid too large PDF --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index dda52e653fe..255d4dcf453 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2247,7 +2247,7 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - if (count($objects) > 1) { + if (count($objects) > 1 && count($objects) <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 5)) { $object->note_public .= dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' :
    '); foreach ($objects as $elementobject) { $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : '').' '); From 436dbcd81d176737fe6a6a4f8288d38b0d5eb16a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:22:54 +0100 Subject: [PATCH 401/490] Shorter pdf label --- htdocs/langs/en_US/propal.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index ed07831fcba..db7b559a8a7 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -5,7 +5,7 @@ ProposalShort=Proposal ProposalsDraft=Draft commercial proposals ProposalsOpened=Open commercial proposals CommercialProposal=Commercial proposal -PdfCommercialProposalTitle=Commercial proposal +PdfCommercialProposalTitle=Proposal ProposalCard=Proposal card NewProp=New commercial proposal NewPropal=New proposal From 06f378db18d4dfb18956c04b822c630ce48cbbaf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:31:19 +0100 Subject: [PATCH 402/490] FIX Bad use of dol_concatdesc() --- htdocs/core/lib/pdf.lib.php | 27 ++++++++++---------- htdocs/datapolicy/class/datapolicy.class.php | 16 ++++++------ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 255d4dcf453..873b375496e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2247,13 +2247,11 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - if (count($objects) > 1 && count($objects) <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 5)) { - $object->note_public .= dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' :
    '); + if (count($objects) > 1 && count($objects) <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 10)) { + $object->note_public = dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' :
    '); foreach ($objects as $elementobject) { - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : '').' '); - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities("OrderDate").' : '); - $object->note_public .= dol_concatdesc($object->note_public, dol_print_date($elementobject->date, 'day', '', $outputlangs)); - $object->note_public .= dol_concatdesc($object->note_public, '
    '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : '').' '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("OrderDate").' : '.dol_print_date($elementobject->date, 'day', '', $outputlangs).'
    '); } } elseif (count($objects) == 1) { $elementobject = array_shift($objects); @@ -2283,8 +2281,11 @@ function pdf_getLinkedObjects(&$object, $outputlangs) if (count($objects) > 1) { $order = null; - if (empty($object->linkedObjects['commande']) && $object->element != 'commande') $object->note_public .= dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :
    '); - else $object->note_public .= dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefSending").' :
    '); + if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { + $object->note_public = dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :
    '); + } else { + $object->note_public = dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefSending").' :
    '); + } // We concat this record info into fields xxx_value. title is overwrote. foreach ($objects as $elementobject) { if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { // There is not already a link to order and object is not the order, so we show also info with order @@ -2300,12 +2301,12 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } if (! is_object($order)) { - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref)); - $object->note_public .= dol_concatdesc($object->note_public, '
    '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref)); + $object->note_public = dol_concatdesc($object->note_public, '
    '); } else { - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '')); - $object->note_public .= dol_concatdesc($object->note_public, ' / '.$outputlangs->transnoentities($elementobject->ref)); - $object->note_public .= dol_concatdesc($object->note_public, '
    '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '')); + $object->note_public = dol_concatdesc($object->note_public, ' / '.$outputlangs->transnoentities($elementobject->ref)); + $object->note_public = dol_concatdesc($object->note_public, '
    '); } } } elseif (count($objects) == 1) { diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index a7ed08d7e6f..7d53020ce3a 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -269,11 +269,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } // Send mail @@ -343,11 +343,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } From fa4b5d99c0f728c66238e1da52694190af5c7bd0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:35:34 +0100 Subject: [PATCH 403/490] FIX Bad use of dol_concatdesc() --- htdocs/datapolicy/class/datapolicy.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index a7ed08d7e6f..7d53020ce3a 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -269,11 +269,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } // Send mail @@ -343,11 +343,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } From ba724204a430cc841a068b777ebf1d6e2ca727cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:50:32 +0100 Subject: [PATCH 404/490] FIX Bad use of dol_concatdesc() --- htdocs/datapolicy/class/datapolicy.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index bf1033084d5..7383e059ae3 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -259,11 +259,11 @@ class DataPolicy { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } // Send mail @@ -329,11 +329,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } From 38d3b9ca71a8a8d55ebf591539c71c0ee444be7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 11 Nov 2021 16:54:20 +0100 Subject: [PATCH 405/490] fix regex --- htdocs/core/modules/printing/modules_printing.php | 2 +- htdocs/core/modules/printing/printipp.modules.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index 1bbf78df022..fa86d832b73 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -69,7 +69,7 @@ class PrintingDriver $listoffiles = array(); $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); foreach ($dirmodels as $dir) { - $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '.modules.php', '', 'name', SORT_ASC, 0); + $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\.modules.php', '', 'name', SORT_ASC, 0); if (!empty($tmpfiles)) { $listoffiles = array_merge($listoffiles, $tmpfiles); } diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index f290b2b4e90..584e7751fd7 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -108,10 +108,10 @@ class printing_printipp extends PrintingDriver global $conf; $this->db = $db; - $this->host = $conf->global->PRINTIPP_HOST; - $this->port = $conf->global->PRINTIPP_PORT; - $this->user = $conf->global->PRINTIPP_USER; - $this->password = $conf->global->PRINTIPP_PASSWORD; + $this->host = getDolGlobalString('PRINTIPP_HOST'); + $this->port = getDolGlobalString('PRINTIPP_PORT'); + $this->user = getDolGlobalString('PRINTIPP_USER'); + $this->password = getDolGlobalString('PRINTIPP_PASSWORD'); $this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text'); $this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text'); $this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"'); From 00213812010a43454ab7a61558f67009cdd638da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 17:08:35 +0100 Subject: [PATCH 406/490] Fix #yogosha7605 --- htdocs/core/db/mysqli.class.php | 16 ++++++++++++---- htdocs/core/db/pgsql.class.php | 12 ++++++++---- htdocs/core/db/sqlite3.class.php | 16 ++++++++++++---- htdocs/install/upgrade.php | 1 + test/phpunit/CodingPhpTest.php | 4 ++-- test/phpunit/CodingSqlTest.php | 2 +- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 0db4e16a897..b64ec0708e2 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -663,9 +663,13 @@ class DoliDBMysqli extends DoliDB $like = ''; if ($table) { - $like = "LIKE '".$table."'"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table); + + $like = "LIKE '".$this->escape($tmptable)."'"; } - $sql = "SHOW TABLES FROM ".$database." ".$like.";"; + $tmpdatabase = preg_replace('/[^a-z0-9\.\-\_]/i', '', $database); + + $sql = "SHOW TABLES FROM ".$tmpdatabase." ".$like.";"; //print $sql; $result = $this->query($sql); if ($result) { @@ -688,7 +692,9 @@ class DoliDBMysqli extends DoliDB // phpcs:enable $infotables = array(); - $sql = "SHOW FULL COLUMNS FROM ".$table.";"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "SHOW FULL COLUMNS FROM ".$tmptable.";"; dol_syslog($sql, LOG_DEBUG); $result = $this->query($sql); @@ -794,7 +800,9 @@ class DoliDBMysqli extends DoliDB public function DDLDropTable($table) { // phpcs:enable - $sql = "DROP TABLE ".$table; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "DROP TABLE ".$tmptable; if (!$this->query($sql)) { return -1; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 5997349d0c5..ac6b8de33f3 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -937,7 +937,9 @@ class DoliDBPgsql extends DoliDB $escapedlike = ''; if ($table) { - $escapedlike = " AND table_name LIKE '".$this->escape($table)."'"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table); + + $escapedlike = " AND table_name LIKE '".$this->escape($tmptable)."'"; } $result = pg_query($this->db, "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'".$escapedlike." ORDER BY table_name"); if ($result) { @@ -973,8 +975,8 @@ class DoliDBPgsql extends DoliDB $sql .= " '' as \"Extra\","; $sql .= " '' as \"Privileges\""; $sql .= " FROM information_schema.columns infcol"; - $sql .= " WHERE table_schema='public' "; - $sql .= " AND table_name='".$this->escape($table)."'"; + $sql .= " WHERE table_schema = 'public' "; + $sql .= " AND table_name = '".$this->escape($table)."'"; $sql .= " ORDER BY ordinal_position;"; dol_syslog($sql, LOG_DEBUG); @@ -1078,7 +1080,9 @@ class DoliDBPgsql extends DoliDB public function DDLDropTable($table) { // phpcs:enable - $sql = "DROP TABLE ".$table; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "DROP TABLE ".$tmptable; if (!$this->query($sql)) { return -1; diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index c03d2a5ee04..bc01ee7a535 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -875,9 +875,13 @@ class DoliDBSqlite3 extends DoliDB $like = ''; if ($table) { - $like = "LIKE '".$table."'"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table); + + $like = "LIKE '".$this->escape($tmptable)."'"; } - $sql = "SHOW TABLES FROM ".$database." ".$like.";"; + $tmpdatabase = preg_replace('/[^a-z0-9\.\-\_]/i', '', $database); + + $sql = "SHOW TABLES FROM ".$tmpdatabase." ".$like.";"; //print $sql; $result = $this->query($sql); if ($result) { @@ -901,7 +905,9 @@ class DoliDBSqlite3 extends DoliDB // phpcs:enable $infotables = array(); - $sql = "SHOW FULL COLUMNS FROM ".$table.";"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "SHOW FULL COLUMNS FROM ".$tmptable.";"; dol_syslog($sql, LOG_DEBUG); $result = $this->query($sql); @@ -1002,7 +1008,9 @@ class DoliDBSqlite3 extends DoliDB public function DDLDropTable($table) { // phpcs:enable - $sql = "DROP TABLE ".$table; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "DROP TABLE ".$tmptable; if (!$this->query($sql)) { return -1; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index b36914ad36b..c03678151fc 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -260,6 +260,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ ); $listtables = $db->DDLListTables($conf->db->name, ''); + foreach ($listtables as $val) { // Database prefix filter if (preg_match('/^'.MAIN_DB_PREFIX.'/', $val)) { diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 2681164c857..383c37e95e5 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -17,7 +17,7 @@ */ /** - * \file test/phpunit/SqlTest.php + * \file test/phpunit/CodingPhpTest.php * \ingroup test * \brief PHPUnit test * \remarks To run this script as CLI: phpunit filename.php @@ -363,7 +363,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase // Check string sql|set|WHERE|...'".$yyy->xxx with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request. $ok=true; $matches=array(); - preg_match_all('/(sql|SET|WHERE|INSERT|VALUES).+\s*\'"\s*\.\s*\$(.......)/', $filecontent, $matches, PREG_SET_ORDER); + preg_match_all('/(sql|SET|WHERE|INSERT|VALUES|LIKE).+\s*\'"\s*\.\s*\$(.......)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if (! in_array($val[2], array('this->d', 'this->e', 'db->esc', 'dbs->es', 'mydb->e', 'dbsessi', 'db->ida', 'escaped', 'exclude', 'include'))) { $ok=false; // This will generate error diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 9217ebbe7f6..f79205a0443 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -17,7 +17,7 @@ */ /** - * \file test/phpunit/SqlTest.php + * \file test/phpunit/CodingSqlTest.php * \ingroup test * \brief PHPUnit test * \remarks To run this script as CLI: phpunit filename.php From 5eff0e7a0c996a16bb5b2805f77bcec9bfb814c6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 11 Nov 2021 17:48:23 +0100 Subject: [PATCH 407/490] FIX only a superadmin can modify entity --- htdocs/user/card.php | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index dec885e11eb..68218ab16bd 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -448,23 +448,15 @@ if (empty($reshook)) { $object->lang = GETPOST('default_lang', 'aZ09'); // Do we update also ->entity ? - if (!empty($conf->multicompany->enabled)) { // If multicompany is not enabled, we never update the entity of a user. - if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - if (GETPOST('superadmin', 'int')) { - $object->entity = 0; - } else { - $object->entity = 1; // all users are in master entity - } + if (!empty($conf->multicompany->enabled && $user->entity == 0 && !empty($user->admin))) { // If multicompany is not enabled, we never update the entity of a user. + if (GETPOST('superadmin', 'int')) { + $object->entity = 0; } else { - // A user should not be able to move a user into another entity. Only superadmin should be able to do this. - if ($user->entity == 0 && $user->admin) { - if (GETPOST('superadmin', 'int')) { - // We try to set the user as superadmin. - $object->entity = 0; - } else { - // We try to change the entity of user - $object->entity = (GETPOSTISSET('entity') ? GETPOSTINT('entity') : $object->entity); - } + if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $object->entity = 1; // all users are in master entity + } else { + // We try to change the entity of user + $object->entity = (GETPOSTISSET('entity') ? GETPOSTINT('entity') : $object->entity); } } } From e98cfb3ef1b5af51acef2c529d7ae1e48dfa104b Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 11 Nov 2021 18:02:56 +0100 Subject: [PATCH 408/490] FIX Save TakePOS credit note as a pos sale --- htdocs/takepos/invoice.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 660b6cbb18f..2a951a505ae 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -330,6 +330,8 @@ if ($action == 'creditnote' && $user->rights->facture->creer) { $creditnote = new Facture($db); $creditnote->socid = $invoice->socid; $creditnote->date = dol_now(); + $creditnote->module_source = 'takepos'; + $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; $creditnote->type = Facture::TYPE_CREDIT_NOTE; $creditnote->fk_facture_source = $placeid; $creditnote->remise_absolue = $invoice->remise_absolue; From aab9c2e6cacb0ca194d028481645c236be4652f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 18:20:31 +0100 Subject: [PATCH 409/490] Fix #yogosha7605 --- htdocs/core/db/mysqli.class.php | 5 +++-- htdocs/core/db/pgsql.class.php | 5 +++-- htdocs/core/db/sqlite3.class.php | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index b64ec0708e2..4dd71f0e351 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -933,8 +933,9 @@ class DoliDBMysqli extends DoliDB public function DDLDropField($table, $field_name) { // phpcs:enable - $sql = "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; - dol_syslog(get_class($this)."::DDLDropField ".$sql, LOG_DEBUG); + $tmp_field_name = preg_replace('/[^a-z0-9\.\-\_]/i', '', $field_name); + + $sql = "ALTER TABLE ".$table." DROP COLUMN `".$tmp_field_name."`"; if ($this->query($sql)) { return 1; } diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index ac6b8de33f3..7cf0a5d905a 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1240,8 +1240,9 @@ class DoliDBPgsql extends DoliDB public function DDLDropField($table, $field_name) { // phpcs:enable - $sql = "ALTER TABLE ".$table." DROP COLUMN ".$field_name; - dol_syslog($sql, LOG_DEBUG); + $tmp_field_name = preg_replace('/[^a-z0-9\.\-\_]/i', '', $field_name); + + $sql = "ALTER TABLE ".$table." DROP COLUMN ".$tmp_field_name; if (!$this->query($sql)) { $this->error = $this->lasterror(); return -1; diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index bc01ee7a535..d1d6a4b680a 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -1120,8 +1120,9 @@ class DoliDBSqlite3 extends DoliDB public function DDLDropField($table, $field_name) { // phpcs:enable - $sql = "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; - dol_syslog(get_class($this)."::DDLDropField ".$sql, LOG_DEBUG); + $tmp_field_name = preg_replace('/[^a-z0-9\.\-\_]/i', '', $field_name); + + $sql = "ALTER TABLE ".$table." DROP COLUMN `".$tmp_field_name."`"; if (!$this->query($sql)) { $this->error = $this->lasterror(); return -1; From fd1585eda07ad2e2459fbbb486a91a1e150dc7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 11 Nov 2021 18:23:34 +0100 Subject: [PATCH 410/490] add load langs --- htdocs/core/lib/functions2.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 26c56d45463..fe6e8e0fa40 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2131,30 +2131,38 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') // Special cases, to work with non standard path if ($objecttype == 'facture' || $objecttype == 'invoice') { + $langs->load('bills'); $classpath = 'compta/facture/class'; $module = 'facture'; $myobject = 'facture'; } elseif ($objecttype == 'commande' || $objecttype == 'order') { + $langs->load('orders'); $classpath = 'commande/class'; $module = 'commande'; $myobject = 'commande'; } elseif ($objecttype == 'propal') { + $langs->load('propal'); $classpath = 'comm/propal/class'; } elseif ($objecttype == 'supplier_proposal') { + $langs->load('supplier_proposal'); $classpath = 'supplier_proposal/class'; } elseif ($objecttype == 'shipping') { + $langs->load('sendings'); $classpath = 'expedition/class'; $myobject = 'expedition'; $module = 'expedition_bon'; } elseif ($objecttype == 'delivery') { + $langs->load('deliveries'); $classpath = 'delivery/class'; $myobject = 'delivery'; $module = 'delivery_note'; } elseif ($objecttype == 'contract') { + $langs->load('contracts'); $classpath = 'contrat/class'; $module = 'contrat'; $myobject = 'contrat'; } elseif ($objecttype == 'member') { + $langs->load('members'); $classpath = 'adherents/class'; $module = 'adherent'; $myobject = 'adherent'; @@ -2163,13 +2171,16 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') $module = 'cabinetmed'; $myobject = 'cabinetmedcons'; } elseif ($objecttype == 'fichinter') { + $langs->load('interventions'); $classpath = 'fichinter/class'; $module = 'ficheinter'; $myobject = 'fichinter'; } elseif ($objecttype == 'project') { + $langs->load('projects'); $classpath = 'projet/class'; $module = 'projet'; } elseif ($objecttype == 'task') { + $langs->load('projects'); $classpath = 'projet/class'; $module = 'projet'; $myobject = 'task'; From a725ffefdd80286502770c9eddfda64d69f30aa4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 18:30:17 +0100 Subject: [PATCH 411/490] Fix sql error --- htdocs/takepos/index.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 4d729bde2fa..1ec50dd3799 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1037,13 +1037,10 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { } $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; -$sql .= " entity = ".$conf->entity." AND "; -<<<<<<< HEAD +$sql .= " entity = ".((int) $conf->entity)." AND "; +$sql .= " posnumber = ".((int) $_SESSION["takeposterminal"])." AND "; $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; -======= -$sql .= " posnumber = ".$_SESSION["takeposterminal"]." AND "; -$sql .= " date(date_creation) = CURDATE()"; ->>>>>>> branch '12.0' of git@github.com:Dolibarr/dolibarr.git + $resql = $db->query($sql); if ($resql) { From 21c2dba9222913883e3aa46d6ea0af9ef007a64b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 19:06:55 +0100 Subject: [PATCH 412/490] Fix phpcs --- htdocs/compta/facture/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d9be7ff3f1c..e01d71a1020 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5118,7 +5118,6 @@ if ($action == 'create') { print ' :'.price($retainedWarranty).' '; } } else { // Credit note - $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentneutral'; From 53b565ec1d8324f4289b2b5f5462ed62b2a5668c Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 11 Nov 2021 20:06:21 +0100 Subject: [PATCH 413/490] Fix date_select go away when sorting subscription --- htdocs/adherents/subscription/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 7146e89648e..4c9935b76a8 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -311,6 +311,7 @@ print ''; print ''; print ''; print ''; +print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); From 3b21fc2d37e71f057a0f971a5ac233e5a00a7127 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Nov 2021 10:50:19 +0100 Subject: [PATCH 414/490] Better way to report value of stock when PRODUIT_MULTIPRICES is on --- htdocs/langs/en_US/stocks.lang | 2 +- htdocs/product/stock/product.php | 69 +++++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 8c0cc76f075..19875f55148 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -96,7 +96,7 @@ RealStock=Real Stock RealStockDesc=Physical/real stock is the stock currently in the warehouses. RealStockWillAutomaticallyWhen=The real stock will be modified according to this rule (as defined in the Stock module): VirtualStock=Virtual stock -VirtualStockAtDate=Virtual stock at date +VirtualStockAtDate=Virtual stock at a future date VirtualStockAtDateDesc=Virtual stock once all the pending orders that are planned to be processed before the chosen date will be finished VirtualStockDesc=Virtual stock is the calculated stock available once all open/pending actions (that affect stocks) are closed (purchase orders received, sales orders shipped, manufacturing orders produced, etc) AtDate=At date diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 23900c85c0b..247d11d00c6 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -763,7 +763,7 @@ if ($id > 0 || $ref) { if ($result < 0) { dol_print_error($db, $object->error); } - $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; } // Number of product from customer order already sent (partial shipping) @@ -797,7 +797,7 @@ if ($id > 0 || $ref) { if ($result < 0) { dol_print_error($db, $object->error); } - $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; } // Number of product from supplier order already received (partial receipt) @@ -983,6 +983,7 @@ if (!$variants) { $entrepotstatic = new Entrepot($db); $product_lot_static = new Productlot($db); + $num = 0; $total = 0; $totalvalue = $totalvaluesell = 0; @@ -1025,18 +1026,45 @@ if (!$variants) { print ''.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').''; // Sell price + $minsellprice = null; $maxsellprice = null; print ''; - print price(price2num($object->price, 'MU'), 1); if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + foreach ($object->multiprices as $priceforlevel) { + if (is_numeric($priceforlevel)) { + if (is_null($maxsellprice) || $priceforlevel > $maxsellprice) { + $maxsellprice = $priceforlevel; + } + if (is_null($minsellprice) || $priceforlevel < $minsellprice) { + $minsellprice = $priceforlevel; + } + } + } + print ''; + if ($minsellprice != $maxsellprice) { + print price(price2num($minsellprice, 'MU'), 1).' - '.price(price2num($maxsellprice, 'MU'), 1); + } else { + print price(price2num($minsellprice, 'MU'), 1); + } + print ''; print $form->textwithpicto('', $langs->trans("Variable")); + } else { + print price(price2num($object->price, 'MU'), 1); } print ''; // Value sell print ''; - print price(price2num($object->price * $obj->reel, 'MT'), 1); if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + print ''; + if ($minsellprice != $maxsellprice) { + print price(price2num($minsellprice * $obj->reel, 'MT'), 1).' - '.price(price2num($maxsellprice * $obj->reel, 'MT'), 1); + } else { + print price(price2num($minsellprice * $obj->reel, 'MT'), 1); + } + print ''; print $form->textwithpicto('', $langs->trans("Variable")); + } else { + print price(price2num($object->price * $obj->reel, 'MT'), 1); } print ''; print ''; @@ -1148,17 +1176,28 @@ if (!$variants) { print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' '; print ''; print ''; - print ($total ? price($totalvaluesell / $total, 1) : ' '); - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - print $form->textwithpicto('', $langs->trans("Variable")); + if ($num) { + if ($total) { + print ''; + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + print $form->textwithpicto('', $langs->trans("Variable")); + } else { + print price($totalvaluesell / $total, 1); + } + print ''; + } } print ''; // Value to sell - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) { - print price(price2num($totalvaluesell, 'MT'), 1); - } else { - print $langs->trans("Variable"); + print ''; + if ($num) { + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print price(price2num($totalvaluesell, 'MT'), 1); + } else { + print $form->textwithpicto('', $langs->trans("Variable")); + } + print ''; } print ''; print ''; @@ -1180,13 +1219,13 @@ if (!$variants) { } print ''; if (!empty($user->rights->produit->creer)) { - print ''; + print ''; print ''; print ''; print ''; print ''; } else { - print ''; + print ''; print ''; print ''; print ''; @@ -1200,7 +1239,7 @@ if (!$variants) { foreach ($lines as $line) { $ent = new Entrepot($db); $ent->fetch($line['fk_entrepot']); - print ''; + print ''; print ''; print ''; if (!empty($user->rights->produit->creer)) { From 5c8d91ba6c817bd8215f935f672a38559251b20d Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama Date: Fri, 12 Nov 2021 12:46:18 +0200 Subject: [PATCH 415/490] BankAccountNumber is not required. The IBAN can contain all the needed information. So there is no reason for the account number to be required --- htdocs/core/modules/modSociete.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index ca5b484499a..60e593cf3f1 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -757,7 +757,7 @@ class modSociete extends DolibarrModules 'sr.bank' => "Bank", 'sr.code_banque' => "BankCode", 'sr.code_guichet' => "DeskCode", - 'sr.number' => "BankAccountNumber*", + 'sr.number' => "BankAccountNumber", 'sr.cle_rib' => "BankAccountNumberKey", 'sr.bic' => "BIC", 'sr.iban_prefix' => "IBAN", From de435576a988144ed9059d0d05147deea09f7d1f Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama Date: Fri, 12 Nov 2021 12:46:37 +0200 Subject: [PATCH 416/490] Allow WithdrawMode to be imported --- htdocs/core/modules/modSociete.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 60e593cf3f1..2826091155c 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -766,6 +766,7 @@ class modSociete extends DolibarrModules 'sr.owner_address' => "BankAccountOwnerAddress", 'sr.default_rib' => 'Default', 'sr.rum' => 'RUM', + 'sr.frstrecur' => "WithdrawMode", 'sr.type' => "Type ban is defaut", ); @@ -797,6 +798,7 @@ class modSociete extends DolibarrModules 'sr.owner_address' => 'address of account holder', 'sr.default_rib' => '1 (default account) / 0 (not default)', 'sr.rum' => 'RUM code', + 'sr.frstrecur' => 'FRST', 'sr.type' => 'ban', ); From 968ffbcef0b379929c8417c9a7c14143a60a7b22 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 12 Nov 2021 13:06:41 +0100 Subject: [PATCH 417/490] FIX add ldap hash algo --- htdocs/core/class/html.formldap.class.php | 17 +++++--- htdocs/core/lib/security.lib.php | 53 +++++++++++++---------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/htdocs/core/class/html.formldap.class.php b/htdocs/core/class/html.formldap.class.php index acee0bbbea7..1f9d6591560 100644 --- a/htdocs/core/class/html.formldap.class.php +++ b/htdocs/core/class/html.formldap.class.php @@ -81,16 +81,21 @@ class FormLdap } $arraylist = array( - "pbkdf2sha256" => "PBKDF2_SHA256", - "ssha512" => "SSHA512", - "ssha256" => "SSHA256", + //"pbkdf2sha256" => "PBKDF2_SHA256", + "ssha512" => "SSHA-512", + "ssha384" => "SSHA-384", + "ssha256" => "SSHA-256", "ssha" => "SSHA", + "sha512" => "SHA-512", + "sha384" => "SHA-384", + "sha256" => "SHA-256", "sha" => "SHA", "md5" => "MD5", "smd5" => "SMD5", - "cryptmd5" => "CRYPT-MD5", - "cryptsha512" => "CRYPT-SHA512", - "cryptsha256" => "CRYPT-SHA256", + //"cryptmd5" => "CRYPT-MD5", + //"cryptsha512" => "CRYPT-SHA512", + //"cryptsha384" => "CRYPT-SHA384", + //"cryptsha256" => "CRYPT-SHA256", "crypt" => "CRYPT", "clear" => "CLEAR" ); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 1eb737880c6..ec3d73f2f72 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -97,7 +97,7 @@ function dol_decode($chain, $key = '1') * If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash'). * * @param string $chain String to hash - * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap with no salt, '5':sha256, '6':password_hash). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4': for OpenLdap, '5':sha256, '6':password_hash). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string * @see getRandomPassword() */ @@ -122,7 +122,7 @@ function dol_hash($chain, $type = '0') } elseif ($type == '3' || $type == 'md5') { return md5($chain); } elseif ($type == '4' || $type == 'openldap') { - return dolGetLdapHash($chain, getDolGlobalString('LDAP_PASSWORD_HASH_TYPE', 'md5'), getDolGlobalString('MAIN_SECURITY_SALT')); + return dolGetLdapPasswordHash($chain, getDolGlobalString('LDAP_PASSWORD_HASH_TYPE', 'md5'), getDolGlobalString('MAIN_SECURITY_SALT')); } elseif ($type == '5' || $type == 'sha256') { return hash('sha256', $chain); } elseif ($type == '6' || $type == 'password_hash') { @@ -145,7 +145,7 @@ function dol_hash($chain, $type = '0') * * @param string $chain String to hash (not hashed string) * @param string $hash hash to compare - * @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4': for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return bool True if the computed hash is the same as the given one */ function dol_verifyHash($chain, $hash, $type = '0') @@ -168,41 +168,46 @@ function dol_verifyHash($chain, $hash, $type = '0') } /** - * Returns a specific ldap hash of a string. + * Returns a specific ldap hash of a password. * - * @param string $chain String to hash + * @param string $password Password to hash * @param string $type Type of hash - * @return string Hash of string + * @return string Hash of password */ -function dolGetLdapHash($chain, $type = 'md5') +function dolGetLdapPasswordHash($password, $type = 'md5') { if (empty($type)) { $type = 'md5'; } + $salt = substr(sha1(time()), 0, 8); + if ($type === 'md5') { - return '{MD5}' . base64_encode(pack("H*", md5($chain))); // For OpenLdap with md5 (based on an unencrypted password in base) + return '{MD5}' . base64_encode(hash("md5", $password, true)); //For OpenLdap with md5 (based on an unencrypted password in base) } elseif ($type === 'md5frommd5') { - return '{MD5}' . base64_encode(hex2bin($chain)); // Create OpenLDAP MD5 password from Dolibarr MD5 password + return '{MD5}' . base64_encode(hex2bin($password)); // Create OpenLDAP MD5 password from Dolibarr MD5 password } elseif ($type === 'smd5') { - mt_srand((double)microtime()*1000000); - $salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand()); - return "{SMD5}" . base64_encode(pack("H*", md5($chain . $salt)) . $salt); + return "{SMD5}" . base64_encode(hash("md5", $password . $salt, true) . $salt); } elseif ($type === 'sha') { - return '{SHA}' . base64_encode(sha1($chain), true); + return '{SHA}' . base64_encode(hash("sha1", $password, true)); } elseif ($type === 'ssha') { - mt_srand((double)microtime()*1000000); - $salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand()); - return "{SSHA}" . base64_encode(pack("H*", sha1($chain . $salt)) . $salt); + return "{SSHA}" . base64_encode(hash("sha1", $password . $salt, true) . $salt); + } elseif ($type === 'sha256') { + return "{SHA256}" . base64_encode(hash("sha256", $password, true)); + } elseif ($type === 'ssha256') { + return "{SSHA256}" . base64_encode(hash("sha256", $password . $salt, true) . $salt); + } elseif ($type === 'sha384') { + return "{SHA384}" . base64_encode(hash("sha384", $password, true)); + } elseif ($type === 'ssha384') { + return "{SSHA384}" . base64_encode(hash("sha384", $password . $salt, true) . $salt); + } elseif ($type === 'sha512') { + return "{SHA512}" . base64_encode(hash("sha512", $password, true)); + } elseif ($type === 'ssha512') { + return "{SSHA512}" . base64_encode(hash("sha512", $password . $salt, true) . $salt); } elseif ($type === 'crypt') { - // Generate salt - $salt = ""; - $pattern = '0123456789'.'abcdefghijklmnopqrstuvwxyz'.'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.'./'; - mt_srand((double)microtime() * 1000000); - while (strlen($salt) < 2) { - $salt .= substr($pattern, (rand() % strlen($pattern)), 1); - } - return '{CRYPT}' . crypt($chain, $salt); + return '{CRYPT}' . crypt($password, $salt); + } elseif ($type === 'clear') { + return '{CLEAR}' . $password; // Just for test, plain text password is not secured ! } } From 1169ae551fc2acc5d5c38ebf633e001fe3fc1ba1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 12 Nov 2021 13:12:49 +0100 Subject: [PATCH 418/490] FIX remove debug --- htdocs/core/class/ldap.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index e4b22cc529c..120c2993801 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -238,9 +238,9 @@ class Ldap // Upgrade connexion to TLS, if requested by the configuration if (!empty($conf->global->LDAP_SERVER_USE_TLS)) { // For test/debug - ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7); - ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3); - ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); + //ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7); + //ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3); + //ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); $resulttls = ldap_start_tls($this->connection); if (!$resulttls) { From 7324375caad3b0335234db2d17c5f3d4c091924b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 12 Nov 2021 13:15:40 +0100 Subject: [PATCH 419/490] FIX missing rename function --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/user/class/user.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index fb77b062780..0b5fddd5da4 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2714,7 +2714,7 @@ class Adherent extends CommonObject if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) { // Create OpenLDAP MD5 password from Dolibarr MD5 password // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))" - $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dolGetLdapHash($this->pass_indatabase_crypted, 'md5frommd5'); + $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dolGetLdapPasswordHash($this->pass_indatabase_crypted, 'md5frommd5'); } } } elseif (!empty($this->pass_indatabase)) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ae663bc9fdd..daa23328b63 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2948,7 +2948,7 @@ class User extends CommonObject // Just for the default MD5 ! if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) { if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) { - $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dolGetLdapHash($this->pass_indatabase_crypted, 'md5frommd5'); // Create OpenLDAP MD5 password from Dolibarr MD5 password + $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dolGetLdapPasswordHash($this->pass_indatabase_crypted, 'md5frommd5'); // Create OpenLDAP MD5 password from Dolibarr MD5 password } } } elseif (!empty($this->pass_indatabase)) { From 991c1b4f139da7873ee85d5d0b72a9e8e862c6ff Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 12 Nov 2021 13:20:58 +0100 Subject: [PATCH 420/490] ADD Klarna provider with Stripe --- htdocs/stripe/class/stripe.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 9324d7d3a5d..d60b084ff39 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -409,6 +409,9 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) { $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) } + if (!empty($conf->global->STRIPE_KLARNA)) { + $paymentmethodtypes[] = "klarna"; + } if (!empty($conf->global->STRIPE_BANCONTACT)) { $paymentmethodtypes[] = "bancontact"; } @@ -450,7 +453,9 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_GIROPAY)) { unset($dataforintent['setup_future_usage']); } - + if (!empty($conf->global->STRIPE_KLARNA)) { + unset($dataforintent['setup_future_usage']); + } if (!is_null($payment_method)) { $dataforintent["payment_method"] = $payment_method; $description .= ' - '.$payment_method; @@ -602,6 +607,9 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_BANCONTACT)) { $paymentmethodtypes[] = "bancontact"; } + if (!empty($conf->global->STRIPE_KLARNA)) { + $paymentmethodtypes[] = "klarna"; + } if (!empty($conf->global->STRIPE_IDEAL)) { $paymentmethodtypes[] = "ideal"; } From 97d2722c4ce36f2b7a962bccb28687d8b9f2ef57 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 12 Nov 2021 13:21:40 +0100 Subject: [PATCH 421/490] Update stripe.php --- htdocs/stripe/admin/stripe.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 06f417e48df..77c8d9a03b2 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -390,6 +390,20 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code print ''; } +// Activate Klarna +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code + print ''; +} + // Activate Bancontact if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code print '
    '.$formproduct->selectWarehouses('', 'fk_entrepot').'
    '.$formproduct->selectWarehouses('', 'fk_entrepot').'
    '.$langs->trans("Warehouse").'
    '.$langs->trans("Warehouse").''.$langs->trans("StockLimit").''.$langs->trans("DesiredStock").'
    '.$ent->getNomUrl(3).'
    '.$ent->getNomUrl(3).''.$line['seuil_stock_alerte'].''.$line['desiredstock'].'
    '; + print $langs->trans("STRIPE_KLARNA").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_KLARNA'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_KLARNA", $arrval, $conf->global->STRIPE_KLARNA); + } + print '   '.$langs->trans("ExampleOnlyForKlarnaCustomers").''; + print '
    '; From 9e5a20545d0ec684de52963ff770d9213d76a8c3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 12 Nov 2021 13:23:11 +0100 Subject: [PATCH 422/490] FIX dolGetLdapPasswordHash use your own random salt --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index ec3d73f2f72..58d69842f66 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -122,7 +122,7 @@ function dol_hash($chain, $type = '0') } elseif ($type == '3' || $type == 'md5') { return md5($chain); } elseif ($type == '4' || $type == 'openldap') { - return dolGetLdapPasswordHash($chain, getDolGlobalString('LDAP_PASSWORD_HASH_TYPE', 'md5'), getDolGlobalString('MAIN_SECURITY_SALT')); + return dolGetLdapPasswordHash($chain, getDolGlobalString('LDAP_PASSWORD_HASH_TYPE', 'md5')); } elseif ($type == '5' || $type == 'sha256') { return hash('sha256', $chain); } elseif ($type == '6' || $type == 'password_hash') { From daadcf2fc36662aeb8985771fbbe26c90aedaa2d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 12 Nov 2021 12:23:40 +0000 Subject: [PATCH 423/490] Fixing style errors. --- htdocs/stripe/class/stripe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index d60b084ff39..a520e83f0ee 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -411,7 +411,7 @@ class Stripe extends CommonObject } if (!empty($conf->global->STRIPE_KLARNA)) { $paymentmethodtypes[] = "klarna"; - } + } if (!empty($conf->global->STRIPE_BANCONTACT)) { $paymentmethodtypes[] = "bancontact"; } @@ -609,7 +609,7 @@ class Stripe extends CommonObject } if (!empty($conf->global->STRIPE_KLARNA)) { $paymentmethodtypes[] = "klarna"; - } + } if (!empty($conf->global->STRIPE_IDEAL)) { $paymentmethodtypes[] = "ideal"; } From 715a65eab25ef3fdb932c0c31763dc1be5bd62d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Nov 2021 13:33:59 +0100 Subject: [PATCH 424/490] Clean code for md theme --- htdocs/admin/modulehelp.php | 3 +++ htdocs/core/class/html.form.class.php | 3 ++- htdocs/main.inc.php | 2 +- htdocs/theme/md/style.css.php | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index f0211d1b795..da76f01fd6c 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -70,6 +70,9 @@ print ''."\n".''; $arrayofnatures = array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fb0bba95ac4..92dba4d4de0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4905,8 +4905,9 @@ class Form $formconfirm .= ($question ? '
    '.img_help('', '').' '.$question.'
    ' : ''); $formconfirm .= ''."\n"; - $formconfirm .= "\n\n"; + $formconfirm .= "\n\n"; $formconfirm .= ''; - if (!empty($hidemargininfos)) { - print ''; + if (!empty($hidemargininfos)) { + print ''; + } } - } - print '
    '; - print ''."\n"; + print '
    '; + print '' . "\n"; - print ''; - print ''; - print ''; - print ''; - if ($conf->global->MARGIN_TYPE == "1") { - print ''; - } else { - print ''; - } - print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { - print ''; - } - if (!empty($conf->global->DISPLAY_MARK_RATES)) { - print ''; - } - print ''; - - if (!empty($conf->product->enabled)) { - //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { - print ''; - print ''; - print ''; - print ''; - print ''; + print '
    '.$langs->trans('Margins').''.$langs->trans('SellingPrice').''.$langs->trans('BuyingPrice').''.$langs->trans('CostPrice').''.$langs->trans('Margin').''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').'
    '.$langs->trans('MarginOnProducts').''.price($marginInfo['pv_products']).''.price($marginInfo['pa_products']).''.price($marginInfo['margin_on_products']).'
    '; + print ''; + print ''; + print ''; + if ($conf->global->MARGIN_TYPE == "1") { + print ''; + } else { + print ''; + } + print ''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { - print ''; + print ''; } if (!empty($conf->global->DISPLAY_MARK_RATES)) { - print ''; + print ''; } print ''; - } - if (!empty($conf->service->enabled)) { - print ''; - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { - print ''; + if (!empty($conf->product->enabled)) { + //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { + print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { + print ''; + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { + print ''; + } + print ''; } - if (!empty($conf->global->DISPLAY_MARK_RATES)) { - print ''; - } - print ''; - } - if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { - print ''; - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { - print ''; + if (!empty($conf->service->enabled)) { + print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { + print ''; + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { + print ''; + } + print ''; } - if (!empty($conf->global->DISPLAY_MARK_RATES)) { - print ''; + + if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { + print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { + print ''; + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { + print ''; + } + print ''; } - print ''; + print $hookmanager->resPrint; + print '
    ' . $langs->trans('Margins') . '' . $langs->trans('SellingPrice') . '' . $langs->trans('BuyingPrice') . '' . $langs->trans('CostPrice') . '' . $langs->trans('Margin') . ''.(($marginInfo['margin_rate_products'] == '') ? '' : price($marginInfo['margin_rate_products'], null, null, null, null, 2).'%').'' . $langs->trans('MarginRate') . ''.(($marginInfo['mark_rate_products'] == '') ? '' : price($marginInfo['mark_rate_products'], null, null, null, null, 2).'%').'' . $langs->trans('MarkRate') . '
    '.$langs->trans('MarginOnServices').''.price($marginInfo['pv_services']).''.price($marginInfo['pa_services']).''.price($marginInfo['margin_on_services']).''.(($marginInfo['margin_rate_services'] == '') ? '' : price($marginInfo['margin_rate_services'], null, null, null, null, 2).'%').'
    ' . $langs->trans('MarginOnProducts') . '' . price($marginInfo['pv_products']) . '' . price($marginInfo['pa_products']) . '' . price($marginInfo['margin_on_products']) . '' . (($marginInfo['margin_rate_products'] == '') ? '' : price($marginInfo['margin_rate_products'], null, null, null, null, 2) . '%') . '' . (($marginInfo['mark_rate_products'] == '') ? '' : price($marginInfo['mark_rate_products'], null, null, null, null, 2) . '%') . '
    '.(($marginInfo['mark_rate_services'] == '') ? '' : price($marginInfo['mark_rate_services'], null, null, null, null, 2).'%').'
    '.$langs->trans('TotalMargin').''.price($marginInfo['pv_total']).''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').'
    ' . $langs->trans('MarginOnServices') . '' . price($marginInfo['pv_services']) . '' . price($marginInfo['pa_services']) . '' . price($marginInfo['margin_on_services']) . '' . (($marginInfo['margin_rate_services'] == '') ? '' : price($marginInfo['margin_rate_services'], null, null, null, null, 2) . '%') . '' . (($marginInfo['mark_rate_services'] == '') ? '' : price($marginInfo['mark_rate_services'], null, null, null, null, 2) . '%') . '
    '.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'
    ' . $langs->trans('TotalMargin') . '' . price($marginInfo['pv_total']) . '' . price($marginInfo['pa_total']) . '' . price($marginInfo['total_margin']) . '' . (($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2) . '%') . '' . (($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2) . '%') . '
    '; + print '
    '; + } elseif ($reshook > 0) { + print $hookmanager->resPrint; } - print '
    '; - print ''; } } From 0f402897a47f45cb2cbe5a821dcedd79b17e7caa Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 18 Nov 2021 10:55:05 +0100 Subject: [PATCH 479/490] add add_replace --- htdocs/core/class/hookmanager.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 691c20e10f8..c113f2c3bb9 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -230,7 +230,8 @@ class HookManager 'setContentSecurityPolicy', 'setHtmlTitle', 'completeTabsHead', - 'formDolBanner' + 'formDolBanner', + 'displayMarginInfos', ) )) { $hooktype = 'addreplace'; From ef447bacbffb5d71914ec70b7eac924b53bb7a2a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 18 Nov 2021 12:12:30 +0100 Subject: [PATCH 480/490] NEW add form confirm hook in paiement card --- htdocs/compta/paiement.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 2740b09427a..fbb6abdedae 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -802,6 +802,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie dol_print_error($db); } + $formconfirm = ''; // Save button if ($action != 'add_paiement') { @@ -840,7 +841,16 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $text .= '
    '.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); print ''; } - print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm); + $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 "\n"; From cdde6ecf94bd381432a4d5ce08e50040ca137e22 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 18 Nov 2021 12:17:02 +0100 Subject: [PATCH 481/490] NEW add form confirm hook in paiement card --- htdocs/compta/paiement.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index fbb6abdedae..29682460d3a 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -853,6 +853,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $formconfirm = $hookmanager->resPrint; } + // Print form confirm + print $formconfirm; + print "\n"; } } From e652b93878f1f5615849223615e60bd212e2617a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 12:58:31 +0100 Subject: [PATCH 482/490] Autoswitch on inventory tab on validation of inventory Fix disabled button when some data are available. --- htdocs/core/actions_addupdatedelete.inc.php | 11 ++++++ htdocs/core/class/commonobject.class.php | 6 ++- htdocs/langs/en_US/stocks.lang | 2 + htdocs/product/inventory/card.php | 7 ++++ .../inventory/class/inventory.class.php | 14 +++---- htdocs/product/inventory/inventory.php | 39 ++++++++++++------- 6 files changed, 57 insertions(+), 22 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 10d25b2aa09..4857902b8cc 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -140,6 +140,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { header("Location: ".$urltogo); exit; } else { + $error++; // Creation KO if (!empty($object->errors)) { setEventMessages(null, $object->errors, 'errors'); @@ -255,6 +256,7 @@ if ($action == 'update' && !empty($permissiontoadd)) { if ($result > 0) { $action = 'view'; } else { + $error++; // Creation KO setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; @@ -284,6 +286,7 @@ if ($action == "update_extras" && !empty($permissiontoadd)) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); $action = 'view'; } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit_extras'; } @@ -301,9 +304,11 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) { if ($result > 0) { // Delete OK setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".$backurlforlist); exit; } else { + $error++; if (!empty($object->errors)) { setEventMessages(null, $object->errors, 'errors'); } else { @@ -347,6 +352,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } $action = ''; @@ -383,6 +389,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { } } } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } $action = ''; @@ -414,6 +421,7 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) { } } } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } $action = ''; @@ -425,6 +433,7 @@ if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) { if ($result >= 0) { // Nothing else done } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } $action = ''; @@ -456,6 +465,7 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) { } } } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } $action = ''; @@ -481,6 +491,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object exit; } else { + $error++; setEventMessages($objectutil->error, $objectutil->errors, 'errors'); $action = ''; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 812353591ed..aed5bc9515f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8730,7 +8730,11 @@ abstract class CommonObject $res = $this->db->query($sql); if ($res === false) { $error++; - $this->errors[] = $this->db->lasterror(); + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $this->errors[] = "ErrorRefAlreadyExists"; + } else { + $this->errors[] = $this->db->lasterror(); + } } } diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 19875f55148..2fa24d467ca 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -264,3 +264,5 @@ ProductBatchDoesNotExist=Product with batch/serial does not exist ProductBarcodeDoesNotExist=Product with barcode does not exist WarehouseId=Warehouse ID WarehouseRef=Warehouse Ref +SaveQtyFirst=Save the real inventoried quantities first, before asking creation of the stock movement. +InventoryStartedShort=Started \ No newline at end of file diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 91edba380cd..1f036e1fa3c 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -109,6 +109,7 @@ if ($reshook < 0) { } if (empty($reshook)) { + $savaction = $action; $error = 0; $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; @@ -152,6 +153,12 @@ if (empty($reshook)) { $autocopy = 'MAIN_MAIL_AUTOCOPY_INVENTORY_TO'; $trackid = 'stockinv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + + if (!$error && $savaction == 'confirm_validate' && $action == '' && $object->id > 0) { + // Switch to the tab inventory + header("Location: ".DOL_URL_ROOT.'/product/inventory/inventory.php?id='.$object->id); + exit; + } } diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 57abc333a58..3e83d62ecf2 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -59,10 +59,10 @@ class Inventory extends CommonObject */ public $picto = 'inventory'; - const STATUS_DRAFT = 0; - const STATUS_VALIDATED = 1; - const STATUS_RECORDED = 2; - const STATUS_CANCELED = 9; + const STATUS_DRAFT = 0; // Draft + const STATUS_VALIDATED = 1; // Inventory is in process + const STATUS_RECORDED = 2; // Inventory is finisged. Stock movement has been recorded. + const STATUS_CANCELED = 9; // Canceled /** * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') @@ -368,7 +368,7 @@ class Inventory extends CommonObject } /** - * Set to Recorded + * Set to inventory to status "Closed". It means all stock movements were recorded. * * @param User $user User that creates * @param bool $notrigger false=launch triggers after, true=disable triggers @@ -616,11 +616,11 @@ class Inventory extends CommonObject $labelStatus = array(); $labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated').' ('.$langs->transnoentitiesnoconv('Started').')'; + $labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated').' ('.$langs->transnoentitiesnoconv('InventoryStartedShort').')'; $labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); $labelStatus[self::STATUS_RECORDED] = $langs->transnoentitiesnoconv('Closed'); $labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Started'); + $labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('InventoryStartedShort'); $labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); $labelStatusShort[self::STATUS_RECORDED] = $langs->transnoentitiesnoconv('Closed'); diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 9a4d61209ba..ce657f1c9d6 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -310,20 +310,22 @@ $help_url = ''; llxHeader('', $langs->trans('Inventory'), $help_url); -// Disable button Generate movement if data were not saved +// Disable button Generate movement if data were modified and not saved print ''; @@ -639,12 +640,14 @@ if ($object->id > 0) { //Call method to undo changes in real qty print ''; @@ -667,7 +670,7 @@ if ($object->id > 0) { print ''; } print ''.$langs->trans("ExpectedQty").''; - print ''; + print ''; print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); print ''; if ($object->status == $object::STATUS_VALIDATED) { @@ -692,7 +695,7 @@ if ($object->id > 0) { print ''; } print ''; - print ''; + print ''; print ''; print ''; // Actions @@ -764,17 +767,22 @@ if ($object->id > 0) { print ''; // Real quantity - print ''; + print ''; if ($object->status == $object::STATUS_VALIDATED) { $qty_view = GETPOST("id_".$obj->rowid) && price2num(GETPOST("id_".$obj->rowid), 'MS') >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view; - if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) { + + //if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) { + if ($qty_view != '') { $hasinput = true; } + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; print ''; print ''; + print ''; - print '  '; print ''.img_delete().''; print ''; $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; @@ -801,10 +809,13 @@ if ($object->id > 0) { print ''; + // Call method to disable the button if no qty entered yet for inventory + if ($object->status != $object::STATUS_VALIDATED || !$hasinput) { print ''; From 2d4f971508bc6b9d797d529ed31782d4beb5943f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 13:10:52 +0100 Subject: [PATCH 483/490] Fix verifCond must return false if string is '0' Hide a not used property. --- htdocs/core/lib/functions.lib.php | 10 +++++----- htdocs/product/inventory/class/inventory.class.php | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 48fcdaa5010..7d8d7c5bc7b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8132,10 +8132,10 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = /** * Verify if condition in string is ok or not * - * @param string $strRights String with condition to check - * @return boolean True or False. Return True if strRights is '' + * @param string $strToEvaluate String with condition to check + * @return boolean True or False. Note: It returns True if $strToEvaluate is '' */ -function verifCond($strRights) +function verifCond($strToEvaluate) { global $user, $conf, $langs; global $leftmenu; @@ -8143,8 +8143,8 @@ function verifCond($strRights) //print $strRights."
    \n"; $rights = true; - if ($strRights != '') { - $str = 'if(!('.$strRights.')) { $rights = false; }'; + if ($strToEvaluate !== '') { + $str = 'if(!('.$strToEvaluate.')) { $rights = false; }'; dol_eval($str); // The dol_eval must contains all the global $xxx used into a condition } return $rights; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 3e83d62ecf2..b224667f1c6 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -101,8 +101,7 @@ class Inventory extends CommonObject 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), - 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>1, 'position'=>35), - + 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>0, 'position'=>35), // This date is not used so disabled. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), 'date_validation' => array('type'=>'datetime', 'label'=>'DateValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>502), From 2a39a1dc9382262653b5ef7651c8533dd3cf2f90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 13:55:55 +0100 Subject: [PATCH 484/490] Keep option to enable field --- htdocs/product/inventory/class/inventory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index b224667f1c6..b972e44245b 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -101,7 +101,7 @@ class Inventory extends CommonObject 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), - 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>0, 'position'=>35), // This date is not used so disabled. + 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), 'date_validation' => array('type'=>'datetime', 'label'=>'DateValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>502), From 0649dc598dd4dc77204f33d3448ef1ed4a6f5a8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 19:25:07 +0100 Subject: [PATCH 485/490] Clean code --- htdocs/core/class/conf.class.php | 49 ++++++++++--------- .../doc/doc_generic_usergroup_odt.modules.php | 2 +- htdocs/cron/class/cronjob.class.php | 16 +++--- htdocs/user/group/card.php | 4 +- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 59045725d06..be4006f1fca 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -110,10 +110,12 @@ class Conf // Common objects that are not modules $this->mycompany = new stdClass(); $this->admin = new stdClass(); - $this->browser = new stdClass(); $this->medias = new stdClass(); $this->global = new stdClass(); + // Common objects that are not modules and set by the main and not into the this->setValues() + $this->browser = new stdClass(); + $this->cache = array(); $this->modules = array(); $this->modules_parts = array( @@ -152,7 +154,6 @@ class Conf $this->facture = new stdClass(); $this->contrat = new stdClass(); $this->user = new stdClass(); - $this->usergroup = new stdClass(); $this->adherent = new stdClass(); $this->bank = new stdClass(); $this->notification = new stdClass(); @@ -162,18 +163,18 @@ class Conf } /** - * Load setup values into conf object (read llx_const) for a specified entity - * Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called. + * Load setup values into conf object (read llx_const) for a specified entity + * Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called. * - * @param DoliDB $db Database handler * @param int $entity Entity to get * @return int < 0 if KO, >= 0 if OK */ - public function setEntityValues($db, $entity) + public function setEntityValues($entity) { if ($this->entity != $entity) { + // If we ask to reload setup for a new entity $this->entity = $entity; - return $this->setValues($db); + return $this->setValues($this->db); } return 0; @@ -197,31 +198,39 @@ class Conf } } - // Properly declare multi-modules objects. - $this->global = new stdClass(); - $this->multicompany = new stdClass(); + // Common objects that are not modules + $this->mycompany = new stdClass(); + $this->admin = new stdClass(); + $this->medias = new stdClass(); + $this->global = new stdClass(); + + // Common objects that are not modules and set by the main and not into the this->setValues() + //$this->browser = new stdClass(); // This is set by main and not into this setValues(), so we keep it intact. // First level object // TODO Remove this part. - $this->expedition_bon = new stdClass(); - $this->delivery_note = new stdClass(); - $this->fournisseur = new stdClass(); + $this->syslog = new stdClass(); + $this->expedition_bon = new stdClass(); + $this->delivery_note = new stdClass(); + $this->fournisseur = new stdClass(); $this->product = new stdClass(); $this->service = new stdClass(); $this->contrat = new stdClass(); $this->actions = new stdClass(); $this->agenda = new stdClass(); - $this->commande = new stdClass(); - $this->propal = new stdClass(); + $this->commande = new stdClass(); + $this->propal = new stdClass(); $this->facture = new stdClass(); $this->contrat = new stdClass(); - $this->usergroup = new stdClass(); + $this->user = new stdClass(); $this->adherent = new stdClass(); - $this->bank = new stdClass(); + $this->bank = new stdClass(); $this->notification = new stdClass(); - $this->mailing = new stdClass(); + $this->mailing = new stdClass(); $this->expensereport = new stdClass(); $this->productbatch = new stdClass(); + + $this->cache = array(); $this->modules = array();; $this->modules_parts = array( 'css' => array(), @@ -470,10 +479,6 @@ class Conf $this->user->dir_output = $rootforuser."/users"; $this->user->dir_temp = $rootfortemp."/users/temp"; - // For usergroup storage - $this->usergroup->dir_output = $rootforuser."/usergroups"; - $this->usergroup->dir_temp = $rootfortemp."/usergroups/temp"; - // For proposal storage $this->propal->multidir_output = array($this->entity => $rootfordata."/propale"); $this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp"); diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 134c5e00362..a934c7a50d9 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -258,7 +258,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup } } - $dir = $conf->usergroup->dir_output; + $dir = $conf->user->dir_output.'/usergroups'; $objectref = dol_sanitizeFileName($object->ref); if (!preg_match('/specimen/i', $objectref)) { $dir .= "/".$objectref; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 44564e1b0ab..34fe7b6cd58 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1081,7 +1081,7 @@ class Cronjob extends CommonObject dol_syslog("We try to run a job in entity ".$this->entity." when we are in entity ".$conf->entity, LOG_WARNING); } $savcurrententity = $conf->entity; - $conf->setEntityValues($this->db, $this->entity); + $conf->setEntityValues($this->entity); dol_syslog(get_class($this)."::run_jobs entity for running job is ".$conf->entity); require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -1090,13 +1090,13 @@ class Cronjob extends CommonObject if ($result < 0) { $this->error = "User Error:".$user->error; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($this->db, $savcurrententity); + $conf->setEntityValues($savcurrententity); return -1; } else { if (empty($user->id)) { $this->error = " User user login:".$userlogin." do not exists"; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($this->db, $savcurrententity); + $conf->setEntityValues($savcurrententity); return -1; } } @@ -1126,7 +1126,7 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($this->db, $savcurrententity); + $conf->setEntityValues($savcurrententity); return -1; } @@ -1241,7 +1241,7 @@ class Cronjob extends CommonObject if ($ret === false) { $this->error = $langs->trans('CronCannotLoadLib').': '.$libpath; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($this->db, $savcurrententity); + $conf->setEntityValues($savcurrententity); return -1; } @@ -1250,7 +1250,7 @@ class Cronjob extends CommonObject $result = $langs->load($this->module_name.'@'.$this->module_name); // If this->module_name was an existing language file, this will make nothing if ($result < 0) { // If technical error dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR); - $conf->setEntityValues($this->db, $savcurrententity); + $conf->setEntityValues($savcurrententity); return -1; } @@ -1316,11 +1316,11 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($this->db, $savcurrententity); + $conf->setEntityValues($savcurrententity); return -1; } - $conf->setEntityValues($this->db, $savcurrententity); + $conf->setEntityValues($savcurrententity); return $error ?-1 : 1; } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 3e1f31602b2..f24c4232a8e 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -237,7 +237,7 @@ if (empty($reshook)) { } // Actions to build doc - $upload_dir = $conf->usergroup->dir_output; + $upload_dir = $conf->user->dir_output.'/usergroups'; $permissiontoadd = $user->rights->user->user->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -478,7 +478,7 @@ if ($action == 'create') { */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->usergroup->dir_output."/".dol_sanitizeFileName($object->ref); + $filedir = $conf->user->dir_output."/usergroups/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->user->user->creer; $delallowed = $user->rights->user->user->supprimer; From d24120d6f9e6cb2d0927035fe4cab16b144e57e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 19:27:40 +0100 Subject: [PATCH 486/490] Clean code --- htdocs/core/class/conf.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index be4006f1fca..8776060b60f 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -116,6 +116,7 @@ class Conf // Common objects that are not modules and set by the main and not into the this->setValues() $this->browser = new stdClass(); + // Common arrays $this->cache = array(); $this->modules = array(); $this->modules_parts = array( @@ -230,6 +231,7 @@ class Conf $this->expensereport = new stdClass(); $this->productbatch = new stdClass(); + // Common arrays $this->cache = array(); $this->modules = array();; $this->modules_parts = array( From e81c118a27233a40de22919863b37c26ba34b660 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 19:38:56 +0100 Subject: [PATCH 487/490] FIX Use the SQL standard for the if confition --- htdocs/core/db/DoliDB.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 1ebea289470..daa5f657549 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -77,7 +77,8 @@ abstract class DoliDB implements Database */ public function ifsql($test, $resok, $resko) { - return 'IF('.$test.','.$resok.','.$resko.')'; + //return 'IF('.$test.','.$resok.','.$resko.')'; // Not sql standard + return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; } /** From 9789ae23d78f5b6a1090259be7800761954d0b2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 20:12:46 +0100 Subject: [PATCH 488/490] Update llx_c_paiement.sql --- htdocs/install/mysql/data/llx_c_paiement.sql | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_paiement.sql b/htdocs/install/mysql/data/llx_c_paiement.sql index a7156b6d6da..e29b47639f2 100644 --- a/htdocs/install/mysql/data/llx_c_paiement.sql +++ b/htdocs/install/mysql/data/llx_c_paiement.sql @@ -30,18 +30,18 @@ -- Types paiement -- -insert into llx_c_paiement (id,code,libelle,type,active) values ( 1, 'TIP', 'TIP', 2,0); -insert into llx_c_paiement (id,code,libelle,type,active) values ( 2, 'VIR', 'Transfer', 2,1); -insert into llx_c_paiement (id,code,libelle,type,active) values ( 3, 'PRE', 'Debit order', 2,1); -insert into llx_c_paiement (id,code,libelle,type,active) values ( 4, 'LIQ', 'Cash', 2,1); -insert into llx_c_paiement (id,code,libelle,type,active) values ( 6, 'CB', 'Credit card', 2,1); -insert into llx_c_paiement (id,code,libelle,type,active) values ( 7, 'CHQ', 'Cheque', 2,1); -insert into llx_c_paiement (id,code,libelle,type,active) values (50, 'VAD', 'Online payment', 2,0); -insert into llx_c_paiement (id,code,libelle,type,active) values (51, 'TRA', 'Traite', 2,0); -insert into llx_c_paiement (id,code,libelle,type,active) values (52, 'LCR', 'LCR', 2,0); -insert into llx_c_paiement (id,code,libelle,type,active) values (53, 'FAC', 'Factor', 2,0); -INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (100, 'KLA', 'Klarna', 1,1); -INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (101, 'SOF', 'Sofort', 1,1); -INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (102, 'BAN', 'Bancontact', 1,1); -INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (103, 'IDE', 'iDeal', 1,1); -INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (104, 'GIR', 'Giropay', 1,1); +insert into llx_c_paiement (id,code,libelle,type,active) values ( 1, 'TIP', 'TIP', 2, 0); +insert into llx_c_paiement (id,code,libelle,type,active) values ( 2, 'VIR', 'Transfer', 2, 1); +insert into llx_c_paiement (id,code,libelle,type,active) values ( 3, 'PRE', 'Debit order', 2, 1); +insert into llx_c_paiement (id,code,libelle,type,active) values ( 4, 'LIQ', 'Cash', 2, 1); +insert into llx_c_paiement (id,code,libelle,type,active) values ( 6, 'CB', 'Credit card', 2, 1); +insert into llx_c_paiement (id,code,libelle,type,active) values ( 7, 'CHQ', 'Cheque', 2, 1); +insert into llx_c_paiement (id,code,libelle,type,active) values (50, 'VAD', 'Online payment', 2, 0); +insert into llx_c_paiement (id,code,libelle,type,active) values (51, 'TRA', 'Traite', 2, 0); +insert into llx_c_paiement (id,code,libelle,type,active) values (52, 'LCR', 'LCR', 2, 0); +insert into llx_c_paiement (id,code,libelle,type,active) values (53, 'FAC', 'Factor', 2, 0); +INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (100, 'KLA', 'Klarna', 1, 0); +INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (101, 'SOF', 'Sofort', 1, 0); +INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (102, 'BAN', 'Bancontact', 1, 0); +INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (103, 'IDE', 'iDeal', 1, 0); +INSERT INTO llx_c_paiement (id,code,libelle,type,active) values (104, 'GIR', 'Giropay', 1, 0); From 2afe6ccb4b4b5e5736a3a9bdd056576199179a99 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 21:26:35 +0100 Subject: [PATCH 489/490] Debug feature shown/hide canceled orders --- htdocs/langs/en_US/main.lang | 4 +++- htdocs/langs/en_US/projects.lang | 2 -- htdocs/projet/element.php | 38 +++++++++++++++++++------------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a0b9fda9f64..f765340af4f 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1158,4 +1158,6 @@ Properties=Properties hasBeenValidated=%s has been validated ClientTZ=Client Time Zone (user) NotClosedYet=Not yet closed -ClearSignature=Signature reset \ No newline at end of file +ClearSignature=Signature reset +CanceledHidden=Canceled hidden +CanceledShown=Canceled shown diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index e9e626dd7fc..c19f32a0396 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -37,8 +37,6 @@ OpportunitiesStatusForOpenedProjects=Leads amount of open projects by status OpportunitiesStatusForProjects=Leads amount of projects by status ShowProject=Show project ShowTask=Show task -ShowCanceled=Show canceled -HideCanceled=Hide canceled SetProject=Set project NoProject=No project defined or owned NbOfProjects=Number of projects diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 05b7f962509..e455d6f599f 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1016,6 +1016,9 @@ foreach ($listofreferent as $key => $value) { } } + $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 'fk_projet'); + + if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) { $selectList = $formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300 minwidth75imp', -2, !empty($project_field) ? $project_field : 'fk_projet'); if ($selectList < 0) { @@ -1046,23 +1049,29 @@ foreach ($listofreferent as $key => $value) { } $addform .= '
    '; } - if ($key == "order_supplier") { - $addform .= ' - '.$langs->trans("ShowCanceled").' + if (is_array($elementarray) && !count($elementarray) > 0 && $key == "order_supplier") { + $addform = '
    + '.$langs->trans("CanceledShown").' '; +
    '.$addform; } print load_fiche_titre($langs->trans($title), $addform, ''); @@ -1131,7 +1140,6 @@ foreach ($listofreferent as $key => $value) { } print ''; - $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 'fk_projet'); if (is_array($elementarray) && count($elementarray) > 0) { $total_ht = 0; $total_ttc = 0; @@ -1186,12 +1194,12 @@ foreach ($listofreferent as $key => $value) { if (!empty($element->close_code) && $element->close_code == 'replaced') { $qualifiedfortotal = false; // Replacement invoice, do not include into total } - } elseif (($key == 'order_supplier') && ($element->status == 7)) { + } elseif ($key == 'order_supplier' && $element->status == 7) { $qualifiedfortotal = false; // It makes no sense to include canceled orders in the total } - if (($key == "order_supplier") && ($element->status == 7)) { - print ''; + if ($key == "order_supplier" && $element->status == 7) { + print ''; } else { print ''; } From 92b0fde4ca1da50cd9d86c27283710ac7599bb02 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 21:37:33 +0100 Subject: [PATCH 490/490] Debug v15 --- htdocs/langs/en_US/salaries.lang | 1 + htdocs/salaries/ajax/ajaxsalaries.php | 8 ++++++- htdocs/salaries/card.php | 2 +- htdocs/theme/md/style.css.php | 30 ++++++++++++++++----------- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index c0e115a20df..20a10694500 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -24,3 +24,4 @@ SalariesStatistics=Salary statistics SalariesAndPayments=Salaries and payments ConfirmDeleteSalaryPayment=Do you want to delete this salary payment ? FillFieldFirst=Fill employee field first +UpdateAmountWithLastSalary=Set amount with last salary diff --git a/htdocs/salaries/ajax/ajaxsalaries.php b/htdocs/salaries/ajax/ajaxsalaries.php index dc7715ff6ba..adea28ee8ce 100644 --- a/htdocs/salaries/ajax/ajaxsalaries.php +++ b/htdocs/salaries/ajax/ajaxsalaries.php @@ -47,8 +47,14 @@ require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; restrictedArea($user, 'salaries'); + +/* + * View + */ + $fk_user = GETPOST('fk_user', 'int'); $return_arr = array(); + if (!empty(GETPOST('fk_user', 'int'))) { $sql = "SELECT s.amount, s.rowid FROM ".MAIN_DB_PREFIX."salary as s"; $sql .= " WHERE s.fk_user = ".((int) $fk_user); @@ -60,7 +66,7 @@ if (!empty(GETPOST('fk_user', 'int'))) { $obj = $db->fetch_object($resql); $label = "Salary amount"; $row_array['label'] = $label; - $row_array['value'] = $obj->amount; + $row_array['value'] = price2num($obj->amount, 'MT'); $row_array['key'] = "Amount"; array_push($return_arr, $row_array); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 3caf2afa7bd..b0abeeb134a 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -668,7 +668,7 @@ if ($action == 'create') { ); } else { - alert("'.$langs->trans("FillFieldFirst").'"); + alert("'.dol_escape_js($langs->trans("FillFieldFirst")).'"); } }); diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5ea2e6c0529..a2d912d46e6 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -657,6 +657,10 @@ input:-webkit-autofill { -webkit-box-shadow: 0 0 0 50px #FBFFEA inset; } +input[type=checkbox], input[type=radio] { + margin: 0 3px 0 3px; +} + /* CSS for placeholder */ .placeholder { color: #ccc; } ::-webkit-input-placeholder { color:#ccc; } @@ -922,6 +926,19 @@ textarea.centpercent { .marginright2 { margin-: 2px; } +.paddingtop { + padding-top: 4px; +} +.paddingtop2 { + padding-top: 2px; +} +.paddingbottom { + padding-bottom: 4px; +} +.paddingbottom2 { + padding-bottom: 2px; +} + .cursordefault { cursor: default; } @@ -3324,18 +3341,7 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd .smallpaddingimp { padding: 4px !important; } -.nopaddingleft { - padding-: 0px; -} -.nopaddingright { - padding-: 0px; -} -.nopaddingtopimp { - padding-top: 0px !important; -} -.nopaddingbottomimp { - padding-bottom: 0px !important; -} + .notopnoleft { border-collapse: collapse; border: 0px;