From 7e174412b7dc20f0885fd8c3f807a903466d2b11 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 7 Jul 2021 10:30:01 +0200 Subject: [PATCH 1/9] FIX display of extrafields on shipping lines --- htdocs/core/class/commonobject.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 64fdb956ab0..b3ae722a5d3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7492,6 +7492,9 @@ abstract class CommonObject if ($display_type == 'card') { $out .= ''; + if ( ! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ) { + $out .= ''; + } $out .= ''; From 0e2c57fe65734dddf69590c7997b22a5c17aa1f3 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 7 Jul 2021 14:50:10 +0200 Subject: [PATCH 2/9] Fix php 8 warning on user page --- htdocs/core/lib/usergroups.lib.php | 4 ++-- htdocs/user/bank.php | 3 +-- htdocs/user/card.php | 7 +++++-- htdocs/user/clicktodial.php | 4 +++- htdocs/user/notify/card.php | 2 +- htdocs/user/param_ihm.php | 10 ++++++---- htdocs/user/perms.php | 2 +- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index cd9ae5ad297..29f208e5254 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -906,7 +906,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // Use MAIN_OPTIMIZEFORTEXTBROWSER - if ($foruserprofile) { + if ($foruserprofile && !empty($fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) { //$default=yn($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER); $default = $langs->trans('No'); print ''; @@ -953,7 +953,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // Use MAIN_OPTIMIZEFORTEXTBROWSER - if ($foruserprofile) { + if ($foruserprofile && !empty($fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND)) { //$default=yn($conf->global->MAIN_OPTIMIZEFORCOLORBLIND); $default = $langs->trans('No'); print ''; diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index fc9002e13fb..0eaf3d533a9 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -506,7 +506,6 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac $exp->id = $objp->rowid; $exp->ref = $objp->ref; - $exp->fk_type = $objp->fk_type; $exp->status = $objp->status; print ''; @@ -557,7 +556,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac print_liste_field_titre("RIB"); print_liste_field_titre("IBAN"); print_liste_field_titre("BIC"); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch '); print "\n"; if ($account->id > 0) { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 1efbdb18714..92284d45e1c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1451,8 +1451,11 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.$langs->trans("None").''; } else { $huser = new User($db); - $huser->fetch($object->fk_user); - print $huser->getNomUrl(1); + if ($huser->fetch($object->fk_user) > 0) { + print $huser->getNomUrl(1); + } else { + print ''.$langs->trans("None").''; + } } print ''; print "\n"; diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 0a9a65a2852..79450f2d811 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -150,7 +150,9 @@ if ($id > 0) { if (!empty($user->admin)) { print 'ClickToDial URL'; print ''; - $url = $conf->global->CLICKTODIAL_URL; + if (!empty($conf->global->CLICKTODIAL_URL)) { + $url = $conf->global->CLICKTODIAL_URL; + } if (!empty($object->clicktodial_url)) { $url = $object->clicktodial_url; } diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 978c2d990b7..4ef62f25ab5 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -437,7 +437,7 @@ if ($result > 0) { } print '
'; - if ($optioncss != '') { + if (!empty($optioncss)) { print ''; } print ''; diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index b492e31177f..72f9b075be9 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -370,10 +370,12 @@ if ($action == 'edit') { print empty($dolibarr_main_demo) ? '' : ' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; - if (!empty($tmparray[$object->conf->MAIN_LANDING_PAGE])) { - print $langs->trans($tmparray[$object->conf->MAIN_LANDING_PAGE]); - } else { - print $object->conf->MAIN_LANDING_PAGE; + if (!empty($object->conf->MAIN_LANDING_PAGE)) { + if (!empty($tmparray[$object->conf->MAIN_LANDING_PAGE])) { + print $langs->trans($tmparray[$object->conf->MAIN_LANDING_PAGE]); + } else { + print $object->conf->MAIN_LANDING_PAGE; + } } //print $form->selectarray('MAIN_LANDING_PAGE', $tmparray, (! empty($object->conf->MAIN_LANDING_PAGE)?$object->conf->MAIN_LANDING_PAGE:''), 0, 0, 0, '', 1); print ''; diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 2136d0f07c5..957c7a3a819 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -407,7 +407,7 @@ if ($result) { print ''; print img_picto($langs->trans("Active"), 'tick'); print ''; - } elseif (is_array($permsgroupbyentity[$entity])) { + } elseif (isset($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) { if (in_array($obj->id, $permsgroupbyentity[$entity])) { // Permission granted by group if ($caneditperms) { print ''; From a94218312737171b27da53ce8cd7fe841937e8dd Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 7 Jul 2021 15:02:00 +0200 Subject: [PATCH 3/9] better fix for optioncss --- htdocs/user/notify/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 4ef62f25ab5..3acad0ac0c3 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -437,7 +437,7 @@ if ($result > 0) { } print ''; - if (!empty($optioncss)) { + if (isset($optioncss) && $optioncss != '') { print ''; } print ''; From d6c327ed857c497335558bba0504142fe91b7fc1 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 8 Jul 2021 13:17:07 +0200 Subject: [PATCH 4/9] Remove duplicate code --- htdocs/product/class/product.class.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 0ac8cba1391..28bf0288c7b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5282,17 +5282,6 @@ class Product extends CommonObject } $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; } - if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) { - $filterStatus = '4'; - if (isset($includedraftpoforvirtual)) { - $filterStatus = '0,'.$filterStatus; - } - $result = $this->load_stats_reception(0, $filterStatus, 1); - if ($result < 0) { - dol_print_error($this->db, $this->error); - } - $stock_reception_fournisseur = $this->stats_reception['qty']; - } if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) { $filterStatus = '4'; if (isset($includedraftpoforvirtual)) { From 7870336f2a2cd17b59ce2c7100c74390f77ebe85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 16:31:01 +0200 Subject: [PATCH 5/9] Update card.php --- htdocs/user/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 92284d45e1c..152c39f79ac 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1451,7 +1451,8 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.$langs->trans("None").''; } else { $huser = new User($db); - if ($huser->fetch($object->fk_user) > 0) { + if ($object->fk_user > 0) { + $huser->fetch($object->fk_user); print $huser->getNomUrl(1); } else { print ''.$langs->trans("None").''; From 38fac48c300760283b22a3fa594e88b65f495ec0 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Thu, 8 Jul 2021 17:18:47 +0200 Subject: [PATCH 6/9] FIX: in kanban view, Dolibarr says "no updates available" even if updates are available --- htdocs/admin/modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 494dfc2f625..f60e011f41c 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -919,7 +919,6 @@ if ($mode == 'common' || $mode == 'commonkanban') { if ($objMod->needUpdate) { $versionTitle = $langs->trans('ModuleUpdateAvailable').' : '.$objMod->lastVersion; print ''.$versiontrans.''; - $foundoneexternalmodulewithupdate++; } else { print $versiontrans; } @@ -937,6 +936,9 @@ if ($mode == 'common' || $mode == 'commonkanban') { print "\n"; } + if ($objMod->needUpdate) { + $foundoneexternalmodulewithupdate++; + } } if ($action == 'checklastversion') { From e83df923591777399da8e468ac9d1c022a2d61e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 17:24:05 +0200 Subject: [PATCH 7/9] Trans --- htdocs/langs/en_US/banks.lang | 2 +- htdocs/langs/en_US/cashdesk.lang | 2 +- htdocs/langs/en_US/ticket.lang | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index df7192bee25..a0b7942d446 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -115,7 +115,7 @@ TransferTo=To TransferFromToDone=A transfer from %s to %s of %s %s has been recorded. CheckTransmitter=Sender ValidateCheckReceipt=Validate this check receipt? -ConfirmValidateCheckReceipt=Are you sure that you want to submit this check receipt for validation? No changes are possible it's done. +ConfirmValidateCheckReceipt=Are you sure that you want to submit this check receipt for validation? No changes will be possible once validated. DeleteCheckReceipt=Delete this check receipt? ConfirmDeleteCheckReceipt=Are you sure you want to delete this check receipt? BankChecks=Bank checks diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index aba05d67fc8..86fdfd753a5 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -127,4 +127,4 @@ AllowDelayedPayment=Allow delayed payment PrintPaymentMethodOnReceipts=Print payment method on tickets|receipts WeighingScale=Weighing scale ShowPriceHT = Display the column with the price excluding tax (on screen) -ShowPriceHTOnReceipt = Display the column with the price excluding tax (on receipt) +ShowPriceHTOnReceipt = Display the column with the price excluding tax (on the receipt) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index eea045bdc89..3c074688b8e 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -55,7 +55,7 @@ TypeContact_ticket_internal_SUPPORTTEC=Assigned user TypeContact_ticket_external_SUPPORTCLI=Customer contact / incident tracking TypeContact_ticket_external_CONTRIBUTOR=External contributor -OriginEmail=Email reporter +OriginEmail=Reporter Email Notify_TICKET_SENTBYMAIL=Send ticket message by email # Status From 1209253d5791c3e083ec94911870c5e5da543ffe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 18:12:15 +0200 Subject: [PATCH 8/9] Sanitize data --- htdocs/core/class/dolreceiptprinter.class.php | 23 ++++++++++--------- htdocs/core/lib/functions.lib.php | 8 +++++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index c109bc65733..45c87401416 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -390,7 +390,7 @@ class dolReceiptPrinter extends Printer $error = 0; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; $sql .= ' (name, fk_type, fk_profile, parameter, entity)'; - $sql .= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; + $sql .= ' VALUES ("'.$this->db->escape($name).'", '.((int) $type).', '.((int) $profile).', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -415,10 +415,10 @@ class dolReceiptPrinter extends Printer $error = 0; $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; $sql .= ' SET name="'.$this->db->escape($name).'"'; - $sql .= ', fk_type='.$type; - $sql .= ', fk_profile='.$profile; + $sql .= ', fk_type='.((int) $type); + $sql .= ', fk_profile='.((int) $profile); $sql .= ', parameter="'.$this->db->escape($parameter).'"'; - $sql .= ' WHERE rowid='.$printerid; + $sql .= ' WHERE rowid='.((int) $printerid); $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -438,7 +438,7 @@ class dolReceiptPrinter extends Printer global $conf; $error = 0; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE rowid='.$printerid; + $sql .= ' WHERE rowid='.((int) $printerid); $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -480,7 +480,7 @@ class dolReceiptPrinter extends Printer global $conf; $error = 0; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= " WHERE rowid = ".((int) $this->db->escape($templateid)); + $sql .= " WHERE rowid = ".((int) $templateid); $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); if (!$resql) { @@ -505,7 +505,7 @@ class dolReceiptPrinter extends Printer $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; $sql .= ' SET name="'.$this->db->escape($name).'"'; $sql .= ', template="'.$this->db->escape($template).'"'; - $sql .= ' WHERE rowid='.$templateid; + $sql .= ' WHERE rowid='.((int) $templateid); $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -524,6 +524,7 @@ class dolReceiptPrinter extends Printer public function sendTestToPrinter($printerid) { global $conf; + $error = 0; $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png'); //$this->profile = CapabilityProfile::load("TM-T88IV"); @@ -543,7 +544,7 @@ class dolReceiptPrinter extends Printer // If is DummyPrintConnector send to log to debugging if ($this->printer->connector instanceof DummyPrintConnector) { - $data = $this->printer->connector-> getData(); + $data = $this->printer->connector->getData(); dol_syslog($data); } $this->printer->close(); @@ -899,7 +900,7 @@ class dolReceiptPrinter extends Printer public function initPrinter($printerid) { global $conf; - if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { + if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { $this->connector = new DummyPrintConnector(); $this->printer = new Printer($this->connector, $this->profile); return; @@ -934,8 +935,8 @@ class dolReceiptPrinter extends Printer $parameters = explode(':', $parameter); $this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]); break; - case 4: - $this->connector = new WindowsPrintConnector($parameter); + case 4: // LPT1, smb://... + $this->connector = new WindowsPrintConnector(dol_sanitizePathName($parameter)); break; case 5: $this->connector = new CupsPrintConnector($parameter); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 721c553c291..c4a8452d1d1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1075,7 +1075,8 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1) } /** - * Clean a string to use it as a path name + * Clean a string to use it as a path name. + * Replace also '--' and ' -' strings, they are used for parameters separation. * * @param string $str String to clean * @param string $newstr String to replace bad chars with @@ -1087,7 +1088,10 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1) function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1) { $filesystem_forbidden_chars = array('<', '>', '?', '*', '|', '"', '°'); - return dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars); + $tmp = dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars); + $tmp = preg_replace('/\-\-+/', '_', $tmp); + $tmp = preg_replace('/\s+\-/', ' _', $tmp); + return $tmp; } /** From ddc37ef38c6d1450a55ac1ffe3cedb90417854c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 20:58:19 +0200 Subject: [PATCH 9/9] Fix missing lang param --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 82ff19e3771..2647cba166c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1707,9 +1707,9 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print ''."\n"; foreach ($arrayofjs as $jsfile) { if (preg_match('/^(http|\/\/)/i', $jsfile)) { - print ''."\n"; + print ''."\n"; } else { - print ''."\n"; + print ''."\n"; } } }