From af99cab839eeb185b2e40503b25476184b60a976 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Jul 2021 13:46:20 +0200 Subject: [PATCH 1/9] CSS --- htdocs/compta/index.php | 2 +- htdocs/core/boxes/box_factures.php | 2 +- htdocs/core/boxes/box_factures_imp.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 8db217747ef..b1ad18e6461 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -226,7 +226,7 @@ if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { print $thirdpartystatic->getNomUrl(1, 'customer', 44); print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { - print ''.price($obj->total_ht).''; + print ''.price($obj->total_ht).''; } print ''.price($obj->total_ttc).''; print ''.dol_print_date($db->jdate($obj->tms), 'day').''; diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 2a97d738cd8..12382ccb583 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -180,7 +180,7 @@ class box_factures extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', + 'td' => 'class="right nowraponall amount"', 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 391fc2e7cd0..400ae910749 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -182,7 +182,7 @@ class box_factures_imp extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', + 'td' => 'class="nowraponall right amount"', 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); From 0d9cf07035708afe950967d2d62e0fe687a8b2ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Jul 2021 14:07:35 +0200 Subject: [PATCH 2/9] Show ref of invoice into tooltip --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 8cef291c2d7..721a7b92ae8 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1095,7 +1095,7 @@ $( document ).ready(function() { $max_sale = 0; while ($obj = $db->fetch_object($resql)) { echo '$("#customerandsales").append(\''; - echo 'jdate($obj->datec), '%H:%M', 'tzuser'))).'" onclick="place=\\\''; + echo 'jdate($obj->datec), '%H:%M', 'tzuser')).' - '.$obj->ref).'" onclick="place=\\\''; $num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref)); echo $num_sale; if (str_replace("-", "", $num_sale) > $max_sale) { From b12aae4a99459193e93d710cfc242e94fdd02afd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Jul 2021 14:26:32 +0200 Subject: [PATCH 3/9] FIX amount of payment deleted in unalterable log (for old record must look the log of creation to know amount). --- .../interface_50_modBlockedlog_ActionsBlockedLog.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index cab0702c5c1..741cc4d09bc 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -118,6 +118,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers foreach ($object->amounts as $amount) { $amounts += price2num($amount); } + } elseif (!empty($object->amount)) { + $amounts = $object->amount; } } elseif (strpos($action, 'PAYMENT') !== false && !in_array($action, array('PAYMENT_ADD_TO_BANK'))) { $qualified++; From ba8d60f4d4b62b1cd1bda6d5faaeb995b600055d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Jul 2021 14:48:05 +0200 Subject: [PATCH 4/9] FIX amount of payment deleted in unalterable log (for old record must look the log of creation to know amount). --- htdocs/blockedlog/class/blockedlog.class.php | 175 ++++++++++--------- 1 file changed, 88 insertions(+), 87 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 112456480e1..a7be2fb3630 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -549,110 +549,111 @@ class BlockedLog $totalamount = 0; - if (!is_array($object->amounts) && $object->amount) { - $object->amounts = array($object->id => $object->amount); - } + // Loop on each invoice payment amount + if (is_array($object->amounts) && !empty($object->amounts)) { + $paymentpartnumber = 0; + foreach ($object->amounts as $objid => $amount) { + if (empty($amount)) { + continue; + } - $paymentpartnumber = 0; - foreach ($object->amounts as $objid => $amount) { - if (empty($amount)) { - continue; - } + $totalamount += $amount; - $totalamount += $amount; + $tmpobject = null; + if ($this->element == 'payment_supplier') { + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $tmpobject = new FactureFournisseur($this->db); + } elseif ($this->element == 'payment') { + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $tmpobject = new Facture($this->db); + } elseif ($this->element == 'payment_donation') { + include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; + $tmpobject = new Don($this->db); + } elseif ($this->element == 'payment_various') { + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; + $tmpobject = new PaymentVarious($this->db); + } - $tmpobject = null; - if ($this->element == 'payment_supplier') { - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $tmpobject = new FactureFournisseur($this->db); - } elseif ($this->element == 'payment') { - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $tmpobject = new Facture($this->db); - } elseif ($this->element == 'payment_donation') { - include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; - $tmpobject = new Don($this->db); - } elseif ($this->element == 'payment_various') { - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; - $tmpobject = new PaymentVarious($this->db); - } + if (!is_object($tmpobject)) { + continue; + } - if (!is_object($tmpobject)) { - continue; - } + $result = $tmpobject->fetch($objid); - $result = $tmpobject->fetch($objid); - - if ($result <= 0) { - $this->error = $tmpobject->error; - $this->errors = $tmpobject->errors; - dol_syslog("Failed to fetch object with id ".$objid, LOG_ERR); - return -1; - } - - $paymentpart = new stdClass(); - $paymentpart->amount = $amount; - - if (!in_array($this->element, array('payment_donation', 'payment_various'))) { - $result = $tmpobject->fetch_thirdparty(); - if ($result == 0) { - $this->error = 'Failed to fetch thirdparty for object with id '.$tmpobject->id; - $this->errors[] = $this->error; - dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR); - return -1; - } elseif ($result < 0) { + if ($result <= 0) { $this->error = $tmpobject->error; $this->errors = $tmpobject->errors; + dol_syslog("Failed to fetch object with id ".$objid, LOG_ERR); return -1; } - $paymentpart->thirdparty = new stdClass(); - foreach ($tmpobject->thirdparty as $key => $value) { - if (in_array($key, $arrayoffieldstoexclude)) { - continue; // Discard some properties - } - if (!in_array($key, array( - 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode', - 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' - ))) { - continue; // Discard if not into a dedicated list - } - if (!is_object($value) && !is_null($value) && $value !== '') { - $paymentpart->thirdparty->{$key} = $value; - } - } - } + $paymentpart = new stdClass(); + $paymentpart->amount = $amount; - // Init object to avoid warnings - if ($this->element == 'payment_donation') { - $paymentpart->donation = new stdClass(); - } else { - $paymentpart->invoice = new stdClass(); - } + if (!in_array($this->element, array('payment_donation', 'payment_various'))) { + $result = $tmpobject->fetch_thirdparty(); + if ($result == 0) { + $this->error = 'Failed to fetch thirdparty for object with id '.$tmpobject->id; + $this->errors[] = $this->error; + dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR); + return -1; + } elseif ($result < 0) { + $this->error = $tmpobject->error; + $this->errors = $tmpobject->errors; + return -1; + } - if ($this->element != 'payment_various') { - foreach ($tmpobject as $key => $value) { - if (in_array($key, $arrayoffieldstoexclude)) { - continue; // Discard some properties - } - if (!in_array($key, array( - 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public' - ))) { - continue; // Discard if not into a dedicated list - } - if (!is_object($value) && !is_null($value) && $value !== '') { - if ($this->element == 'payment_donation') { - $paymentpart->donation->{$key} = $value; - } elseif ($this->element == 'payment_various') { - $paymentpart->various->{$key} = $value; - } else { - $paymentpart->invoice->{$key} = $value; + $paymentpart->thirdparty = new stdClass(); + foreach ($tmpobject->thirdparty as $key => $value) { + if (in_array($key, $arrayoffieldstoexclude)) { + continue; // Discard some properties + } + if (!in_array($key, array( + 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode', + 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' + ))) { + continue; // Discard if not into a dedicated list + } + if (!is_object($value) && !is_null($value) && $value !== '') { + $paymentpart->thirdparty->{$key} = $value; } } } - $paymentpartnumber++; // first payment will be 1 - $this->object_data->payment_part[$paymentpartnumber] = $paymentpart; + // Init object to avoid warnings + if ($this->element == 'payment_donation') { + $paymentpart->donation = new stdClass(); + } else { + $paymentpart->invoice = new stdClass(); + } + + if ($this->element != 'payment_various') { + foreach ($tmpobject as $key => $value) { + if (in_array($key, $arrayoffieldstoexclude)) { + continue; // Discard some properties + } + if (!in_array($key, array( + 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public' + ))) { + continue; // Discard if not into a dedicated list + } + if (!is_object($value) && !is_null($value) && $value !== '') { + if ($this->element == 'payment_donation') { + $paymentpart->donation->{$key} = $value; + } elseif ($this->element == 'payment_various') { + $paymentpart->various->{$key} = $value; + } else { + $paymentpart->invoice->{$key} = $value; + } + } + } + + $paymentpartnumber++; // first payment will be 1 + $this->object_data->payment_part[$paymentpartnumber] = $paymentpart; + } } + } elseif (!empty($object->amount)) { + $totalamount = $object->amount; } $this->object_data->amount = $totalamount; From 0fe46b53d855ac0cfb56ab8c1fdff70195456ff2 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 13 Jul 2021 15:18:40 +0200 Subject: [PATCH 5/9] FIX : method_exists needs object at first param --- 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 bb648a71625..f0bf57485a9 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -262,7 +262,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) // Remove a line if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) { - if (method_exists('deleteline', $object)) { + if (method_exists($object, 'deleteline')) { $result = $object->deleteline($user, $lineid); // For backward compatibility } else { $result = $object->deleteLine($user, $lineid); From 724d00fc6cd114f57a73bdaef86e8b2b0a8f7994 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jul 2021 02:20:15 +0200 Subject: [PATCH 6/9] Fix phpcs --- htdocs/core/class/hookmanager.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index b22caf17f04..5e24ee03fa4 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -296,9 +296,9 @@ class HookManager $this->resPrint .= $actionclassinstance->resprints; } } - } - // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) - else { + } else { + // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) + // TODO. this test should be done into the method of hook by returning nothing if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) { continue; From cd5e1d603e8dc26e312dc1d186298749537a847f Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Wed, 14 Jul 2021 12:02:03 +0200 Subject: [PATCH 7/9] fix showInputField checkbox and radio type --- htdocs/core/class/commonobject.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9e6204bd364..a726987c607 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5898,7 +5898,10 @@ abstract class CommonObject $type = 'varchar'; } elseif (is_array($this->fields[$key]['arrayofkeyval'])) { $param['options'] = $this->fields[$key]['arrayofkeyval']; - $type = 'select'; + $type = $this->fields[$key]['type']; + if(!in_array($type, array('select', 'checkbox', 'radio'))) { + $type = 'select'; + } } else { $param['options'] = array(); $type = $this->fields[$key]['type']; From b552c6b4fe012d64511875795c837e8e9eda707d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jul 2021 14:32:05 +0200 Subject: [PATCH 8/9] Fix status color --- htdocs/compta/facture/list.php | 2 +- htdocs/holiday/class/holiday.class.php | 8 ++++++-- htdocs/holiday/list.php | 3 ++- htdocs/langs/en_US/main.lang | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index cc52984d6d4..f25b2b05975 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1043,7 +1043,7 @@ if ($resql) { $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= ''; } - // If the user can view prospects other than his' + // Filter on product tags if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 2b0641ff9ae..82229198185 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1251,6 +1251,8 @@ class Holiday extends CommonObject public function LibStatut($status, $mode = 0, $startdate = '') { // phpcs:enable + global $langs; + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); @@ -1266,9 +1268,11 @@ class Holiday extends CommonObject $this->labelStatusShort[self::STATUS_REFUSED] = $langs->trans('RefuseCP'); } + $params = array(); $statusType = 'status6'; - if (!empty($startdate) && $startdate > dol_now()) { + if (!empty($startdate) && $startdate >= dol_now()) { // If not yet passed, we use a green "in live" color $statusType = 'status4'; + $params = array('tooltip'=>$this->labelStatus[$status].' - '.$langs->trans("Forthcoming")); } if ($status == self::STATUS_DRAFT) { $statusType = 'status0'; @@ -1283,7 +1287,7 @@ class Holiday extends CommonObject $statusType = 'status5'; } - return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode, '', $params); } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index ece1f9c9ec7..ab57a497e8e 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -730,6 +730,7 @@ if ($resql) { $holidaystatic->id = $obj->rowid; $holidaystatic->ref = ($obj->ref ? $obj->ref : $obj->rowid); $holidaystatic->statut = $obj->status; + $holidaystatic->date_debut = $db->jdate($obj->date_debut); // User $userstatic->id = $obj->fk_user; @@ -790,7 +791,7 @@ if ($resql) { } if (!empty($arrayfields['duration']['checked'])) { print ''; - $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); + $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates print $nbopenedday.' '.$langs->trans('DurationDays'); print ''; if (!$i) { diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 863b94af564..94c851bf346 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1137,3 +1137,4 @@ CopiedToClipboard=Copied to clipboard InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration. ConfirmCancel=Are you sure you want to cancel EmailMsgID=Email MsgID +Forthcoming=Forthcoming \ No newline at end of file From a773652c04e4158ab9661e48db7fac0b97106dcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jul 2021 14:37:07 +0200 Subject: [PATCH 9/9] Fix phpcs --- htdocs/core/class/commonobject.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 51254bede5d..d050af4883a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5918,8 +5918,10 @@ abstract class CommonObject } elseif (is_array($this->fields[$key]['arrayofkeyval'])) { $param['options'] = $this->fields[$key]['arrayofkeyval']; $type = $this->fields[$key]['type']; - if(!in_array($type, array('select', 'checkbox', 'radio'))) { + if (!in_array($type, array('select', 'checkbox', 'radio'))) { $type = 'select'; + } else { + $type = $this->fields[$key]['type']; } } else { $param['options'] = array();