From 64aa90f8df6209a17b39464e185affb065b79979 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2023 09:48:51 +0200 Subject: [PATCH 1/9] FIX Total of holidays is doubled --- htdocs/holiday/list.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 0deaf878a9a..9ed3700bda5 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -957,8 +957,6 @@ if ($id && empty($user->rights->holiday->readall) && !in_array($id, $childids)) } 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); // user jdate(..., 1) because num_open_day need UTC dates - $totalduration += $nbopenedday; print $nbopenedday; //print ' '.$langs->trans('DurationDays'); print ''; From 09821dfe54bc2fbe6049c9baab4a131869bafe68 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2023 09:50:58 +0200 Subject: [PATCH 2/9] css --- htdocs/theme/eldy/global.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 3840fc7b36b..3994e7a5778 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -191,7 +191,7 @@ th.wrapcolumntitle dl dt a span.fas.fa-list { .liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], .liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth], */ -.liste_titre input[name=search_month] { +.liste_titre input[name=search_month], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] { margin-right: 4px; } From b0db4490f6451cb04d3c8afd49630b13d0dfbeb3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2023 09:53:28 +0200 Subject: [PATCH 3/9] Fix CSS --- htdocs/theme/md/style.css.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 4801147f409..b2fcd7e6b31 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -494,7 +494,7 @@ th.wrapcolumntitle dl dt a span.fas.fa-list { vertical-align: bottom; } -.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], +/*.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create], .liste_titre input[name=search_month_lim], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end], .liste_titre input[name=search_month_create], @@ -506,10 +506,15 @@ th.wrapcolumntitle dl dt a span.fas.fa-list { .liste_titre input[name=search_day_create], .liste_titre input[name=search_day_start], .liste_titre input[name=search_day_end], .liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], .liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth], +*/ +.liste_titre input[name=search_month], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] { + margin-right: 4px; +} select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth { margin-right: 4px; } + input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { color: var(--colortext); border: none; From 1aca5fd1be94f1338ec203ad79aa1ee5240bfcad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2023 10:26:19 +0200 Subject: [PATCH 4/9] Fix kanban of holiday when type of leave too large --- .../expensereport/class/expensereport.class.php | 2 +- htdocs/expensereport/list.php | 17 +++++++++++------ htdocs/holiday/class/holiday.class.php | 9 ++++++--- htdocs/holiday/list.php | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 3d944b7734a..63f10dc2b17 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1807,7 +1807,7 @@ class ExpenseReport extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($max ? dol_trunc($ref, $max) : $ref); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 59518af9cca..629d1097906 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -798,6 +798,9 @@ if ($resql) { print ''; } print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref if (!empty($arrayfields['d.ref']['checked'])) { @@ -953,16 +956,18 @@ if ($resql) { print ''; } print ''; - } - if (!$i) { - $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } print "\n"; } - $total_total_ht = $total_total_ht + $obj->total_ht; - $total_total_tva = $total_total_tva + $obj->total_tva; - $total_total_ttc = $total_total_ttc + $obj->total_ttc; + + $total_total_ht = $total_total_ht + $obj->total_ht; + $total_total_tva = $total_total_tva + $obj->total_tva; + $total_total_ttc = $total_total_ttc + $obj->total_ttc; + $i++; } } else { diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index c66706a0598..c01feb32d6c 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2471,15 +2471,18 @@ class Holiday extends CommonObject if (property_exists($this, 'fk_type')) { $return .= '
'; //$return .= ''.$langs->trans("Type").' : '; - $return .= ''.$arraydata['labeltype'].''; + $return .= '
'.dol_escape_htmltag($arraydata['labeltype']).'
'; } if (property_exists($this, 'date_debut') && property_exists($this, 'date_fin')) { - $return .= '
'.dol_print_date($this->date_debut, 'day').''; + $return .= ''.dol_print_date($this->date_debut, 'day').''; $return .= ' '.$langs->trans("To").' '; $return .= ''.dol_print_date($this->date_fin, 'day').''; + if (!empty($arraydata['nbopenedday'])) { + $return .= ' ('.$arraydata['nbopenedday'].')'; + } } if (method_exists($this, 'getLibStatut')) { - $return .= '
'.$this->getLibStatut(3).'
'; + $return .= '
'.$this->getLibStatut(3).'
'; } $return .= ''; $return .= ''; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 9ed3700bda5..e333735490f 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -895,7 +895,7 @@ if ($id && empty($user->rights->holiday->readall) && !in_array($id, $childids)) $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); } - $arraydata = array('user'=>$userstatic, 'labeltype'=>$labeltypeleavetoshow, 'selected'=>$selected); + $arraydata = array('user'=>$userstatic, 'labeltype'=>$labeltypeleavetoshow, 'selected'=>$selected, 'nbopenedday'=>$nbopenedday); } print $holidaystatic->getKanbanView('', $arraydata); if ($i == ($imaxinloop - 1)) { From bf3c0e9d4a1fe43cdb0cc2b2c4126a4153ebdef7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2023 10:52:15 +0200 Subject: [PATCH 5/9] FIX Avoid duplicate popup when popup setup to work as ajax --- htdocs/comm/mailing/class/mailing.class.php | 6 +-- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/compta/bank/class/account.class.php | 42 +++++++++++++------ htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 2 +- .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 2 +- .../class/knowledgerecord.class.php | 2 +- .../class/opensurveysondage.class.php | 6 +-- htdocs/product/stock/class/entrepot.class.php | 2 +- htdocs/resource/class/dolresource.class.php | 2 +- htdocs/salaries/class/salary.class.php | 2 +- .../class/supplier_proposal.class.php | 2 +- htdocs/ticket/class/ticket.class.php | 6 +-- 15 files changed, 47 insertions(+), 35 deletions(-) diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index b6c542fb4a8..5710ea27fe8 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -788,9 +788,7 @@ class Mailing extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs, $hookmanager; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $conf, $langs, $hookmanager; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; // Force disable tooltips @@ -844,7 +842,7 @@ class Mailing extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index efdc7b26ed8..0b737679879 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3853,7 +3853,7 @@ class Propal extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index deaa2e5fbc1..c01b56207f8 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1465,11 +1465,16 @@ class Account extends CommonObject * @param string $option ''=Show ref, 'reflabel'=Show ref+label * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0, $morecss = '') { - global $conf, $langs, $user; + global $conf, $langs; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } include_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -1490,10 +1495,6 @@ class Account extends CommonObject $label = implode($this->getTooltipContentArray($params)); } - $linkclose = ''; - $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"'); - $linkclose .= $dataparams.' class="'.$classfortooltip.'">'; - $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; if ($mode == 'transactions') { $url = DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$this->id; @@ -1512,17 +1513,34 @@ class Account extends CommonObject } } - $linkstart = 'trans("BankAccount"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"'); + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } - if ($option == 'nolink') { - $linkstart = ''; - $linkend = ''; + if ($option == 'nolink' || empty($url)) { + $linkstart = ''; + if ($option == 'nolink' || empty($url)) { + $linkend = ''; + } else { + $linkend = ''; } $result .= $linkstart; + if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a807a4f0de6..42c44c5f885 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2096,7 +2096,7 @@ class Facture extends CommonInvoice $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($max ?dol_trunc($this->ref, $max) : $this->ref); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 7db2cf5546b..ff86a6aa5af 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2104,7 +2104,7 @@ class Contrat extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($this->ref ? $this->ref : $this->id); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index a9bf9491dd8..4eab9d366a3 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1858,7 +1858,7 @@ class Expedition extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ff1964fbe9f..20480bff90c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -972,7 +972,7 @@ class CommandeFournisseur extends CommonOrder $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index fa907866532..7e9c74a82c0 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2871,7 +2871,7 @@ class FactureFournisseur extends CommonInvoice $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($max ?dol_trunc($ref, $max) : $ref); diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index e26f9c7d96a..28e32c3ad35 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -847,7 +847,7 @@ class KnowledgeRecord extends CommonObject $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); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } } } diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 18213acdb89..01ec49e2fed 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -457,9 +457,7 @@ class Opensurveysondage extends CommonObject */ public function getNomUrl($withpicto = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $conf, $langs; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; // Force disable tooltips @@ -509,7 +507,7 @@ class Opensurveysondage extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index f43b76f843e..95457b6a973 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -815,7 +815,7 @@ class Entrepot extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : $this->label); diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 1e6a1a0c332..93d166a7e74 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -848,7 +848,7 @@ class Dolresource extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 5a114def6f1..c0512d0be72 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -552,7 +552,7 @@ class Salary extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright pictofixedwidth"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.' pictofixedwidth"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 47514bb4b2f..dff5ae02d89 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2579,7 +2579,7 @@ class SupplierProposal extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index b44768968e8..3dc4d8a3088 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1488,9 +1488,7 @@ class Ticket extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $conf, $langs; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; // Force disable tooltips @@ -1545,7 +1543,7 @@ class Ticket extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; From e31cdbe297b79aa90ea36997975b599a4daec755 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2023 19:47:45 +0200 Subject: [PATCH 6/9] Fix dispatch tab on reception (no way to change batch number once set) --- htdocs/core/lib/sendings.lib.php | 2 +- htdocs/expedition/dispatch.php | 9 +++++---- htdocs/reception/card.php | 4 ++-- htdocs/reception/contact.php | 2 +- htdocs/reception/dispatch.php | 15 ++++++++++++--- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 45a9222e594..030e6ed3e35 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -47,7 +47,7 @@ function shipping_prepare_head($object) $head[$h][2] = 'shipping'; $h++; - if ($object->statut == Expedition::STATUS_DRAFT) { + if ($object->statut == Expedition::STATUS_DRAFT) { $head[$h][0] = DOL_URL_ROOT."/expedition/dispatch.php?id=".$object->id; $head[$h][1] = $langs->trans("ShipmentDistribution"); $head[$h][2] = 'dispatch'; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 8417699cb19..c4974b00990 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -96,7 +96,7 @@ if ($id > 0 || !empty($ref)) { $result = restrictedArea($user, 'expedition', $object, ''); if (!isModEnabled('stock')) { - accessforbidden(); + accessforbidden('Module stock disabled'); } $usercancreate = $user->hasRight('expedition', 'creer'); @@ -167,9 +167,10 @@ if ($action == 'updatelines' && $usercancreate) { $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= " ON ps.rowid = pb.fk_product_stock"; - $sql .= " WHERE pb.batch ='".$db->escape($lot)."'"; + $sql .= " WHERE pb.batch = '".$db->escape($lot)."'"; $sql .= " AND ps.fk_product =".((int) GETPOST($prod, 'int')) ; $sql .= " AND ps.fk_entrepot =".((int) GETPOST($ent, 'int')) ; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -758,8 +759,8 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; print ''; - print ''; - //print ''; + print ''; + //print ''; print ''; if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { print ''; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index cb3c2628286..b9a52cc8f60 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -144,12 +144,12 @@ if ($user->socid) { } if (isModEnabled("reception") || $origin == 'reception' || empty($origin)) { - $result = restrictedArea($user, 'reception', $id); + $result = restrictedArea($user, 'reception', $object->id); } else { // We do not use the reception module, so we test permission on the supplier orders if ($origin == 'supplierorder' || $origin == 'order_supplier') { $result = restrictedArea($user, 'fournisseur', $origin_id, 'commande_fournisseur', 'commande'); - } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + } elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) { accessforbidden(); } } diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index e33885d0d51..333bc0b723f 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -72,7 +72,7 @@ if ($origin == 'reception') { } else { if ($origin == 'supplierorder' || $origin == 'order_supplier') { $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande'); - } elseif (!$user->hasRight($origin, "lire") && !$user->hasRight($origin, "read")) { + } elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) { accessforbidden(); } } diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php index 112a6d51cd0..6faca7674ea 100644 --- a/htdocs/reception/dispatch.php +++ b/htdocs/reception/dispatch.php @@ -106,11 +106,20 @@ if (empty($conf->reception->enabled)) { $permissiontocontrol = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))); } -// $id is id of a purchase order. -$result = restrictedArea($user, 'fournisseur', $object, 'reception'); +// $id is id of a reception +if (isModEnabled("reception") || $origin == 'reception' || empty($origin)) { + $result = restrictedArea($user, 'reception', $object->id); +} else { + // We do not use the reception module, so we test permission on the supplier orders + if ($origin == 'supplierorder' || $origin == 'order_supplier') { + $result = restrictedArea($user, 'fournisseur', $origin_id, 'commande_fournisseur', 'commande'); + } elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) { + accessforbidden(); + } +} if (!isModEnabled('stock')) { - accessforbidden(); + accessforbidden('Module stock disabled'); } $usercancreate = $user->hasRight('reception', 'creer'); From 81921b9906544e7fbc52bd05c01fe44c675a2c71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2023 22:33:35 +0200 Subject: [PATCH 7/9] FIX #25884 --- 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 29d1f8a0018..241bfdb5a1c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -74,7 +74,7 @@ $group = GETPOST("group", "int", 3); $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search -if (empty($id)) { +if (empty($id) && $action != 'create') { $id = $user->id; } From b35a2e228187b817f6f20b47a4c1ad74a2b76c6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2023 23:03:52 +0200 Subject: [PATCH 8/9] FIX Edition of shipment detail with lot not updating correctly tables --- htdocs/expedition/class/expedition.class.php | 4 - .../class/expeditionlinebatch.class.php | 2 + htdocs/expedition/dispatch.php | 155 +++++++++++------- 3 files changed, 99 insertions(+), 62 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 4eab9d366a3..dd79f20bea4 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2837,8 +2837,6 @@ class ExpeditionLigne extends CommonObjectLine */ public function delete($user = null, $notrigger = 0) { - global $conf; - $error = 0; $this->db->begin(); @@ -2902,8 +2900,6 @@ class ExpeditionLigne extends CommonObjectLine */ public function update($user = null, $notrigger = 0) { - global $conf; - $error = 0; dol_syslog(get_class($this)."::update id=$this->id, entrepot_id=$this->entrepot_id, product_id=$this->fk_product, qty=$this->qty"); diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php index b010564768f..73f352ac21a 100644 --- a/htdocs/expedition/class/expeditionlinebatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -45,6 +45,7 @@ class ExpeditionLineBatch extends CommonObject public $dluo_qty; // deprecated, use qty public $entrepot_id; public $fk_origin_stock; // rowid in llx_product_batch table + public $fk_warehouse; // for future use in v19 public $fk_expeditiondet; @@ -123,6 +124,7 @@ class ExpeditionLineBatch extends CommonObject $sql .= ", batch"; $sql .= ", qty"; $sql .= ", fk_origin_stock"; + // TODO Add fk_warehouse here $sql .= ") VALUES ("; $sql .= $id_line_expdet.","; $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : ("'".$this->db->idate($this->sellby))."'").","; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index c4974b00990..25c0295e2ab 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -148,47 +148,53 @@ if ($action == 'updatelines' && $usercancreate) { $lot = ''; $dDLUO = ''; $dDLC = ''; - if ($modebatch == "batch") { //TODO: Make impossible to input non existing batchcode + if ($modebatch == "batch") { //TODO: Make impossible to input non existing batch code $lot = GETPOST('lot_number_'.$reg[1].'_'.$reg[2]); $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'year', 'int')); $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'year', 'int')); } - // We ask to move a qty - if (($modebatch == "batch" && GETPOST($qty) > 0) || ($modebatch == "barcode" && GETPOST($qty) != 0)) { - if (!(GETPOST($ent, 'int') > 0)) { - dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.'); - $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline); - setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors'); - $error++; - } - if ($modebatch == "batch") { - $sql = "SELECT pb.rowid "; - $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; - $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps"; - $sql .= " ON ps.rowid = pb.fk_product_stock"; - $sql .= " WHERE pb.batch = '".$db->escape($lot)."'"; - $sql .= " AND ps.fk_product =".((int) GETPOST($prod, 'int')) ; - $sql .= " AND ps.fk_entrepot =".((int) GETPOST($ent, 'int')) ; + $newqty = price2num(GETPOST($qty, 'alpha'), 'MS'); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - if ($num > 1) { - dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').'); - setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors'); - $error++; - } elseif ($num < 1) { - dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.'); - setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors'); - $error++; + // We ask to move a qty + if (($modebatch == "batch" && $newqty >= 0) || ($modebatch == "barcode" && $newqty != 0)) { + if ($newqty > 0) { // If we want a qty, we make test on input data + if (!(GETPOST($ent, 'int') > 0)) { + dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.'); + $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline); + setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors'); + $error++; + } + if (!$error && $modebatch == "batch") { + $sql = "SELECT pb.rowid "; + $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; + $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " ON ps.rowid = pb.fk_product_stock"; + $sql .= " WHERE pb.batch = '".$db->escape($lot)."'"; + $sql .= " AND ps.fk_product = ".((int) GETPOST($prod, 'int')) ; + $sql .= " AND ps.fk_entrepot = ".((int) GETPOST($ent, 'int')) ; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + if ($num > 1) { + dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').'); + setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors'); + $error++; + } elseif ($num < 1) { + dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.'); + setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors'); + $error++; + } + $db->free($resql); } - $db->free($resql); } } + //var_dump($key.' '.$newqty.' '.$idline.' '.$error); if (!$error) { $qtystart = 0; + if ($idline > 0) { $result = $expeditiondispatch->fetch($idline); if ($result < 0) { @@ -196,22 +202,38 @@ if ($action == 'updatelines' && $usercancreate) { $error++; } else { $qtystart = $expeditiondispatch->qty; - $expeditiondispatch->qty = GETPOST($qty); + $expeditiondispatch->qty = $newqty; $expeditiondispatch->entrepot_id = GETPOST($ent, 'int'); - $result = $expeditiondispatch->update($user); + if ($newqty > 0) { + $result = $expeditiondispatch->update($user); + } else { + $result = $expeditiondispatch->delete($user); + } if ($result < 0) { setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors'); $error++; } if (!$error && $modebatch == "batch") { - $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET"; - $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null"); - $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null"); - $sql .= " , qty = ".((float) price2num(GETPOST($qty, 'int'), 'MS')); - $sql .= " WHERE fk_expeditiondet = ".((int) $idline); - $sql .= " AND batch = ".((int) $idline); + if ($newqty > 0) { + $suffixkeyfordate = preg_replace('/^product_batch/', '', $key); + $sellby = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffixkeyfordate.'month'), GETPOST('dlc'.$suffixkeyfordate.'day'), GETPOST('dlc'.$suffixkeyfordate.'year'), ''); + $eatby = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffixkeyfordate.'month'), GETPOST('dluo'.$suffixkeyfordate.'day'), GETPOST('dluo'.$suffixkeyfordate.'year')); + + $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET"; + $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null"); + $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null"); + $sql .= " , qty = ".((float) $newqty); + // TODO Add a column fk_warehouse + $sql .= " WHERE fk_expeditiondet = ".((int) $idline); + $sql .= " AND batch = '".$db->escape($lot)."'"; + } else { + $sql = " DELETE FROM ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element; + $sql .= " WHERE fk_expeditiondet = ".((int) $idline); + $sql .= " AND batch = '".$db->escape($lot)."'"; + } + $resql = $db->query($sql); if (!$db->query($sql)) { dol_print_error($db); @@ -223,24 +245,29 @@ if ($action == 'updatelines' && $usercancreate) { $expeditiondispatch->fk_expedition = $object->id; $expeditiondispatch->entrepot_id = GETPOST($ent, 'int'); $expeditiondispatch->fk_origin_line = GETPOST($fk_commandedet, 'int'); - $expeditiondispatch->qty = GETPOST($qty, 'int'); - $idline = $expeditiondispatch->insert($user); - if ($idline < 0) { - setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors'); - $error++; - } + $expeditiondispatch->qty = $newqty; - if ($modebatch == "batch" && !$error) { - $expeditionlinebatch->sellby = $dDLUO; - $expeditionlinebatch->eatby = $dDLC; - $expeditionlinebatch->batch = $lot; - $expeditionlinebatch->qty = GETPOST($qty, 'int'); - $expeditionlinebatch->fk_origin_stock = 0; - $result = $expeditionlinebatch->create($idline); - if ($result < 0) { - setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors'); + if ($newqty > 0) { + $idline = $expeditiondispatch->insert($user); + if ($idline < 0) { + setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors'); $error++; } + + if ($modebatch == "batch" && !$error) { + $expeditionlinebatch->sellby = $dDLUO; + $expeditionlinebatch->eatby = $dDLC; + $expeditionlinebatch->batch = $lot; + $expeditionlinebatch->qty = $newqty; + $expeditionlinebatch->fk_origin_stock = 0; + $expeditionlinebatch->fk_warehouse = GETPOST($ent, 'int'); + + $result = $expeditionlinebatch->create($idline); + if ($result < 0) { + setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors'); + $error++; + } + } } } @@ -249,8 +276,8 @@ if ($action == 'updatelines' && $usercancreate) { $mouv = new MouvementStock($db); $product = GETPOST($prod, 'int'); $entrepot = GETPOST($ent, 'int'); - $qtymouv = GETPOST($qty) - $qtystart; - $price = GETPOST($pu); + $qtymouv = price2num(GETPOST($qty, 'alpha'), 'MS') - $qtystart; + $price = price2num(GETPOST($pu), 'MU'); $comment = GETPOST('comment'); $inventorycode = dol_print_date(dol_now(), 'dayhourlog'); $now = dol_now(); @@ -483,7 +510,7 @@ if ($object->id > 0 || !empty($object->ref)) { print '
'; print ''; - // Get list of lines from the shipments $products_dispatched with qty dispatched for each product id + // Get list of lines of the shipment $products_dispatched, with qty dispatched for each product id $products_dispatched = array(); $sql = "SELECT ed.fk_origin_line as rowid, sum(ed.qty) as qty"; $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; @@ -504,6 +531,7 @@ if ($object->id > 0 || !empty($object->ref)) { } $db->free($resql); } + //$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,"; $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, '' AS sref, l.qty as qty,"; $sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse"; @@ -566,8 +594,12 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; } print ''; - print ''; - print ' '; + } + print ''; if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { @@ -611,6 +643,7 @@ if ($object->id > 0 || !empty($object->ref)) { $conf->cache['product'] = array(); + // Loop on each line of origin order while ($i < $num) { $objp = $db->fetch_object($resql); @@ -959,7 +992,13 @@ if ($object->id > 0 || !empty($object->ref)) { // Qty to dispatch print ''; print ''."\n"; $found = 0; +print ''; print ''; print ''; print '\n\n"; $found++; +print ''; print ''; print ''; print ''; print ''; print '\n\n"; $found++; - +print ''; print ''; print ''; print ''."\n"; $found = 0; +print ''; print ''; print ''; print '\n\n"; $found++; - +print ''; print ''; print ''; print '\n\n"; $found++; if (isModEnabled("reception")) { + print ''; print ''; print ''; print '\n\n"; $found++; } else { + print ''; print ''; print ''; print ''; + } + print "
'.$langs->trans("QtyOrdered").''.$langs->trans("QtyDispatchedShort").''.$langs->trans("QtyToDispatchShort"); + if ($object->status == Expedition::STATUS_DRAFT) { + print ''.$langs->trans("QtyToDispatchShort"); // Qty to dispatch (sum for all lines of batch detail if there is) + } else { + print ''.$langs->trans("QtyDispatchedShort").''.$langs->trans("QtyToDispatchShort"); print ''; print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; - print ''; + $amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)); + if (count($products_dispatched)) { + // There is already existing lines into llx_expeditiondet, this means a plan for the shipment has already been started. + // In such a case, we do not suggest new values, we suggest the value known. + $amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : '')); + } + print ''; print ''; if (isModEnabled('productbatch') && $objp->tobatch > 0) { From ec8c2a7d6237e772fd22351f96b8b62494470c29 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2023 01:39:57 +0200 Subject: [PATCH 9/9] Debug dispatch tab --- htdocs/admin/stock.php | 10 +++- htdocs/core/lib/reception.lib.php | 2 +- htdocs/expedition/card.php | 4 ++ htdocs/expedition/class/expedition.class.php | 21 ++++----- htdocs/expedition/dispatch.php | 41 ++++++++++++----- htdocs/expedition/js/lib_dispatch.js.php | 13 +++--- htdocs/fourn/commande/dispatch.php | 6 ++- htdocs/fourn/js/lib_dispatch.js.php | 5 +- htdocs/langs/en_US/receptions.lang | 1 + htdocs/langs/en_US/sendings.lang | 1 + .../product/stock/class/productlot.class.php | 6 +-- htdocs/reception/card.php | 1 + htdocs/reception/contact.php | 2 + htdocs/reception/dispatch.php | 46 +++++++++---------- htdocs/reception/note.php | 14 ++---- 15 files changed, 100 insertions(+), 73 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 603d7778aa9..15a88dea730 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -216,6 +216,7 @@ print '
'.$langs->trans("DeStockOnBill").''; @@ -237,6 +238,7 @@ print "
'.$langs->trans("DeStockOnValidateOrder").''; @@ -260,6 +262,7 @@ $found++; //if (isModEnabled('expedition')) //{ +print ''; print '
'.$langs->trans("DeStockOnShipment").''; @@ -276,7 +279,7 @@ if (isModEnabled("expedition")) { print "
'.$langs->trans("DeStockOnShipmentOnClosing").''; @@ -309,6 +312,7 @@ print '
'.$langs->trans("ReStockOnBill").''; @@ -330,7 +334,7 @@ print "
'.$langs->trans("ReStockOnValidateOrder").''; @@ -352,6 +356,7 @@ print "
'.$langs->trans("StockOnReception").''; @@ -380,6 +385,7 @@ if (isModEnabled("reception")) { print "
'.$langs->trans("ReStockOnDispatchOrder").''; diff --git a/htdocs/core/lib/reception.lib.php b/htdocs/core/lib/reception.lib.php index 6cdbe2cd5eb..2b4944c99f2 100644 --- a/htdocs/core/lib/reception.lib.php +++ b/htdocs/core/lib/reception.lib.php @@ -46,7 +46,7 @@ function reception_prepare_head(Reception $object) $head[$h][2] = 'reception'; $h++; - if ($object->statut == Reception::STATUS_DRAFT) { + if ($object->statut == Reception::STATUS_DRAFT || ($object->statut == Reception::STATUS_VALIDATED && empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))) { $head[$h][0] = DOL_URL_ROOT."/reception/dispatch.php?id=".$object->id; $head[$h][1] = $langs->trans("ReceptionDistribution"); $head[$h][2] = 'dispatch'; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 79dec7b7ebd..318d66635ec 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2532,6 +2532,10 @@ if ($action == 'create') { // TODO Show also lines ordered but not delivered + if (empty($num_prod)) { + print '
'.$langs->trans("NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv("ShipmentDistribution")).'
\n"; print ''; print '
'; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index dd79f20bea4..df4b92fe76f 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -757,7 +757,7 @@ class Expedition extends CommonObject // If stock increment is done on sending (recommanded choice) if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { - $result = $this->manageStockMvtOnEvt($user); + $result = $this->manageStockMvtOnEvt($user, "ShipmentValidatedInDolibarr"); if ($result < 0) { return -2; } @@ -1091,14 +1091,11 @@ class Expedition extends CommonObject $this->model_pdf = trim($this->model_pdf); } - - // Check parameters // Put here code to add control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; $sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").","; $sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").","; @@ -1124,7 +1121,6 @@ class Expedition extends CommonObject $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").","; $sql .= " entity=".$conf->entity; - $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -1596,11 +1592,12 @@ class Expedition extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); + if ($originline > 0 && $originline == $obj->fk_origin_line) { $line->entrepot_id = 0; // entrepod_id in details_entrepot $line->qty_shipped += $obj->qty_shipped; } else { - $line = new ExpeditionLigne($this->db); + $line = new ExpeditionLigne($this->db); // new group to start $line->entrepot_id = $obj->fk_entrepot; // this is a property of a shipment line $line->qty_shipped = $obj->qty_shipped; // this is a property of a shipment line } @@ -2196,12 +2193,14 @@ class Expedition extends CommonObject /** * Manage Stock MVt onb Close or valid Shipment - * @param User $user Object user that modify - * @return int <0 if ko, >0 if ok + * + * @param User $user Object user that modify + * @param string $labelmovement Label of movement + * @return int <0 if KO, >0 if OK * @throws Exception * */ - private function manageStockMvtOnEvt($user) + private function manageStockMvtOnEvt($user, $labelmovement = 'ShipmentClassifyClosedInDolibarr') { global $langs; @@ -2248,7 +2247,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref)); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2259,7 +2258,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 25c0295e2ab..01b98c22a0c 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -25,9 +25,9 @@ */ /** - * \file htdocs/expedition/dispatch.php + * \file htdocs/expedition/dispatch.php * \ingroup expedition - * \brief Page to dispatch shipments + * \brief Page to dispatch shipments */ // Load Dolibarr environment @@ -60,6 +60,9 @@ $fk_default_warehouse = GETPOST('fk_default_warehouse', 'int'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); +$error = 0; +$errors = array(); + if ($user->socid) { $socid = $user->socid; } @@ -75,6 +78,7 @@ if (GETPOSTISSET("projectid")) { $object = new Expedition($db); $objectorder = new Commande($db); + if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); if ($result <= 0) { @@ -271,8 +275,9 @@ if ($action == 'updatelines' && $usercancreate) { } } - // If module stock is enabled and the stock increase is done on purchase order dispatching - if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + // If module stock is enabled and the stock decrease is done on edtion of this page + /* + if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_DISPATCH_ORDER)) { $mouv = new MouvementStock($db); $product = GETPOST($prod, 'int'); $entrepot = GETPOST($ent, 'int'); @@ -307,6 +312,7 @@ if ($action == 'updatelines' && $usercancreate) { } } } + */ } } } @@ -317,6 +323,9 @@ if ($action == 'updatelines' && $usercancreate) { } else { $db->commit(); setEventMessages($langs->trans("ReceptionUpdated"), null); + + header("Location: ".DOL_URL_ROOT.'/expedition/dispatch.php?id='.$object->id); + exit; } } elseif ($action == 'setdate_livraison' && $usercancreate) { $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); @@ -346,7 +355,8 @@ $morejs = array('/expedition/js/lib_dispatch.js.php'); llxHeader('', $title, $help_url, '', 0, 0, $morejs); if ($object->id > 0 || !empty($object->ref)) { - $lines = $object->lines; + $lines = $object->lines; // This is an array of detail of line, on line per source order line found intolines[]->fk_origin_line, then each line may have sub data + //var_dump($lines[0]->fk_origin_line); exit; $num_prod = count($lines); @@ -493,7 +503,7 @@ if ($object->id > 0 || !empty($object->ref)) { print '
'; $disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0. - if ($object->statut == Reception::STATUS_DRAFT) { + if ($object->statut == Expedition::STATUS_DRAFT) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $formproduct->loadWarehouses(); @@ -847,8 +857,10 @@ if ($object->id > 0 || !empty($object->ref)) { } // Qty to dispatch print ''; - print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; - print ''; + print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; + $suggestedvalue = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : $objd->qty); + //var_dump($suggestedvalue);exit; + print ''; print ''; print ''; if (isModEnabled('productbatch') && $objp->tobatch > 0) { @@ -991,7 +1003,7 @@ if ($object->id > 0 || !empty($object->ref)) { } // Qty to dispatch print ''; - print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; + print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; $amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)); if (count($products_dispatched)) { // There is already existing lines into llx_expeditiondet, this means a plan for the shipment has already been started. @@ -1055,14 +1067,14 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; if ($nbproduct) { - $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); + //$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if (empty($reshook)) { - if (empty($conf->reception->enabled)) { + /*if (empty($conf->reception->enabled)) { print $langs->trans("Comment").' : '; print 'trans("DispatchSupplierOrder", $object->ref); @@ -1075,6 +1087,8 @@ if ($object->id > 0 || !empty($object->ref)) { $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception"); print '
'; + */ + print 'id > 0 || !empty($object->ref)) { print ''; diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index b227a3e4a43..bbcd91e32a2 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -83,22 +83,18 @@ if (isModEnabled("reception")) { } $permissionnote = $user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php +// TODO Test on reception module on only if ($origin == 'reception') { $result = restrictedArea($user, $origin, $object->id); } else { - if ($origin == 'reception') { - $result = restrictedArea($user, $origin, $object->id); - } else { - if ($origin == 'supplierorder' || $origin == 'order_supplier') { - $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande'); - } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { - accessforbidden(); - } + if ($origin == 'supplierorder' || $origin == 'order_supplier') { + $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande'); + } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + accessforbidden(); } } - /* * Actions */