From 65ecd2f3eff5ac37d5211842639646c64c9442f8 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 22 Feb 2022 17:06:10 +0100 Subject: [PATCH 01/23] Fix : fix error of permission in holiday --- htdocs/holiday/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 70d9c8da54d..cbee61c6962 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -113,7 +113,7 @@ if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'holiday', $object->id, 'holiday'); +$result = restrictedArea($user, 'holiday', $object->id, 'holiday','','','rowid',$object->statut); /* @@ -1400,7 +1400,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { // Confirmation messages if ($action == 'delete') { - if ($user->rights->holiday->delete) { + if ($candelete) { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("TitleDeleteCP"), $langs->trans("ConfirmDeleteCP"), "confirm_delete", '', 0, 1); } } From 19dbed1804c0a74195a785f81381a765e0ac3fa4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 22 Feb 2022 16:10:56 +0000 Subject: [PATCH 02/23] Fixing style errors. --- htdocs/holiday/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index cbee61c6962..bbabc5327d8 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -113,7 +113,7 @@ if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'holiday', $object->id, 'holiday','','','rowid',$object->statut); +$result = restrictedArea($user, 'holiday', $object->id, 'holiday', '', '', 'rowid', $object->statut); /* From 0e0dd1ec6cb0e551d0f665b070f3e077b787f683 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 22 Feb 2022 17:42:11 +0100 Subject: [PATCH 03/23] FIX: invoice pdf: lines originating from deposits were not detailed anymore --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 54c7d9060ab..9bc7df340cf 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1271,7 +1271,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $textwasmodified = ($note == $prodser->note); if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; } - } elseif ($object->element == 'facture' || $object->element == 'facturefourn') { + } elseif (($object->element == 'facture' || $object->element == 'facturefourn') && preg_match('/^\(DEPOSIT\).+/', $desc)) { // We must not replace '(DEPOSIT)' when it is alone, it will be translated and detailed later $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc); } From 73b04deb19b7a2d2a0a4a2681441587f0dbfeced Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Feb 2022 00:17:49 +0100 Subject: [PATCH 04/23] Fix error management. --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c96f24760c0..63f2977acdb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1944,7 +1944,7 @@ if ($action == 'create') { // We verify whether the object is provisionally numbering $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') { + if ($ref == 'PROV' || $ref == '') { $numref = $object->getNextNumRef($soc); if (empty($numref)) { $error++; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ba96725ddbd..3ed5ede556c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1877,8 +1877,12 @@ if ($action == 'create' && $usercancreate) { if ($action == 'validate') { // We check that object has a temporary ref $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') { + if ($ref == 'PROV' || $ref == '') { $numref = $object->getNextNumRef($soc); + if (empty($numref)) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } else { $numref = $object->ref; } @@ -1915,7 +1919,9 @@ if ($action == 'create' && $usercancreate) { ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + if (!$error) { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + } } // Confirm back to draft status From ed6f4b4ee1a0cf96ec64427623c41ff0055fd2b4 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 23 Feb 2022 15:33:51 +0100 Subject: [PATCH 05/23] Display Salary Paiement on compta report --- htdocs/compta/resultat/clientfourn.php | 4 +++- htdocs/compta/resultat/index.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index b5aca49aaae..f650244d677 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -857,7 +857,7 @@ if ($modecompta == 'BOOKKEEPING') { if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') { if ($modecompta == 'CREANCES-DETTES') { - $column = 'p.datev'; + $column = 'b.datev'; } else { $column = 'p.datep'; } @@ -865,6 +865,7 @@ if ($modecompta == 'BOOKKEEPING') { $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank=b.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=s.fk_user"; $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; if (!empty($date_start) && !empty($date_end)) { @@ -876,6 +877,7 @@ if ($modecompta == 'BOOKKEEPING') { $sql .= " UNION "; $sql .= " SELECT u.rowid, u.firstname, u.lastname, p.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank=b.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; if (!empty($date_start) && !empty($date_end)) { diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 2d4ea6fc9e0..5f10013f294 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -611,7 +611,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom if (!empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { if ($modecompta == 'CREANCES-DETTES') { - $column = 'p.datev'; + $column = 'b.datev'; } if ($modecompta == "RECETTES-DEPENSES") { $column = 'p.datep'; @@ -621,6 +621,7 @@ if (!empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $mo $subtotal_ttc = 0; $sql = "SELECT p.label as nom, date_format(".$column.",'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank=b.rowid"; $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; if (!empty($date_start) && !empty($date_end)) { $sql .= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'"; From 4d2dde0fe48d335a434a0e88a5101d878d1c7b7e Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 24 Feb 2022 14:34:06 +0100 Subject: [PATCH 06/23] fix bookmarks info bubble --- htdocs/bookmarks/bookmarks.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index d24ba63ef55..f8daff1cd14 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -66,7 +66,7 @@ function printDropdownBookmarksList() // Url to list bookmark - $listbtn = ''; + $listbtn = ''; $listbtn .= img_picto('', 'bookmark', 'class="paddingright"').$langs->trans('Bookmarks').''; // Url to go on create new bookmark page From 1040555baf505faa00f4676f80e2a2558a55fc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9=20GDSOFT?= Date: Fri, 25 Feb 2022 11:26:56 +0100 Subject: [PATCH 07/23] accoutancy : subleger label input automatic filling when selecting subleger account in select2 list --- htdocs/accountancy/bookkeeping/card.php | 5 +++-- htdocs/core/class/html.formaccounting.class.php | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index c156a388735..df43f28bd1f 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -659,7 +659,7 @@ if ($action == 'create') { // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1); + print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1,'maxwidth250','','subledger_label'); } else { print 'subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">'; } @@ -728,7 +728,7 @@ if ($action == 'create') { // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1); + print $formaccounting->select_auxaccount('', 'subledger_account', 1,'maxwidth250','','subledger_label'); } else { print ''; } @@ -758,6 +758,7 @@ if ($action == 'create') { print ""; } print ''; + } } } else { diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index dc6e6d8c6cd..638d3a4bdfd 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -441,7 +441,7 @@ class FormAccounting extends Form * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * @return string String with HTML select */ - public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250', $usecache = '') + public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250', $usecache = '', $labelhtmlname = '') { // phpcs:enable @@ -505,7 +505,20 @@ class FormAccounting extends Form // Build select $out .= Form::selectarray($htmlname, $aux_account, $selectid, ($showempty ? (is_numeric($showempty) ? 1 : $showempty): 0), 0, 0, '', 0, 0, 0, '', $morecss, 1); + //automatic filling if we give the name of the subledger_label input + if (!empty($labelhtmlname)) { + $out .= ''; + } + return $out; } From c0dd96a45654aa8f85f5fcc7278bfcc510cf97bb Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 25 Feb 2022 10:36:02 +0000 Subject: [PATCH 08/23] Fixing style errors. --- htdocs/accountancy/bookkeeping/card.php | 5 ++--- htdocs/core/class/html.formaccounting.class.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index df43f28bd1f..01e78cf4d27 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -659,7 +659,7 @@ if ($action == 'create') { // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1,'maxwidth250','','subledger_label'); + print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); } else { print 'subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">'; } @@ -728,7 +728,7 @@ if ($action == 'create') { // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1,'maxwidth250','','subledger_label'); + print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); } else { print ''; } @@ -758,7 +758,6 @@ if ($action == 'create') { print ""; } print ''; - } } } else { diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 638d3a4bdfd..645e045a903 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -518,7 +518,7 @@ class FormAccounting extends Form '; } - + return $out; } From be95662ece21162f475fb42876cff87e2843cf06 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Feb 2022 13:19:01 +0100 Subject: [PATCH 09/23] Revert "NEW : accoutancy : subleger label input automatic filling when selecting subleger account in select2 list" --- htdocs/accountancy/bookkeeping/card.php | 4 ++-- htdocs/core/class/html.formaccounting.class.php | 15 +-------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 01e78cf4d27..c156a388735 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -659,7 +659,7 @@ if ($action == 'create') { // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1); } else { print 'subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">'; } @@ -728,7 +728,7 @@ if ($action == 'create') { // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + print $formaccounting->select_auxaccount('', 'subledger_account', 1); } else { print ''; } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 645e045a903..dc6e6d8c6cd 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -441,7 +441,7 @@ class FormAccounting extends Form * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * @return string String with HTML select */ - public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250', $usecache = '', $labelhtmlname = '') + public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250', $usecache = '') { // phpcs:enable @@ -505,19 +505,6 @@ class FormAccounting extends Form // Build select $out .= Form::selectarray($htmlname, $aux_account, $selectid, ($showempty ? (is_numeric($showempty) ? 1 : $showempty): 0), 0, 0, '', 0, 0, 0, '', $morecss, 1); - //automatic filling if we give the name of the subledger_label input - if (!empty($labelhtmlname)) { - $out .= ''; - } return $out; } From 84db3437bd60524105b93f98da0ab4a5adf510a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Feb 2022 14:13:42 +0100 Subject: [PATCH 10/23] Add missing ' in command --- htdocs/admin/tools/export_files.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index 36be1f273ff..a3c20d0dffc 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -173,7 +173,7 @@ if ($compression == 'zip') { // We also exclude '/temp/' dir and 'documents/admin/documents' // We make escapement here and call executeCLI without escapement because we don't want to have the '*.log' escaped. - $cmd = "tar -cf ".escapeshellcmd($outputdir."/".$file)." --exclude-vcs --exclude-caches-all --exclude='temp' --exclude='*.log' --exclude='*.pdf_preview-*.png' --exclude='documents/admin/documents' -C '".escapeshellcmd(dol_sanitizePathName($dirtoswitch))."' '".escapeshellcmd(dol_sanitizeFileName($dirtocompress))."'"; + $cmd = "tar -cf '".escapeshellcmd($outputdir."/".$file)."' --exclude-vcs --exclude-caches-all --exclude='temp' --exclude='*.log' --exclude='*.pdf_preview-*.png' --exclude='documents/admin/documents' -C '".escapeshellcmd(dol_sanitizePathName($dirtoswitch))."' '".escapeshellcmd(dol_sanitizeFileName($dirtocompress))."'"; $result = $utils->executeCLI($cmd, $outputfile, 0, null, 1); From c242a0561bbb4c000df21d337b492732597aaf27 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 25 Feb 2022 16:11:16 +0100 Subject: [PATCH 11/23] Fix shipping list, e.shipping_method_id should be e.fk_shipping_method. Disabled searchall for shipping method, does not work. --- htdocs/expedition/list.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 378d95e00c8..2d81c5e0545 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -116,7 +116,7 @@ $fieldstosearchall = array( 'e.ref'=>"Ref", 's.nom'=>"ThirdParty", 'e.note_public'=>'NotePublic', - 'e.shipping_method_id'=>'SendingMethod', + //'e.fk_shipping_method'=>'SendingMethod', // TODO fix this, does not work 'e.tracking_number'=>"TrackingNumber", ); if (empty($user->socid)) { @@ -134,7 +134,7 @@ $arrayfields = array( 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0, 'position'=>7), 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers, 'position'=>8), 'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1, 'position'=>9), - 'e.shipping_method_id'=>array('label'=>$langs->trans('SendingMethod'), 'checked'=>1, 'position'=>10), + 'e.fk_shipping_method'=>array('label'=>$langs->trans('SendingMethod'), 'checked'=>1, 'position'=>10), 'e.tracking_number'=>array('label'=>$langs->trans("TrackingNumber"), 'checked'=>1, 'position'=>11), 'e.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'position'=>12), 'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), @@ -654,7 +654,7 @@ if (!empty($arrayfields['e.date_delivery']['checked'])) { print ''; print ''; } -if (!empty($arrayfields['e.shipping_method_id']['checked'])) { +if (!empty($arrayfields['e.fk_shipping_method']['checked'])) { // Delivery method print ''; $shipment->fetch_delivery_methods(); @@ -751,8 +751,8 @@ if (!empty($arrayfields['e.weight']['checked'])) { if (!empty($arrayfields['e.date_delivery']['checked'])) { print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); } -if (!empty($arrayfields['e.shipping_method_id']['checked'])) { - print_liste_field_titre($arrayfields['e.shipping_method_id']['label'], $_SERVER["PHP_SELF"], "e.fk_shipping_method", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['e.fk_shipping_method']['checked'])) { + print_liste_field_titre($arrayfields['e.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "e.fk_shipping_method", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['e.tracking_number']['checked'])) { print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center '); @@ -901,7 +901,7 @@ while ($i < min($num, $limit)) { print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); print "\n"; } - if (!empty($arrayfields['e.shipping_method_id']['checked'])) { + if (!empty($arrayfields['e.fk_shipping_method']['checked'])) { // Get code using getLabelFromKey $code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); print ''; From b989c257ad956c79a5d990a1f51e733790416c79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Feb 2022 18:53:21 +0100 Subject: [PATCH 12/23] Fix report on salaries --- htdocs/compta/resultat/clientfourn.php | 45 ++++++++++++-------------- htdocs/compta/resultat/index.php | 27 ++++++++++------ 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index f650244d677..8f71015517c 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -857,34 +857,29 @@ if ($modecompta == 'BOOKKEEPING') { if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') { if ($modecompta == 'CREANCES-DETTES') { - $column = 'b.datev'; + $column = 's.dateep'; // We use the date of end of period of salary + + $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, s.label as label, date_format($column,'%Y-%m') as dm, sum(s.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."salary as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = s.fk_user"; + $sql .= " WHERE s.entity IN (".getEntity('salary').")"; + if (!empty($date_start) && !empty($date_end)) { + $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; + } + $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, s.fk_user, s.label, dm"; } else { $column = 'p.datep'; + $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid = p.fk_salary"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = s.fk_user"; + $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; + if (!empty($date_start) && !empty($date_end)) { + $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; + } + $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, s.fk_user, p.label, dm"; } - $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank=b.rowid"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=s.fk_user"; - $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; - if (!empty($date_start) && !empty($date_end)) { - $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; - } - $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, s.fk_user, p.label, dm"; - - // For backward compatibility with old module salary - $sql .= " UNION "; - $sql .= " SELECT u.rowid, u.firstname, u.lastname, p.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank=b.rowid"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; - $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; - if (!empty($date_start) && !empty($date_end)) { - $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; - } - $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm"; - $newsortfield = $sortfield; if ($newsortfield == 's.nom, s.rowid') { $newsortfield = 'u.firstname, u.lastname'; @@ -898,7 +893,7 @@ if ($modecompta == 'BOOKKEEPING') { $sql .= $db->order($newsortfield, $sortorder); } - dol_syslog("get payment salaries"); + dol_syslog("get salaries"); $result = $db->query($sql); $subtotal_ht = 0; $subtotal_ttc = 0; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 5f10013f294..2d3ba90cd7d 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -611,22 +611,31 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom if (!empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { if ($modecompta == 'CREANCES-DETTES') { - $column = 'b.datev'; + $column = 's.dateep'; // we use the date of end of period of salary + + $sql = "SELECT s.label as nom, date_format(".$column.",'%Y-%m') as dm, sum(s.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."salary as s"; + $sql .= " WHERE s.entity IN (".getEntity('salary').")"; + if (!empty($date_start) && !empty($date_end)) { + $sql .= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'"; + } + $sql .= " GROUP BY s.label, dm"; } if ($modecompta == "RECETTES-DEPENSES") { $column = 'p.datep'; + + $sql = "SELECT p.label as nom, date_format(".$column.",'%Y-%m') as dm, sum(p.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON p.fk_salary = s.rowid"; + $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; + if (!empty($date_start) && !empty($date_end)) { + $sql .= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'"; + } + $sql .= " GROUP BY p.label, dm"; } $subtotal_ht = 0; $subtotal_ttc = 0; - $sql = "SELECT p.label as nom, date_format(".$column.",'%Y-%m') as dm, sum(p.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank=b.rowid"; - $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; - if (!empty($date_start) && !empty($date_end)) { - $sql .= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'"; - } - $sql .= " GROUP BY p.label, dm"; dol_syslog("get social salaries payments"); $result = $db->query($sql); From 488049c6a657df9004bacdaef595b247cdb9b80f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Feb 2022 20:36:40 +0100 Subject: [PATCH 13/23] FIX bad position of extrafields for interventions --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/fichinter/card.php | 72 +++++++++++++++-------- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8dabc902e5c..4b3d6fca2d3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7699,7 +7699,7 @@ abstract class CommonObject if (empty($reshook)) { if (key_exists('label', $extrafields->attributes[$this->table_element]) && is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0) { $out .= "\n"; - $out .= ' '; + $out .= ' '; $out .= "\n"; $extrafields_collapse_num = ''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 8d21a789648..daef20542a5 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -354,7 +354,7 @@ if ($nolinesbefore) { } if (is_object($objectline)) { $temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', 1, 'line'); - ; + if (!empty($temps)) { print '
'; print $temps; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index a58a62b5ffd..e02a601c9cd 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1342,6 +1342,23 @@ if ($action == 'create') { print ''; // ancre pour retourner sur la ligne print dol_htmlentitiesbr($objp->description); + $objectline = new FichinterLigne($db); + $objectline->fetch($objp->rowid); + $objectline->fetch_optionals(); + + $extrafields->fetch_name_optionals_label($objectline->table_element); + + if (!empty($extrafields)) { + $temps = $objectline->showOptionals($extrafields, 'view', array(), '', '', 1, 'line'); + if (!empty($temps)) { + print '
'; + print $temps; + print '
'; + } + } + + print ''; + // Date print ''.(empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR) ?dol_print_date($db->jdate($objp->date_intervention), 'dayhour') : dol_print_date($db->jdate($objp->date_intervention), 'day')).''; @@ -1378,15 +1395,6 @@ if ($action == 'create') { } print ''; - - $line = new FichinterLigne($db); - $line->fetch($objp->rowid); - - $extrafields->fetch_name_optionals_label($line->table_element); - - $line->fetch_optionals(); - - print $line->showOptionals($extrafields, 'view', array('colspan'=>5)); } // Line in update mode @@ -1405,6 +1413,22 @@ if ($action == 'create') { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('np_desc', $objp->description, '', 164, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%'); $doleditor->Create(); + + $objectline = new FichinterLigne($db); + $objectline->fetch($objp->rowid); + $objectline->fetch_optionals(); + + $extrafields->fetch_name_optionals_label($objectline->table_element); + + if (!empty($extrafields)) { + $temps = $objectline->showOptionals($extrafields, 'edit', array(), '', '', 1, 'line'); + if (!empty($temps)) { + print '
'; + print $temps; + print '
'; + } + } + print ''; // Date d'intervention @@ -1431,14 +1455,6 @@ if ($action == 'create') { print ''; print ''; print ''."\n"; - - $line = new FichinterLigne($db); - $line->fetch($objp->rowid); - - $extrafields->fetch_name_optionals_label($line->table_element); - $line->fetch_optionals(); - - print $line->showOptionals($extrafields, 'edit', array('colspan'=>5)); } $i++; @@ -1481,6 +1497,20 @@ if ($action == 'create') { $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'restricthtml'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%'); $doleditor->Create(); } + + $objectline = new FichinterLigne($db); + $extrafields->fetch_name_optionals_label($objectline->table_element); + + if (is_object($objectline)) { + $temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', 1, 'line'); + + if (!empty($temps)) { + print '
'; + print $temps; + print '
'; + } + } + print ''; // Date intervention @@ -1513,14 +1543,6 @@ if ($action == 'create') { print ''; print ''; - //Line extrafield - - $lineadd = new FichinterLigne($db); - - $extrafields->fetch_name_optionals_label($lineadd->table_element); - - print $lineadd->showOptionals($extrafields, 'edit', array('colspan'=>5)); - if (!$num) { print ''; } From eba20957f3572965aa029a7c0e4e47624b534964 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Feb 2022 21:45:29 +0100 Subject: [PATCH 14/23] Fix CSS Conflicts: htdocs/projet/list.php --- htdocs/core/class/html.form.class.php | 15 ++++++++------- htdocs/core/class/html.formcategory.class.php | 4 ++-- htdocs/core/class/html.formother.class.php | 19 ++++++++++--------- htdocs/projet/list.php | 4 ++-- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8a0b66e0b78..f25c9aad9d3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1599,7 +1599,7 @@ class Form * @param string $exclude List of contacts id to exclude * @param string $limitto Disable answers that are not id in this array list * @param integer $showfunction Add function into label - * @param string $moreclass Add more class to class style + * @param string $morecss Add more class to class style * @param integer $showsoc Add company into label * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) @@ -1609,10 +1609,10 @@ class Form * @return int <0 if KO, Nb of contact in list if OK * @deprecated You can use selectcontacts directly (warning order of param was changed) */ - public function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '') + public function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $morecss = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '') { // phpcs:enable - print $this->selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $moreclass, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid); + print $this->selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $morecss, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid); return $this->num; } @@ -1629,7 +1629,7 @@ class Form * @param string $exclude List of contacts id to exclude * @param string $limitto Disable answers that are not id in this array list * @param integer $showfunction Add function into label - * @param string $moreclass Add more class to class style + * @param string $morecss Add more class to class style * @param bool $options_only Return options only (for ajax treatment) * @param integer $showsoc Add company into label * @param int $forcecombo Force to use combo box (so no ajax beautify effect) @@ -1640,7 +1640,7 @@ class Form * @param integer $disableifempty Set tag 'disabled' on select if there is no choice * @return int|string <0 if KO, HTML with select string if OK. */ - public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false, $disableifempty = 0) + public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $morecss = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false, $disableifempty = 0) { global $conf, $langs, $hookmanager, $action; @@ -1687,7 +1687,7 @@ class Form $num = $this->db->num_rows($resql); if ($htmlname != 'none' && !$options_only) { - $out .= ''; } if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) { @@ -2080,7 +2080,7 @@ class Form if ($num) { // Enhance with select2 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out = ajax_combobox($htmlname).$out; + $out .= ajax_combobox($htmlname); } } else { dol_print_error($this->db); @@ -2089,6 +2089,7 @@ class Form if ($outputmode) { return $outarray; } + return $out; } diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php index 518a8f93290..1a2c02deb54 100644 --- a/htdocs/core/class/html.formcategory.class.php +++ b/htdocs/core/class/html.formcategory.class.php @@ -49,13 +49,13 @@ class FormCategory extends Form $categoryArray = $this->select_all_categories($type, "", "", 64, 0, 1); $categoryArray[-2] = "- ".$langs->trans('NotCategorized')." -"; - $tmptitle = $langs->trans("Category"); + $tmptitle = $langs->transnoentitiesnoconv("Category"); $filter = ''; $filter .= '
'; $filter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); //$filter .= $langs->trans('Categories').": "; - $filter .= Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, "minwidth300", 0, 0, '', '', $tmptitle); + $filter .= Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, "minwidth300 widthcentpercentminusx", 0, 0, '', '', $tmptitle); $filter .= "
"; return $filter; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 2b7466628a5..aa0e5486761 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -473,15 +473,6 @@ class FormOther $langs->load('users'); $out = ''; - // Enhance with select2 - if ($conf->use_javascript_ajax) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - - $comboenhancement = ajax_combobox($htmlname); - if ($comboenhancement) { - $out .= $comboenhancement; - } - } $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectSalesRep', array(), $this, $action); @@ -622,6 +613,16 @@ class FormOther $out .= ''; + // Enhance with select2 + if ($conf->use_javascript_ajax) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + + $comboenhancement = ajax_combobox($htmlname); + if ($comboenhancement) { + $out .= $comboenhancement; + } + } + return $out; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 6019011956a..552022f883f 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -806,7 +806,7 @@ $includeonly = ''; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); $moreforfilter .= '
'; // If the user can view thirdparties other than his' @@ -814,7 +814,7 @@ if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx'); $moreforfilter .= '
'; } From fb0e2f9c6c87fcaa05c59212a62573d5b9c9c2be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Feb 2022 01:00:22 +0100 Subject: [PATCH 15/23] FIX #yogosha9095 --- htdocs/core/lib/geturl.lib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 50ae7c33561..1f6c088ac1b 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -215,7 +215,14 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = } // Common check on ip (local and external) - $arrayofmetadataserver = array('100.100.100.200' => 'Alibaba', '192.0.0.192'=> 'Oracle', '192.80.8.124'=>'Packet'); + // See list on https://tagmerge.com/gist/a7b9d57ff8ec11d63642f8778609a0b8 + // Not evasive url that ar enot IP are excluded by test on IP v4/v6 validity. + $arrayofmetadataserver = array( + '100.100.100.200' => 'Alibaba', + '192.0.0.192' => 'Oracle', + '192.80.8.124' => 'Packet', + '100.88.222.5' => 'Tencent cloud', + ); foreach ($arrayofmetadataserver as $ipofmetadataserver => $nameofmetadataserver) { if ($iptocheck == $ipofmetadataserver) { $info['http_code'] = 400; From 3e41c9cb9769ebabaf7b5ffcdccfe95e28d17c68 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sat, 26 Feb 2022 11:13:02 +0100 Subject: [PATCH 16/23] FIX: Show product photo on Supplier order Cornas model. --- .../supplier_order/doc/pdf_cornas.modules.php | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 5fcd0ee20de..8d8df36e088 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -546,31 +546,30 @@ class pdf_cornas extends ModelePDFSuppliersOrders $posYAfterDescription = 0; // We start with Photo of product line - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page - $pdf->AddPage('', '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - $pdf->setPage($pageposbefore + 1); + if ($this->getColumnStatus('photo')) { + // We start with Photo of product line + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page + $pdf->AddPage('', '', true); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + $pdf->setPage($pageposbefore + 1); - $curY = $tab_top_newpage; + $curY = $tab_top_newpage; - // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { - $showpricebeforepagebreak = 1; - } else { - $showpricebeforepagebreak = 0; + // Allows data in the first page if description is long enough to break in multiples pages + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + $showpricebeforepagebreak = 1; + } else { + $showpricebeforepagebreak = 0; + } } - } - if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { - $curX = $this->posxpicture - 1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi - // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage = $curY + $imglinesize['height']; + if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { + $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + // $pdf->Image does not increase value return by getY, so we save it manually + $posYAfterImage = $curY + $imglinesize['height']; + } } // Description of product line $curX = $this->posxdesc - 1; From 5d0408f7af4bef67ea24b5ab469968feac1f600e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Feb 2022 19:15:40 +0100 Subject: [PATCH 17/23] Fix filter on member list --- htdocs/adherents/list.php | 8 ++++---- htdocs/projet/list.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 322c08bd77c..996f2d16c8d 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -307,7 +307,7 @@ $memberstatic = new Adherent($db); $now = dol_now(); -if (!empty($search_categ) || !empty($catid)) { +if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) { $sql = "SELECT DISTINCT"; } else { $sql = "SELECT"; @@ -336,7 +336,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; if (!empty($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; } -if (!empty($search_categ) || !empty($catid)) { +if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) { // We need this table joined to the select in order to filter by categ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; } @@ -540,7 +540,7 @@ if ($search_login) { if ($search_email) { $param .= "&search_email=".urlencode($search_email); } -if ($search_categ) { +if ($search_categ > 0 || $search_categ == -2) { $param .= "&search_categ=".urlencode($search_categ); } if ($search_company) { @@ -573,7 +573,7 @@ if ($search_phone_mobile != '') { if ($search_filter && $search_filter != '-1') { $param .= "&search_filter=".urlencode($search_filter); } -if ($search_status != "" && $search_status != Adherent::STATUS_DRAFT) { +if ($search_status != "" && $search_status != -3) { $param .= "&search_status=".urlencode($search_status); } if ($search_type > 0) { diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 552022f883f..cc9099b463b 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -687,7 +687,7 @@ if ($search_opp_percent != '') { if ($search_public != '') { $param .= '&search_public='.urlencode($search_public); } -if ($search_project_user != '') { +if ($search_project_user > 0) { $param .= '&search_project_user='.urlencode($search_project_user); } if ($search_sale > 0) { From 2ce50b6c00cb830552f614a787de657428fb1a33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Feb 2022 19:30:46 +0100 Subject: [PATCH 18/23] CSS --- htdocs/theme/eldy/global.inc.php | 4 ++-- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index f26e9765db2..b88cecda187 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -5210,7 +5210,7 @@ td.cal_other_month { /* ============================================================================== */ /* CSS for treeview */ -.treeview ul { background-color: transparent !important; margin-bottom: 4px !important; margin-top: 0 !important; padding-top: 8px !important; } +.treeview ul { background-color: transparent !important; margin-bottom: 4px !important; margin-top: 0 !important; padding-top: 2px !important; } .treeview li { background-color: transparent !important; padding: 0 0 0 16px !important; min-height: 30px; } .treeview .hover { color: var(--colortextlink) !important; text-decoration: underline !important; } .treeview .hitarea { margin-top: 3px; } @@ -6223,7 +6223,7 @@ span.noborderoncategories a, li.noborderoncategories a { /* vertical-align: top; */ } span.noborderoncategories { - padding: 4px 5px 0px 5px; + padding: 3px 5px 3px 5px; display: inline-block; } .categtextwhite, .treeview .categtextwhite.hover { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index aeb25a84933..15c9ef74612 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -6063,7 +6063,7 @@ span.noborderoncategories a, li.noborderoncategories a { line-height: normal; } span.noborderoncategories { - padding: 3px 5px 0px 5px; + padding: 3px 5px 3px 5px; } .categtextwhite, .treeview .categtextwhite.hover { color: #fff !important; From b9649632fa9b27de72c051029c19fc665348649e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Feb 2022 11:53:29 +0100 Subject: [PATCH 19/23] Fix update --- htdocs/adherents/class/adherent.class.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 1faa9271623..6a2c69e32fe 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -659,8 +659,7 @@ class Adherent extends CommonObject $nbrowsaffected = 0; $error = 0; - dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=". - $this->email); + dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=".$this->email); // Clean parameters $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname); @@ -693,7 +692,9 @@ class Adherent extends CommonObject $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' $sql .= ", login = ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); $sql .= ", societe = ".($this->company ? "'".$this->db->escape($this->company)."'" : ($this->societe ? "'".$this->db->escape($this->societe)."'" : "null")); - $sql .= ", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) : "null"); + if ($this->socid) { + $sql .= ", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) : "null"); // Must be modified only when creating from a third-party + } $sql .= ", address = ".($this->address ? "'".$this->db->escape($this->address)."'" : "null"); $sql .= ", zip = ".($this->zip ? "'".$this->db->escape($this->zip)."'" : "null"); $sql .= ", town = ".($this->town ? "'".$this->db->escape($this->town)."'" : "null"); @@ -713,9 +714,6 @@ class Adherent extends CommonObject $sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid); $sql .= ", morphy = '".$this->db->escape($this->morphy)."'"; $sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null"); - if ($this->socid) { - $sql .= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party - } if ($this->datefin) { $sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription } From 32f2eb8c94d277b131f73521c18309fb8cf8cae0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Feb 2022 12:13:06 +0100 Subject: [PATCH 20/23] Debug v15 --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_user.key.sql | 2 +- htdocs/install/mysql/tables/llx_user.sql | 12 ++++++------ htdocs/user/card.php | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 4d4248c1ac0..df86c80e72e 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -503,3 +503,6 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE','Holiday aprouved','Executed when a holiday is aprouved','holiday',803); INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_CANCEL','Holiday canceled','Executed when a holiday is canceled','holiday',802); INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_DELETE','Holiday deleted','Executed when a holiday is deleted','holiday',804); + +-- VMYSQL4.3 ALTER TABLE llx_user MODIFY COLUMN fk_soc integer NULL; +-- VPGSQL8.2 ALTER TABLE llx_user ALTER COLUMN fk_soc DROP NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_user.key.sql b/htdocs/install/mysql/tables/llx_user.key.sql index 047a10f1e90..f2250ccea75 100644 --- a/htdocs/install/mysql/tables/llx_user.key.sql +++ b/htdocs/install/mysql/tables/llx_user.key.sql @@ -21,7 +21,7 @@ ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login, entity); -ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc); +ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc); ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_socpeople (fk_socpeople); ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_member (fk_member); diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 8aa0d381e26..6cfdf8bfbb8 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -64,12 +64,12 @@ create table llx_user --module_comm smallint DEFAULT 1, --module_compta smallint DEFAULT 1, - fk_soc integer, -- id thirdparty if user linked to a company (external user) - fk_socpeople integer, -- id contact origin if user linked to a contact - fk_member integer, -- if member if suer linked to a member - fk_user integer, -- Supervisor, hierarchic parent - fk_user_expense_validator integer, - fk_user_holiday_validator integer, + fk_soc integer NULL, -- id thirdparty if user linked to a company (external user) + fk_socpeople integer NULL, -- id contact origin if user linked to a contact + fk_member integer NULL, -- if member if suer linked to a member + fk_user integer NULL, -- Supervisor, hierarchic parent + fk_user_expense_validator integer NULL, + fk_user_holiday_validator integer NULL, idpers1 varchar(128), idpers2 varchar(128), diff --git a/htdocs/user/card.php b/htdocs/user/card.php index c5103278dda..50ce988838c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -915,7 +915,7 @@ if ($action == 'create' || $action == 'adduserldap') { $defaultemployee = '1'; print ''; print ''.$langs->trans('Employee').''; - print ''; + print ''; //print $form->selectyesno("employee", (GETPOST('employee') != '' ?GETPOST('employee') : $defaultemployee), 1); print ''; From 40d67d70d2c399aec5ef3b5910aaca6ae425f05b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Feb 2022 12:33:40 +0100 Subject: [PATCH 21/23] Fix module partnership --- .../mysql/data/llx_c_partnership_type.sql | 27 +++++++++++++++++++ htdocs/langs/en_US/main.lang | 2 ++ .../partnership/class/partnership.class.php | 6 ++--- .../class/partnershiputils.class.php | 2 +- htdocs/partnership/partnership_card.php | 7 ++--- htdocs/partnership/partnership_list.php | 2 +- 6 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 htdocs/install/mysql/data/llx_c_partnership_type.sql diff --git a/htdocs/install/mysql/data/llx_c_partnership_type.sql b/htdocs/install/mysql/data/llx_c_partnership_type.sql new file mode 100644 index 00000000000..9410911b374 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_partnership_type.sql @@ -0,0 +1,27 @@ +-- Copyright (C) 2020 florian HENRY florian.henry@scopen.fr +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- + +-- +-- Do not place a comment at the end of the line, this file is parsed when +-- from the install and all '--' are removed. +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + +INSERT INTO llx_c_partnership_type (code, label, active) VALUES ('DEFAULT', 'Default', 1); + diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 2d850927782..6cb069d53c3 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1164,3 +1164,5 @@ NotClosedYet=Not yet closed ClearSignature=Reset signature CanceledHidden=Canceled hidden CanceledShown=Canceled shown +Terminate=Terminate +Terminated=Terminated diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 39cf2da2b2f..adc9e115aa5 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -118,7 +118,7 @@ class Partnership extends CommonObject 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Canceled'),), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Terminated'),), 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), @@ -1085,12 +1085,12 @@ class Partnership extends CommonObject $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved'); $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused'); - $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated'); $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved'); $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused'); - $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated'); } $statusType = 'status'.$status; diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 35b8a3b01e5..ef4f7cfdeb4 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -64,7 +64,7 @@ class PartnershipUtils { global $conf, $langs, $user; - $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + $managedfor = empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) ? 'thirdparty' : $conf->global->PARTNERSHIP_IS_MANAGED_FOR; if ($managedfor != 'member') { return 0; // If option 'PARTNERSHIP_IS_MANAGED_FOR' = 'thirdparty', this cron job does nothing. diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index 6afb9c88912..bfaec42eaa4 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -79,13 +79,14 @@ $permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd & $permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; -$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; +$managedfor = empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) ? 'thirdparty' : $conf->global->PARTNERSHIP_IS_MANAGED_FOR; if (empty($conf->partnership->enabled)) accessforbidden(); if (empty($permissiontoread)) accessforbidden(); if ($object->id > 0 && $object->fk_member > 0 && $managedfor != 'member') accessforbidden(); if ($object->id > 0 && $object->fk_soc > 0 && $managedfor != 'thirdparty') accessforbidden(); + /* * Actions */ @@ -581,7 +582,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Approve if ($object->status == $object::STATUS_VALIDATED) { if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print dolGetButtonAction($langs->trans('Approved'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_accept&confirm=yes&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('Approve'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_accept&confirm=yes&token='.newToken(), '', $permissiontoadd); } else { $langs->load("errors"); print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Approved"), 'default', '#', '', 0); @@ -591,7 +592,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Cancel if ($permissiontoadd) { if ($object->status == $object::STATUS_APPROVED) { - print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('Resiliate'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); } elseif ($object->status > $object::STATUS_APPROVED) { // print ''.$langs->trans("Re-Open").''."\n"; print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken(), '', $permissiontoadd); diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 2703d431e1a..89394960632 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -74,7 +74,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; +$managedfor = empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) ? 'thirdparty' : $conf->global->PARTNERSHIP_IS_MANAGED_FOR; if ($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; From 8866d447c794c67ce19fde5c72dafcd531ac61d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Feb 2022 16:01:07 +0100 Subject: [PATCH 22/23] Fix error message --- htdocs/langs/en_US/errors.lang | 2 +- htdocs/main.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 293bf4ad53b..5a955ec0df3 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -64,7 +64,7 @@ ErrorDestinationAlreadyExists=Another file with the name %s already exist ErrorPartialFile=File not received completely by server. ErrorNoTmpDir=Temporary directy %s does not exists. ErrorUploadBlockedByAddon=Upload blocked by a PHP/Apache plugin. -ErrorFileSizeTooLarge=File size is too large. +ErrorFileSizeTooLarge=File size is too large or file not provided. ErrorFieldTooLong=Field %s is too long. ErrorSizeTooLongForIntType=Size too long for int type (%s digits maximum) ErrorSizeTooLongForVarcharType=Size too long for string type (%s chars maximum) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 46315f2d688..e4b6d88a42c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -504,7 +504,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( // If token is not provided or empty, error (we are in case it is mandatory) if (!GETPOST('token', 'alpha') || GETPOST('token', 'alpha') == 'notrequired') { if (GETPOST('uploadform', 'int')) { - dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused. File size too large."); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused. File size too large or not provided."); $langs->loadLangs(array("errors", "install")); print $langs->trans("ErrorFileSizeTooLarge").' '; print $langs->trans("ErrorGoBackAndCorrectParameters"); From ca236c556a63a77d0f97c5af69f956ce885671ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Feb 2022 19:45:53 +0100 Subject: [PATCH 23/23] FIX Blocking situation when a payment was deleted in bank. FIX Missing or bad permissions --- htdocs/compta/facture/card.php | 4 +- htdocs/compta/paiement.php | 12 +++- htdocs/compta/paiement/card.php | 67 ++++++++++++++++++- .../compta/paiement/class/paiement.class.php | 2 + htdocs/langs/en_US/banks.lang | 1 + htdocs/societe/class/societe.class.php | 32 ++++----- 6 files changed, 97 insertions(+), 21 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f2b26c73242..1d57f9c13d4 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -734,7 +734,7 @@ if (empty($reshook)) { } if (!$error) { - // On verifie si la facture a des paiements + // We check if invoice has payments $sql = 'SELECT pf.amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; $sql .= ' WHERE pf.fk_facture = '.((int) $object->id); @@ -984,7 +984,7 @@ if (empty($reshook)) { $db->rollback(); } } - } elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate) { + } elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercanissuepayment) { // Delete payment $object->fetch($id); if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) { diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 635727233d3..96d482b33ae 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -75,6 +75,12 @@ $hookmanager->initHooks(array('paiementcard', 'globalcard')); $formquestion = array(); +$usercanissuepayment = !empty($user->rights->facture->paiement); + +$fieldid = 'rowid'; +$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft); + /* * Actions @@ -87,7 +93,7 @@ if ($reshook < 0) { } if (empty($reshook)) { - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { + if (($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) && $usercanissuepayment) { $error = 0; $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); @@ -202,7 +208,7 @@ if (empty($reshook)) { /* * Action confirm_paiement */ - if ($action == 'confirm_paiement' && $confirm == 'yes') { + if ($action == 'confirm_paiement' && $confirm == 'yes' && $usercanissuepayment) { $error = 0; $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); @@ -486,7 +492,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.$langs->trans('AccountToDebit').''; } print ''; - $form->select_comptes($accountid, 'accountid', 0, '', 2); + print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, '', 1); print ''; } else { print ' '; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 93fdd415513..8ff229f7ba7 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -64,6 +64,8 @@ if ($socid && $socid != $object->thirdparty->id) { accessforbidden(); } +$error = 0; + /* * Actions @@ -191,6 +193,39 @@ if ($action == 'setdatep' && !empty($_POST['datepday'])) { setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); } } +if ($action == 'createbankpayment' && !empty($user->rights->facture->paiement)) { + $db->begin(); + + // Create the record into bank for the amount of payment $object + if (!$error) { + $label = '(CustomerInvoicePayment)'; + if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) { + $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + } + + $bankaccountid = GETPOST('accountid', 'int'); + if ($bankaccountid > 0) { + $object->paiementcode = $object->type_code; + $object->amounts = $object->getAmountsArray(); + + $result = $object->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', ''); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } else { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); + $error++; + } + } + + + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } +} /* @@ -315,7 +350,37 @@ if (!empty($conf->banque->enabled)) { print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted'); } else { $langs->load("admin"); - print ''.$langs->trans("NoRecordFoundIBankcAccount", $langs->transnoentitiesnoconv("Module85Name")).''; + print ''; + print $langs->trans("NoRecordFoundIBankcAccount", $langs->transnoentitiesnoconv("Module85Name")); + print ''; + if (!empty($user->rights->facture->paiement)) { + // Try to guess $bankaccountidofinvoices that is ID of bank account defined on invoice. + // Return null if not found, return 0 if it has different value for at least 2 invoices, return the value if same on all invoices where a bank is defined. + $amountofpayments = $object->getAmountsArray(); + $bankaccountidofinvoices = null; + foreach ($amountofpayments as $idinvoice => $amountofpayment) { + $tmpinvoice = new Facture($db); + $tmpinvoice->fetch($idinvoice); + if ($tmpinvoice->fk_account > 0 && $bankaccountidofinvoices !== 0) { + if (is_null($bankaccountidofinvoices)) { + $bankaccountidofinvoices = $tmpinvoice->fk_account; + } elseif ($bankaccountidofinvoices != $tmpinvoice->fk_account) { + $bankaccountidofinvoices = 0; + } + } + } + + print '
'; + print ''; + print ''; + print ''; + print ' '.$langs->trans("ToCreateRelatedRecordIntoBank").': '; + print $form->select_comptes($bankaccountidofinvoices, 'accountid', 0, '', 2, '', 0, '', 1); + //print ''; + print ''; + //print ''; + print '
'; + } } print ''; print ''; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index ab68ac7f9b1..3abf38fb16e 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -951,6 +951,7 @@ class Paiement extends CommonObject * * @param string $filter Filter * @return int|array <0 if KO or array of invoice id + * @see getAmountsArray() */ public function getBillsArray($filter = '') { @@ -984,6 +985,7 @@ class Paiement extends CommonObject * Return list of amounts of payments. * * @return int|array Array of amount of payments + * @see getBillsArray() */ public function getAmountsArray() { diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index f066877f676..35ec6ac563b 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -182,3 +182,4 @@ IfYouDontReconcileDisableProperty=If you don't make the bank reconciliations on NoBankAccountDefined=No bank account defined NoRecordFoundIBankcAccount=No record found in bank account. Commonly, this occurs when a record has been deleted manually from the list of transaction in the bank account (for example during a reconciliation of the bank account). Another reason is that the payment was recorded when the module "%s" was disabled. AlreadyOneBankAccount=Already one bank account defined +ToCreateRelatedRecordIntoBank=To create missing related bank record \ No newline at end of file diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8a5f8166106..9fb7783c345 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -41,6 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonincoterm.class.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; + /** * Class to manage third parties objects (customers, suppliers, prospects...) */ @@ -2573,7 +2574,7 @@ class Societe extends CommonObject $name .= ' ('.$this->name_alias.')'; } - $result = ''; $label = ''; + $result = ''; $label = ''; $label2 = ''; $linkstart = ''; $linkend = ''; if (!empty($this->logo) && class_exists('Form')) { @@ -2641,47 +2642,48 @@ class Societe extends CommonObject } $label .= '
'.implode(' ', $phonelist); } + if (!empty($this->address)) { - $label .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); // Address + country + $label2 .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); // Address + country } elseif (!empty($this->country_code)) { - $label .= '
'.$langs->trans('Country').': '.$this->country_code; + $label2 .= '
'.$langs->trans('Country').': '.$this->country_code; } if (!empty($this->tva_intra) || (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP) && strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'vatnumber') !== false)) { - $label .= '
'.$langs->trans('VATIntra').': '.dol_escape_htmltag($this->tva_intra); + $label2 .= '
'.$langs->trans('VATIntra').': '.dol_escape_htmltag($this->tva_intra); } if (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP)) { if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid1') !== false) { - $label .= '
'.$langs->trans('ProfId1'.$this->country_code).': '.$this->idprof1; + $label2 .= '
'.$langs->trans('ProfId1'.$this->country_code).': '.$this->idprof1; } if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid2') !== false) { - $label .= '
'.$langs->trans('ProfId2'.$this->country_code).': '.$this->idprof2; + $label2 .= '
'.$langs->trans('ProfId2'.$this->country_code).': '.$this->idprof2; } if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid3') !== false) { - $label .= '
'.$langs->trans('ProfId3'.$this->country_code).': '.$this->idprof3; + $label2 .= '
'.$langs->trans('ProfId3'.$this->country_code).': '.$this->idprof3; } if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid4') !== false) { - $label .= '
'.$langs->trans('ProfId4'.$this->country_code).': '.$this->idprof4; + $label2 .= '
'.$langs->trans('ProfId4'.$this->country_code).': '.$this->idprof4; } if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid5') !== false) { - $label .= '
'.$langs->trans('ProfId5'.$this->country_code).': '.$this->idprof5; + $label2 .= '
'.$langs->trans('ProfId5'.$this->country_code).': '.$this->idprof5; } if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid6') !== false) { - $label .= '
'.$langs->trans('ProfId6'.$this->country_code).': '.$this->idprof6; + $label2 .= '
'.$langs->trans('ProfId6'.$this->country_code).': '.$this->idprof6; } } if (!empty($this->code_client) && ($this->client == 1 || $this->client == 3)) { - $label .= '
'.$langs->trans('CustomerCode').': '.$this->code_client; + $label2 .= '
'.$langs->trans('CustomerCode').': '.$this->code_client; } if (!empty($this->code_fournisseur) && $this->fournisseur) { - $label .= '
'.$langs->trans('SupplierCode').': '.$this->code_fournisseur; + $label2 .= '
'.$langs->trans('SupplierCode').': '.$this->code_fournisseur; } if (!empty($conf->accounting->enabled) && ($this->client == 1 || $this->client == 3)) { - $label .= '
'.$langs->trans('CustomerAccountancyCode').': '.($this->code_compta ? $this->code_compta : $this->code_compta_client); + $label2 .= '
'.$langs->trans('CustomerAccountancyCode').': '.($this->code_compta ? $this->code_compta : $this->code_compta_client); } if (!empty($conf->accounting->enabled) && $this->fournisseur) { - $label .= '
'.$langs->trans('SupplierAccountancyCode').': '.$this->code_compta_fournisseur; + $label2 .= '
'.$langs->trans('SupplierAccountancyCode').': '.$this->code_compta_fournisseur; } - $label .= ''; + $label .= ($label2 ? '
'.$label2 : '').''; // Add type of canvas $linkstart .= (!empty($this->canvas) ? '&canvas='.$this->canvas : '');