From 4aab805b4edfbb536690b2c279e0078374d7b165 Mon Sep 17 00:00:00 2001 From: Laurent Magnin Date: Fri, 16 Apr 2021 12:39:39 +0200 Subject: [PATCH 01/74] FIX:Add ticket substition template --- htdocs/core/lib/functions.lib.php | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2b981530834..c3ce5128f57 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6838,6 +6838,28 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, /*$substitutionarray['__MEMBER_NOTE_PUBLIC__'] = '__MEMBER_NOTE_PUBLIC__'; $substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/ } +// add variables subtitutions ticket + if (!empty($conf->ticket->enabled) && (!is_object($object) || $object->element == 'ticket')) { + $substitutionarray['__TICKET_TRACKID__'] = '__TICKET_TRACKID__'; + $substitutionarray['__TICKET_REF__'] = '__TICKET_REF__'; + $substitutionarray['__TICKET_SUBJECT__'] = '__TICKET_SUBJECT__'; + $substitutionarray['__TICKET_TYPE__'] = '__TICKET_TYPE__'; + $substitutionarray['__TICKET_SEVERITY__'] = '__TICKET_SEVERITY__'; + $substitutionarray['__TICKET_CATEGORY__'] = '__TICKET_CATEGORY__'; + $substitutionarray['__TICKET_ANALYTIC_CODE__'] = '__TICKET_ANALYTIC_CODE__'; + $substitutionarray['__TICKET_MESSAGE__'] = '__TICKET_MESSAGE__'; + $substitutionarray['__TICKET_PROGRESSION__'] = '__TICKET_PROGRESSION__'; + $substitutionarray['__TICKET_USER_ASSIGN__'] = '__TICKET_USER_ASSIGN__'; + $substitutionarray['__TICKET_USER_CREATE__'] = '__TICKET_USER_CREATE__'; + + +} + + + + + + if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element == 'candidature')) { $substitutionarray['__CANDIDATE_FULLNAME__'] = '__CANDIDATE_FULLNAME__'; $substitutionarray['__CANDIDATE_FIRSTNAME__'] = '__CANDIDATE_FIRSTNAME__'; @@ -7025,6 +7047,21 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); } +// add substition variable for ticket + if (is_object($object) && $object->element == 'ticket') { + $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; + $substitutionarray['__TICKET_REF__'] = $object->ref; + $substitutionarray['__TICKET_SUBJECT__'] = $object->subject; + $substitutionarray['__TICKET_TYPE__'] = $object->type_code; + $substitutionarray['__TICKET_SEVERITY__'] = $object->severity_code; + $substitutionarray['__TICKET_CATEGORY__'] = $object->category_code; // For backward compatibility + $substitutionarray['__TICKET_ANALYTIC_CODE__'] = $object->category_code; + $substitutionarray['__TICKET_MESSAGE__'] = $object->message; + $substitutionarray['__TICKET_PROGRESSION__'] = $object->progress; + $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($user->firstname, $user->lastname); + $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($user->firstname, $user->lastname); + } + // Create dynamic tags for __EXTRAFIELD_FIELD__ if ($object->table_element && $object->id > 0) { From db0b00f93abcf4b804f5a9eaa25b76ada2902f0b Mon Sep 17 00:00:00 2001 From: Laurent Magnin Date: Fri, 2 Jul 2021 12:30:07 +0200 Subject: [PATCH 02/74] Standard ticket substitutions --- htdocs/core/lib/functions.lib.php | 26 +++++++++++++------------- htdocs/ticket/card.php | 25 ------------------------- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f25e13ee88c..149cbd8530a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6848,7 +6848,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, /*$substitutionarray['__MEMBER_NOTE_PUBLIC__'] = '__MEMBER_NOTE_PUBLIC__'; $substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/ } -// add variables subtitutions ticket + // add variables subtitutions ticket if (!empty($conf->ticket->enabled) && (!is_object($object) || $object->element == 'ticket')) { $substitutionarray['__TICKET_TRACKID__'] = '__TICKET_TRACKID__'; $substitutionarray['__TICKET_REF__'] = '__TICKET_REF__'; @@ -6861,14 +6861,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__TICKET_PROGRESSION__'] = '__TICKET_PROGRESSION__'; $substitutionarray['__TICKET_USER_ASSIGN__'] = '__TICKET_USER_ASSIGN__'; $substitutionarray['__TICKET_USER_CREATE__'] = '__TICKET_USER_CREATE__'; - - -} - - - - - + } if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element == 'candidature')) { $substitutionarray['__CANDIDATE_FULLNAME__'] = '__CANDIDATE_FULLNAME__'; @@ -7058,7 +7051,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); } -// add substition variable for ticket + // add substition variable for ticket if (is_object($object) && $object->element == 'ticket') { $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; $substitutionarray['__TICKET_REF__'] = $object->ref; @@ -7069,10 +7062,17 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__TICKET_ANALYTIC_CODE__'] = $object->category_code; $substitutionarray['__TICKET_MESSAGE__'] = $object->message; $substitutionarray['__TICKET_PROGRESSION__'] = $object->progress; - $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($user->firstname, $user->lastname); - $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($user->firstname, $user->lastname); - } + $userstat = new User($db); + if ($object->fk_user_assign > 0) { + $userstat->fetch($object->fk_user_assign); + $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); + } + if ($object->fk_user_create > 0) { + $userstat->fetch($object->fk_user_create); + $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); + } + } // Create dynamic tags for __EXTRAFIELD_FIELD__ if ($object->table_element && $object->id > 0) { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 5faa7b201b7..7de6ea2d966 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1347,31 +1347,6 @@ if ($action == 'create' || $action == 'presend') { $morehtmlright = ''; $help = ""; $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object); - if ($object->fk_soc > 0) { - $substitutionarray['__THIRDPARTY_NAME__'] = $object->thirdparty->name; - } - $substitutionarray['__USER_SIGNATURE__'] = $user->signature; - $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; - $substitutionarray['__TICKET_REF__'] = $object->ref; - $substitutionarray['__TICKET_SUBJECT__'] = $object->subject; - $substitutionarray['__TICKET_TYPE__'] = $object->type_code; - $substitutionarray['__TICKET_SEVERITY__'] = $object->severity_code; - $substitutionarray['__TICKET_CATEGORY__'] = $object->category_code; // For backward compatibility - $substitutionarray['__TICKET_ANALYTIC_CODE__'] = $object->category_code; - $substitutionarray['__TICKET_MESSAGE__'] = $object->message; - $substitutionarray['__TICKET_PROGRESSION__'] = $object->progress; - if ($object->fk_user_assign > 0) { - $userstat->fetch($object->fk_user_assign); - $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); - } - - if ($object->fk_user_create > 0) { - $userstat->fetch($object->fk_user_create); - $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); - } - foreach ($substitutionarray as $key => $val) { - $help .= $key.' -> '.$langs->trans($val).'
'; - } $morehtmlright .= $form->textwithpicto(''.$langs->trans("TicketMessageSubstitutionReplacedByGenericValues").'', $help, 1, 'helpclickable', '', 0, 3, 'helpsubstitution'); print '
'; From 5f40c2e9dde572e872796fc1d40538cc603867a0 Mon Sep 17 00:00:00 2001 From: Laurent Magnin Date: Fri, 19 Nov 2021 17:08:07 +0100 Subject: [PATCH 03/74] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 648a2e6b0dc..f3a7a6116e9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6992,7 +6992,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, // add variables subtitutions ticket if (!empty($conf->ticket->enabled) && (!is_object($object) || $object->element == 'ticket')) { $substitutionarray['__TICKET_TRACKID__'] = '__TICKET_TRACKID__'; - $substitutionarray['__TICKET_REF__'] = '__TICKET_REF__'; $substitutionarray['__TICKET_SUBJECT__'] = '__TICKET_SUBJECT__'; $substitutionarray['__TICKET_TYPE__'] = '__TICKET_TYPE__'; $substitutionarray['__TICKET_SEVERITY__'] = '__TICKET_SEVERITY__'; @@ -7001,7 +7000,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__TICKET_MESSAGE__'] = '__TICKET_MESSAGE__'; $substitutionarray['__TICKET_PROGRESSION__'] = '__TICKET_PROGRESSION__'; $substitutionarray['__TICKET_USER_ASSIGN__'] = '__TICKET_USER_ASSIGN__'; - $substitutionarray['__TICKET_USER_CREATE__'] = '__TICKET_USER_CREATE__'; } if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element == 'candidature')) { From c8c6d5c1d24f5e9f091ff789f8fdb523a5522085 Mon Sep 17 00:00:00 2001 From: Laurent Magnin Date: Fri, 19 Nov 2021 17:09:51 +0100 Subject: [PATCH 04/74] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f3a7a6116e9..f2c968412b2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7194,7 +7194,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, // add substition variable for ticket if (is_object($object) && $object->element == 'ticket') { $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; - $substitutionarray['__TICKET_REF__'] = $object->ref; + $substitutionarray['__REF__'] = $object->ref; $substitutionarray['__TICKET_SUBJECT__'] = $object->subject; $substitutionarray['__TICKET_TYPE__'] = $object->type_code; $substitutionarray['__TICKET_SEVERITY__'] = $object->severity_code; @@ -7210,7 +7210,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if ($object->fk_user_create > 0) { $userstat->fetch($object->fk_user_create); - $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); + $substitutionarray['__USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); } } From 812e5a3b72b4c7aeaa6a5e6c0c2681a3706012c0 Mon Sep 17 00:00:00 2001 From: alsoft10 Date: Mon, 13 Dec 2021 16:02:27 +0530 Subject: [PATCH 05/74] Feature update : #19569 --- .../class/emailcollector.class.php | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f4341109000..7e97cf9b110 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2067,6 +2067,14 @@ class EmailCollector extends CommonObject $errorforactions++; $this->error = 'Failed to create ticket: '.$langs->trans($tickettocreate->error); $this->errors = $tickettocreate->errors; + } else { + if($attachments) { + $destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref; + if (!dol_is_dir($destdir)) { + dol_mkdir($destdir); + $this->getmsg($connection, $imapemail, $destdir); + } + } } } } @@ -2290,7 +2298,7 @@ class EmailCollector extends CommonObject * @param string $mid prefix * @return array Array with number and object */ - private function getmsg($mbox, $mid) + private function getmsg($mbox, $mid, $destdir='') { // input $mbox = IMAP stream, $mid = message id // output all the following: @@ -2311,7 +2319,7 @@ class EmailCollector extends CommonObject } else { // multipart: cycle through each part foreach ($s->parts as $partno0 => $p) { - $this->getpart($mbox, $mid, $p, $partno0 + 1); + $this->getpart($mbox, $mid, $p, $partno0 + 1, $destdir); } } } @@ -2340,7 +2348,7 @@ class EmailCollector extends CommonObject * @param string $partno Partno * @return void */ - private function getpart($mbox, $mid, $p, $partno) + private function getpart($mbox, $mid, $p, $partno, $destdir='') { // $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple global $htmlmsg, $plainmsg, $charset, $attachments; @@ -2378,6 +2386,39 @@ class EmailCollector extends CommonObject $filename = ($params['filename']) ? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode() $attachments[$filename] = $data; // this is a problem if two files have same name + + // Get file name (with extension) + $file_name_complete = $params['filename']; + + + $destination = $destdir.'/'.$file_name_complete; + + // Extract file extension + $extension = pathinfo($file_name_complete, PATHINFO_EXTENSION); + + // Extract file name without extension + $file_name = pathinfo($file_name_complete, PATHINFO_FILENAME); + + // Save an original file name variable to track while renaming if file already exists + $file_name_original = $file_name; + + // Increment file name by 1 + $num = 1; + + /** + * Check if the same file name already exists in the upload folder, + * append increment number to the original filename + */ + while (file_exists($destdir."/" . $file_name . "." . $extension)) { + $file_name = (string) $file_name_original . ' (' . $num . ')'; + $file_name_complete = $file_name . "." . $extension; + $destination = $destdir.'/'.$file_name_complete; + $num++; + } + + + file_put_contents($destination, $data); + } // TEXT From 90f25ab21ac0759c4119386f654d87f5979b6ea8 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Fri, 17 Dec 2021 12:09:14 +0700 Subject: [PATCH 06/74] FIX supplier_proposal when line update price U.P change 0 modify --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index ea10b4d7137..b239b6cc3da 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -725,6 +725,7 @@ class SupplierProposal extends CommonObject $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu = $pu_ht = $tabprice[3]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; From 5dd0aa05495a500582ca7153c90c360948cc197c Mon Sep 17 00:00:00 2001 From: alsoft10 Date: Thu, 23 Dec 2021 18:14:12 +0530 Subject: [PATCH 07/74] Feature Update #19678 --- htdocs/main.inc.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 9753f4b3d83..be964015f75 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1744,6 +1744,14 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } } } + + //If you want to load custom javascript file from your selected theme directory + if (!empty($conf->global->ALLOW_THEME_JS)) { + $theme_js = dol_buildpath('/theme/'.$conf->theme.'/'.$conf->theme.'.js', 0); + if (file_exists($theme_js)) { + print ''."\n"; + } + } if (!empty($head)) { print $head."\n"; From a2cb020394be4a2d2d955359f07ac8170cfd88ff Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 23 Dec 2021 12:45:26 +0000 Subject: [PATCH 08/74] Fixing style errors. --- .../emailcollector/class/emailcollector.class.php | 13 ++++++------- htdocs/main.inc.php | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 7e97cf9b110..243b93a55c3 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2068,7 +2068,7 @@ class EmailCollector extends CommonObject $this->error = 'Failed to create ticket: '.$langs->trans($tickettocreate->error); $this->errors = $tickettocreate->errors; } else { - if($attachments) { + if ($attachments) { $destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref; if (!dol_is_dir($destdir)) { dol_mkdir($destdir); @@ -2298,7 +2298,7 @@ class EmailCollector extends CommonObject * @param string $mid prefix * @return array Array with number and object */ - private function getmsg($mbox, $mid, $destdir='') + private function getmsg($mbox, $mid, $destdir = '') { // input $mbox = IMAP stream, $mid = message id // output all the following: @@ -2348,7 +2348,7 @@ class EmailCollector extends CommonObject * @param string $partno Partno * @return void */ - private function getpart($mbox, $mid, $p, $partno, $destdir='') + private function getpart($mbox, $mid, $p, $partno, $destdir = '') { // $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple global $htmlmsg, $plainmsg, $charset, $attachments; @@ -2386,11 +2386,11 @@ class EmailCollector extends CommonObject $filename = ($params['filename']) ? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode() $attachments[$filename] = $data; // this is a problem if two files have same name - + // Get file name (with extension) $file_name_complete = $params['filename']; - + $destination = $destdir.'/'.$file_name_complete; // Extract file extension @@ -2407,7 +2407,7 @@ class EmailCollector extends CommonObject /** * Check if the same file name already exists in the upload folder, - * append increment number to the original filename + * append increment number to the original filename */ while (file_exists($destdir."/" . $file_name . "." . $extension)) { $file_name = (string) $file_name_original . ' (' . $num . ')'; @@ -2418,7 +2418,6 @@ class EmailCollector extends CommonObject file_put_contents($destination, $data); - } // TEXT diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index be964015f75..345ef7b496e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1744,9 +1744,9 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } } } - + //If you want to load custom javascript file from your selected theme directory - if (!empty($conf->global->ALLOW_THEME_JS)) { + if (!empty($conf->global->ALLOW_THEME_JS)) { $theme_js = dol_buildpath('/theme/'.$conf->theme.'/'.$conf->theme.'.js', 0); if (file_exists($theme_js)) { print ''."\n"; From 7ca333f4d7c79df70be61520d26dfab62d813708 Mon Sep 17 00:00:00 2001 From: kamel Date: Mon, 24 Jan 2022 17:04:46 +0100 Subject: [PATCH 09/74] Fix the vat report by month and rate (with also the vat src code) --- htdocs/core/lib/tax.lib.php | 275 +++++++++++++++++++----------------- 1 file changed, 145 insertions(+), 130 deletions(-) diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 40e50544b22..3249166c083 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -696,7 +696,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) { // Count on delivery date (use invoice date as delivery is unknown) - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; @@ -739,7 +739,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; @@ -799,66 +799,71 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $rate = -1; $oldrowid = ''; while ($assoc = $db->fetch_array($resql)) { + $rate_key = $assoc['rate']; + if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) { + $rate_key .= ' (' . $assoc['vat_src_code'] . ')'; + } + // Code to avoid warnings when array entry not defined - if (!isset($list[$assoc['rate']]['totalht'])) { - $list[$assoc['rate']]['totalht'] = 0; + if (!isset($list[$rate_key]['totalht'])) { + $list[$rate_key]['totalht'] = 0; } - if (!isset($list[$assoc['rate']]['vat'])) { - $list[$assoc['rate']]['vat'] = 0; + if (!isset($list[$rate_key]['vat'])) { + $list[$rate_key]['vat'] = 0; } - if (!isset($list[$assoc['rate']]['localtax1'])) { - $list[$assoc['rate']]['localtax1'] = 0; + if (!isset($list[$rate_key]['localtax1'])) { + $list[$rate_key]['localtax1'] = 0; } - if (!isset($list[$assoc['rate']]['localtax2'])) { - $list[$assoc['rate']]['localtax2'] = 0; + if (!isset($list[$rate_key]['localtax2'])) { + $list[$rate_key]['localtax2'] = 0; } if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid $oldrowid = $assoc['rowid']; - $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; - $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; + $list[$rate_key]['totalht'] += $assoc['total_ht']; + $list[$rate_key]['vat'] += $assoc['total_vat']; + $list[$rate_key]['localtax1'] += $assoc['total_localtax1']; + $list[$rate_key]['localtax2'] += $assoc['total_localtax2']; } - $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; - $list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']); - $list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']); + $list[$rate_key]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$rate_key]['dtype'][] = $assoc['dtype']; + $list[$rate_key]['datef'][] = $db->jdate($assoc['datef']); + $list[$rate_key]['datep'][] = $db->jdate($assoc['datep']); - $list[$assoc['rate']]['company_name'][] = $assoc['company_name']; - $list[$assoc['rate']]['company_id'][] = $assoc['company_id']; - $list[$assoc['rate']]['company_alias'][] = $assoc['company_alias']; - $list[$assoc['rate']]['company_email'][] = $assoc['company_email']; - $list[$assoc['rate']]['company_tva_intra'][] = $assoc['company_tva_intra']; - $list[$assoc['rate']]['company_client'][] = $assoc['company_client']; - $list[$assoc['rate']]['company_fournisseur'][] = $assoc['company_fournisseur']; - $list[$assoc['rate']]['company_customer_code'][] = $assoc['company_customer_code']; - $list[$assoc['rate']]['company_supplier_code'][] = $assoc['company_supplier_code']; - $list[$assoc['rate']]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code']; - $list[$assoc['rate']]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code']; - $list[$assoc['rate']]['company_status'][] = $assoc['company_status']; + $list[$rate_key]['company_name'][] = $assoc['company_name']; + $list[$rate_key]['company_id'][] = $assoc['company_id']; + $list[$rate_key]['company_alias'][] = $assoc['company_alias']; + $list[$rate_key]['company_email'][] = $assoc['company_email']; + $list[$rate_key]['company_tva_intra'][] = $assoc['company_tva_intra']; + $list[$rate_key]['company_client'][] = $assoc['company_client']; + $list[$rate_key]['company_fournisseur'][] = $assoc['company_fournisseur']; + $list[$rate_key]['company_customer_code'][] = $assoc['company_customer_code']; + $list[$rate_key]['company_supplier_code'][] = $assoc['company_supplier_code']; + $list[$rate_key]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code']; + $list[$rate_key]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code']; + $list[$rate_key]['company_status'][] = $assoc['company_status']; - $list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']); - $list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']); + $list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']); - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - $list[$assoc['rate']]['type'][] = $assoc['type']; - $list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['rate']]['descr'][] = $assoc['descr']; + $list[$rate_key]['facid'][] = $assoc['facid']; + $list[$rate_key]['facnum'][] = $assoc['facnum']; + $list[$rate_key]['type'][] = $assoc['type']; + $list[$rate_key]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$rate_key]['descr'][] = $assoc['descr']; - $list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['rate']]['vat_list'][] = $assoc['total_vat']; - $list[$assoc['rate']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2']; + $list[$rate_key]['totalht_list'][] = $assoc['total_ht']; + $list[$rate_key]['vat_list'][] = $assoc['total_vat']; + $list[$rate_key]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$rate_key]['localtax2_list'][] = $assoc['total_localtax2']; - $list[$assoc['rate']]['pid'][] = $assoc['pid']; - $list[$assoc['rate']]['pref'][] = $assoc['pref']; - $list[$assoc['rate']]['ptype'][] = $assoc['ptype']; + $list[$rate_key]['pid'][] = $assoc['pid']; + $list[$rate_key]['pref'][] = $assoc['pref']; + $list[$rate_key]['ptype'][] = $assoc['ptype']; - $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['rate']]['payment_ref'][] = $assoc['payment_ref']; - $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; + $list[$rate_key]['payment_id'][] = $assoc['payment_id']; + $list[$rate_key]['payment_ref'][] = $assoc['payment_ref']; + $list[$rate_key]['payment_amount'][] = $assoc['payment_amount']; $rate = $assoc['rate']; } @@ -876,7 +881,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { // Count on invoice date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; @@ -919,7 +924,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; @@ -979,66 +984,71 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $rate = -1; $oldrowid = ''; while ($assoc = $db->fetch_array($resql)) { + $rate_key = $assoc['rate']; + if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) { + $rate_key .= ' (' . $assoc['vat_src_code'] . ')'; + } + // Code to avoid warnings when array entry not defined - if (!isset($list[$assoc['rate']]['totalht'])) { - $list[$assoc['rate']]['totalht'] = 0; + if (!isset($list[$rate_key]['totalht'])) { + $list[$rate_key]['totalht'] = 0; } - if (!isset($list[$assoc['rate']]['vat'])) { - $list[$assoc['rate']]['vat'] = 0; + if (!isset($list[$rate_key]['vat'])) { + $list[$rate_key]['vat'] = 0; } - if (!isset($list[$assoc['rate']]['localtax1'])) { - $list[$assoc['rate']]['localtax1'] = 0; + if (!isset($list[$rate_key]['localtax1'])) { + $list[$rate_key]['localtax1'] = 0; } - if (!isset($list[$assoc['rate']]['localtax2'])) { - $list[$assoc['rate']]['localtax2'] = 0; + if (!isset($list[$rate_key]['localtax2'])) { + $list[$rate_key]['localtax2'] = 0; } if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid $oldrowid = $assoc['rowid']; - $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; - $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; + $list[$rate_key]['totalht'] += $assoc['total_ht']; + $list[$rate_key]['vat'] += $assoc['total_vat']; + $list[$rate_key]['localtax1'] += $assoc['total_localtax1']; + $list[$rate_key]['localtax2'] += $assoc['total_localtax2']; } - $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; - $list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']); - $list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']); + $list[$rate_key]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$rate_key]['dtype'][] = $assoc['dtype']; + $list[$rate_key]['datef'][] = $db->jdate($assoc['datef']); + $list[$rate_key]['datep'][] = $db->jdate($assoc['datep']); - $list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']); - $list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']); + $list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']); - $list[$assoc['rate']]['company_name'][] = $assoc['company_name']; - $list[$assoc['rate']]['company_id'][] = $assoc['company_id']; - $list[$assoc['rate']]['company_alias'][] = $assoc['company_alias']; - $list[$assoc['rate']]['company_email'][] = $assoc['company_email']; - $list[$assoc['rate']]['company_tva_intra'][] = $assoc['company_tva_intra']; - $list[$assoc['rate']]['company_client'][] = $assoc['company_client']; - $list[$assoc['rate']]['company_fournisseur'][] = $assoc['company_fournisseur']; - $list[$assoc['rate']]['company_customer_code'][] = $assoc['company_customer_code']; - $list[$assoc['rate']]['company_supplier_code'][] = $assoc['company_supplier_code']; - $list[$assoc['rate']]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code']; - $list[$assoc['rate']]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code']; - $list[$assoc['rate']]['company_status'][] = $assoc['company_status']; + $list[$rate_key]['company_name'][] = $assoc['company_name']; + $list[$rate_key]['company_id'][] = $assoc['company_id']; + $list[$rate_key]['company_alias'][] = $assoc['company_alias']; + $list[$rate_key]['company_email'][] = $assoc['company_email']; + $list[$rate_key]['company_tva_intra'][] = $assoc['company_tva_intra']; + $list[$rate_key]['company_client'][] = $assoc['company_client']; + $list[$rate_key]['company_fournisseur'][] = $assoc['company_fournisseur']; + $list[$rate_key]['company_customer_code'][] = $assoc['company_customer_code']; + $list[$rate_key]['company_supplier_code'][] = $assoc['company_supplier_code']; + $list[$rate_key]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code']; + $list[$rate_key]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code']; + $list[$rate_key]['company_status'][] = $assoc['company_status']; - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - $list[$assoc['rate']]['type'][] = $assoc['type']; - $list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['rate']]['descr'][] = $assoc['descr']; + $list[$rate_key]['facid'][] = $assoc['facid']; + $list[$rate_key]['facnum'][] = $assoc['facnum']; + $list[$rate_key]['type'][] = $assoc['type']; + $list[$rate_key]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$rate_key]['descr'][] = $assoc['descr']; - $list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['rate']]['vat_list'][] = $assoc['total_vat']; - $list[$assoc['rate']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2']; + $list[$rate_key]['totalht_list'][] = $assoc['total_ht']; + $list[$rate_key]['vat_list'][] = $assoc['total_vat']; + $list[$rate_key]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$rate_key]['localtax2_list'][] = $assoc['total_localtax2']; - $list[$assoc['rate']]['pid'][] = $assoc['pid']; - $list[$assoc['rate']]['pref'][] = $assoc['pref']; - $list[$assoc['rate']]['ptype'][] = $assoc['ptype']; + $list[$rate_key]['pid'][] = $assoc['pid']; + $list[$rate_key]['pref'][] = $assoc['pref']; + $list[$rate_key]['ptype'][] = $assoc['ptype']; - $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['rate']]['payment_ref'][] = $assoc['payment_ref']; - $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; + $list[$rate_key]['payment_id'][] = $assoc['payment_id']; + $list[$rate_key]['payment_ref'][] = $assoc['payment_ref']; + $list[$rate_key]['payment_amount'][] = $assoc['payment_amount']; $rate = $assoc['rate']; } @@ -1056,7 +1066,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql = ''; // Count on payments date - $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; + $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; $sql .= " d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; $sql .= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; $sql .= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; @@ -1101,55 +1111,60 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $rate = -1; $oldrowid = ''; while ($assoc = $db->fetch_array($resql)) { + $rate_key = $assoc['rate']; + if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) { + $rate_key .= ' (' . $assoc['vat_src_code'] . ')'; + } + // Code to avoid warnings when array entry not defined - if (!isset($list[$assoc['rate']]['totalht'])) { - $list[$assoc['rate']]['totalht'] = 0; + if (!isset($list[$rate_key]['totalht'])) { + $list[$rate_key]['totalht'] = 0; } - if (!isset($list[$assoc['rate']]['vat'])) { - $list[$assoc['rate']]['vat'] = 0; + if (!isset($list[$rate_key]['vat'])) { + $list[$rate_key]['vat'] = 0; } - if (!isset($list[$assoc['rate']]['localtax1'])) { - $list[$assoc['rate']]['localtax1'] = 0; + if (!isset($list[$rate_key]['localtax1'])) { + $list[$rate_key]['localtax1'] = 0; } - if (!isset($list[$assoc['rate']]['localtax2'])) { - $list[$assoc['rate']]['localtax2'] = 0; + if (!isset($list[$rate_key]['localtax2'])) { + $list[$rate_key]['localtax2'] = 0; } if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid $oldrowid = $assoc['rowid']; - $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; - $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; + $list[$rate_key]['totalht'] += $assoc['total_ht']; + $list[$rate_key]['vat'] += $assoc['total_vat']; + $list[$rate_key]['localtax1'] += $assoc['total_localtax1']; + $list[$rate_key]['localtax2'] += $assoc['total_localtax2']; } - $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['rate']]['dtype'][] = 'ExpenseReportPayment'; - $list[$assoc['rate']]['datef'][] = $assoc['datef']; - $list[$assoc['rate']]['company_name'][] = ''; - $list[$assoc['rate']]['company_id'][] = ''; - $list[$assoc['rate']]['user_id'][] = $assoc['fk_user_author']; - $list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']); - $list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']); + $list[$rate_key]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$rate_key]['dtype'][] = 'ExpenseReportPayment'; + $list[$rate_key]['datef'][] = $assoc['datef']; + $list[$rate_key]['company_name'][] = ''; + $list[$rate_key]['company_id'][] = ''; + $list[$rate_key]['user_id'][] = $assoc['fk_user_author']; + $list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']); - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - $list[$assoc['rate']]['type'][] = $assoc['type']; - $list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['rate']]['descr'][] = $assoc['descr']; + $list[$rate_key]['facid'][] = $assoc['facid']; + $list[$rate_key]['facnum'][] = $assoc['facnum']; + $list[$rate_key]['type'][] = $assoc['type']; + $list[$rate_key]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$rate_key]['descr'][] = $assoc['descr']; - $list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['rate']]['vat_list'][] = $assoc['total_vat']; - $list[$assoc['rate']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2']; + $list[$rate_key]['totalht_list'][] = $assoc['total_ht']; + $list[$rate_key]['vat_list'][] = $assoc['total_vat']; + $list[$rate_key]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$rate_key]['localtax2_list'][] = $assoc['total_localtax2']; - $list[$assoc['rate']]['pid'][] = $assoc['pid']; - $list[$assoc['rate']]['pref'][] = $assoc['pref']; - $list[$assoc['rate']]['ptype'][] = 'ExpenseReportPayment'; + $list[$rate_key]['pid'][] = $assoc['pid']; + $list[$rate_key]['pref'][] = $assoc['pref']; + $list[$rate_key]['ptype'][] = 'ExpenseReportPayment'; - $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['rate']]['payment_ref'][] = $assoc['payment_ref']; - $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; + $list[$rate_key]['payment_id'][] = $assoc['payment_id']; + $list[$rate_key]['payment_ref'][] = $assoc['payment_ref']; + $list[$rate_key]['payment_amount'][] = $assoc['payment_amount']; $rate = $assoc['rate']; } From 2b5bc29d1baf549aab10e11f01ea2f1e69b5f40e Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 25 Jan 2022 10:00:33 +0100 Subject: [PATCH 10/74] NEW stock filter in reassort lists --- htdocs/product/reassort.php | 123 ++++++++++++++++----------------- htdocs/product/reassortlot.php | 96 +++++++++++++++---------- 2 files changed, 119 insertions(+), 100 deletions(-) diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 62bfd626f82..23258aa1e86 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -39,14 +39,14 @@ $action = GETPOST('action', 'aZ09'); $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$type = GETPOST("type", "int"); +$type = GETPOSTISSET('type') ? GETPOST('type', 'int') : Product::TYPE_PRODUCT; $search_barcode = GETPOST("search_barcode", 'alpha'); -$catid = GETPOST('catid', 'int'); $toolowstock = GETPOST('toolowstock'); $tosell = GETPOST("tosell"); $tobuy = GETPOST("tobuy"); $fourn_id = GETPOST("fourn_id", 'int'); $sbarcode = GETPOST("sbarcode", 'int'); +$search_stock_physique = GETPOST('search_stock_physique', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -68,7 +68,11 @@ $offset = $limit * $page; // Load sale and categ filters $search_sale = GETPOST("search_sale"); -$search_categ = GETPOST("search_categ"); +if (GETPOSTISSET('catid')) { + $search_categ = GETPOST('catid', 'int'); +} else { + $search_categ = GETPOST('search_categ', 'int'); +} // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); @@ -111,11 +115,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $tobuy = ""; $search_sale = ""; $search_categ = ""; - $type = ""; - $catid = ''; $toolowstock = ''; $fourn_id = ''; $sbarcode = ''; + $search_stock_physique = ''; } @@ -146,13 +149,22 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON s.fk_entrepot = e.rowid A if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; } -// We'll need this table joined to the select in order to filter by categ -if ($search_categ) { - $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -} $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) { - $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ +if (!empty($search_categ) && $search_categ != '-1') { + $sql .= " AND "; + if ($search_categ == -2) { + $sql .= " NOT EXISTS "; + } else { + $sql .= " EXISTS "; + } + $sql .= "("; + $sql .= " SELECT cp.fk_categorie, cp.fk_product"; + $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_product as cp"; + $sql .= " WHERE cp.fk_product = p.rowid"; // Join for the needed table to filter by categ + if ($search_categ > 0) { + $sql .= " AND cp.fk_categorie = " . ((int) $search_categ); + } + $sql .= ")"; } if ($sall) { $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); @@ -183,24 +195,32 @@ if (!empty($tobuy)) { if (!empty($canvas)) { $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; } -if ($catid > 0) { - $sql .= " AND cp.fk_categorie = ".((int) $catid); -} if ($fourn_id > 0) { $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id); } -// Insert categ filter -if ($search_categ > 0) { - $sql .= " AND cp.fk_categorie = ".((int) $search_categ); -} $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; $sql .= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +$sql_having = ''; if ($toolowstock) { - $sql .= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; + $sql_having .= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; +} +if ($search_stock_physique != '') { + //$natural_search_physique = natural_search('HAVING SUM(' . $db->ifsql('s.reel IS NULL', '0', 's.reel') . ')', $search_stock_physique, 1, 1); + $natural_search_physique = natural_search('SUM(' . $db->ifsql('s.reel IS NULL', '0', 's.reel') . ')', $search_stock_physique, 1, 1); + $natural_search_physique = " " . substr($natural_search_physique, 1, -1); // remove first "(" and last ")" characters + if (!empty($sql_having)) { + $sql_having .= " AND"; + } else { + $sql_having .= " HAVING"; + } + $sql_having .= $natural_search_physique; +} +if (!empty($sql_having)) { + $sql .= $sql_having; } $sql .= $db->order($sortfield, $sortorder); @@ -253,7 +273,7 @@ if ($resql) { if ($tobuy) { $param .= "&tobuy=".urlencode($tobuy); } - if ($type) { + if ($type != '') { $param .= "&type=".urlencode($type); } if ($fourn_id) { @@ -268,7 +288,7 @@ if ($resql) { if ($search_sale) { $param .= "&search_sale=".urlencode($search_sale); } - if ($search_categ) { + if (!empty($search_categ) && $search_categ != '-1') { $param .= "&search_categ=".urlencode($search_categ); } if ($toolowstock) { @@ -277,8 +297,8 @@ if ($resql) { if ($sbarcode) { $param .= "&sbarcode=".urlencode($sbarcode); } - if ($catid) { - $param .= "&catid=".urlencode($catid); + if ($search_stock_physique) { + $param .= '&search_stock_physique=' . urlencode($search_stock_physique); } llxHeader("", $texte, $helpurl); @@ -292,10 +312,10 @@ if ($resql) { print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit); - if (!empty($catid)) { + if ($search_categ > 0) { print "
"; $c = new Categorie($db); - $c->fetch($catid); + $c->fetch($search_categ); $ways = $c->print_all_ways(' > ', 'product/reassort.php'); print " > ".$ways[0]."
\n"; print "

"; @@ -306,7 +326,7 @@ if ($resql) { if (!empty($conf->categorie->enabled)) { $moreforfilter .= '
'; $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); - $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); $moreforfilter .= '
'; } @@ -323,32 +343,6 @@ if ($resql) { print '
'; } - $param = ''; - if ($tosell) { - $param .= "&tosell=".urlencode($tosell); - } - if ($tobuy) { - $param .= "&tobuy=".urlencode($tobuy); - } - if ($type) { - $param .= "&type=".urlencode($type); - } - if ($fourn_id) { - $param .= "&fourn_id=".urlencode($fourn_id); - } - if ($snom) { - $param .= "&snom=".urlencode($snom); - } - if ($sref) { - $param .= "&sref=".urlencode($sref); - } - if ($toolowstock) { - $param .= "&toolowstock=".urlencode($toolowstock); - } - if ($search_categ) { - $param .= "&search_categ=".urlencode($search_categ); - } - $formProduct = new FormProduct($db); $formProduct->loadWarehouses(); $warehouses_list = $formProduct->cache_warehouses; @@ -378,7 +372,10 @@ if ($resql) { // Stock limit print ' '; print ' '; - print ' '; + // Physical stock + print ''; + print ''; + print ''; if ($virtualdiffersfromphysical) { print ' '; } @@ -396,14 +393,14 @@ if ($resql) { //Line for column titles print ""; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder); if (!empty($conf->service->enabled) && $type == 1) { - print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", '', $param, "", $sortfield, $sortorder, 'center '); } - print_liste_field_titre("StockLimit", $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", $param, "", '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock", $param, "", '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("StockLimit", $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", '', $param, "", $sortfield, $sortorder, 'right '); + print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock", '', $param, "", $sortfield, $sortorder, 'right '); + print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", '', $param, "", $sortfield, $sortorder, 'right '); // Details per warehouse if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) if ($nb_warehouse > 1) { @@ -413,15 +410,15 @@ if ($resql) { } } if ($virtualdiffersfromphysical) { - print_liste_field_titre("VirtualStock", $_SERVER["PHP_SELF"], "", $param, "", '', $sortfield, $sortorder, 'right ', 'VirtualStockDesc'); + print_liste_field_titre("VirtualStock", $_SERVER["PHP_SELF"], "", '', $param, "", $sortfield, $sortorder, 'right ', 'VirtualStockDesc'); } // Units if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print_liste_field_titre("Unit", $_SERVER["PHP_SELF"], "unit_short", $param, "", 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Unit", $_SERVER["PHP_SELF"], "unit_short", '', $param, 'align="right"', $sortfield, $sortorder); } print_liste_field_titre(''); - print_liste_field_titre("ProductStatusOnSell", $_SERVER["PHP_SELF"], "p.tosell", $param, "", '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("ProductStatusOnBuy", $_SERVER["PHP_SELF"], "p.tobuy", $param, "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("ProductStatusOnSell", $_SERVER["PHP_SELF"], "p.tosell", '', $param, "", $sortfield, $sortorder, 'right '); + print_liste_field_titre("ProductStatusOnBuy", $_SERVER["PHP_SELF"], "p.tobuy", '', $param, "", $sortfield, $sortorder, 'right '); // Hook fields $parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 2bd62b2ce22..c5463e3e4e2 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -41,16 +41,16 @@ $action = GETPOST('action', 'aZ09'); $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$type = GETPOST("type", "int"); +$type = GETPOSTISSET('type') ? GETPOST('type', 'int') : Product::TYPE_PRODUCT; $search_barcode = GETPOST("search_barcode", 'alpha'); $search_warehouse = GETPOST('search_warehouse', 'alpha'); $search_batch = GETPOST('search_batch', 'alpha'); -$catid = GETPOST('catid', 'int'); $toolowstock = GETPOST('toolowstock'); $tosell = GETPOST("tosell"); $tobuy = GETPOST("tobuy"); $fourn_id = GETPOST("fourn_id", 'int'); $sbarcode = GETPOST("sbarcode", 'int'); +$search_stock_physique = GETPOST('search_stock_physique', 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -72,7 +72,11 @@ $offset = $limit * $page; // Load sale and categ filters $search_sale = GETPOST("search_sale"); -$search_categ = GETPOST("search_categ"); +if (GETPOSTISSET('catid')) { + $search_categ = GETPOST('catid', 'int'); +} else { + $search_categ = GETPOST('search_categ', 'int'); +} // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); @@ -102,13 +106,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $tobuy = ""; $search_sale = ""; $search_categ = ""; - $type = ""; - $catid = ''; $toolowstock = ''; $search_batch = ''; $search_warehouse = ''; $fourn_id = ''; $sbarcode = ''; + $search_stock_physique = ''; } @@ -135,13 +138,22 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps on p.rowid = ps.fk_pro $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid'; // Link on unique key $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key -// We'll need this table joined to the select in order to filter by categ -if ($search_categ > 0) { - $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -} $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ > 0) { - $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ +if (!empty($search_categ) && $search_categ != '-1') { + $sql .= " AND "; + if ($search_categ == -2) { + $sql .= " NOT EXISTS "; + } else { + $sql .= " EXISTS "; + } + $sql .= "("; + $sql .= " SELECT cp.fk_categorie, cp.fk_product"; + $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_product as cp"; + $sql .= " WHERE cp.fk_product = p.rowid"; // Join for the needed table to filter by categ + if ($search_categ > 0) { + $sql .= " AND cp.fk_categorie = " . ((int) $search_categ); + } + $sql .= ")"; } if ($sall) { $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); @@ -172,16 +184,9 @@ if (!empty($tobuy)) { if (!empty($canvas)) { $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; } -if ($catid > 0) { - $sql .= " AND cp.fk_categorie = ".((int) $catid); -} if ($fourn_id > 0) { $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id); } -// Insert categ filter -if ($search_categ > 0) { - $sql .= " AND cp.fk_categorie = ".((int) $search_categ); -} if ($search_warehouse) { $sql .= natural_search("e.ref", $search_warehouse); } @@ -195,8 +200,22 @@ $sql .= " ps.fk_entrepot,"; $sql .= " e.ref, e.lieu, e.fk_parent,"; $sql .= " pb.batch, pb.eatby, pb.sellby,"; $sql .= " pl.rowid, pl.eatby, pl.sellby"; +$sql_having = ''; if ($toolowstock) { - $sql .= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet + $sql_having .= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet +} +if ($search_stock_physique != '') { + $natural_search_physique = natural_search('SUM(' . $db->ifsql('pb.qty IS NULL', '0', 'pb.qty') . ')', $search_stock_physique, 1, 1); + $natural_search_physique = " " . substr($natural_search_physique, 1, -1); // remove first "(" and last ")" characters + if (!empty($sql_having)) { + $sql_having .= " AND"; + } else { + $sql_having .= " HAVING"; + } + $sql_having .= $natural_search_physique; +} +if (!empty($sql_having)) { + $sql .= $sql_having; } $sql .= $db->order($sortfield, $sortorder); @@ -248,7 +267,7 @@ if ($resql) { if ($tobuy) { $param .= "&tobuy=".urlencode($tobuy); } - if ($type) { + if ($type != '') { $param .= "&type=".urlencode($type); } if ($fourn_id) { @@ -269,18 +288,18 @@ if ($resql) { if ($search_warehouse) { $param .= "&search_warehouse=".urlencode($search_warehouse); } - if ($catid) { - $param .= "&catid=".urlencode($catid); - } if ($toolowstock) { $param .= "&toolowstock=".urlencode($toolowstock); } if ($search_sale) { $param .= "&search_sale=".urlencode($search_sale); } - if ($search_categ > 0) { + if (!empty($search_categ) && $search_categ != '-1') { $param .= "&search_categ=".urlencode($search_categ); } + if ($search_stock_physique) { + $param .= '&search_stock_physique=' . urlencode($search_stock_physique); + } /*if ($eatby) $param.="&eatby=".$eatby; if ($sellby) $param.="&sellby=".$sellby;*/ @@ -295,10 +314,10 @@ if ($resql) { print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit, 0, 0, 1); - if (!empty($catid)) { + if ($search_categ > 0) { print "
"; $c = new Categorie($db); - $c->fetch($catid); + $c->fetch($search_categ); $ways = $c->print_all_ways(' > ', 'product/reassortlot.php'); print " > ".$ways[0]."
\n"; print "

"; @@ -309,7 +328,7 @@ if ($resql) { if (!empty($conf->categorie->enabled)) { $moreforfilter .= '
'; $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); - $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); $moreforfilter .= '
'; } //$moreforfilter.=$langs->trans("StockTooLow").' '; @@ -342,14 +361,17 @@ if ($resql) { } print ''; print ''; - print ' '; - print ' '; if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { print ' '; } if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { print ' '; } + // Physical stock + print ''; + print ''; + print ''; + print ' '; print ' '; print ' '; print ''; @@ -360,21 +382,21 @@ if ($resql) { //Line for column titles print ""; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder); if (!empty($conf->service->enabled) && $type == 1) { - print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", '', $param, "", $sortfield, $sortorder, 'center '); } - print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", $param, "", '', $sortfield, $sortorder); + print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", '', $param, "", $sortfield, $sortorder); //print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right ); - print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", $param, "", '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", '', $param, "", $sortfield, $sortorder, 'center '); if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pb.sellby", $param, "", '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pb.sellby", '', $param, "", $sortfield, $sortorder, 'center '); } if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", $param, "", '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", '', $param, "", $sortfield, $sortorder, 'center '); } - print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", '', $param, "", $sortfield, $sortorder, 'right '); // TODO Add info of running suppliers/customers orders //print_liste_field_titre("TheoreticalStock",$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'',$sortfield,$sortorder, 'right '); print_liste_field_titre(''); From 4edbd5c4e3ff7f1d1ae8d5742dd44a50086a5239 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 25 Jan 2022 10:31:45 +0100 Subject: [PATCH 11/74] NEW : Creation of the function select_bom() used to display bom select list --- htdocs/bom/tpl/objectline_create.tpl.php | 2 +- htdocs/core/class/html.form.class.php | 51 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 7419c4618e0..0a3a3b34e7a 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -109,7 +109,7 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { if (!empty($conf->global->BOM_SUB_BOM)) { print '
'.$langs->trans("or").'
'.$langs->trans("BOM"); // TODO Add component to select a BOM - print ''; + $form->select_bom(); } print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 88fca7b536a..fe47047150d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2362,6 +2362,57 @@ class Form } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + + /** + * Return list of BOM for customer in Ajax if Ajax activated or go to select_produits_list + * + * @param int $selected Preselected BOM id + * @param string $htmlname Name of HTML select field (must be unique in page). + * @param int $limit Limit on number of returned lines + * @param int $status Sell status -1=Return all bom, 0=Draft BOM, 1=Validated BOM + * @param int $type type of the BOM (-1=Return all BOM, 0=Return disassemble BOM, 1=Return manufacturing BOM) + * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param string $morecss Add more css on select + * @return void|string + */ + public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 1, $showempty = '1', $morecss = '', $nooutput = '') + { + // phpcs:enable + global $conf, $user, $langs, $db; + $error = 0; + $out = ''; + + $out .= ''; - $sql = 'SELECT b.rowid, b.ref, b.label'; + $sql = 'SELECT b.rowid, b.ref, b.label, b.fk_product'; $sql.= ' FROM '.MAIN_DB_PREFIX.'bom_bom as b'; - $sql .= ' WHERE b.entity IN ('.getEntity('bom').')'; - if(!empty($status)) $sql.= ' AND status = '.$status; - if(!empty($type)) $sql.= ' AND status = '. $type; + $sql.= ' WHERE b.entity IN ('.getEntity('bom').')'; + if(!empty($status)) $sql.= ' AND status = '. (int) $status; + if(!empty($type)) $sql.= ' AND status = '. (int) $type; if(!empty($limit)) $sql.= 'LIMIT '. (int) $limit; $resql = $db->query($sql); if($resql){ @@ -2399,8 +2407,10 @@ class Form $out .= '> '; } while ($obj = $db->fetch_object($resql)){ - if($obj->rowid == $selected) $out .= ''; - $out .= ''; + $product = new Product($db); + $res = $product->fetch($obj->fk_product); + if($obj->rowid == $selected) $out .= ''; + $out .= ''; } } else { $error++; From f37c04bc2f7ab59c407c261b27b03a92c25357f5 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 25 Jan 2022 12:06:40 +0100 Subject: [PATCH 13/74] NEW : Add the possibility to add sub-BOMs to BOM --- htdocs/bom/bom_card.php | 15 ++++++++++++--- htdocs/bom/tpl/objectline_view.tpl.php | 7 ------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 748aea4ddb2..26764072956 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -148,8 +148,17 @@ if (empty($reshook)) { $error = 0; // Set if we used free entry or predefined product - $idprod = (int) GETPOST('idprod', 'int'); - $bom_child = (int) GETPOST('bom_select', 'int'); + $bom_child_id = (int) GETPOST('bom_id', 'int'); + if($bom_child_id > 0){ + $bom_child = new BOM($db); + $res = $bom_child->fetch($bom_child_id); + if($res){ + $idprod = $bom_child->fk_product; + } + } else { + $idprod = (int) GETPOST('idprod', 'int'); + } + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); $qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); @@ -173,7 +182,7 @@ if (empty($reshook)) { $bomline = new BOMLine($db); $bomline->fk_bom = $id; $bomline->fk_product = $idprod; - $bomline->fk_bom_child = $bom_child; + $bomline->fk_bom_child = $bom_child_id; $bomline->qty = $qty; $bomline->qty_frozen = (int) $qty_frozen; $bomline->disable_stock_change = (int) $disable_stock_change; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 82626c12fec..f62143188eb 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -202,13 +202,6 @@ if ($resql) { // Product print ''.$sub_bom_product->getNomUrl(1).''; - // Sub-BOM - if ($sub_bom_line->fk_bom_child > 0) { - print ''.$sub_bom->getNomUrl(1).''; - } else { - print ' '; - } - // Qty print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; if ($sub_bom_line->qty_frozen > 0) { From 08d830f4501c959129d8b48156f73bec23659478 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 25 Jan 2022 16:40:28 +0100 Subject: [PATCH 14/74] FIX : Fixing total_cost, qty_frozen and display problems --- htdocs/bom/tpl/objectline_view.tpl.php | 36 +++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index f62143188eb..0c74cee43ce 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -41,7 +41,7 @@ if (empty($object) || !is_object($object)) { } -global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax; +global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs; if (empty($dateSelector)) { $dateSelector = 0; @@ -83,8 +83,10 @@ $tmpproduct->fetch($line->fk_product); $tmpbom = new BOM($object->db); $res = $tmpbom->fetch($line->fk_bom_child); if ($tmpbom->id > 0) { - print $tmpbom->getNomUrl(1); print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; + print $tmpproduct->getNomUrl(1); + print ' '.$langs->trans('OR').' '; + print $tmpbom->getNomUrl(1); } else { print $tmpproduct->getNomUrl(1); print ' - '.$tmpproduct->label; @@ -176,7 +178,7 @@ if ($action == 'selectlines') { print ''; // Select of all the sub-BOM lines -$sql = 'SELECT rowid, fk_bom_child, fk_product FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; +$sql = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; $sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; $resql = $object->db->query($sql); @@ -199,14 +201,23 @@ if ($resql) { print ''; } - // Product - print ''.$sub_bom_product->getNomUrl(1).''; + // Product OR BOM + print ''; + if(!empty($obj->fk_bom_child)){ + print $sub_bom_product->getNomUrl(1); + print ' '.$langs->trans('OR').' '; + print $sub_bom->getNomUrl(1); + } else { + print $sub_bom_product->getNomUrl(1); + print ''; + } // Qty - print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; if ($sub_bom_line->qty_frozen > 0) { - print ''.$sub_bom_line->qty_frozen.''; + print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; + print ''.$langs->trans('Yes').''; } else { + print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; print ' '; } @@ -221,9 +232,16 @@ if ($resql) { print ''.$sub_bom_line->efficiency.''; // Cost price if it's defined - if ($sub_bom_product->cost_price > 0) { + if (!empty($obj->fk_bom_child)) { + $bom = new BOM($object->db); + $bom->fetch($obj->fk_bom_child); + $bom->calculateCosts(); + $bom->total_cost * $line->qty; + print ''.price($bom->total_cost * $line->qty).''; + $total_cost+= $bom->total_cost * $line->qty; + } elseif ($sub_bom_product->cost_price > 0) { print ''.price($sub_bom_product->cost_price * $line->qty).''; - $total_cost.= $sub_bom_product->cost_price * $line->qty; + $total_cost+= $sub_bom_product->cost_price * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined print ''.price($sub_bom_product->pmp * $line->qty).''; $total_cost.= $sub_bom_product->pmp * $line->qty; From ec1f78424742205349ca757190a67eb7ac03bc3a Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 26 Jan 2022 11:43:44 +0100 Subject: [PATCH 15/74] replace restricthtml to nohtml. --- htdocs/exports/export.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index c0a48b97222..544a9ead888 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -391,14 +391,14 @@ if ($step == 4 && $action == 'submitFormField') { $newcode = (string) preg_replace('/\./', '_', $code); //print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n
"; $filterqualified = 1; - if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') { + if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'nohtml') == '') { $filterqualified = 0; - } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) { + } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'nohtml')) && GETPOST($newcode, 'nohtml') <= 0)) { $filterqualified = 0; } if ($filterqualified) { //print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n"; - $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'restricthtml'); + $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'nohtml'); } } $array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] : ''); From 23e5ff08ebcee4a9d0997d644cec5f5d481ebe11 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 26 Jan 2022 12:07:06 +0100 Subject: [PATCH 16/74] change to alphawithlgt --- htdocs/exports/export.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 544a9ead888..3373a299586 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -391,14 +391,14 @@ if ($step == 4 && $action == 'submitFormField') { $newcode = (string) preg_replace('/\./', '_', $code); //print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n
"; $filterqualified = 1; - if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'nohtml') == '') { + if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'alphawithlgt') == '') { $filterqualified = 0; - } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'nohtml')) && GETPOST($newcode, 'nohtml') <= 0)) { + } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'alphawithlgt')) && GETPOST($newcode, 'alphawithlgt') <= 0)) { $filterqualified = 0; } if ($filterqualified) { //print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n"; - $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'nohtml'); + $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'alphawithlgt'); } } $array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] : ''); From 42f252b636fec9f16cf133c470c30408e6944aa5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jan 2022 12:39:41 +0100 Subject: [PATCH 17/74] Add one more test --- test/phpunit/SecurityTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 6bece069cc9..2d14a35dce9 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -359,7 +359,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $_POST['param8b']='objnotdefined\''; @@ -501,6 +501,10 @@ class SecurityTest extends PHPUnit\Framework\TestCase print __METHOD__." result param7 = ".$result."\n"; $this->assertEquals('"c:\this is a path~1\aaan &#x;;;;" abcdef', $result); + $result=GETPOST("param8e", 'restricthtml'); + print __METHOD__." result param8e = ".$result."\n"; + $this->assertEquals('', $result); + $result=GETPOST("param12", 'restricthtml'); print __METHOD__." result=".$result."\n"; $this->assertEquals(trim($_POST["param12"]), $result, 'Test a string with DOCTYPE and restricthtml'); @@ -519,7 +523,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $result=GETPOST("param15", 'restricthtml'); // src=>0xbeefed print __METHOD__." result=".$result."\n"; - $this->assertEquals("0xbeefed", $result, 'Test 15a'); // The GETPOST return a harmull string + $this->assertEquals("0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string // Test with restricthtml + MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES to test disabling of bad atrributes $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1; From 60fff852abbad96965bb66c3a2b87af9427efd9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jan 2022 12:53:06 +0100 Subject: [PATCH 18/74] Merge branch '14.0' of git@github.com:Dolibarr/dolibarr.git into 14.0 --- htdocs/core/modules/modUser.class.php | 2 +- htdocs/exports/export.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index f7b6b9aec69..c4043779c64 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -239,7 +239,7 @@ class modUser extends DolibarrModules 'u.accountancy_code'=>'Text', 'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text", 'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text', - 'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.datelastlogin'=>'Date', + 'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.signature'=>"Text", 'u.datelastlogin'=>'Date', 'u.fk_user'=>"List:user:login", 'u.birth'=>'Date', 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname", diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 3373a299586..df03b6a1cdc 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -389,16 +389,17 @@ if ($step == 4 && $action == 'submitFormField') { $_SESSION["export_filtered_fields"] = array(); foreach ($objexport->array_export_TypeFields[0] as $code => $type) { // $code: s.fieldname $value: Text|Boolean|List:ccc $newcode = (string) preg_replace('/\./', '_', $code); - //print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n
"; + //print 'xxx '.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n
"; + $check = 'alphanohtml'; $filterqualified = 1; - if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'alphawithlgt') == '') { + if (!GETPOSTISSET($newcode) || GETPOST($newcode, $check) == '') { $filterqualified = 0; - } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'alphawithlgt')) && GETPOST($newcode, 'alphawithlgt') <= 0)) { + } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, $check)) && GETPOST($newcode, $check) <= 0)) { $filterqualified = 0; } if ($filterqualified) { //print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n"; - $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'alphawithlgt'); + $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, $check); } } $array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] : ''); From 36068d4279375d8b813d097f9deecd998babecb3 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 26 Jan 2022 14:41:36 +0100 Subject: [PATCH 19/74] FIX : Fixing total errors --- htdocs/bom/class/bom.class.php | 41 ++++++++++++++++++-------- htdocs/bom/tpl/objectline_view.tpl.php | 17 ++++------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 0520c76dde2..6f170fb066b 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1064,26 +1064,41 @@ class BOM extends CommonObject $tmpproduct->cost_price = 0; $tmpproduct->pmp = 0; - $result = $tmpproduct->fetch($line->fk_product, '', '', '', 0, 1, 1); // We discard selling price and language loading - if ($result < 0) { - $this->error = $tmpproduct->error; - return -1; - } - $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); - if (empty($line->unit_cost)) { - if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { - $line->unit_cost = $productFournisseur->fourn_unitprice; + if(empty($line->fk_bom_child)){ + $result = $tmpproduct->fetch($line->fk_product, '', '', '', 0, 1, 1); // We discard selling price and language loading + if ($result < 0) { + $this->error = $tmpproduct->error; + return -1; + } + $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); + if (empty($line->unit_cost)) { + if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { + $line->unit_cost = $productFournisseur->fourn_unitprice; + } + } + + $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); + + $this->total_cost += $line->total_cost; + } else { + $bom_child= new BOM($this->db); + $res = $bom_child->fetch($line->fk_bom_child); + if($res>0){ + $bom_child->calculateCosts(); + $this->total_cost += $bom_child->total_cost; + } else { + $this->error = $bom_child->error; + return -2; } } - $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); - - $this->total_cost += $line->total_cost; } $this->total_cost = price2num($this->total_cost, 'MT'); - if ($this->qty) { + if ($this->qty > 0) { $this->unit_cost = price2num($this->total_cost / $this->qty, 'MU'); + } elseif ($this->qty < 0) { + $this->unit_cost = price2num($this->total_cost * $this->qty, 'MU'); } } } diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 0c74cee43ce..fc40c8a54f2 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -232,27 +232,22 @@ if ($resql) { print ''.$sub_bom_line->efficiency.''; // Cost price if it's defined - if (!empty($obj->fk_bom_child)) { - $bom = new BOM($object->db); - $bom->fetch($obj->fk_bom_child); - $bom->calculateCosts(); - $bom->total_cost * $line->qty; - print ''.price($bom->total_cost * $line->qty).''; - $total_cost+= $bom->total_cost * $line->qty; - } elseif ($sub_bom_product->cost_price > 0) { + if ($sub_bom_product->cost_price > 0) { print ''.price($sub_bom_product->cost_price * $line->qty).''; $total_cost+= $sub_bom_product->cost_price * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined print ''.price($sub_bom_product->pmp * $line->qty).''; $total_cost.= $sub_bom_product->pmp * $line->qty; } else { // Minimum purchase price if cost price and PMP aren't defined - $sql_supplier_price = 'SELECT MIN(price) AS min_price FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; + $sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; $sql_supplier_price.= ' WHERE fk_product = '. (int) $sub_bom_product->id; $resql_supplier_price = $object->db->query($sql_supplier_price); if ($resql_supplier_price) { $obj = $object->db->fetch_object($resql_supplier_price); - print ''.price($obj->min_price * $line->qty).''; - $total_cost+= $obj->min_price * $line->qty; + $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty; + + print ''.price($line_cost).''; + $total_cost+= $line_cost; } } From 6d3066a312b802ba92d7606e6c432d01f42db21b Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 26 Jan 2022 14:46:45 +0100 Subject: [PATCH 20/74] FIX : Fixing trads --- htdocs/bom/tpl/objectline_view.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index fc40c8a54f2..e8550e9d6b6 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -85,7 +85,7 @@ $res = $tmpbom->fetch($line->fk_bom_child); if ($tmpbom->id > 0) { print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; print $tmpproduct->getNomUrl(1); - print ' '.$langs->trans('OR').' '; + print ' '.$langs->trans('or').' '; print $tmpbom->getNomUrl(1); } else { print $tmpproduct->getNomUrl(1); @@ -205,7 +205,7 @@ if ($resql) { print ''; if(!empty($obj->fk_bom_child)){ print $sub_bom_product->getNomUrl(1); - print ' '.$langs->trans('OR').' '; + print ' '.$langs->trans('or').' '; print $sub_bom->getNomUrl(1); } else { print $sub_bom_product->getNomUrl(1); From 9342fa8781b6df278054e6d92acf08696a88734c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 26 Jan 2022 14:15:53 +0000 Subject: [PATCH 21/74] Fixing style errors. --- htdocs/bom/bom_card.php | 14 +++++++------- htdocs/bom/class/bom.class.php | 4 ++-- htdocs/bom/tpl/objectline_view.tpl.php | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 26764072956..d31e21e635b 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -149,13 +149,13 @@ if (empty($reshook)) { // Set if we used free entry or predefined product $bom_child_id = (int) GETPOST('bom_id', 'int'); - if($bom_child_id > 0){ - $bom_child = new BOM($db); - $res = $bom_child->fetch($bom_child_id); - if($res){ - $idprod = $bom_child->fk_product; - } - } else { + if ($bom_child_id > 0) { + $bom_child = new BOM($db); + $res = $bom_child->fetch($bom_child_id); + if ($res) { + $idprod = $bom_child->fk_product; + } + } else { $idprod = (int) GETPOST('idprod', 'int'); } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 6f170fb066b..4923e9d0ca2 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1064,7 +1064,7 @@ class BOM extends CommonObject $tmpproduct->cost_price = 0; $tmpproduct->pmp = 0; - if(empty($line->fk_bom_child)){ + if (empty($line->fk_bom_child)) { $result = $tmpproduct->fetch($line->fk_product, '', '', '', 0, 1, 1); // We discard selling price and language loading if ($result < 0) { $this->error = $tmpproduct->error; @@ -1083,7 +1083,7 @@ class BOM extends CommonObject } else { $bom_child= new BOM($this->db); $res = $bom_child->fetch($line->fk_bom_child); - if($res>0){ + if ($res>0) { $bom_child->calculateCosts(); $this->total_cost += $bom_child->total_cost; } else { diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index e8550e9d6b6..4360d521036 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -85,8 +85,8 @@ $res = $tmpbom->fetch($line->fk_bom_child); if ($tmpbom->id > 0) { print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; print $tmpproduct->getNomUrl(1); - print ' '.$langs->trans('or').' '; - print $tmpbom->getNomUrl(1); + print ' '.$langs->trans('or').' '; + print $tmpbom->getNomUrl(1); } else { print $tmpproduct->getNomUrl(1); print ' - '.$tmpproduct->label; @@ -203,14 +203,14 @@ if ($resql) { // Product OR BOM print ''; - if(!empty($obj->fk_bom_child)){ + if (!empty($obj->fk_bom_child)) { print $sub_bom_product->getNomUrl(1); print ' '.$langs->trans('or').' '; print $sub_bom->getNomUrl(1); - } else { + } else { print $sub_bom_product->getNomUrl(1); - print ''; - } + print ''; + } // Qty if ($sub_bom_line->qty_frozen > 0) { @@ -232,7 +232,7 @@ if ($resql) { print ''.$sub_bom_line->efficiency.''; // Cost price if it's defined - if ($sub_bom_product->cost_price > 0) { + if ($sub_bom_product->cost_price > 0) { print ''.price($sub_bom_product->cost_price * $line->qty).''; $total_cost+= $sub_bom_product->cost_price * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined @@ -244,7 +244,7 @@ if ($resql) { $resql_supplier_price = $object->db->query($sql_supplier_price); if ($resql_supplier_price) { $obj = $object->db->fetch_object($resql_supplier_price); - $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty; + $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty; print ''.price($line_cost).''; $total_cost+= $line_cost; From 83d80cc3801b6df9723d2055002435687f2ddeb1 Mon Sep 17 00:00:00 2001 From: kamel Date: Wed, 26 Jan 2022 15:45:00 +0100 Subject: [PATCH 22/74] Correction recuperation de la vat_rate_show --- htdocs/compta/tva/quadri_detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 4b44959bc1a..68dcaa55fb6 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -47,7 +47,7 @@ $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "produ $refresh = (GETPOSTISSET('submit') || GETPOSTISSET('vat_rate_show') || GETPOSTISSET('invoice_type')) ? true : false; $invoice_type = GETPOSTISSET('invoice_type') ? GETPOST('invoice_type', 'alpha') : ''; -$vat_rate_show = GETPOSTISSET('vat_rate_show') ? GETPOST('vat_rate_show', 'int') : -1; +$vat_rate_show = GETPOSTISSET('vat_rate_show') ? GETPOST('vat_rate_show', 'alphanohtml') : -1; include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php'; From db57d1a99f8095aabef7663a88e51a5c4fad053d Mon Sep 17 00:00:00 2001 From: kamel Date: Wed, 26 Jan 2022 15:53:03 +0100 Subject: [PATCH 23/74] =?UTF-8?q?Correction=20lien=20pour=20afficher=20le?= =?UTF-8?q?=20detail=20de=20la=20tva=20si=20la=20tva=20est=20pr=C3=A9sente?= =?UTF-8?q?=20cot=C3=A9=20client=20en=20fournisseur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/tva/quadri_detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 68dcaa55fb6..1ba3e2ab28e 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -409,7 +409,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%'; print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; @@ -643,7 +643,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%'; print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; From d38ff3ad9b6fc60a672f08aea834265cccc54e1d Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 26 Jan 2022 15:53:30 +0100 Subject: [PATCH 24/74] FIX : Fixing stickler returns --- htdocs/core/class/html.form.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e7fd8d27967..caf20ffcbad 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2374,6 +2374,8 @@ class Form * @param int $type type of the BOM (-1=Return all BOM, 0=Return disassemble BOM, 1=Return manufacturing BOM) * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param string $morecss Add more css on select + * @param string $nooutput + * @param string $forcecombo * @return void|string */ public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 1, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0) @@ -2396,20 +2398,20 @@ class Form $sql = 'SELECT b.rowid, b.ref, b.label, b.fk_product'; $sql.= ' FROM '.MAIN_DB_PREFIX.'bom_bom as b'; $sql.= ' WHERE b.entity IN ('.getEntity('bom').')'; - if(!empty($status)) $sql.= ' AND status = '. (int) $status; - if(!empty($type)) $sql.= ' AND status = '. (int) $type; - if(!empty($limit)) $sql.= 'LIMIT '. (int) $limit; + if (!empty($status)) $sql.= ' AND status = '. (int) $status; + if (!empty($type)) $sql.= ' AND status = '. (int) $type; + if (!empty($limit)) $sql.= 'LIMIT '. (int) $limit; $resql = $db->query($sql); - if($resql){ + if ($resql) { if ($showempty) { $out .= ''; + if ($obj->rowid == $selected) $out .= ''; $out .= ''; } } else { From e52fb89182ce2b22a992015860859fbe1142e128 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 26 Jan 2022 16:36:58 +0100 Subject: [PATCH 25/74] FIX : Fixing stickler returns --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index caf20ffcbad..6c4c3b411b8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2374,8 +2374,8 @@ class Form * @param int $type type of the BOM (-1=Return all BOM, 0=Return disassemble BOM, 1=Return manufacturing BOM) * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. * @param string $morecss Add more css on select - * @param string $nooutput - * @param string $forcecombo + * @param string $nooutput No print, return the output into a string + * @param int $forcecombo Force to use combo box * @return void|string */ public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 1, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0) From 2e525a719d11eb77d0aa81f2720a6f8c8c9596dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jan 2022 19:12:02 +0100 Subject: [PATCH 26/74] Fix selection of migration script --- htdocs/install/upgrade.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 70257bba79e..1bc372c4c00 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -307,8 +307,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $filelist = array(); $i = 0; $ok = 0; - $from = '^'.$newversionfrom; - $to = $newversionto.'\.sql$'; + $from = '^'.preg_quote($newversionfrom, '/'); + $to = preg_quote($newversionto.'.sql', '/').'$'; // Get files list $filesindir = array(); @@ -326,9 +326,9 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Define which file to run foreach ($filesindir as $file) { - if (preg_match('/'.$from.'/i', $file)) { + if (preg_match('/'.$from.'\-/i', $file)) { $filelist[] = $file; - } elseif (preg_match('/'.$to.'/i', $file)) { // First test may be false if we migrate from x.y.* to x.y.* + } elseif (preg_match('/\-'.$to.'/i', $file)) { // First test may be false if we migrate from x.y.* to x.y.* $filelist[] = $file; } } From 928075bbf684c2f36064342fb634e3b920a943ea Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 26 Jan 2022 20:13:10 +0100 Subject: [PATCH 27/74] fix error in commande.class.php --- htdocs/commande/class/commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e3b2c64c92a..c315a4fcd61 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -626,7 +626,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql .= " SET fk_statut = ".self::STATUS_DRAFT."',"; + $sql .= " SET fk_statut = ".self::STATUS_DRAFT.","; $sql .= " fk_user_modif = ".((int) $user->id); $sql .= " WHERE rowid = ".((int) $this->id); From 4693b9702bbc77016aff152009be91fc759b0e2a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 27 Jan 2022 06:20:11 +0100 Subject: [PATCH 28/74] Copyright --- htdocs/compta/tva/quadri_detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 1ba3e2ab28e..15c45d6055b 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -6,7 +6,7 @@ * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Eric Seigne - * Copyright (C) 2021 Open-Dsi + * Copyright (C) 2021-2022 Open-Dsi * * 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 From 2d0427a5b1da1396b00ba19942b6ef0299f176b0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 27 Jan 2022 06:21:07 +0100 Subject: [PATCH 29/74] Update tax.lib.php --- htdocs/core/lib/tax.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 3249166c083..490b95cc92d 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -6,7 +6,7 @@ * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2015 Marcos García - * Copyright (C) 2021 Open-Dsi + * Copyright (C) 2021-2022 Open-Dsi * * 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 From 4f08409419c6be93074c9f8a54bcc7719346538f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 27 Jan 2022 12:02:58 +0100 Subject: [PATCH 30/74] fix:waring php --- htdocs/product/class/html.formproduct.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index da10faa4f34..3c080f159f8 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -655,11 +655,13 @@ class FormProduct } foreach ($productIdArray as $productId) { - foreach ($this->cache_lot[$productId] as $id => $arraytypes) { - if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) { - $label = $arraytypes['entrepot_label'].' - '; - $label .= $arraytypes['batch']; - $out .= ''; + if (array_key_exists($productId, $this->cache_lot)) { + foreach ($this->cache_lot[$productId] as $id => $arraytypes) { + if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) { + $label = $arraytypes['entrepot_label'] . ' - '; + $label .= $arraytypes['batch']; + $out .= ''; + } } } } From 6bd2caee084ab97e08e2a882ec11f6a5f3e982dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Jan 2022 16:35:09 +0100 Subject: [PATCH 31/74] test --- htdocs/public/test/test_exec.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index ccb8f346fc4..94a1d96462b 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -87,9 +87,11 @@ print "*** TEST READ OF /test.txt FILE AND LS /dev/std*
\n"; exec('cat /test.txt; ls /dev/std*; sleep 1;', $out, $ret); print $ret."
\n"; print_r($out); +print '
'; print '

'."\n"; + print "*** TRY TO RUN CLAMDSCAN
\n"; $ret = 0; From 3f9feef91432dc2cc402054b6a3ab1eca816ffae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Jan 2022 20:38:38 +0100 Subject: [PATCH 32/74] Comment --- htdocs/contrat/class/contrat.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 27e8cc6bf95..b2c9543453b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -387,7 +387,7 @@ class Contrat extends CommonObject if ($contratline->statut != ContratLigne::STATUS_OPEN) { $contratline->context = $this->context; - $result = $contratline->active_line($user, $date_start, -1, $comment); + $result = $contratline->active_line($user, $date_start, -1, $comment); // This call trigger LINECONTRACT_ACTIVATE if ($result < 0) { $error++; $this->error = $contratline->error; From dcb7e39bd2141ed9ecab5124a32933eaa6d74d83 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Fri, 28 Jan 2022 02:27:09 +0100 Subject: [PATCH 33/74] Update llx_c_action_trigger.sql --- htdocs/install/mysql/data/llx_c_action_trigger.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 258b56f1471..2df33b47184 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -9,6 +9,7 @@ -- Copyright (C) 2013 Cedric Gross -- Copyright (C) 2014 Raphaël Doursenaud -- Copyright (C) 2015 Bahfir Abbes +-- Copyright (C) 2021-2022 Anthony Berton -- -- 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 @@ -155,3 +156,11 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',151); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_DELETE','Task deleted','Executed when a project task is deleted','project',152); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ACTION_CREATE','Action added','Executed when an action is added to the agenda','agenda',700); + +-- oliday +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_CREATE','Holiday created','Executed when a holiday is created','holiday',800); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_MODIFY','Holiday modified','Executed when a holiday is modified','holiday',801); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Holiday validated','Executed when a holiday is validated','holiday',802); +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); From 6fdbda93f858b2dc39836364cc2bb4fb82d0e926 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Fri, 28 Jan 2022 02:28:55 +0100 Subject: [PATCH 34/74] Update 14.0.0-15.0.0.sql --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 7 +++++++ 1 file changed, 7 insertions(+) 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 476e63aab68..9af52c8700a 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 @@ -494,3 +494,10 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('USER_DELETE','User update','Executed when a user is deleted','user',303); INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('USER_NEW_PASSWORD','User update','Executed when a user is change password','user',304); INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('USER_ENABLEDISABLE','User update','Executed when a user is enable or disable','user',305); + +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_CREATE','Holiday created','Executed when a holiday is created','holiday',800); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_MODIFY','Holiday modified','Executed when a holiday is modified','holiday',801); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Holiday validated','Executed when a holiday is validated','holiday',802); +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); From 7fb0a788355ec40084f772d12419d367445cc901 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Fri, 28 Jan 2022 02:30:04 +0100 Subject: [PATCH 35/74] Update card.php --- htdocs/holiday/card.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 1c357d8b759..1944969c6fa 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -784,6 +784,12 @@ if (empty($reshook)) { $result = $object->update($user); if ($result >= 0 && $oldstatus == Holiday::STATUS_APPROVED) { // holiday was already validated, status 3, so we must increase back the balance + // Call trigger + $result = $object->call_trigger('HOLIDAY_CANCEL', $user); + if ($result < 0) { + $error++; + } + // Calculcate number of days consummed $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); From 28e4cf55538f83e12998b9063fdb899bbbbffe2f Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Fri, 28 Jan 2022 02:30:49 +0100 Subject: [PATCH 36/74] Update card.php --- htdocs/holiday/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 1944969c6fa..02c845aa6d1 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2014-2017 Ferran Marcet * Copyright (C) 2018 Frédéric France * Copyright (C) 2020-2021 Udo Tamm + * Copyright (C) 2022 Anthony Berton * * 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 From 1214ffaf3dcd375e68f92a4915c096fb306baa97 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 28 Jan 2022 01:32:44 +0000 Subject: [PATCH 37/74] 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 02c845aa6d1..fb53811aeaf 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -790,7 +790,7 @@ if (empty($reshook)) { if ($result < 0) { $error++; } - + // Calculcate number of days consummed $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); From 047c55bd0228f2137a19f99f78d49ae3689d9d31 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 08:49:47 +0100 Subject: [PATCH 38/74] Fix look and feel v15 --- htdocs/product/price.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index d21574e696e..45ecbd9bafa 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1278,22 +1278,30 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; + } else { + print '
' . $langs->trans("UpdateDefaultPrice") . '
'; } } if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; + } else { + print '
' . $langs->trans("AddCustomerPrice") . '
'; } } if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; + } else { + print '
' . $langs->trans("UpdateVAT") . '
'; } if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; + } else { + print '
' . $langs->trans("UpdateLevelPrices") . '
'; } } } From 5ff37febe3a05064cdaa94cff6973089fa8f6e33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 09:58:58 +0100 Subject: [PATCH 39/74] Trans --- htdocs/blockedlog/class/blockedlog.class.php | 6 +++--- htdocs/langs/en_US/blockedlog.lang | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 83ab700f59a..578e1afa497 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -320,12 +320,12 @@ class BlockedLog $this->error++; } } elseif ($this->action == 'MODULE_SET') { - return 'System to track events into unalterable logs were enabled'; + return ''.$langs->trans("BlockedLogEnabled").''; } elseif ($this->action == 'MODULE_RESET') { if ($this->signature == '0000000000') { - return 'System to track events into unalterable logs were disabled after some recording were done. We saved a special Fingerprint to track the chain as broken.'; + return ''.$langs->trans("BlockedLogDisabled").''; } else { - return 'System to track events into unalterable logs were disabled. This is possible because no record were done yet.'; + return ''.$langs->trans("BlockedLogDisabledBis").''; } } diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 44cb183050a..a1046827559 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -52,3 +52,6 @@ BlockedLogDisableNotAllowedForCountry=List of countries where usage of this modu OnlyNonValid=Non-valid TooManyRecordToScanRestrictFilters=Too many records to scan/analyze. Please restrict list with more restrictive filters. RestrictYearToExport=Restrict month / year to export +BlockedLogEnabled=System to track events into unalterable logs has been enabled +BlockedLogDisabled=System to track events into unalterable logs has been disabled after some recording were done. We saved a special Fingerprint to track the chain as broken +BlockedLogDisabledBis=System to track events into unalterable logs has been disabled. This is possible because no record were done yet. \ No newline at end of file From 8c38125e79d654367ede5699856a60b66ecb41fe Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Fri, 28 Jan 2022 10:30:41 +0100 Subject: [PATCH 40/74] Update vcard.php --- htdocs/user/vcard.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/user/vcard.php b/htdocs/user/vcard.php index 57778c44259..ee33821ace7 100644 --- a/htdocs/user/vcard.php +++ b/htdocs/user/vcard.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2021-2022 Anthony Berton * * 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 @@ -64,27 +65,27 @@ $v->setUid('DOLIBARR-USERID-'.$user2->id); $v->setName($user2->lastname, $user2->firstname, "", $user2->civility_code, ""); $v->setFormattedName($user2->getFullName($langs, 1)); -$v->setPhoneNumber($user2->phone_pro, "TYPE=WORK;VOICE"); -//$v->setPhoneNumber($user2->phone_perso,"TYPE=HOME;VOICE"); -$v->setPhoneNumber($user2->phone_mobile, "TYPE=CELL;VOICE"); -$v->setPhoneNumber($user2->fax, "TYPE=WORK;FAX"); +$v->setPhoneNumber($user2->office_phone, "TYPE=WORK;VOICE"); +$v->setPhoneNumber($user2->personal_mobile,"TYPE=HOME;VOICE"); +$v->setPhoneNumber($user2->user_mobile, "TYPE=CELL;VOICE"); +$v->setPhoneNumber($user2->office_fax, "TYPE=WORK;FAX"); $country = $user2->country_code ? $user2->country : ''; $v->setAddress("", "", $user2->address, $user2->town, $user2->state, $user2->zip, $country, "TYPE=WORK;POSTAL"); $v->setLabel("", "", $user2->address, $user2->town, $user2->state, $user2->zip, $country, "TYPE=WORK"); -$v->setEmail($user2->email); +$v->setEmail($user2->email, "TYPE=WORK"); $v->setNote($user2->note); $v->setTitle($user2->poste); // Data from linked company if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (!$user2->phone_pro) { + if (!$user2->office_phone) { $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); } - if (!$user2->fax) { + if (!$user2->office_fax) { $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); } if (!$user2->zip) { @@ -96,16 +97,16 @@ if ($company->id) { // was set before, don't set twice } elseif (empty(trim($user2->email))) { // when user e-mail is empty, use only company e-mail - $v->setEmail($company->email); + $v->setEmail($company->email, "TYPE=WORK"); } elseif (strtolower(end(explode("@", $user2->email))) == strtolower(end(explode("@", $company->email)))) { // when e-mail domain of user and company are the same, use user e-mail at first (and company e-mail at second) - $v->setEmail($user2->email); + $v->setEmail($user2->email, "TYPE=WORK"); // support by Microsoft Outlook (2019 and possible earlier) $v->setEmail($company->email, 'INTERNET'); } else { // when e-mail of user and company complete different use company e-mail at first (and user e-mail at second) - $v->setEmail($company->email); + $v->setEmail($company->email, "TYPE=WORK"); // support by Microsoft Outlook (2019 and possible earlier) $v->setEmail($user2->email, 'INTERNET'); @@ -118,7 +119,7 @@ if ($company->id) { } // Personal informations -$v->setPhoneNumber($user2->phone_perso, "TYPE=HOME;VOICE"); +$v->setPhoneNumber($user2->personal_mobile, "TYPE=HOME;VOICE"); if ($user2->birth) { $v->setBirthday($user2->birth); } From adac1d3dbb1cb2499274f765b82717998c1c998b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 28 Jan 2022 09:34:52 +0000 Subject: [PATCH 41/74] Fixing style errors. --- htdocs/user/vcard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/vcard.php b/htdocs/user/vcard.php index ee33821ace7..0f9085d0b52 100644 --- a/htdocs/user/vcard.php +++ b/htdocs/user/vcard.php @@ -66,7 +66,7 @@ $v->setName($user2->lastname, $user2->firstname, "", $user2->civility_code, ""); $v->setFormattedName($user2->getFullName($langs, 1)); $v->setPhoneNumber($user2->office_phone, "TYPE=WORK;VOICE"); -$v->setPhoneNumber($user2->personal_mobile,"TYPE=HOME;VOICE"); +$v->setPhoneNumber($user2->personal_mobile, "TYPE=HOME;VOICE"); $v->setPhoneNumber($user2->user_mobile, "TYPE=CELL;VOICE"); $v->setPhoneNumber($user2->office_fax, "TYPE=WORK;FAX"); From 34f3ec8a39e9e743980d9557b2069a1fba3d49b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 11:11:36 +0100 Subject: [PATCH 42/74] Try a fix with php that return a fatal error on some mysql --- htdocs/core/db/mysqli.class.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 4dd71f0e351..fa24e4a70ac 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -210,6 +210,8 @@ class DoliDBMysqli extends DoliDB { dol_syslog(get_class($this)."::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name", LOG_DEBUG); + //mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); + // Can also be // mysqli::init(); mysql::options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0'); mysqli::options(MYSQLI_OPT_CONNECT_TIMEOUT, 5); // return mysqli::real_connect($host, $user, $pass, $db, $port); @@ -255,6 +257,8 @@ class DoliDBMysqli extends DoliDB return false; } + + /** * Execute a SQL request and return the resultset * @@ -288,11 +292,16 @@ class DoliDBMysqli extends DoliDB } } - if (!$this->database_name) { - // Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE) - $ret = $this->db->query($query, $result_mode); - } else { - $ret = $this->db->query($query, $result_mode); + try { + if (!$this->database_name) { + // Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE) + $ret = $this->db->query($query, $result_mode); + } else { + $ret = $this->db->query($query, $result_mode); + } + } catch (Exception $e) { + dol_syslog(get_class($this)."::query Exception in query instead of returning an error: ".$e->getMessage(), LOG_ERR); + $ret = false; } if (!preg_match("/^COMMIT/i", $query) && !preg_match("/^ROLLBACK/i", $query)) { From b65f849c5de3ef963f53e2f8c741228fc66f7b5b Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Fri, 28 Jan 2022 11:22:12 +0100 Subject: [PATCH 43/74] New - Improve the reading of profIDs --- htdocs/core/lib/functions.lib.php | 30 ++++++++++++++++++++++++++++++ htdocs/main.inc.php | 14 +++++++------- htdocs/societe/card.php | 4 ++-- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a59f35a3978..edab23ce514 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2925,6 +2925,36 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor return $htmllink; } +/** + * Format profIDs according to country + * + * @param string $profID value of profID to format + * @param string $profIDtype type of profID to format (ProfId1, ProfId2, ProfId3, ProfId4, ProfId5, ProfId6 or VATIntra) + * @param string $countrycode Country code to use for formatting + * @param int $addcpButton Add button to copy to clipboard (1 => show only on hoover ; 2 => always display ) + * @param string $separ Separation between numbers for a better visibility example : xxx xxx xxx xxxxx + * @return string Formated profID + */ +function dol_print_profids($profID, $profIDtype, $countrycode = '', $addcpButton = 1, $separ = ' ') +{ + global $mysoc; + + if (empty($profID) || empty($profIDtype)) return ''; + if (empty($countrycode)) $countrycode = $mysoc->country_code; + $newProfID = $profID; + $id = substr($profIDtype, -1); + $ret = ''; + if (strtoupper($countrycode) == 'FR') { + // France + if ($id == 1 && dol_strlen($newProfID) == 9) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3); + if ($id == 2 && dol_strlen($newProfID) == 14) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3).$separ.substr($newProfID, 9, 5); + if ($profIDtype == 'VATIntra' && dol_strlen($newProfID) == 13) $newProfID = substr($newProfID, 0, 4).$separ.substr($newProfID, 4, 3).$separ.substr($newProfID, 7, 3).$separ.substr($newProfID, 10, 3); + } + if (!empty($addcpButton)) $ret = showValueWithClipboardCPButton(dol_escape_htmltag($profID), ($addcpButton == 1 ? 1 : 0), $newProfID); + else $ret = $newProfID; + return $ret; +} + /** * Format phone numbers according to country * diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index fd811877295..acc8c440821 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2073,24 +2073,24 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= '
'; if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId1", $mysoc->country_code).': '.showValueWithClipboardCPButton(getDolGlobalString("MAIN_INFO_SIREN")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId1", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIREN")).''; } if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId2", $mysoc->country_code).': '.showValueWithClipboardCPButton(getDolGlobalString("MAIN_INFO_SIRET")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId2", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIRET")).''; } if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId3", $mysoc->country_code).': '.showValueWithClipboardCPButton(getDolGlobalString("MAIN_INFO_APE")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId3", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_APE")).''; } if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId4", $mysoc->country_code).': '.showValueWithClipboardCPButton(getDolGlobalString("MAIN_INFO_RCS")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId4", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_RCS")).''; } if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId5", $mysoc->country_code).': '.showValueWithClipboardCPButton(getDolGlobalString("MAIN_INFO_PROFID5")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId5", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID5")).''; } if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId6", $mysoc->country_code).': '.showValueWithClipboardCPButton(getDolGlobalString("MAIN_INFO_PROFID6")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId6", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID6")).''; } - $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.showValueWithClipboardCPButton(getDolGlobalString("MAIN_INFO_TVAINTRA")).''; + $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.dol_print_profids(getDolGlobalString("MAIN_INFO_TVAINTRA")).''; $dropdownBody .= '
'; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b6c483fc026..43e9bb30314 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2542,7 +2542,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''.$idprof.''; $key = 'idprof'.$i; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->$key)); + print dol_print_profids($object->$key, 'ProfId'.$i, $object->country_code, 1); if ($object->$key) { if ($object->id_prof_check($i, $object) > 0) { print '   '.$object->id_prof_url($i, $object); @@ -2655,7 +2655,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans('VATIntra').''; if ($object->tva_intra) { $s = ''; - $s .= showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)); + $s .= dol_print_profids($object->tva_intra, 'VATIntra', $object->country_code, 1); $s .= ''; if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) { From 66b6b5e91a5610ba3c578ce853ade877a7b00aee Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Fri, 28 Jan 2022 11:31:17 +0100 Subject: [PATCH 44/74] stickler-ci --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index edab23ce514..6c6a328596f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2951,7 +2951,7 @@ function dol_print_profids($profID, $profIDtype, $countrycode = '', $addcpButton if ($profIDtype == 'VATIntra' && dol_strlen($newProfID) == 13) $newProfID = substr($newProfID, 0, 4).$separ.substr($newProfID, 4, 3).$separ.substr($newProfID, 7, 3).$separ.substr($newProfID, 10, 3); } if (!empty($addcpButton)) $ret = showValueWithClipboardCPButton(dol_escape_htmltag($profID), ($addcpButton == 1 ? 1 : 0), $newProfID); - else $ret = $newProfID; + else $ret = $newProfID; return $ret; } From da744f5cb9de1b41f6a65d10cba718aa3667df7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 13:44:15 +0100 Subject: [PATCH 45/74] Fix link --- htdocs/core/boxes/box_scheduled_jobs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 53cf5c79571..94695034cce 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -170,7 +170,7 @@ class box_scheduled_jobs extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="center"', - 'textnoformat' => ($nbjobsinerror ? '
'.$nbjobsinerror.'
' : '
0
') + 'textnoformat' => ($nbjobsinerror ? '
'.$nbjobsinerror.'
' : '
0
') ); } else { $this->info_box_contents[0][0] = array( From bd2d7792f453c5ba20f004eca7647348a590e7cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 13:52:42 +0100 Subject: [PATCH 46/74] css --- htdocs/core/lib/product.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 10c838b4c43..117871b4712 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -382,7 +382,7 @@ function show_stats_for_company($product, $socid) } $langs->load("propal"); print ''; - print ''.img_object('', 'propal', 'class="paddingright"').$langs->trans("Proposals").''; + print ''.img_object('', 'propal', 'class="pictofixedwidth"').$langs->trans("Proposals").''; print ''; print $product->stats_propale['customers']; print ''; @@ -401,7 +401,7 @@ function show_stats_for_company($product, $socid) } $langs->load("supplier_proposal"); print ''; - print ''.img_object('', 'supplier_proposal', 'class="paddingright"').$langs->trans("SupplierProposals").''; + print ''.img_object('', 'supplier_proposal', 'class="pictofixedwidth"').$langs->trans("SupplierProposals").''; print ''; print $product->stats_proposal_supplier['suppliers']; print ''; @@ -420,7 +420,7 @@ function show_stats_for_company($product, $socid) } $langs->load("orders"); print ''; - print ''.img_object('', 'order', 'class="paddingright"').$langs->trans("CustomersOrders").''; + print ''.img_object('', 'order', 'class="pictofixedwidth"').$langs->trans("CustomersOrders").''; print ''; print $product->stats_commande['customers']; print ''; @@ -439,7 +439,7 @@ function show_stats_for_company($product, $socid) } $langs->load("orders"); print ''; - print ''.img_object('', 'supplier_order', 'class="paddingright"').$langs->trans("SuppliersOrders").''; + print ''.img_object('', 'supplier_order', 'class="pictofixedwidth"').$langs->trans("SuppliersOrders").''; print ''; print $product->stats_commande_fournisseur['suppliers']; print ''; @@ -458,7 +458,7 @@ function show_stats_for_company($product, $socid) } $langs->load("bills"); print ''; - print ''.img_object('', 'bill').' '.$langs->trans("CustomersInvoices").''; + print ''.img_object('', 'bill', 'class="pictofixedwidth"').$langs->trans("CustomersInvoices").''; print ''; print $product->stats_facture['customers']; print ''; @@ -477,7 +477,7 @@ function show_stats_for_company($product, $socid) } $langs->load("bills"); print ''; - print ''.img_object('', 'supplier_invoice', 'class="paddingright"').$langs->trans("SuppliersInvoices").''; + print ''.img_object('', 'supplier_invoice', 'class="pictofixedwidth"').$langs->trans("SuppliersInvoices").''; print ''; print $product->stats_facture_fournisseur['suppliers']; print ''; @@ -497,7 +497,7 @@ function show_stats_for_company($product, $socid) } $langs->load("contracts"); print ''; - print ''.img_object('', 'contract', 'class="paddingright"').$langs->trans("Contracts").''; + print ''.img_object('', 'contract', 'class="pictofixedwidth"').$langs->trans("Contracts").''; print ''; print $product->stats_contrat['customers']; print ''; @@ -518,7 +518,7 @@ function show_stats_for_company($product, $socid) $langs->load("mrp"); print ''; - print ''.img_object('', 'bom', 'class="paddingright"').$langs->trans("BOM").''; + print ''.img_object('', 'bom', 'class="pictofixedwidth"').$langs->trans("BOM").''; print ''; print ''; @@ -540,7 +540,7 @@ function show_stats_for_company($product, $socid) } $langs->load("mrp"); print ''; - print ''.img_object('', 'mrp', 'class="paddingright"').$langs->trans("MO").''; + print ''.img_object('', 'mrp', 'class="pictofixedwidth"').$langs->trans("MO").''; print ''; print $form->textwithpicto($product->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); print $form->textwithpicto($product->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed")); From e70604c48582bba174c886b60590392b0d0457fe Mon Sep 17 00:00:00 2001 From: Salvatore Chiariello Date: Fri, 28 Jan 2022 14:57:36 +0100 Subject: [PATCH 47/74] NEW|New #17123 added ExtraFields for Stock Mouvement --- htdocs/core/class/extrafields.class.php | 3 - htdocs/core/lib/stock.lib.php | 5 + .../llx_stock_mouvement_extrafields.sql | 24 ++++ htdocs/langs/en_US/products.lang | 1 + htdocs/langs/it_IT/products.lang | 1 + .../admin/stock_mouvement_extrafields.php | 126 ++++++++++++++++++ htdocs/product/class/product.class.php | 14 +- htdocs/product/stock/movement_list.php | 36 ++++- .../product/stock/tpl/extrafields_add.tpl.php | 52 ++++++++ .../product/stock/tpl/stockcorrection.tpl.php | 3 + .../product/stock/tpl/stocktransfer.tpl.php | 3 + 11 files changed, 257 insertions(+), 11 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_stock_mouvement_extrafields.sql create mode 100644 htdocs/product/admin/stock_mouvement_extrafields.php create mode 100644 htdocs/product/stock/tpl/extrafields_add.tpl.php diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4c0ec1ff5a5..a6f09493a74 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -804,9 +804,6 @@ class ExtraFields if ($elementtype == 'order_supplier') { $elementtype = 'commande_fournisseur'; } - if ($elementtype == 'stock_mouvement') { - $elementtype = 'movement'; - } $array_name_label = array(); diff --git a/htdocs/core/lib/stock.lib.php b/htdocs/core/lib/stock.lib.php index 2e58e6c8082..066bf2165be 100644 --- a/htdocs/core/lib/stock.lib.php +++ b/htdocs/core/lib/stock.lib.php @@ -109,6 +109,11 @@ function stock_admin_prepare_head() $head[$h][2] = 'attributes'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_mouvement_extrafields.php'; + $head[$h][1] = $langs->trans("StockMouvementExtraFields"); + $head[$h][2] = 'stockMouvementAttributes'; + $h++; + complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove'); return $head; diff --git a/htdocs/install/mysql/tables/llx_stock_mouvement_extrafields.sql b/htdocs/install/mysql/tables/llx_stock_mouvement_extrafields.sql new file mode 100644 index 00000000000..c13218b631e --- /dev/null +++ b/htdocs/install/mysql/tables/llx_stock_mouvement_extrafields.sql @@ -0,0 +1,24 @@ +-- =================================================================== +-- Copyright (C) 2022 Salvatore Chiariello +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + +CREATE TABLE llx_stock_mouvement_extrafields ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_object integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index a8942bd337f..14715670882 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -410,3 +410,4 @@ DefaultBOMDesc=The default BOM recommended to use to manufacture this product. T Rank=Rank SwitchOnSaleStatus=Switch on sale status SwitchOnPurchaseStatus=Switch on purchase status +StockMouvementExtraFields= Extra Fields (stock mouvement) diff --git a/htdocs/langs/it_IT/products.lang b/htdocs/langs/it_IT/products.lang index f33ca8759bf..f5b9043b4e8 100644 --- a/htdocs/langs/it_IT/products.lang +++ b/htdocs/langs/it_IT/products.lang @@ -410,3 +410,4 @@ DefaultBOMDesc=The default BOM recommended to use to manufacture this product. T Rank=Rank SwitchOnSaleStatus=Switch on sale status SwitchOnPurchaseStatus=Switch on purchase status +StockMouvementExtraFields= Campi extra (movimenti scorte) diff --git a/htdocs/product/admin/stock_mouvement_extrafields.php b/htdocs/product/admin/stock_mouvement_extrafields.php new file mode 100644 index 00000000000..0369c397e22 --- /dev/null +++ b/htdocs/product/admin/stock_mouvement_extrafields.php @@ -0,0 +1,126 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/product/admin/stock_mouvement_extrafields.php + * \ingroup stock + * \brief Page to setup extra fields of stock mouvement + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('stock@stock', 'admin')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); + +$action = GETPOST('action', 'aZ09'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'stock_mouvement'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + + +llxHeader('', $langs->trans("StockSetup"), $help_url); + + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("StockSetup"), $linkback, 'title_setup'); + + +$head = stock_admin_prepare_head(); + +print dol_get_fiche_head($head, 'stockMouvementAttributes', $langs->trans("StockMouvementExtraFields"), -1, 'account'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +print dol_get_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* + * Creation of an optional field + */ +if ($action == 'create') +{ + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* + * Edition of an optional field + */ +if ($action == 'edit' && !empty($attrname)) +{ + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 27b2bdaff2c..c141c9ab526 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5122,7 +5122,7 @@ class Product extends CommonObject * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct) * @return int <0 if KO, >0 if OK */ - public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0) + public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0,$extrafields = null) { // phpcs:enable if ($id_entrepot) { @@ -5145,6 +5145,11 @@ class Product extends CommonObject $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', '', '', '', false, 0, $disablestockchangeforsubproduct); if ($result >= 0) { + if($extrafields){ + $array_options = $extrafields->getOptionalsFromPost('stock_mouvement'); + $movementstock->array_options = $array_options; + $movementstock->insertExtraFields(); + } $this->db->commit(); return 1; } else { @@ -5176,7 +5181,7 @@ class Product extends CommonObject * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct) * @return int <0 if KO, >0 if OK */ - public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0) + public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0,$extrafields = null) { // phpcs:enable if ($id_entrepot) { @@ -5199,6 +5204,11 @@ class Product extends CommonObject $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot, false, 0, $disablestockchangeforsubproduct); if ($result >= 0) { + if($extrafields){ + $array_options = $extrafields->getOptionalsFromPost('stock_mouvement'); + $movementstock->array_options = $array_options; + $movementstock->insertExtraFields(); + } $this->db->commit(); return 1; } else { diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 405528a3480..73c6751262a 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -139,6 +139,9 @@ $arrayfields = array( //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500) ); + +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; + if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) { unset($arrayfields['pl.sellby']); } @@ -381,7 +384,9 @@ if ($action == "correct_stock") { $batch, GETPOST('inventorycode', 'alphanohtml'), $origin_element, - $origin_id + $origin_id, + 0, + $extrafields ); // We do not change value of stock for a correction } else { $result = $product->correct_stock( @@ -393,7 +398,9 @@ if ($action == "correct_stock") { price2num(GETPOST('unitprice'), 'MT'), GETPOST('inventorycode', 'alphanohtml'), $origin_element, - $origin_id + $origin_id, + 0, + $extrafields ); // We do not change value of stock for a correction } @@ -500,7 +507,11 @@ if ($action == "transfert_stock" && !$cancel) { $eatby, $sellby, $batch, - GETPOST('inventorycode') + GETPOST('inventorycode'), + '', + null, + 0, + $extrafields ); // Add stock $result2 = $product->correct_stock_batch( @@ -513,7 +524,11 @@ if ($action == "transfert_stock" && !$cancel) { $eatby, $sellby, $batch, - GETPOST('inventorycode', 'alphanohtml') + GETPOST('inventorycode', 'alphanohtml'), + '', + null, + 0, + $extrafields ); } } else { @@ -525,7 +540,11 @@ if ($action == "transfert_stock" && !$cancel) { 1, GETPOST("label", 'san_alpha'), $pricesrc, - GETPOST('inventorycode', 'alphanohtml') + GETPOST('inventorycode', 'alphanohtml'), + '', + null, + 0, + $extrafields ); // Add stock @@ -536,7 +555,11 @@ if ($action == "transfert_stock" && !$cancel) { 0, GETPOST("label", 'san_alpha'), $pricedest, - GETPOST('inventorycode', 'alphanohtml') + GETPOST('inventorycode', 'alphanohtml'), + '', + null, + 0, + $extrafields ); } if (!$error && $result1 >= 0 && $result2 >= 0) { @@ -1434,6 +1457,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } // Extra fields + $object = $movement; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); diff --git a/htdocs/product/stock/tpl/extrafields_add.tpl.php b/htdocs/product/stock/tpl/extrafields_add.tpl.php new file mode 100644 index 00000000000..9cf61564ebe --- /dev/null +++ b/htdocs/product/stock/tpl/extrafields_add.tpl.php @@ -0,0 +1,52 @@ + + * Copyright (C) 2014 Juanjo Menent + * + * 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 . + * + * Need to have following variables defined: + * $object (invoice, order, ...) + * $action + * $conf + * $langs + * + * $parameters + * $cols + */ + +// Protection to avoid direct call of template +if (empty($conf) || !is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + +?> + +executeHooks('formObjectOptions', $parameters, $movement, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (empty($reshook)) { + $params = array(); + if (isset($tpl_context)) $params['tpl_context'] = $tpl_context; + $params['cols'] = $parameters['colspanvalue']; + print $movement->showOptionals($extrafields, 'create', $params); +} + +?> + diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 00699b95e18..eb84df7d14e 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -179,6 +179,9 @@ print '\n"; } + // $objectsrc->lines contains the line of the purchase order + // $dispatchLines is list of lines with dispatching detail (with product, qty and warehouse). One purchase order line may have n of this dispatch lines. + + $arrayofpurchaselinealreadyoutput= array(); + + // $_POST contains fk_commandefourndet_X_Y where Y is num of product line and X is number of splitted line $indiceAsked = 1; - while ($indiceAsked <= $numAsked) { + while ($indiceAsked <= $numAsked) { // Loop on $dispatchLines. Warning: $dispatchLines must be sorted by fk_commandefourndet (it is a regroupment key on output) $product = new Product($db); + + // We search the purchase order line that is linked to the dispatchLines foreach ($objectsrc->lines as $supplierLine) { if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) { $line = $supplierLine; @@ -1055,7 +1063,6 @@ if ($action == 'create') { print ''."\n"; print ''."\n"; - // Product label if ($line->fk_product > 0) { // If predefined product $product->fetch($line->fk_product); @@ -1064,42 +1071,45 @@ if ($action == 'create') { print ''; print ''; // ancre pour retourner sur la ligne - print ''; + if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice + print ''; - // Show product and description - $product_static = $product; + // Show product and description + $product_static = $product; - $text = $product_static->getNomUrl(1); - $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); - $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); - print $form->textwithtooltip($text, $description, 3, '', '', $i); + $text = $product_static->getNomUrl(1); + $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); + $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); + print $form->textwithtooltip($text, $description, 3, '', '', $i); - // Show range - print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); + // Show range + print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); - // Add description in form - if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print ($line->desc && $line->desc != $line->product_label) ? '
'.dol_htmlentitiesbr($line->desc) : ''; + // Add description in form + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { + print ($line->desc && $line->desc != $line->product_label) ? '
'.dol_htmlentitiesbr($line->desc) : ''; + } } - print ''; } else { print ""; - if ($type == 1) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } + if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice + if ($type == 1) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } - if (!empty($line->label)) { - $text .= ' '.$line->label.''; - print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); - } else { - print $text.' '.nl2br($line->desc); - } + if (!empty($line->label)) { + $text .= ' '.$line->label.''; + print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); + } else { + print $text.' '.nl2br($line->desc); + } - // Show range - print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); + // Show range + print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); + } print "\n"; } @@ -1110,8 +1120,11 @@ if ($action == 'create') { print ''; print ''; - // Qty - print ''.$line->qty; + // Qty in source purchase order line + print ''; + if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice + print $line->qty; + } print ''; print ''; print ''; @@ -1121,7 +1134,9 @@ if ($action == 'create') { // Qty already received print ''; $quantityDelivered = $objectsrc->receptions[$line->id]; - print $quantityDelivered; + if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice + print $quantityDelivered; + } print ''; print ''; @@ -1190,6 +1205,9 @@ if ($action == 'create') { } } } + + $arrayofpurchaselinealreadyoutput[$line->id] = $line->id; + print "\n"; $extralabelslines = $extrafields->attributes[$line->table_element]; @@ -1756,7 +1774,9 @@ if ($action == 'create') { //var_dump($alreadysent); } - // Loop on each product to send/sent + $arrayofpurchaselinealreadyoutput = array(); + + // Loop on each product to send/sent. Warning: $lines must be sorted by ->fk_commandefourndet (it is a regroupment key on output) for ($i = 0; $i < $num_prod; $i++) { print ''; // id of order line print ''; @@ -1778,32 +1798,35 @@ if ($action == 'create') { } print ''; - - $text = $lines[$i]->product->getNomUrl(1); - $text .= ' - '.$label; - $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description)); - print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); - if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; + if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { + $text = $lines[$i]->product->getNomUrl(1); + $text .= ' - '.$label; + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description)); + print $form->textwithtooltip($text, $description, 3, '', '', $i); + print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { + print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; + } } print "\n"; } else { print ""; - if ($lines[$i]->product_type == Product::TYPE_SERVICE) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } + if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { + if ($lines[$i]->product_type == Product::TYPE_SERVICE) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } - if (!empty($lines[$i]->label)) { - $text .= ' '.$lines[$i]->label.''; - print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); - } else { - print $text.' '.nl2br($lines[$i]->description); - } + if (!empty($lines[$i]->label)) { + $text .= ' '.$lines[$i]->label.''; + print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); + } else { + print $text.' '.nl2br($lines[$i]->description); + } - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + } print "\n"; } @@ -1815,33 +1838,39 @@ if ($action == 'create') { // Qty ordered - print ''.$lines[$i]->qty_asked.''; + print ''; + if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { + print $lines[$i]->qty_asked; + } + print ''; // Qty in other receptions (with reception and warehouse used) if ($origin && $origin_id > 0) { print ''; - foreach ($alreadysent as $key => $val) { - if ($lines[$i]->fk_commandefourndet == $key) { - $j = 0; - foreach ($val as $receptionline_id => $receptionline_var) { - if ($receptionline_var['reception_id'] == $lines[$i]->fk_reception) { - continue; // We want to show only "other receptions" - } + if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { + foreach ($alreadysent as $key => $val) { + if ($lines[$i]->fk_commandefourndet == $key) { + $j = 0; + foreach ($val as $receptionline_id => $receptionline_var) { + if ($receptionline_var['reception_id'] == $lines[$i]->fk_reception) { + continue; // We want to show only "other receptions" + } - $j++; - if ($j > 1) { - print '
'; - } - $reception_static->fetch($receptionline_var['reception_id']); - print $reception_static->getNomUrl(1); - print ' - '.$receptionline_var['qty']; + $j++; + if ($j > 1) { + print '
'; + } + $reception_static->fetch($receptionline_var['reception_id']); + print $reception_static->getNomUrl(1); + print ' - '.$receptionline_var['qty']; - $htmltext = $langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($receptionline_var['date_valid'], 'dayhour')); - if (!empty($conf->stock->enabled) && $receptionline_var['warehouse'] > 0) { - $warehousestatic->fetch($receptionline_var['warehouse']); - $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); + $htmltext = $langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($receptionline_var['date_valid'], 'dayhour')); + if (!empty($conf->stock->enabled) && $receptionline_var['warehouse'] > 0) { + $warehousestatic->fetch($receptionline_var['warehouse']); + $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); + } + print ' '.$form->textwithpicto('', $htmltext, 1); } - print ' '.$form->textwithpicto('', $htmltext, 1); } } } @@ -1971,6 +2000,8 @@ if ($action == 'create') { } print ""; + $arrayofpurchaselinealreadyoutput[$lines[$i]->fk_commandefourndet] = $lines[$i]->fk_commandefourndet; + // Display lines extrafields $extralabelslines = $extrafields->attributes[$lines[$i]->table_element]; if (is_array($extralabelslines) && count($extralabelslines) > 0) { From 7c9b97d035661d0c2b98dd3ec26009f428548581 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 16:29:27 +0100 Subject: [PATCH 49/74] css --- htdocs/core/ajax/selectsearchbox.php | 48 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 1814b476d06..ae4f7c41515 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -65,58 +65,58 @@ $arrayresult = array(); // Define $searchform if (!empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) { - $arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (((!empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) { - $arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) { - $arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (((!empty($conf->product->enabled) && $user->rights->produit->lire) || (!empty($conf->service->enabled) && $user->rights->service->lire)) && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) { - $arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); // search on lot/serial numbers if ( ! empty($conf->productbatch->enabled) ) { - $arrayresult['searchintobatch'] = array('position'=>32, 'shortcut'=>'B', 'img'=>'object_lot', 'label'=>$langs->trans("SearchIntoBatch", $search_boxvalue), 'text'=>img_picto('', 'object_lot').' '.$langs->trans("SearchIntoBatch", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/stock/productlot_list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintobatch'] = array('position'=>32, 'shortcut'=>'B', 'img'=>'object_lot', 'label'=>$langs->trans("SearchIntoBatch", $search_boxvalue), 'text'=>img_picto('', 'object_lot', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoBatch", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/stock/productlot_list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } } if (!empty($conf->mrp->enabled) && $user->rights->mrp->read && empty($conf->global->MAIN_SEARCHFORM_MRP_DISABLED)) { - $arrayresult['searchintomo'] = array('position'=>35, 'shortcut'=>'', 'img'=>'object_mrp', 'label'=>$langs->trans("SearchIntoMO", $search_boxvalue), 'text'=>img_picto('', 'object_mrp').' '.$langs->trans("SearchIntoMO", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/mrp/mo_list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintomo'] = array('position'=>35, 'shortcut'=>'', 'img'=>'object_mrp', 'label'=>$langs->trans("SearchIntoMO", $search_boxvalue), 'text'=>img_picto('', 'object_mrp', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMO", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/mrp/mo_list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) { - $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_project', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_project').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_project', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_project', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) { - $arrayresult['searchintotasks'] = array('position'=>45, 'img'=>'object_projecttask', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('', 'object_projecttask').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintotasks'] = array('position'=>45, 'img'=>'object_projecttask', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('', 'object_projecttask', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } if (!empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) { - $arrayresult['searchintopropal'] = array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintopropal'] = array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) { - $arrayresult['searchintoorder'] = array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintoorder'] = array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) { - $arrayresult['searchintoshipment'] = array('position'=>80, 'img'=>'object_shipment', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('', 'object_shipment').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintoshipment'] = array('position'=>80, 'img'=>'object_shipment', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('', 'object_shipment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) { - $arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) { - $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_supplier_proposal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_supplier_proposal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED)) { - $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_supplier_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_supplier_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) { - $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_supplier_invoice', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_supplier_invoice', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } // Customer payments @@ -125,7 +125,7 @@ if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUST 'position'=>170, 'img'=>'object_payment', 'label'=>$langs->trans("SearchIntoCustomerPayments", $search_boxvalue), - 'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoCustomerPayments", $search_boxvalue), + 'text'=>img_picto('', 'object_payment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerPayments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/paiement/list.php?leftmenu=customers_bills_payment'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } @@ -135,7 +135,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S 'position'=>175, 'img'=>'object_payment', 'label'=>$langs->trans("SearchIntoVendorPayments", $search_boxvalue), - 'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoVendorPayments", $search_boxvalue), + 'text'=>img_picto('', 'object_payment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoVendorPayments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/paiement/list.php?leftmenu=suppliers_bills_payment'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } @@ -145,29 +145,29 @@ if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_ 'position'=>180, 'img'=>'object_payment', 'label'=>$langs->trans("SearchIntoMiscPayments", $search_boxvalue), - 'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoMiscPayments", $search_boxvalue), + 'text'=>img_picto('', 'object_payment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMiscPayments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) { - $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) { - $arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->rights->ticket->read) { - $arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } // HR if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) { - $arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) { - $arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } if (!empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) { - $arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } // Execute hook addSearchEntry From 8d75f575e5693506679aa86f9c269e8e66dd961c Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 28 Jan 2022 16:35:14 +0100 Subject: [PATCH 50/74] Fix missing reception module description translation key. --- htdocs/core/modules/modReception.class.php | 2 +- htdocs/langs/en_US/receptions.lang | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 4696f15019a..29c10ccb3e5 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -47,7 +47,7 @@ class modReception extends DolibarrModules $this->module_position = '40'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); - $this->description = "Gestion des réceptions fournisseurs"; + $this->description = "ReceptionDescription"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; diff --git a/htdocs/langs/en_US/receptions.lang b/htdocs/langs/en_US/receptions.lang index d9e8bdeebb7..3d69873c5fc 100644 --- a/htdocs/langs/en_US/receptions.lang +++ b/htdocs/langs/en_US/receptions.lang @@ -1,5 +1,6 @@ # Dolibarr language file - Source file is en_US - receptions -ReceptionsSetup=Product Reception setup +ReceptionDescription=Vendor reception management (Create reception documents) +ReceptionsSetup=Vendor Reception setup RefReception=Ref. reception Reception=Reception Receptions=Receptions From 9d228b13de3cfd3b60c6985cf6bf85bc276d81a5 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Fri, 28 Jan 2022 17:22:41 +0100 Subject: [PATCH 51/74] FIX pay value --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 02d25d30797..f1d4f62587f 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -290,7 +290,7 @@ if ($action == 'valid' && $user->rights->facture->creer) { $payment->datepaye = $now; $payment->fk_account = $bankaccount; $payment->amounts[$invoice->id] = $amountofpayment; - if ($pay == 'cash') { + if ($pay == 'LIQ') { $payment->pos_change = price2num(GETPOST('excess', 'alpha')); } From 807ff75b6a872b40e03f2d2f1a2c5a5cacedbac2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 28 Jan 2022 16:36:15 +0000 Subject: [PATCH 52/74] Fixing style errors. --- .../admin/stock_mouvement_extrafields.php | 27 +++++++++---------- htdocs/product/class/product.class.php | 8 +++--- .../product/stock/tpl/extrafields_add.tpl.php | 3 +-- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/htdocs/product/admin/stock_mouvement_extrafields.php b/htdocs/product/admin/stock_mouvement_extrafields.php index 0369c397e22..23e5aadc9cc 100644 --- a/htdocs/product/admin/stock_mouvement_extrafields.php +++ b/htdocs/product/admin/stock_mouvement_extrafields.php @@ -91,34 +91,31 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; +if ($action != 'create' && $action != 'edit') { + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } /* * Creation of an optional field */ -if ($action == 'create') -{ - print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); +if ($action == 'create') { + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* * Edition of an optional field */ -if ($action == 'edit' && !empty($attrname)) -{ - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); +if ($action == 'edit' && !empty($attrname)) { + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c141c9ab526..9a4eba6c97d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5122,7 +5122,7 @@ class Product extends CommonObject * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct) * @return int <0 if KO, >0 if OK */ - public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0,$extrafields = null) + public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null) { // phpcs:enable if ($id_entrepot) { @@ -5145,7 +5145,7 @@ class Product extends CommonObject $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', '', '', '', false, 0, $disablestockchangeforsubproduct); if ($result >= 0) { - if($extrafields){ + if ($extrafields) { $array_options = $extrafields->getOptionalsFromPost('stock_mouvement'); $movementstock->array_options = $array_options; $movementstock->insertExtraFields(); @@ -5181,7 +5181,7 @@ class Product extends CommonObject * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct) * @return int <0 if KO, >0 if OK */ - public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0,$extrafields = null) + public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null) { // phpcs:enable if ($id_entrepot) { @@ -5204,7 +5204,7 @@ class Product extends CommonObject $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot, false, 0, $disablestockchangeforsubproduct); if ($result >= 0) { - if($extrafields){ + if ($extrafields) { $array_options = $extrafields->getOptionalsFromPost('stock_mouvement'); $movementstock->array_options = $array_options; $movementstock->insertExtraFields(); diff --git a/htdocs/product/stock/tpl/extrafields_add.tpl.php b/htdocs/product/stock/tpl/extrafields_add.tpl.php index 9cf61564ebe..62921f0a6e0 100644 --- a/htdocs/product/stock/tpl/extrafields_add.tpl.php +++ b/htdocs/product/stock/tpl/extrafields_add.tpl.php @@ -26,8 +26,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || !is_object($conf)) -{ +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } From 26865411560643342d49f874df9973d3f1a0f851 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 17:59:58 +0100 Subject: [PATCH 53/74] Fix late picto --- htdocs/commande/list.php | 9 ++++----- htdocs/compta/index.php | 4 ++-- htdocs/core/lib/invoice.lib.php | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 717b57ae8b1..febab2d5917 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1462,11 +1462,6 @@ if ($resql) { print ''; print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1); - // Warning late icon and note - if ($generic_commande->hasDelay()) { - print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); - } - $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; @@ -1590,6 +1585,10 @@ if ($resql) { if (!empty($arrayfields['c.date_commande']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_commande), 'day'); + // Warning late icon and note + if ($generic_commande->hasDelay()) { + print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); + } print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 332f68c1293..c68a686d2bf 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -210,11 +210,11 @@ if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { print ''; print $tmpinvoice->getNomUrl(1, ''); print ''; - print ''; if ($tmpinvoice->hasDelay()) { + print ''; print img_warning($langs->trans("Late")); + print ''; } - print ''; print ''; $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index c64c63fc0dd..1e4cdf16791 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -1196,11 +1196,6 @@ function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) print ''; print $tmpinvoice->getNomUrl(1, ''); print ''; - print ''; - if ($tmpinvoice->hasDelay()) { - print img_warning($langs->trans("Late")); - } - print ''; print ''; $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); @@ -1212,7 +1207,12 @@ function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) print ''; print $societestatic->getNomUrl(1, 'customer'); print ''; - print ''.dol_print_date($db->jdate($obj->datelimite), 'day').''; + print ''; + print dol_print_date($db->jdate($obj->datelimite), 'day'); + if ($tmpinvoice->hasDelay()) { + print img_warning($langs->trans("Late")); + } + print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { print ''.price($obj->total_ht).''; } From 3ec2769a0558e4fd0c5b6608fee370bdd41535bb Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Fri, 28 Jan 2022 17:22:41 +0100 Subject: [PATCH 54/74] FIX pay value --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index ec2fd256cfe..3e4fbd89527 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -290,7 +290,7 @@ if ($action == 'valid' && $user->rights->facture->creer) { $payment->datepaye = $now; $payment->fk_account = $bankaccount; $payment->amounts[$invoice->id] = $amountofpayment; - if ($pay == 'cash') { + if ($pay == 'LIQ') { $payment->pos_change = price2num(GETPOST('excess', 'alpha')); } From c04a572e0b548b5c3a4c1d30b38ba0358a96f228 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 18:46:21 +0100 Subject: [PATCH 55/74] Fix doc --- htdocs/emailcollector/class/emailcollector.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index ab8d940192b..17fe55d0583 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2498,6 +2498,7 @@ class EmailCollector extends CommonObject * * @param Object $mbox Structure * @param string $mid prefix + * @param string $destdir Target dir for attachments * @return array Array with number and object */ private function getmsg($mbox, $mid, $destdir = '') @@ -2548,6 +2549,7 @@ class EmailCollector extends CommonObject * @param string $mid Part no * @param Object $p Object p * @param string $partno Partno + * @param string $destdir Target dir for attachments * @return void */ private function getpart($mbox, $mid, $p, $partno, $destdir = '') From 28f4ab4c90efac46e4162076ad4c4e4eefacebca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 18:52:50 +0100 Subject: [PATCH 56/74] Update supplier_proposal.class.php --- .../supplier_proposal/class/supplier_proposal.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index b239b6cc3da..7980e3fc2ba 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -725,7 +725,9 @@ class SupplierProposal extends CommonObject $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; - $pu = $pu_ht = $tabprice[3]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; @@ -733,6 +735,11 @@ class SupplierProposal extends CommonObject $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; + $pu = $pu_ht; + if ($price_base_type == 'TTC') { + $pu = $pu_ttc; + } + //Fetch current line from the database and then clone the object and set it in $oldline property $line = new SupplierProposalLine($this->db); $line->fetch($rowid); From 8c403655a77d664dd1e7f835e2fd1db5e7131b3a Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Fri, 17 Dec 2021 12:09:14 +0700 Subject: [PATCH 57/74] FIX supplier_proposal when line update price U.P change 0 modify --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index ea10b4d7137..b239b6cc3da 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -725,6 +725,7 @@ class SupplierProposal extends CommonObject $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu = $pu_ht = $tabprice[3]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; From 05ef2c714e7f9540d149c667b03f4251cd6095b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 18:52:50 +0100 Subject: [PATCH 58/74] Update supplier_proposal.class.php --- .../supplier_proposal/class/supplier_proposal.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index b239b6cc3da..7980e3fc2ba 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -725,7 +725,9 @@ class SupplierProposal extends CommonObject $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; - $pu = $pu_ht = $tabprice[3]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; @@ -733,6 +735,11 @@ class SupplierProposal extends CommonObject $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; + $pu = $pu_ht; + if ($price_base_type == 'TTC') { + $pu = $pu_ttc; + } + //Fetch current line from the database and then clone the object and set it in $oldline property $line = new SupplierProposalLine($this->db); $line->fetch($rowid); From 289ce87f6d9d32df3ef332bb4729e84de247a5d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 19:06:41 +0100 Subject: [PATCH 59/74] Fix fatal error --- htdocs/core/lib/functions.lib.php | 10 ++++++---- htdocs/main.inc.php | 14 +++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6c6a328596f..9e1affe3b41 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2928,8 +2928,8 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor /** * Format profIDs according to country * - * @param string $profID value of profID to format - * @param string $profIDtype type of profID to format (ProfId1, ProfId2, ProfId3, ProfId4, ProfId5, ProfId6 or VATIntra) + * @param string $profID Value of profID to format + * @param string $profIDtype Type of profID to format ('1', '2', '3', '4', '5', '6' or 'VAT') * @param string $countrycode Country code to use for formatting * @param int $addcpButton Add button to copy to clipboard (1 => show only on hoover ; 2 => always display ) * @param string $separ Separation between numbers for a better visibility example : xxx xxx xxx xxxxx @@ -2939,7 +2939,9 @@ function dol_print_profids($profID, $profIDtype, $countrycode = '', $addcpButton { global $mysoc; - if (empty($profID) || empty($profIDtype)) return ''; + if (empty($profID) || empty($profIDtype)) { + return ''; + } if (empty($countrycode)) $countrycode = $mysoc->country_code; $newProfID = $profID; $id = substr($profIDtype, -1); @@ -2948,7 +2950,7 @@ function dol_print_profids($profID, $profIDtype, $countrycode = '', $addcpButton // France if ($id == 1 && dol_strlen($newProfID) == 9) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3); if ($id == 2 && dol_strlen($newProfID) == 14) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3).$separ.substr($newProfID, 9, 5); - if ($profIDtype == 'VATIntra' && dol_strlen($newProfID) == 13) $newProfID = substr($newProfID, 0, 4).$separ.substr($newProfID, 4, 3).$separ.substr($newProfID, 7, 3).$separ.substr($newProfID, 10, 3); + if ($profIDtype === 'VAT' && dol_strlen($newProfID) == 13) $newProfID = substr($newProfID, 0, 4).$separ.substr($newProfID, 4, 3).$separ.substr($newProfID, 7, 3).$separ.substr($newProfID, 10, 3); } if (!empty($addcpButton)) $ret = showValueWithClipboardCPButton(dol_escape_htmltag($profID), ($addcpButton == 1 ? 1 : 0), $newProfID); else $ret = $newProfID; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index acc8c440821..657b17434d7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2073,24 +2073,24 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= '
'; if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId1", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIREN")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId1", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIREN"), 1).''; } if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId2", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIRET")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId2", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIRET"), 2).''; } if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId3", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_APE")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId3", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_APE"), 3).''; } if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId4", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_RCS")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId4", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_RCS"), 4).''; } if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId5", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID5")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId5", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID5"), 5).''; } if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId6", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID6")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId6", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID6"), 6).''; } - $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.dol_print_profids(getDolGlobalString("MAIN_INFO_TVAINTRA")).''; + $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.dol_print_profids(getDolGlobalString("MAIN_INFO_TVAINTRA"), 'VAT').''; $dropdownBody .= '
'; From 288a6564dcace6819c6d08f3c40dd6419b391160 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 19:28:37 +0100 Subject: [PATCH 60/74] CSS --- htdocs/admin/index.php | 17 +++++++++++++---- htdocs/theme/eldy/global.inc.php | 6 ++++++ htdocs/theme/md/style.css.php | 12 ++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index daf20ce5aa2..787a9d6d820 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -47,6 +47,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp); print load_fiche_titre($langs->trans("SetupArea"), '', 'tools'); + if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('//i', '
', $conf->global->MAIN_MOTD_SETUPPAGE); if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { @@ -76,12 +77,15 @@ print $langs->trans("SetupDescription2", $langs->transnoentities("MenuCompanySet print "

"; print ''; -print '

'; +print '
'; // Show info setup company if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { $setupcompanynotcomplete = 1; } + +print '
'; + print img_picto('', 'company', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit&token='.newToken()), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); print '

'; print $langs->trans("SetupDescription3b"); @@ -90,10 +94,13 @@ if (!empty($setupcompanynotcomplete)) { $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"'); print '
'; } + +print '
'; + print '
'; print '
'; -print '
'; -print '
'; + +print '
'; // Show info setup module print img_picto('', 'cog', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); @@ -103,7 +110,9 @@ if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FO $warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"'); print '
'; } -print '
'; + +print '
'; + print '
'; print '
'; print '
'; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index a26fe1aa2fa..e347bf0395a 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -255,6 +255,12 @@ input:invalid, select:invalid, input.--error , select.--error { border-color: #ea1212; } +section.setupsection { + padding: 20px; + background-color: var(--colorbacktitle1); + border-radius: 5px; +} + .field-error-icon { color: #ea1212; !important; } /* Focus definitions must be after standard definition */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 7394cbe697f..78745c70531 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -474,6 +474,18 @@ input.short { width: 40px; } +input:invalid, select:invalid, input.--error , select.--error { + border-color: #ea1212; +} + +section.setupsection { + padding: 20px; + background-color: var(--colorbacktitle1); + border-radius: 5px; +} + +.field-error-icon { color: #ea1212; !important; } + textarea { border-radius: 0; border-top:solid 1px var(--inputbordercolor); From 2fa1b01e2162a5758273a2fb65780dd78c861625 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 19:51:59 +0100 Subject: [PATCH 61/74] Fix dark theme --- 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 deb7cdadf9e..291a152a7de 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -59,7 +59,7 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { print "@media (prefers-color-scheme: dark) {"; } print ":root { - --colorbackhmenu1: #1d1e20; + --colorbackhmenu1: #3d3e40; --colorbackvmenu1: #2b2c2e; --colorbacktitle1: #2b2d2f; --colorbacktabcard1: #1d1e20; /* Must be same than colorbackbody */ From 38e39cfa96cd7f1eac1befb7d3df22d760a8568c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 19:28:37 +0100 Subject: [PATCH 62/74] CSS --- htdocs/admin/index.php | 17 +++++++++++++---- htdocs/theme/eldy/global.inc.php | 6 ++++++ htdocs/theme/md/style.css.php | 12 ++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index daf20ce5aa2..787a9d6d820 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -47,6 +47,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp); print load_fiche_titre($langs->trans("SetupArea"), '', 'tools'); + if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('//i', '
', $conf->global->MAIN_MOTD_SETUPPAGE); if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { @@ -76,12 +77,15 @@ print $langs->trans("SetupDescription2", $langs->transnoentities("MenuCompanySet print "

"; print ''; -print '

'; +print '
'; // Show info setup company if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { $setupcompanynotcomplete = 1; } + +print '
'; + print img_picto('', 'company', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit&token='.newToken()), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); print '

'; print $langs->trans("SetupDescription3b"); @@ -90,10 +94,13 @@ if (!empty($setupcompanynotcomplete)) { $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"'); print '
'; } + +print '
'; + print '
'; print '
'; -print '
'; -print '
'; + +print '
'; // Show info setup module print img_picto('', 'cog', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); @@ -103,7 +110,9 @@ if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FO $warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"'); print '
'; } -print '
'; + +print '
'; + print '
'; print '
'; print '
'; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 291a152a7de..bf1e9dc967e 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -255,6 +255,12 @@ input:invalid, select:invalid, input.--error , select.--error { border-color: #ea1212; } +section.setupsection { + padding: 20px; + background-color: var(--colorbacktitle1); + border-radius: 5px; +} + .field-error-icon { color: #ea1212; !important; } /* Focus definitions must be after standard definition */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 0790db17cfb..6c596ad2916 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -463,6 +463,18 @@ input.short { width: 40px; } +input:invalid, select:invalid, input.--error , select.--error { + border-color: #ea1212; +} + +section.setupsection { + padding: 20px; + background-color: var(--colorbacktitle1); + border-radius: 5px; +} + +.field-error-icon { color: #ea1212; !important; } + textarea { border-radius: 0; border-top:solid 1px var(--inputbordercolor); From ffbeda50bd313ebed31a1a2dd4a90f817eee47fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jan 2022 00:07:04 +0100 Subject: [PATCH 63/74] Better picto for collpase of sub-bom --- htdocs/bom/bom_card.php | 11 ++++++----- htdocs/bom/tpl/objectline_view.tpl.php | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index baf6e3e1a91..cbd730e5d23 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -589,13 +589,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $(".collapse_bom").click(function() { console.log("We click on collapse"); var id_bom_line = $(this).attr('id').replace('collapse-', ''); - if($(this).text().indexOf('+') > 0) { + console.log($(this).html().indexOf('folder-open')); + if($(this).html().indexOf('folder-open') <= 0) { $('[parentid="'+ id_bom_line +'"]').show(); - $(this).html('(-) '); + $(this).html(''); } else { $('[parentid="'+ id_bom_line +'"]').hide(); - $(this).html('(+) '); + $(this).html(''); } return false; @@ -605,7 +606,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $("#show_all").click(function() { console.log("We click on show all"); $("[class^=sub_bom_lines]").show(); - $("[class^=collapse_bom]").html('(-) '); + $("[class^=collapse_bom]").html(''); return false; }); @@ -613,7 +614,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $("#hide_all").click(function() { console.log("We click on hide all"); $("[class^=sub_bom_lines]").hide(); - $("[class^=collapse_bom]").html('(+) '); + $("[class^=collapse_bom]").html(''); return false; }); diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 4360d521036..b72ed043581 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -83,10 +83,12 @@ $tmpproduct->fetch($line->fk_product); $tmpbom = new BOM($object->db); $res = $tmpbom->fetch($line->fk_bom_child); if ($tmpbom->id > 0) { - print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' '; print $tmpproduct->getNomUrl(1); - print ' '.$langs->trans('or').' '; + print ' '.$langs->trans("or").' '; print $tmpbom->getNomUrl(1); + print ' '; + print (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? img_picto('', 'folder') : img_picto('', 'folder-open')); + print ''; } else { print $tmpproduct->getNomUrl(1); print ' - '.$tmpproduct->label; From 266fc808af63aa5e49f96343bb64047b1e4c03b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jan 2022 00:15:55 +0100 Subject: [PATCH 64/74] Fix trans --- htdocs/langs/en_US/mrp.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 3f1aac53340..74bed0d9186 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -27,7 +27,7 @@ ConfirmCloneBillOfMaterials=Are you sure you want to clone the bill of materials ConfirmCloneMo=Are you sure you want to clone the Manufacturing Order %s ? ManufacturingEfficiency=Manufacturing efficiency ConsumptionEfficiency=Consumption efficiency -ValueOfMeansLoss=Value of 0.95 means an average of 5%% of loss during the production +ValueOfMeansLoss=Value of 0.95 means an average of 5%% of loss during the manufacturing or the disassembly ValueOfMeansLossForProductProduced=Value of 0.95 means an average of 5%% of loss of produced product DeleteBillOfMaterials=Delete Bill Of Materials DeleteMo=Delete Manufacturing Order From d75dd51bb72d2b3ca7f9f03147c1c31646b42a20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jan 2022 00:39:20 +0100 Subject: [PATCH 65/74] Clean code to debug fulldayevent --- htdocs/comm/action/card.php | 8 ++++---- htdocs/comm/action/class/actioncomm.class.php | 6 +++++- htdocs/comm/action/document.php | 6 +++--- htdocs/core/modules/modFicheinter.class.php | 9 +-------- htdocs/resource/element_resource.php | 10 +++++----- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 52b93acdabb..627c2f0ce51 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -280,7 +280,7 @@ if (empty($reshook) && $action == 'add') { if (!$error) { // Initialisation objet actioncomm $object->priority = GETPOSTISSET("priority") ? GETPOST("priority", "int") : 0; - $object->fulldayevent = (!empty($fulldayevent) ? 1 : 0); + $object->fulldayevent = ($fulldayevent ? 1 : 0); $object->location = GETPOST("location", 'alphanohtml'); $object->label = GETPOST('label', 'alphanohtml'); @@ -1960,7 +1960,7 @@ if ($id > 0) { } // Full day event - print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; + print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent ? 1 : 0, 3).''; $rowspan = 4; if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { @@ -1969,7 +1969,7 @@ if ($id > 0) { // Date start print ''.$langs->trans("DateActionStart").''; - if (!$object->fulldayevent) { + if (empty($object->fulldayevent)) { print dol_print_date($object->datep, 'dayhour', 'tzuser'); } else { print dol_print_date($object->datep, 'day', 'tzuser'); @@ -1982,7 +1982,7 @@ if ($id > 0) { // Date end print ''.$langs->trans("DateActionEnd").''; - if (!$object->fulldayevent) { + if (empty($object->fulldayevent)) { print dol_print_date($object->datef, 'dayhour', 'tzuser'); } else { print dol_print_date($object->datef, 'day', 'tzuser'); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index e2adf06425f..8dd0d9febbe 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -549,7 +549,11 @@ class ActionComm extends CommonObject $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; $sql .= ($userownerid > 0 ? $userownerid : "null").", "; $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; - $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."', "; + $sql .= "'".$this->db->escape($this->label)."', "; + $sql .= "'".$this->db->escape($this->percentage)."', "; + $sql .= "'".$this->db->escape($this->priority)."', "; + $sql .= "'".$this->db->escape($this->fulldayevent)."', "; + $sql .= "'".$this->db->escape($this->location)."', "; $sql .= "'".$this->db->escape($this->transparency)."', "; $sql .= (!empty($this->fk_element) ? ((int) $this->fk_element) : "null").", "; $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 59c101c390d..c69d396cf26 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -194,11 +194,11 @@ if ($object->id > 0) { } // Full day event - print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; + print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent ? 1 : 0, 3).''; // Date start print ''.$langs->trans("DateActionStart").''; - if (!$object->fulldayevent) { + if (empty($object->fulldayevent)) { print dol_print_date($object->datep, 'dayhour', 'tzuser'); } else { print dol_print_date($object->datep, 'day', 'tzuser'); @@ -211,7 +211,7 @@ if ($object->id > 0) { // Date end print ''.$langs->trans("DateActionEnd").''; - if (!$object->fulldayevent) { + if (empty($object->fulldayevent)) { print dol_print_date($object->datef, 'dayhour', 'tzuser'); } else { print dol_print_date($object->datef, 'day', 'tzuser'); diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index 356b9ca6f51..1e3bb99c070 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -179,18 +179,11 @@ class modFicheinter extends DolibarrModules 'fd.rowid'=>'InterLineId', 'fd.date'=>"InterLineDate", 'fd.duree'=>"InterLineDuration", 'fd.description'=>"InterLineDesc" ); - //$this->export_TypeFields_array[$r]=array( - // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', - // 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text', - // 's.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text", - // 'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text", - // 'fd.total_ht'=>"Numeric" - //); $this->export_TypeFields_array[$r] = array( 's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.datec'=>"Date", - 'f.duree'=>"Duree", 'f.fk_statut'=>'Numeric', 'f.description'=>"Text", 'f.datee'=>"Date", 'f.dateo'=>"Date", 'f.fulldayevent'=>"Boolean", + 'f.duree'=>"Duree", 'f.fk_statut'=>'Numeric', 'f.description'=>"Text", 'f.datee'=>"Date", 'f.dateo'=>"Date", 'f.fulldayevent'=>"Text", 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>"Numeric", 'fd.date'=>"Date", 'fd.duree'=>"Duree", 'fd.description'=>"Text", 'fd.total_ht'=>"Numeric" ); diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 7e58c75d35f..d0ca6416390 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -119,7 +119,7 @@ if (empty($reshook)) { if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element == 'action' && $resource_type == 'dolresource' && intval($busy) == 1) { $eventDateStart = $objstat->datep; $eventDateEnd = $objstat->datef; - $isFullDayEvent = intval($objstat->fulldayevent); + $isFullDayEvent = $objstat->fulldayevent; if (empty($eventDateEnd)) { if ($isFullDayEvent) { $eventDateStartArr = dol_getdate($eventDateStart); @@ -194,7 +194,7 @@ if (empty($reshook)) { if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type == 'action' && $object->resource_type == 'dolresource' && intval($object->busy) == 1) { $eventDateStart = $object->objelement->datep; $eventDateEnd = $object->objelement->datef; - $isFullDayEvent = intval($objstat->fulldayevent); + $isFullDayEvent = $objstat->fulldayevent; if (empty($eventDateEnd)) { if ($isFullDayEvent) { $eventDateStartArr = dol_getdate($eventDateStart); @@ -376,11 +376,11 @@ if (!$ret) { } // Full day event - print ''.$langs->trans("EventOnFullDay").''.yn($act->fulldayevent, 3).''; + print ''.$langs->trans("EventOnFullDay").''.yn($act->fulldayevent ? 1 : 0, 3).''; // Date start print ''.$langs->trans("DateActionStart").''; - if (!$act->fulldayevent) { + if (empty($act->fulldayevent)) { print dol_print_date($act->datep, 'dayhour', 'tzuser'); } else { print dol_print_date($act->datep, 'day', 'tzuser'); @@ -393,7 +393,7 @@ if (!$ret) { // Date end print ''.$langs->trans("DateActionEnd").''; - if (!$act->fulldayevent) { + if (empty($act->fulldayevent)) { print dol_print_date($act->datef, 'dayhour', 'tzuser'); } else { print dol_print_date($act->datef, 'day', 'tzuser'); From 37fb02ee760cfff18c795ba468da1ba1c53f4684 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jan 2022 15:50:59 +0100 Subject: [PATCH 66/74] Fix #huntr76f3b405-9f5d-44b1-8434-b52b56ee395f --- htdocs/product/card.php | 24 ++++++++++++------------ htdocs/product/class/product.class.php | 11 +++++++++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 420203eedae..64c6b6817bd 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1870,40 +1870,40 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) { // Brut Weight print ''.$langs->trans("Weight").''; - print ' '; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); + print ' '; + print $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOSTISSET('weight_units') ? GETPOST('weight_units') : $object->weight_units, 0, 2); print ''; } if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length print ''.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").''; - print 'x'; - print 'x'; - print ' '; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->length_units, 0, 2); + print 'x'; + print 'x'; + print ' '; + print $formproduct->selectMeasuringUnits("size_units", "size", GETPOSTISSET('size_units') ? GETPOST('size_units') : $object->length_units, 0, 2); print ''; } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { // Brut Surface print ''.$langs->trans("Surface").''; - print ' '; - print $formproduct->selectMeasuringUnits("surface_units", "surface", $object->surface_units, 0, 2); + print ' '; + print $formproduct->selectMeasuringUnits("surface_units", "surface", GETPOSTISSET('surface_units') ? GETPOST('surface_units') : $object->surface_units, 0, 2); print ''; } if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) { // Brut Volume print ''.$langs->trans("Volume").''; - print ' '; - print $formproduct->selectMeasuringUnits("volume_units", "volume", $object->volume_units, 0, 2); + print ' '; + print $formproduct->selectMeasuringUnits("volume_units", "volume", GETPOSTISSET('volume_units') ? GETPOST('volume_units') : $object->volume_units, 0, 2); print ''; } if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) { // Net Measure print ''.$langs->trans("NetMeasure").''; - print ' '; - print $formproduct->selectMeasuringUnits("net_measure_units", "", $object->net_measure_units, 0, 0); + print ' '; + print $formproduct->selectMeasuringUnits("net_measure_units", "", GETPOSTISSET('net_measure_units') ? GETPOST('net_measure_units') : $object->net_measure_units, 0, 0); print ''; } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 98cff66bf1f..26bf4915d80 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -860,6 +860,8 @@ class Product extends CommonObject */ public function verify() { + global $langs; + $this->errors = array(); $result = 0; @@ -870,6 +872,15 @@ class Product extends CommonObject $result = -2; } + $arrayofnonnegativevalue = array('weight'=>'Weight', 'width'=>'Width', 'height'=>'Height', 'length'=>'Length', 'surface'=>'Surface', 'volume'=>'Volume'); + foreach ($arrayofnonnegativevalue as $key => $value) { + if (property_exists($this, $key) && $this->$key < 0) { + $langs->load("other"); + $this->errors[] = $langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv($value)); + $result = -4; + } + } + $rescode = $this->check_barcode($this->barcode, $this->barcode_type_code); if ($rescode) { if ($rescode == -1) { From 728df13238e47b32e13e7ad3713f04e44ad17580 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jan 2022 16:22:55 +0100 Subject: [PATCH 67/74] Optimize files loaded on login and passwordforgotten page --- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/core/tpl/passwordforgotten.tpl.php | 13 ++++++++++++- htdocs/main.inc.php | 15 ++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index d7e9bda13dd..93efffa687e 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -87,7 +87,7 @@ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $disablenofollow = 0; } -print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disablenofollow); +print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index d33533a3f97..97edcc1d3f2 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -60,7 +60,18 @@ $php_self = str_replace('action=validatenewpassword', '', $php_self); $titleofpage = $langs->trans('SendNewPassword'); -print top_htmlhead('', $titleofpage); +// Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second +$arrayofjs = array(); + +$disablenofollow = 1; +if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) { + $disablenofollow = 0; +} +if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $disablenofollow = 0; +} + +print top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 657b17434d7..4b5c851adf0 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1404,11 +1404,11 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0) * @param int $disablehead Disable head output * @param array $arrayofjs Array of complementary js files * @param array $arrayofcss Array of complementary css files - * @param int $disablejmobile Disable jmobile (No more used) + * @param int $disableforlogin Do not load heavy js and css for login pages * @param int $disablenofollow Disable no follow tag * @return void */ -function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $disablejmobile = 0, $disablenofollow = 0) +function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $disableforlogin = 0, $disablenofollow = 0) { global $db, $conf, $langs, $user, $mysoc, $hookmanager; @@ -1646,15 +1646,16 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } else { print ''."\n"; } - if (!defined('DISABLE_JQUERY_TABLEDND')) { - print ''."\n"; - } // jQuery jnotify if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY')) { print ''."\n"; } + // Table drag and drop lines + if (empty($disableforlogin) && !defined('DISABLE_JQUERY_TABLEDND')) { + print ''."\n"; + } // Chart - if ((empty($conf->global->MAIN_JS_GRAPH) || $conf->global->MAIN_JS_GRAPH == 'chart') && !defined('DISABLE_JS_GRAPH')) { + if (empty($disableforlogin) && (empty($conf->global->MAIN_JS_GRAPH) || $conf->global->MAIN_JS_GRAPH == 'chart') && !defined('DISABLE_JS_GRAPH')) { print ''."\n"; } @@ -1694,7 +1695,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr if (!$disablejs && !empty($conf->use_javascript_ajax)) { // CKEditor - if ((!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) || defined('FORCE_CKEDITOR')) { + if (empty($disableforlogin) && (!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) || defined('FORCE_CKEDITOR')) { print ''."\n"; $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/'; $jsckeditor = 'ckeditor.js'; From 16aa562a131fdab3e309db9895eb949fea5c3df1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jan 2022 16:42:15 +0100 Subject: [PATCH 68/74] Debug v15 --- htdocs/societe/consumption.php | 12 +++++++----- htdocs/theme/eldy/global.inc.php | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 596f9b6f3c6..fcb90df6c9b 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -79,8 +79,8 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $month = ''; } // Customer or supplier selected in drop box -$thirdTypeSelect = GETPOST("third_select_id"); -$type_element = GETPOST('type_element') ?GETPOST('type_element') : ''; +$thirdTypeSelect = GETPOST("third_select_id", 'az09'); +$type_element = GETPOST('type_element') ? GETPOST('type_element') : ''; // Load translation files required by the page $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); @@ -441,9 +441,9 @@ if ($sql_select) { print ''; print ''; print ''; - print ''; // date + print ''; // date print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 1, 0, 0, '', 'valignmiddle maxwidth75imp marginleftonly'); print ''; print ''; print ''; @@ -463,7 +463,7 @@ if ($sql_select) { // Titles with sort buttons print ''; print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); @@ -500,6 +500,8 @@ if ($sql_select) { print $documentstaticline->getLibStatut(5); } elseif ($type_element == 'invoice') { print $documentstatic->getLibStatut(5, $objp->paid); + } elseif ($type_element == 'supplier_invoice') { + print $documentstatic->getLibStatut(5, $objp->paid); } else { print $documentstatic->getLibStatut(5); } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index e347bf0395a..6b146b5b306 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -154,8 +154,9 @@ table.liste th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), table.liste td. max-width: 100px; text-overflow: ellipsis; } -.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 select[name=month], +.liste_titre select[name=year], .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], .liste_titre input[name=search_month_update], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end], @@ -166,6 +167,7 @@ table.liste th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), table.liste td. .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], +*/ select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth, input, input.flat, form.flat select, select, select.flat, .dataTables_length label select { border: none; From 23eda44ba7fb9becefc8ccd5f8d1cb68ec970d4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jan 2022 16:42:15 +0100 Subject: [PATCH 69/74] Debug v15 --- htdocs/societe/consumption.php | 12 +++++++----- htdocs/theme/eldy/global.inc.php | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 596f9b6f3c6..fcb90df6c9b 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -79,8 +79,8 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $month = ''; } // Customer or supplier selected in drop box -$thirdTypeSelect = GETPOST("third_select_id"); -$type_element = GETPOST('type_element') ?GETPOST('type_element') : ''; +$thirdTypeSelect = GETPOST("third_select_id", 'az09'); +$type_element = GETPOST('type_element') ? GETPOST('type_element') : ''; // Load translation files required by the page $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); @@ -441,9 +441,9 @@ if ($sql_select) { print ''; print ''; print ''; - print ''; // date + print ''; // date print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 1, 0, 0, '', 'valignmiddle maxwidth75imp marginleftonly'); print ''; print ''; print ''; @@ -463,7 +463,7 @@ if ($sql_select) { // Titles with sort buttons print ''; print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); @@ -500,6 +500,8 @@ if ($sql_select) { print $documentstaticline->getLibStatut(5); } elseif ($type_element == 'invoice') { print $documentstatic->getLibStatut(5, $objp->paid); + } elseif ($type_element == 'supplier_invoice') { + print $documentstatic->getLibStatut(5, $objp->paid); } else { print $documentstatic->getLibStatut(5); } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index bf1e9dc967e..8c315b7badf 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -154,8 +154,9 @@ table.liste th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), table.liste td. max-width: 100px; text-overflow: ellipsis; } -.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 select[name=month], +.liste_titre select[name=year], .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], .liste_titre input[name=search_month_update], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end], @@ -166,6 +167,7 @@ table.liste th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), table.liste td. .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], +*/ select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth, input, input.flat, form.flat select, select, select.flat, .dataTables_length label select { border: none; From 87f05067ca6bf53b0bd852aeafd9437908ccc708 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jan 2022 16:47:29 +0100 Subject: [PATCH 70/74] Fix rounding price --- htdocs/societe/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index fcb90df6c9b..3624f80187d 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -675,7 +675,7 @@ if ($sql_select) { print ''; print ''.$total_qty.''; print ''.price($total_ht).''; - print ''.price($total_ht / (empty($total_qty) ? 1 : $total_qty)).''; + print ''.price(price2num($total_ht / (empty($total_qty) ? 1 : $total_qty), 'MU')).''; print ""; print ''; From 5942bc57e666d2b659cad665230a4f454f83003c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jan 2022 01:03:07 +0100 Subject: [PATCH 71/74] Add DDOS protection --- dev/setup/apache/virtualhost | 145 +++++++++++++--------- htdocs/core/tpl/login.tpl.php | 7 +- htdocs/core/tpl/passwordforgotten.tpl.php | 6 + 3 files changed, 100 insertions(+), 58 deletions(-) diff --git a/dev/setup/apache/virtualhost b/dev/setup/apache/virtualhost index c3a2dff3e43..8c7682fe3d9 100644 --- a/dev/setup/apache/virtualhost +++ b/dev/setup/apache/virtualhost @@ -1,62 +1,93 @@ -#php_admin_value sendmail_path "/usr/sbin/sendmail -t -i" -#php_admin_value mail.force_extra_parameters "-f postmaster@mydomain.com" -php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f postmaster@mydomain.com" -php_admin_value open_basedir /tmp/:/home/../htdocs + #php_admin_value sendmail_path "/usr/sbin/sendmail -t -i" + #php_admin_value mail.force_extra_parameters "-f postmaster@mydomain.com" + php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f postmaster@mydomain.com" + php_admin_value open_basedir /tmp/:/home/.../htdocs:/home/.../dolibarr_documents: + + ServerName myvirtualalias + ServerAlias myvirtualalias + + UseCanonicalName On + + KeepAlive On + KeepAliveTimeout 5 + MaxKeepAliveRequests 20 + + AddDefaultCharset UTF-8 + + DocumentRoot "/home/.../htdocs" + + + AllowOverride None + Options -Indexes -MultiViews +FollowSymLinks -ExecCGI + Require all granted -ServerName myvirtualalias -ServerAlias myvirtualalias + # To restrict access by a HTTP basic auth + #AuthType Basic + #AuthName "Authenticate to backoffice" + #AuthUserFile /etc/apache2/.htpasswd + #require valid-user + + + # Leaving /public and /api, /dav, .well_known but also wrappers for document and viewimage accessible to everyone + + AuthType None + Require all granted + Satisfy any + + + AuthType None + Require all granted + Satisfy any + + + AuthType None + Require all granted + Satisfy any + + + AuthType None + Require all granted + Satisfy any + + + AuthType None + Require all granted + Satisfy any + -UseCanonicalName On - -AddDefaultCharset UTF-8 - -DocumentRoot "/home/.../htdocs" - - - AllowOverride None - Options -Indexes -MultiViews +FollowSymLinks -ExecCGI - Require all granted - - - - Deny from all - RemoveHandler .phtml .php .php3 .php4 .php5 .php6 .phps .cgi .exe .pl .asp .aspx .shtml .shtm .fcgi .fpl .jsp .htm .html .wml - AddType application/x-httpd-php-source .phtml .php .php3 .php4 .php5 .php6 .phps .cgi .exe .pl .asp .aspx .shtml .shtm .fcgi .fpl .jsp .htm .html .wml - - - -ErrorLog /var/log/apache2/myvirtualalias_error_log -TransferLog /var/log/apache2/myvirtualalias_access_log - -# Compress returned resources of type php pages, text file export, css and javascript -AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript - -AddType text/javascript .jgz -AddEncoding gzip .jgz -ExpiresActive On -ExpiresByType image/x-icon A2592000 -ExpiresByType image/gif A2592000 -ExpiresByType image/png A2592000 -ExpiresByType image/jpeg A2592000 -ExpiresByType text/css A2592000 -ExpiresByType text/javascript A2592000 -ExpiresByType application/x-javascript A2592000 -ExpiresByType application/javascript A2592000 - -SSLEngine On - -# A self-signed (snakeoil) certificate can be created by installing -# the ssl-cert package. See -# /usr/share/doc/apache2.2-common/README.Debian.gz for more info. -# If both key and certificate are stored in the same file, only the -# SSLCertificateFile directive is needed. -SSLCertificateFile /etc/letsencrypt/live/www.mydomain.com/cert.pem -SSLCertificateKeyFile /etc/letsencrypt/live/www.mydomain.com/privkey.pem -SSLCertificateChainFile /etc/letsencrypt/live/www.mydomain.com/chain.pem - -#RewriteEngine on -#RewriteCond %{SERVER_PORT} ^80$ -#RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R] + + ErrorLog /var/log/apache2/myvirtualalias_error_log + TransferLog /var/log/apache2/myvirtualalias_access_log + + # Compress returned resources of type php pages, text file export, css and javascript + AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript + + AddType text/javascript .jgz + AddEncoding gzip .jgz + ExpiresActive On + ExpiresByType image/x-icon A2592000 + ExpiresByType image/gif A2592000 + ExpiresByType image/png A2592000 + ExpiresByType image/jpeg A2592000 + ExpiresByType text/css A2592000 + ExpiresByType text/javascript A2592000 + ExpiresByType application/x-javascript A2592000 + ExpiresByType application/javascript A2592000 + + SSLEngine On + + # A self-signed (snakeoil) certificate can be created by installing + # the ssl-cert package. See + # /usr/share/doc/apache2.2-common/README.Debian.gz for more info. + # If both key and certificate are stored in the same file, only the + # SSLCertificateFile directive is needed. + SSLCertificateFile /etc/letsencrypt/live/www.mydomain.com/cert.pem + SSLCertificateKeyFile /etc/letsencrypt/live/www.mydomain.com/privkey.pem + SSLCertificateChainFile /etc/letsencrypt/live/www.mydomain.com/chain.pem + + #RewriteEngine on + #RewriteCond %{SERVER_PORT} ^80$ + #RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R] diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 93efffa687e..88c1428e8f9 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -30,11 +30,16 @@ if (empty($conf) || !is_object($conf)) { exit; } +// DDOS protection +$size = (int) $_SERVER['CONTENT_LENGTH']; +if ($size > 10000) { + http_response_code(413); + exit; +} require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - header('Cache-Control: Public, must-revalidate'); header("Content-type: text/html; charset=".$conf->file->character_set_client); diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 97edcc1d3f2..b61ef22739a 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -27,6 +27,12 @@ if (empty($conf) || !is_object($conf)) { exit; } +// DDOS protection +$size = (int) $_SERVER['CONTENT_LENGTH']; +if ($size > 10000) { + http_response_code(413); + exit; +} require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; From 9e86e5ce93f35a358df79046882ebf2234640c85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jan 2022 01:43:53 +0100 Subject: [PATCH 72/74] Fix creation of page --- htdocs/core/class/html.form.class.php | 50 +++++++-------- htdocs/website/index.php | 87 ++++++++++++++++----------- 2 files changed, 77 insertions(+), 60 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 88fca7b536a..5142bf00d4c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7993,6 +7993,31 @@ class Form } } + // Try also magic suggest + $out .= ''."\n"; - if (is_array($array) && !empty($array)) { - if ($value_as_key) { - $array = array_combine($array, $array); - } - - if (!empty($array)) { - foreach ($array as $key => $value) { - $newval = ($translate ? $langs->trans($value) : $value); - $newval = ($key_in_label ? $key.' - '.$newval : $newval); - - $out .= '