From 1ccf209c47f711694739d9a68e206040a957c014 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 15 Apr 2022 14:31:44 +0200 Subject: [PATCH 01/45] Close #20653 : edit discount pourcentage --- htdocs/comm/propal/card.php | 9 ++++++++- htdocs/commande/card.php | 7 +++++++ htdocs/compta/facture/card.php | 7 +++++++ htdocs/core/tpl/objectline_title.tpl.php | 19 ++++++++++++++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f6989d90d59..7e653914d08 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -831,7 +831,14 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - } elseif ($action == 'addline' && $usercancreate) { // Add line + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { + // Define vat_rate + $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); + $remise_percent = str_replace('*', '', $remise_percent); + foreach ($object->lines as $line) { + $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + } + }elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 53b6d40d6b0..c4c5905ba0c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -628,6 +628,13 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { + // Define remise_percent + $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); + $remise_percent = str_replace('*', '', $remise_percent); + foreach ($object->lines as $line) { + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + } } elseif ($action == 'addline' && $usercancreate) { // Add a new line $langs->load('errors'); $error = 0; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 10a9429fbe2..ad57b610364 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1976,6 +1976,13 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice); } + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { + // Define vat_rate + $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); + $remise_percent = str_replace('*', '', $remise_percent); + foreach ($object->lines as $line) { + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice); + } } elseif ($action == 'addline' && $usercancreate) { // Add a new line $langs->load('errors'); $error = 0; diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index e8dbec2ac77..f4f962db554 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -105,7 +105,24 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { } // Reduction short -print ''.$langs->trans('ReductionShort').''; +print ''; +print $langs->trans('ReductionShort'); + +if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) { + global $mysoc; + + if (empty($disableedit)) { + print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').''; + } + //print ''; + if (GETPOST('mode', 'aZ09') == 'remiseforalllines') { + print '
'; + print ' %'; + print ''; + print '
'; + } +} +print ''; // Fields for situation invoice if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { From a77ae1ecd95955839010f1875782fb6a8a285b54 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 15 Apr 2022 14:31:59 +0200 Subject: [PATCH 02/45] fix style errors --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 7e653914d08..84078a4f38d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -838,7 +838,7 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - }elseif ($action == 'addline' && $usercancreate) { // Add line + } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); From c23ed7c47b016d386f8df3c456371d4baebaa2a7 Mon Sep 17 00:00:00 2001 From: melina Date: Wed, 20 Apr 2022 14:47:36 +0200 Subject: [PATCH 03/45] Add hooks completeJSProductDisplay --- htdocs/takepos/index.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index b23907b64f1..d64c497d05f 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -360,7 +360,13 @@ function LoadProducts(position, issubcat) { $("#prodiv"+ishow).data("iscat", 0); $("#prodiv"+ishow).attr("class","wrapper2"); $("#prowatermark"+ishow).hide(); - ishow++; //Next product to show after print data product + executeHooks('completeJSProductDisplay', $parameters); + print $hookmanager->resPrint; + ?> } //console.log("Hide the prowatermark for ishow="+ishow); idata++; //Next data everytime @@ -615,6 +621,13 @@ function Search2(keyCodeForEnter) { } $("#prodiv" + i).data("rowid", data[i]['rowid']); $("#prodiv" + i).data("iscat", 0); + executeHooks('completeJSProductDisplay', $parameters); + print $hookmanager->resPrint; + ?> } }).always(function (data) { // If there is only 1 answer From 2992b3e84580c400b9afb401a1c9bb3f4f9253de Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 22 Apr 2022 09:24:23 +0200 Subject: [PATCH 04/45] NEW send last document in mass mailing action --- htdocs/core/actions_massactions.inc.php | 46 ++++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5ec011f5017..171383d7008 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -306,29 +306,51 @@ if (!$error && $massaction == 'confirm_presend') { // TODO Set subdir to be compatible with multi levels dir trees // $subdir = get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element) $filedir = $uploaddir.'/'.$subdir.dol_sanitizeFileName($objectobj->ref); - $file = $filedir.'/'.$filename; + $filepath = $filedir.'/'.$filename; // For supplier invoices, we use the file provided by supplier, not the one we generate if ($objectobj->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($uploaddir.'/'.get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+'); - $file = $fileparams['fullname']; + $filepath = $fileparams['fullname']; } - $mime = dol_mimetype($file); + // try to find other files generated for this object (last_main_doc) + $filename_found = ''; + $filepath_found = ''; + $file_check_list = array(); + $file_check_list[] = array( + 'name' => $filename, + 'path' => $filepath, + ); + if (!empty($objectobj->last_main_doc)) { + $file_check_list[] = array( + 'name' => basename($objectobj->last_main_doc), + 'path' => DOL_DATA_ROOT . '/' . $objectobj->last_main_doc, + ); + } + foreach ($file_check_list as $file_check_arr) { + if (dol_is_file($file_check_arr['path'])) { + $filename_found = $file_check_arr['name']; + $filepath_found = $file_check_arr['path']; + break; + } + } - if (dol_is_file($file)) { + if ($filepath_found) { // Create form object $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array( - 'paths'=>array($file), - 'names'=>array($filename), - 'mimes'=>array($mime) + 'paths'=>array($filepath_found), + 'names'=>array($filename_found), + 'mimes'=>array(dol_mimetype($filepath_found)) ); } else { - $nbignored++; - $langs->load("errors"); - $resaction .= '
'.$langs->trans('ErrorCantReadFile', $file).'

'; - dol_syslog('Failed to read file: '.$file, LOG_WARNING); - continue; + $nbignored++; + $langs->load("errors"); + foreach ($file_check_list as $file_check_arr) { + $resaction .= '
'.$langs->trans('ErrorCantReadFile', $file_check_arr['path']).'

'; + dol_syslog('Failed to read file: '.$file_check_arr['path'], LOG_WARNING); + } + continue; } } From be2502c29f2d69db2dea3972c58e1ae4a889afdd Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 28 Apr 2022 10:50:55 +0200 Subject: [PATCH 05/45] New : module webhook database structure --- .../mysql/tables/llx_webhook_target.key.sql | 27 ++++++++++++++ .../mysql/tables/llx_webhook_target.sql | 36 +++++++++++++++++++ .../llx_webhook_target_extrafields.key.sql | 19 ++++++++++ .../tables/llx_webhook_target_extrafields.sql | 23 ++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_webhook_target.key.sql create mode 100644 htdocs/install/mysql/tables/llx_webhook_target.sql create mode 100644 htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql diff --git a/htdocs/install/mysql/tables/llx_webhook_target.key.sql b/htdocs/install/mysql/tables/llx_webhook_target.key.sql new file mode 100644 index 00000000000..04a0dbb306a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target.key.sql @@ -0,0 +1,27 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_rowid (rowid); +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_ref (ref); +ALTER TABLE llx_webhook_target ADD CONSTRAINT llx_webhook_target_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_status (status); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_webhook_target ADD UNIQUE INDEX uk_webhook_target_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_webhook_target ADD CONSTRAINT llx_webhook_target_fk_field FOREIGN KEY (fk_field) REFERENCES llx_webhook_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_webhook_target.sql b/htdocs/install/mysql/tables/llx_webhook_target.sql new file mode 100644 index 00000000000..f9a6b61d489 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target.sql @@ -0,0 +1,36 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 https://www.gnu.org/licenses/. + + +CREATE TABLE llx_webhook_target( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + label varchar(255), + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + last_main_doc varchar(255), + import_key varchar(14), + model_pdf varchar(255), + status integer NOT NULL, + url varchar(255) NOT NULL, + trigger_codes text NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql new file mode 100644 index 00000000000..c8ebcf12bdc --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql @@ -0,0 +1,19 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_webhook_target_extrafields ADD INDEX idx_target_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql new file mode 100644 index 00000000000..0af3a1fadda --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 https://www.gnu.org/licenses/. + +create table llx_webhook_target_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + From 701960bd70654bf643d07d5c53f829cb175e6d85 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 28 Apr 2022 11:47:13 +0200 Subject: [PATCH 06/45] try to fix build fail --- htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql index 0af3a1fadda..a01ac0e1d1c 100644 --- a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql @@ -16,7 +16,7 @@ create table llx_webhook_target_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, fk_object integer NOT NULL, import_key varchar(14) -- import key ) ENGINE=innodb; From b7106b1731c3acc344ec8b60ab9586a18e26982e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 May 2022 22:22:46 +0200 Subject: [PATCH 07/45] Fix lang --- htdocs/langs/en_US/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index aa92a74eb4e..dcc714776bf 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2249,3 +2249,4 @@ ExportUseLowMemoryMode=Use a low memory mode ExportUseLowMemoryModeHelp=Use the low memory mode to execute the exec of the dump (compression is done through a pipe instead of into the PHP memory). This method does not allow to check that file is completed and error message can't be reported if it fails. ShowQuickAddLink=Show a button to quickly add an element in top right menu HashForPing=Hash used for ping +ReadOnlyMode=Is instance in "Read Only" mode From 7063b7cdb84eb4b6400f6bd0910239a7013938c0 Mon Sep 17 00:00:00 2001 From: melina Date: Mon, 2 May 2022 08:37:37 +0200 Subject: [PATCH 08/45] fix missing line in PR --- htdocs/takepos/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index d64c497d05f..62544c63ca4 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -360,6 +360,7 @@ function LoadProducts(position, issubcat) { $("#prodiv"+ishow).data("iscat", 0); $("#prodiv"+ishow).attr("class","wrapper2"); $("#prowatermark"+ishow).hide(); + ishow++; //Next product to show after print data product Date: Mon, 2 May 2022 10:41:59 +0200 Subject: [PATCH 09/45] fix database files --- ...sql => llx_webhook_target-webhook.key.sql} | 0 ...get.sql => llx_webhook_target-webhook.sql} | 0 .../llx_webhook_target_extrafields.key.sql | 19 --------------- .../tables/llx_webhook_target_extrafields.sql | 23 ------------------- 4 files changed, 42 deletions(-) rename htdocs/install/mysql/tables/{llx_webhook_target.key.sql => llx_webhook_target-webhook.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_webhook_target.sql => llx_webhook_target-webhook.sql} (100%) delete mode 100644 htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql delete mode 100644 htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql diff --git a/htdocs/install/mysql/tables/llx_webhook_target.key.sql b/htdocs/install/mysql/tables/llx_webhook_target-webhook.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_webhook_target.key.sql rename to htdocs/install/mysql/tables/llx_webhook_target-webhook.key.sql diff --git a/htdocs/install/mysql/tables/llx_webhook_target.sql b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_webhook_target.sql rename to htdocs/install/mysql/tables/llx_webhook_target-webhook.sql diff --git a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql deleted file mode 100644 index c8ebcf12bdc..00000000000 --- a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.key.sql +++ /dev/null @@ -1,19 +0,0 @@ --- Copyright (C) ---Put here your own copyright and developer email--- --- --- 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 https://www.gnu.org/licenses/. - - --- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_webhook_target_extrafields ADD INDEX idx_target_fk_object(fk_object); --- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql b/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql deleted file mode 100644 index a01ac0e1d1c..00000000000 --- a/htdocs/install/mysql/tables/llx_webhook_target_extrafields.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Copyright (C) ---Put here your own copyright and developer email--- --- --- 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 https://www.gnu.org/licenses/. - -create table llx_webhook_target_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) -- import key -) ENGINE=innodb; - From bcc645ce3873fc3f4b7581154a0c5a99f6f7f443 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 2 May 2022 10:50:48 +0200 Subject: [PATCH 10/45] NEW const MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND for mailing mass action --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 171383d7008..e8ee88eedc3 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -322,7 +322,7 @@ if (!$error && $massaction == 'confirm_presend') { 'name' => $filename, 'path' => $filepath, ); - if (!empty($objectobj->last_main_doc)) { + if (!empty($conf->global->MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND) && !empty($objectobj->last_main_doc)) { $file_check_list[] = array( 'name' => basename($objectobj->last_main_doc), 'path' => DOL_DATA_ROOT . '/' . $objectobj->last_main_doc, From 0a48c09a7452538337a6e9318663705f79920619 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 2 May 2022 11:35:12 +0200 Subject: [PATCH 11/45] NEW last generated doc if main not found for mailing mass action --- htdocs/core/class/html.formmail.class.php | 6 +++++- htdocs/langs/en_US/main.lang | 3 ++- htdocs/langs/fr_FR/main.lang | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 0c9a1b2531a..5998822a704 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -781,7 +781,11 @@ class FormMail extends Form } elseif ($this->withmaindocfile == -1) { $out .= ''; } - $out .= '
'; + if (!empty($conf->global->MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND)) { + $out .= '
'; + } else { + $out .= '
'; + } } if (is_numeric($this->withfile)) { diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b39124c7c53..530f3b6af0e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -621,6 +621,7 @@ MonthVeryShort11=N MonthVeryShort12=D AttachedFiles=Attached files and documents JoinMainDoc=Join main document +JoinMainDocOrLastGenerated=Send the main document or the last generated one if not found DateFormatYYYYMM=YYYY-MM DateFormatYYYYMMDD=YYYY-MM-DD DateFormatYYYYMMDDHHMM=YYYY-MM-DD HH:SS @@ -1172,4 +1173,4 @@ AddLineOnPosition=Add line on position (at the end if empty) ConfirmAllocateCommercial=Assign sales representative confirmation ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)? CommercialsAffected=Sales representatives affected -CommercialAffected=Sales representative affected \ No newline at end of file +CommercialAffected=Sales representative affected diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 12778f337dd..53ff7d545b3 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -620,6 +620,7 @@ MonthVeryShort11=N MonthVeryShort12=D AttachedFiles=Fichiers et documents joints JoinMainDoc=Joindre le document principal +JoinMainDocOrLastGenerated=Joindre le document principal ou le dernier généré s'il n'a pas été trouvé DateFormatYYYYMM=YYYY-MM DateFormatYYYYMMDD=YYYY-MM-DD DateFormatYYYYMMDDHHMM=YYYY-MM-DD HH:SS From f4f8b67d10a486bb00b7693c99754403bea4920c Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Mon, 2 May 2022 12:57:13 +0200 Subject: [PATCH 12/45] Using deprecated $tmpinvoice->fk_soc Use of deprecated $tmpinvoice->fk_soc instead of using $tmpinvoice->socid --- htdocs/compta/facture/class/facture.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2134570ee2e..0403c07d427 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5209,11 +5209,11 @@ class Facture extends CommonInvoice if (!empty($recipient->email)) { $to = $recipient->email; } else { - $errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->fk_soc.". No email defined for user."; + $errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for user."; $error++; } } else { - $errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->fk_soc; + $errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->socid; $error++; } From 4ea45ac05a59d4e94bbaee8a78e193351453fa8e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 2 May 2022 15:13:42 +0200 Subject: [PATCH 13/45] fix table fields --- htdocs/install/mysql/tables/llx_webhook_target-webhook.sql | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql index f9a6b61d489..6d2cd4a771c 100644 --- a/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql +++ b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql @@ -17,7 +17,7 @@ CREATE TABLE llx_webhook_target( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - ref varchar(128) DEFAULT '(PROV)' NOT NULL, + ref varchar(128) NOT NULL, label varchar(255), description text, note_public text, @@ -26,9 +26,7 @@ CREATE TABLE llx_webhook_target( tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, fk_user_creat integer NOT NULL, fk_user_modif integer, - last_main_doc varchar(255), - import_key varchar(14), - model_pdf varchar(255), + import_key varchar(14), status integer NOT NULL, url varchar(255) NOT NULL, trigger_codes text NOT NULL From 19143d70030329ace5bfef5ec4e51622a221b346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 2 May 2022 15:31:21 +0200 Subject: [PATCH 14/45] default value is second parameter of getDolGlobalString --- htdocs/public/ticket/create_ticket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index dff6a0b2484..371789edc62 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -264,7 +264,7 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) { $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl').'

'; $message .= $infos_new_ticket; - $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE') ? getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE') : $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name); + $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name)); $sendto = GETPOST('email', 'alpha'); From 9f8a9db39eaf4b5addfc4932bd8954859870a84f Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 2 May 2022 15:55:32 +0200 Subject: [PATCH 15/45] NEW field required on mandatory fields --- htdocs/core/lib/functions.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5eef1b43bec..28ec44e5f83 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8990,6 +8990,9 @@ function printCommonFooter($zone = 'private') print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'-1\']").prop(\'value\', \'\');'."\n"; print 'jQuery("select[name=\''.$paramkey.'\'] option[value=\'0\']").prop(\'value\', \'\');'."\n"; + + // Add 'field required' class on closest td for all input elements : input, textarea and select + print 'jQuery(":input[name=\'' . $paramkey . '\']").closest("tr").find("td:first").addClass("fieldrequired");' . "\n"; } } } From 5dfd38c8f9d7c01f02fd7ca0771d055c4c7befce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 May 2022 16:47:28 +0200 Subject: [PATCH 16/45] Clean code for top menu --- htdocs/core/menus/standard/auguria.lib.php | 29 ++++++++++++------- htdocs/core/menus/standard/eldy.lib.php | 17 +++++++---- htdocs/core/menus/standard/empty.php | 27 ++++++++++++----- htdocs/public/recruitment/index.php | 2 +- htdocs/public/recruitment/view.php | 2 +- .../recruitmentjobposition_list.php | 5 ++-- htdocs/theme/eldy/global.inc.php | 16 ++++++++-- htdocs/theme/md/dropdown.inc.php | 2 +- 8 files changed, 69 insertions(+), 31 deletions(-) diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 6b415aec7a2..87a68f081b4 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -231,22 +231,31 @@ function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $cla { global $langs; + $classnameimg = str_replace('class="', 'class="tmenuimage ', $classname); + $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname); + if ($showmode == 1) { - print ''; + print ''; print '
'; print '
'; - print ''; - print ''; - print $text; - print ''; - print ''; + if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { + print ''; + print ''; + print $text; + print ''; + print ''; + } } elseif ($showmode == 2) { + print ''; print '
'; - print ''; - print ''; - print $text; print ''; - print ''; + if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { + print ''; + print ''; + print $text; + print ''; + print ''; + } } } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7d7317979cd..9d84faca7b2 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -626,26 +626,31 @@ function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, { global $conf, $langs; + $classnameimg = str_replace('class="', 'class="tmenuimage ', $classname); + $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname); + //$conf->global->THEME_TOPMENU_DISABLE_TEXT=1; if ($showmode == 1) { - print ''; + print ''; print '
'; print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { - print ''; + print ''; print ''; print $text; print ''; print ''; } } elseif ($showmode == 2) { - print '
'; + print ''; + print '
'; + print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { - print ''; - print ''; + print ''; + print ''; print $text; print ''; - print ''; + print '
'; } } } diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 9a45a9b7fc2..48b94462130 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -513,19 +513,32 @@ function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $class { global $conf, $langs; + $classnameimg = str_replace('class="', 'class="tmenuimage ', $classname); + $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname); + if ($showmode == 1) { - print ''; + print ''; print '
'; print '
'; - print ''; - print ''; - print $text; - print ''; - print ''; + if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { + print ''; + print ''; + print $text; + print ''; + print ''; + } } if ($showmode == 2) { + print ''; print '
'; - print ''; + print '
'; + if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { + print ''; + print ''; + print $text; + print ''; + print ''; + } } } diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index 286b5af55ba..ce30306eb2f 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -199,7 +199,7 @@ if (is_array($results)) { $text .= '   -   '.$mysoc->name.''; $text .= '   -   '.dol_print_date($object->date_creation).''; $text .= ''."\n"; - $text .= '

'.$object->label.'

'."\n"; + $text .= '

'.$object->label.'

'."\n"; } print $text; diff --git a/htdocs/public/recruitment/view.php b/htdocs/public/recruitment/view.php index 955dbd4b586..97997830150 100644 --- a/htdocs/public/recruitment/view.php +++ b/htdocs/public/recruitment/view.php @@ -250,7 +250,7 @@ if (empty($text)) { $text .= '   -   '.$mysoc->name.''; $text .= '   -   '.dol_print_date($object->date_creation).''; $text .= ''."\n"; - $text .= '

'.$object->label.'


'."\n"; + $text .= '

'.$object->label.'


'."\n"; } print $text; diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 3bf5fb94073..395449649d5 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -125,11 +125,10 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { - reset($object->fields); // Reset is required to avoid key() to return null. - $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. + $sortfield = "t.ref"; } if (!$sortorder) { - $sortorder = "ASC"; + $sortorder = "DESC"; } // Initialize array of search criterias diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 5fc9ea92c5b..68bad918155 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2601,8 +2601,20 @@ a.tmenuimage:hover{ text-decoration: none; } - - +/* +.tmenulabel:not(.menuhider), .tmenulabel:not(.menuhider):before { + display: none; +} +.tmenuimage:not(.menuhider), .tmenuimage:not(.menuhider):before { + font-size: 1.5em; +} +.tmenudiv:hover .tmenulabel:not(.menuhider), .tmenudiv:hover .tmenulabel:not(.menuhider):before { + display: initial !important; +} +.tmenudiv:hover .tmenuimage:not(.menuhider), .tmenudiv:hover .tmenulabel:not(.menuhider):before { + font-size: 1.1em !important; +} +*/ /* Do not load menu img for other if hidden to save bandwidth */ diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php index 25cbbb28ea9..a95f8a0be34 100644 --- a/htdocs/theme/md/dropdown.inc.php +++ b/htdocs/theme/md/dropdown.inc.php @@ -201,7 +201,7 @@ button.dropdown-item.global-search-item { } div#topmenu-global-search-dropdown, div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown { - line-height: 46px; + line-height: global->THEME_TOPMENU_DISABLE_IMAGE) ? '46' : '35' ); ?>px; } a.top-menu-dropdown-link { padding: 8px; From 1dd8cfe559e15c6164bce4bd745a4a80c9304795 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 May 2022 20:10:42 +0200 Subject: [PATCH 17/45] NEW More mode for THEME_TOPMENU_DISABLE_IMAGE --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formother.class.php | 6 +- htdocs/core/menus/standard/auguria.lib.php | 12 +-- htdocs/core/menus/standard/eldy.lib.php | 12 +-- htdocs/core/menus/standard/empty.php | 16 ++-- htdocs/intracommreport/card.php | 6 +- htdocs/theme/eldy/dropdown.inc.php | 2 +- htdocs/theme/eldy/global.inc.php | 33 +++++++-- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/dropdown.inc.php | 2 +- htdocs/theme/md/style.css.php | 85 +--------------------- 11 files changed, 61 insertions(+), 117 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 10644578702..e8da753c2fe 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7417,7 +7417,7 @@ class Form // Bom:bom/class/bom.class.php:0:t.status=1:ref // Bom:bom/class/bom.class.php:0:(t.status:=:1):ref $InfoFieldList = explode(":", $objectdesc, 4); - $vartmp = $InfoFieldList[3]; + $vartmp = (empty($InfoFieldList[3]) ? '' : $InfoFieldList[3]); $reg = array(); if (preg_match('/^.*:(\w*)$/', $vartmp, $reg)) { $InfoFieldList[4] = $reg[1]; // take the sort field diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 1107c3b8d34..4e0d3da467e 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1083,12 +1083,14 @@ class FormOther * @param int $invert Invert * @param string $option Option * @param string $morecss More CSS + * @param bool $addjscombo Add js combo * @return string + * @deprecated */ - public function select_year($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp') + public function select_year($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp', $addjscombo = false) { // phpcs:enable - print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss); + print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss, $addjscombo); } /** diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 87a68f081b4..556ee3e609a 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -64,10 +64,10 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout // Show/Hide vertical menu. The hamburger icon for .menuhider action. if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $showmode = 1; - $classname = 'class="tmenu menuhider"'; + $classname = 'class="tmenu menuhider nohover"'; $idsel = 'menu'; - $menu->add('#', (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); + $menu->add('#', (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1 ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } $num = count($newTabMenu); @@ -236,7 +236,7 @@ function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $cla if ($showmode == 1) { print ''; - print '
'; + print '
'; print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { print ''; @@ -246,9 +246,9 @@ function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $cla print ''; } } elseif ($showmode == 2) { - print ''; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { print ''; print ''; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 9d84faca7b2..f81fc3ae482 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -64,10 +64,10 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Show/Hide vertical menu. The hamburger icon for .menuhider action. if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $showmode = 1; - $classname = 'class="tmenu menuhider"'; + $classname = 'class="tmenu menuhider nohover"'; $idsel = 'menu'; - $menu->add('#', (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); + $menu->add('#', (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1 ? '' : ''), 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } $menu_arr = array(); @@ -632,7 +632,7 @@ function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, //$conf->global->THEME_TOPMENU_DISABLE_TEXT=1; if ($showmode == 1) { print ''; - print '
'; + print '
'; print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { print ''; @@ -642,9 +642,9 @@ function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, print ''; } } elseif ($showmode == 2) { - print ''; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { print ''; print ''; diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 48b94462130..cc9db4cb769 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -102,7 +102,7 @@ class MenuManager // Show/Hide vertical menu if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $showmode = 1; - $classname = 'class="tmenu menuhider"'; + $classname = 'class="tmenu menuhider nohover"'; $idsel = 'menu'; $this->menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); @@ -517,8 +517,8 @@ function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $class $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname); if ($showmode == 1) { - print ''; - print '
'; + print '
'; + print '
'; print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { print ''; @@ -529,15 +529,15 @@ function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $class } } if ($showmode == 2) { - print ''; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { - print '
'; + print ''; print ''; print $text; print ''; - print ''; + print '
'; } } } diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index c769b89f9b8..7cc41646732 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -151,7 +151,7 @@ if ($action == 'create') { print ''; // Label - print ''; + print ''; // Declaration print ''; print ''; print ''; diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 6bd8ede6331..6ef8706f476 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -197,7 +197,7 @@ button.dropdown-item.global-search-item { } div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown, div#topmenu-quickadd-dropdown { - global->THEME_TOPMENU_DISABLE_IMAGE)) { ?> + line-height: 46px; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 68bad918155..d132a742899 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2587,8 +2587,7 @@ button.ui-button.ui-corner-all.ui-widget:focus { /* For mainmenu, we always load the img */ div.mainmenu.menu { - background-image: url(); - + } #mainmenutd_menu a.tmenuimage { display: unset; @@ -2601,20 +2600,40 @@ a.tmenuimage:hover{ text-decoration: none; } -/* + +/* To show text of top menu on hover only (THEME_TOPMENU_DISABLE_IMAGE == 2) */ + + .tmenulabel:not(.menuhider), .tmenulabel:not(.menuhider):before { display: none; } -.tmenuimage:not(.menuhider), .tmenuimage:not(.menuhider):before { - font-size: 1.5em; +a.tmenuimage:not(.menuhider), a.tmenuimage:not(.menuhider):before, +div.tmenuimage:not(.menuhider), div.tmenuimage:not(.menuhider):before, +span.tmenuimage:not(.menuhider), span.tmenuimage:not(.menuhider):before { + font-size: 1.3em; + margin-top: 10px !important; } + + .tmenudiv:hover .tmenulabel:not(.menuhider), .tmenudiv:hover .tmenulabel:not(.menuhider):before { display: initial !important; } -.tmenudiv:hover .tmenuimage:not(.menuhider), .tmenudiv:hover .tmenulabel:not(.menuhider):before { +.tmenudiv:hover .tmenuimage:not(.menuhider), .tmenudiv:hover .tmenuimage:not(.menuhider):before { font-size: 1.1em !important; + margin-top: 0px !important; } -*/ + + +li.tmenu:hover .tmenulabel:not(.menuhider), li.tmenu:hover .tmenulabel:not(.menuhider):before { + display: initial !important; +} +li.tmenu:hover .tmenuimage:not(.menuhider), li.tmenu:hover .tmenuimage:not(.menuhider):before { + font-size: 1.1em !important; + margin-top: 0px !important; +} + + + /* Do not load menu img for other if hidden to save bandwidth */ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index dc94669d54f..40a03a0db5b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -276,7 +276,7 @@ $heightmenu = 50; /* height of top menu, part with image */ $heightmenu2 = 49; /* height of top menu, part with login */ $disableimages = 0; $maxwidthloginblock = 180; -if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { +if (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1) { $disableimages = 1; $maxwidthloginblock = $maxwidthloginblock + 50; $minwidthtmenu = 0; } diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php index a95f8a0be34..4bf13e52384 100644 --- a/htdocs/theme/md/dropdown.inc.php +++ b/htdocs/theme/md/dropdown.inc.php @@ -201,7 +201,7 @@ button.dropdown-item.global-search-item { } div#topmenu-global-search-dropdown, div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown { - line-height: global->THEME_TOPMENU_DISABLE_IMAGE) ? '46' : '35' ); ?>px; + line-height: px; } a.top-menu-dropdown-link { padding: 8px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index d5619f362fb..0dbec9bc073 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2438,7 +2438,7 @@ $heightmenu = 48; /* height of top menu, part with image */ $heightmenu2 = 48; /* height of top menu, ârt with login */ $disableimages = 0; $maxwidthloginblock = 110; -if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { +if (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1) { $heightmenu = 30; $disableimages = 1; $maxwidthloginblock = 180; $minwidthtmenu = 0; } ?> @@ -2623,98 +2623,21 @@ a.tmenuimage:focus, .mainmenu.topmenuimage:focus { outline: none; } -/* Do not load menu img if hidden to save bandwidth */ - - - - div.mainmenu.home{ - background-image: url(); background-position-x: center; } -div.mainmenu.billing { - background-image: url(); -} - -div.mainmenu.accountancy { - background-image: url(); -} - -div.mainmenu.agenda { - background-image: url(); -} - -div.mainmenu.bank { - background-image: url(); -} - -div.mainmenu.cashdesk { - background-image: url(); -} - -div.mainmenu.takepos { - background-image: url(); -} - -div.mainmenu.companies { - background-image: url(); -} - -div.mainmenu.commercial { - background-image: url(); -} - -div.mainmenu.ecm { - background-image: url(); -} - -div.mainmenu.externalsite { - background-image: url(); -} - -div.mainmenu.ftp { - background-image: url(); -} - -div.mainmenu.hrm { - background-image: url(); -} - -div.mainmenu.members { - background-image: url(); -} - div.mainmenu.menu { - background-image: url(); top: 10px; left: 1px; } -div.mainmenu.products { - background-image: url(); -} -div.mainmenu.mrp { - background-image: url(); -} -div.mainmenu.project { - background-image: url(); -} - -div.mainmenu.ticket { - background-image: url(); -} - -div.mainmenu.tools { - background-image: url(); -} - -div.mainmenu.website { - background-image: url(); -} +/* Do not load menu img if hidden to save bandwidth */ + + 'name of class for div') From 6aa32e7c7074faf629644e0c123834c72584c6a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 May 2022 20:21:58 +0200 Subject: [PATCH 18/45] Retrograde intracommreport from experimental to dev --- htdocs/compta/index.php | 3 +-- htdocs/core/modules/modIntracommreport.class.php | 2 +- htdocs/intracommreport/card.php | 10 ++++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index c68a686d2bf..207f806dc74 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -527,9 +527,8 @@ if (!empty($conf->tax->enabled) && !empty($user->rights->tax->charges->lire)) { if ($i >= $max) { $othernb += 1; + $tot_ttc += $obj->amount; $i++; - $total_ht += $obj->total_ht; - $total_ttc += $obj->total_ttc; continue; } diff --git a/htdocs/core/modules/modIntracommreport.class.php b/htdocs/core/modules/modIntracommreport.class.php index 817c893934b..50758f90f0c 100644 --- a/htdocs/core/modules/modIntracommreport.class.php +++ b/htdocs/core/modules/modIntracommreport.class.php @@ -50,7 +50,7 @@ class modIntracommreport extends DolibarrModules $this->description = "Intracomm report management (Support for French DEB/DES format)"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version - $this->version = 'experimental'; + $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto = 'intracommreport'; diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index 7cc41646732..e801416d63d 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -23,7 +23,8 @@ */ -/** Terms +/** + * Terms * * DEB = Declaration d'Exchanges de Biens (FR) = Declaration of Exchange of Goods (EN) * DES = Déclaration Européenne de Services (FR) = European Declaration of Services (EN) @@ -32,7 +33,6 @@ * */ - require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php $langs->loadLangs(array("intracommreport")); +$id = GETPOST('id', 'int'); $action = GETPOST('action'); $exporttype = GETPOSTISSET('exporttype') ? GETPOST('exporttype', 'alphanohtml') : 'deb'; // DEB or DES $year = GETPOSTINT('year'); @@ -65,9 +66,13 @@ $formother = new FormOther($db); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('intracommcard', 'globalcard')); +$error = 0; + + /* * Actions */ + $parameters = array('id' => $id); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); @@ -132,6 +137,7 @@ if ($action == 'add' && $user->rights->intracommreport->write) { } } + /* * View */ From 0e429ef058132a28b0874a8f5525081a1c3c5506 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 May 2022 20:26:34 +0200 Subject: [PATCH 19/45] Look and feel v16 --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 10a9429fbe2..8ad3dfd22bc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3520,7 +3520,6 @@ if ($action == 'create') { } - print ''; if ($socid > 0) { @@ -3682,6 +3681,7 @@ if ($action == 'create') { print ''; print ''; print ''; } From 6656ccdb0fca929d74630b253add595d88a40959 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 May 2022 21:11:45 +0200 Subject: [PATCH 20/45] css --- htdocs/theme/eldy/dropdown.inc.php | 14 ++++++++++---- htdocs/theme/eldy/global.inc.php | 1 + htdocs/theme/md/dropdown.inc.php | 13 +++++++++---- htdocs/theme/md/style.css.php | 1 + 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 6ef8706f476..6ca9ad67b1f 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -236,26 +236,28 @@ a.top-menu-dropdown-link { clear: both; } -.dropdown-menu > .bookmark-footer{ +.dropdown-menu > .bookmark-footer { border-top: 1px solid #f0f0f0; background-color: #f9f9f9; padding: 10px; + text-align: start; } -.dropdown-menu > .user-body, .dropdown-body{ +.dropdown-menu > .user-body, .dropdown-body { padding: 15px; border-bottom: 1px solid #f4f4f4; border-top: 1px solid #dddddd; white-space: normal; } -.dropdown-menu > .bookmark-body, .dropdown-body{ +.dropdown-menu > .bookmark-body, .dropdown-body { overflow-y: auto; max-height: 60vh ; /* fallback for browsers without support for calc() */ max-height: calc(90vh - 110px) ; white-space: normal; } +#topmenu-quickadd-dropdown .dropdown-menu > .bookmark-body, #topmenu-quickadd-dropdown .dropdown-body, #topmenu-bookmark-dropdown .dropdown-menu > .bookmark-body, #topmenu-bookmark-dropdown .dropdown-body{ max-height: 60vh ; /* fallback for browsers without support for calc() */ max-height: calc(90vh - 200px) ; @@ -287,7 +289,7 @@ a.top-menu-dropdown-link { #topmenuloginmoreinfo-btn, #topmenulogincompanyinfo-btn { display: block; - text-align: right; + text-align: start; color:#666; cursor: pointer; } @@ -298,6 +300,10 @@ a.top-menu-dropdown-link { font-size: 0.95em; } +a.dropdown-item { + text-align: start; +} + .button-top-menu-dropdown { display: inline-block; padding: 6px 12px; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d132a742899..ff6fe3c4fb8 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1956,6 +1956,7 @@ div.blockvmenulogo object-fit: contain; width: inherit; height: inherit; + image-rendering: -webkit-optimize-contrast; } #mainmenutd_companylogo::after, #mainmenutd_menu::after { content: unset !important; diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php index 4bf13e52384..c56590d7bfa 100644 --- a/htdocs/theme/md/dropdown.inc.php +++ b/htdocs/theme/md/dropdown.inc.php @@ -26,12 +26,12 @@ button.dropdown-item.global-search-item { } div#topmenu-quickadd-dropdown { position: fixed; - right: 65px; + : 65px; top: 0px; } div#topmenu-bookmark-dropdown { position: fixed; - right: 20px; + : 20px; top: 0px; } @@ -221,7 +221,7 @@ a.top-menu-dropdown-link { } .dropdown-menu > .user-header{ - background: rgb(); + background: rgb(--colorbackhmenu1); } @@ -244,6 +244,7 @@ a.top-menu-dropdown-link { border-top: 1px solid #f0f0f0; background-color: #f9f9f9; padding: 10px; + text-align: start; } @@ -293,7 +294,7 @@ a.top-menu-dropdown-link { #topmenuloginmoreinfo-btn, #topmenulogincompanyinfo-btn { display: block; - text-align: right; + text-align: start; color:#666; cursor: pointer; } @@ -304,6 +305,10 @@ a.top-menu-dropdown-link { font-size: 0.95em; } +a.dropdown-item { + text-align: start; +} + .button-top-menu-dropdown { display: inline-block; padding: 6px 12px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 0dbec9bc073..60d7bae21cd 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3085,6 +3085,7 @@ div.blockvmenulogo object-fit: contain; width: inherit; height: inherit; + image-rendering: -webkit-optimize-contrast; } #mainmenutd_companylogo::after { content: unset; From ed6eeb353318c6b5cca004ad52b7521fc04ca399 Mon Sep 17 00:00:00 2001 From: melina Date: Tue, 3 May 2022 09:35:06 +0200 Subject: [PATCH 21/45] add hook doaction in takepos invoice --- htdocs/takepos/invoice.php | 1312 ++++++++++++++++++------------------ 1 file changed, 658 insertions(+), 654 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index de780d92a64..f5fb80f8735 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -49,6 +49,7 @@ if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +$hookmanager->initHooks(array('takeposinvoice')); global $mysoc; @@ -168,11 +169,6 @@ if ($invoice->socid > 0) { $soc->fetch(getDolGlobalString("$constforcompanyid")); } - -/* - * Actions - */ - // Change the currency of invoice if it was modified if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercurrency"])) { if ($invoice->multicurrency_code != $_SESSION["takeposcustomercurrency"]) { @@ -180,730 +176,738 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu } } +/* + * Actions + */ -// Action to record a payment on a TakePOS invoice -if ($action == 'valid' && $user->rights->facture->creer) { - $bankaccount = 0; - $error = 0; +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { - $bankaccount = GETPOST('accountid', 'int'); - } else { - if ($pay == 'LIQ') { - $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility - } elseif ($pay == "CHQ") { - $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility +if (empty($reshook)) { + // Action to record a payment on a TakePOS invoice + if ($action == 'valid' && $user->rights->facture->creer) { + $bankaccount = 0; + $error = 0; + + if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { + $bankaccount = GETPOST('accountid', 'int'); } else { - $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; - $bankaccount = $conf->global->$accountname; + if ($pay == 'LIQ') { + $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility + } elseif ($pay == "CHQ") { + $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility + } else { + $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; + $bankaccount = $conf->global->$accountname; + } } - } - if ($bankaccount <= 0 && $pay != "delayed") { - $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")); - $error++; - } + if ($bankaccount <= 0 && $pay != "delayed") { + $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")); + $error++; + } - $now = dol_now(); - $res = 0; + $now = dol_now(); + $res = 0; - $invoice = new Facture($db); - $invoice->fetch($placeid); + $invoice = new Facture($db); + $invoice->fetch($placeid); - if ($invoice->total_ttc < 0) { - $invoice->type = $invoice::TYPE_CREDIT_NOTE; + if ($invoice->total_ttc < 0) { + $invoice->type = $invoice::TYPE_CREDIT_NOTE; - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE"; - $sql .= " fk_soc = ".((int) $invoice->socid); - $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE; - $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; - $sql .= " ORDER BY rowid DESC"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE"; + $sql .= " fk_soc = ".((int) $invoice->socid); + $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE; + $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; + $sql .= " ORDER BY rowid DESC"; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - $fk_source = $obj->rowid; - if ($fk_source == null) { + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $fk_source = $obj->rowid; + if ($fk_source == null) { + fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); + } + } else { fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); } - } else { - fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); - } - $invoice->fk_facture_source = $fk_source; - $invoice->update($user); - } - - //$sav_FACTURE_ADDON = ''; - //if (!empty($conf->global->TAKEPOS_ADDON)) { - // $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; - // if ($conf->global->TAKEPOS_ADDON == "terminal") $conf->global->FACTURE_ADDON = $conf->global->{'TAKEPOS_ADDON'.$_SESSION["takeposterminal"]}; - // else $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; - //} - - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if ($error) { - dol_htmloutput_errors($errormsg, null, 1); - } elseif ($invoice->statut != Facture::STATUS_DRAFT) { - //If invoice is validated but it is not fully paid is not error and make the payment - if ($invoice->getRemainToPay() > 0) { - $res = 1; - } else { - dol_syslog("Sale already validated"); - dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); - } - } elseif (count($invoice->lines) == 0) { - $error++; - dol_syslog('Sale without lines'); - dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); - } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { - $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; - $conf->global->STOCK_CALCULATE_ON_BILL = 1; - - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); - $batch_rule = 0; - if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; - $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; - } - $res = $invoice->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); - - $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; - } else { - $res = $invoice->validate($user); - if ($res < 0) { - $error++; - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } - } - - // Restore save values - //if (!empty($sav_FACTURE_ADDON)) - //{ - // $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; - //} - - // Add the payment - if (!$error && $res >= 0) { - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay > 0) { - $payment = new Paiement($db); - $payment->datepaye = $now; - $payment->fk_account = $bankaccount; - $payment->amounts[$invoice->id] = $amountofpayment; - if ($pay == 'LIQ') { - $payment->pos_change = price2num(GETPOST('excess', 'alpha')); - } - - // If user has not used change control, add total invoice payment - // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay - if ($amountofpayment == 0 || $amountofpayment > $remaintopay) { - $payment->amounts[$invoice->id] = $remaintopay; - } - - $payment->paiementid = $paiementid; - $payment->num_payment = $invoice->ref; - - if ($pay != "delayed") { - $payment->create($user); - $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded - } + $invoice->fk_facture_source = $fk_source; + $invoice->update($user); } - if ($remaintopay == 0) { - dol_syslog("Invoice is paid, so we set it to status Paid"); - $result = $invoice->setPaid($user); - if ($result > 0) { - $invoice->paye = 1; - } - // set payment method - $invoice->setPaymentMethods($paiementid); - } else { - dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); - } - } else { - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } -} + //$sav_FACTURE_ADDON = ''; + //if (!empty($conf->global->TAKEPOS_ADDON)) { + // $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; + // if ($conf->global->TAKEPOS_ADDON == "terminal") $conf->global->FACTURE_ADDON = $conf->global->{'TAKEPOS_ADDON'.$_SESSION["takeposterminal"]}; + // else $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; + //} -if ($action == 'creditnote' && $user->rights->facture->creer) { - $creditnote = new Facture($db); - $creditnote->socid = $invoice->socid; - $creditnote->date = dol_now(); - $creditnote->module_source = 'takepos'; - $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; - $creditnote->type = Facture::TYPE_CREDIT_NOTE; - $creditnote->fk_facture_source = $placeid; - $creditnote->remise_absolue = $invoice->remise_absolue; - $creditnote->remise_percent = $invoice->remise_percent; - $creditnote->create($user); - - foreach ($invoice->lines as $line) { - // Extrafields - if (method_exists($line, 'fetch_optionals')) { - // load extrafields - $line->fetch_optionals(); - } - // Reset fk_parent_line for no child products and special product - if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { - $fk_parent_line = 0; - } - if ($invoice->type == Facture::TYPE_SITUATION) { - $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id - $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from - if (!empty($invoice->tab_previous_situation_invoice)) { - // search the last standard invoice in cycle and the possible credit note between this last and invoice - // TODO Move this out of loop of $invoice->lines - $tab_jumped_credit_notes = array(); - $lineIndex = count($invoice->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) { - if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { - $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id; - } - $lineIndex--; // go to previous invoice in cycle - } - } - - $maxPrevSituationPercent = 0; - foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { - if ($prevLine->id == $source_fk_prev_id) { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - - //$line->subprice = $line->subprice - $prevLine->subprice; - $line->total_ht = $line->total_ht - $prevLine->total_ht; - $line->total_tva = $line->total_tva - $prevLine->total_tva; - $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; - $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; - $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - - $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; - } - } - - // prorata - $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; - - //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - - // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) - $maxPrevSituationPercent = 0; - foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { - foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) { - if ($prevLine->fk_prev_id == $source_fk_prev_id) { - $maxPrevSituationPercent = $prevLine->situation_percent; - - $line->total_ht -= $prevLine->total_ht; - $line->total_tva -= $prevLine->total_tva; - $line->total_ttc -= $prevLine->total_ttc; - $line->total_localtax1 -= $prevLine->total_localtax1; - $line->total_localtax2 -= $prevLine->total_localtax2; - - $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; - } - } - } - - // prorata - $line->situation_percent += $maxPrevSituationPercent; - - //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - } - } - - $line->fk_facture = $creditnote->id; - $line->fk_parent_line = $fk_parent_line; - - $line->subprice = -$line->subprice; // invert price for object - $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here - $line->total_ht = -$line->total_ht; - $line->total_tva = -$line->total_tva; - $line->total_ttc = -$line->total_ttc; - $line->total_localtax1 = -$line->total_localtax1; - $line->total_localtax2 = -$line->total_localtax2; - - $line->multicurrency_subprice = -$line->multicurrency_subprice; - $line->multicurrency_total_ht = -$line->multicurrency_total_ht; - $line->multicurrency_total_tva = -$line->multicurrency_total_tva; - $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; - - $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked - - $creditnote->lines[] = $line; // insert new line in current object - - // Defined the new fk_parent_line - if ($result > 0 && $line->product_type == 9) { - $fk_parent_line = $result; - } - } - $creditnote->update_price(1); - - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { - $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; - $conf->global->STOCK_CALCULATE_ON_BILL = 1; - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); - $batch_rule = 0; - if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; - $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; - } - $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); - $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; - } else { - $res = $creditnote->validate($user); - } -} - -if ($action == 'history' || $action == 'creditnote') { - if ($action == 'creditnote') { - $placeid = $creditnote->id; - } else { - $placeid = (int) GETPOST('placeid', 'int'); - } - $invoice = new Facture($db); - $invoice->fetch($placeid); -} - -if (($action == "addline" || $action == "freezone") && $placeid == 0) { - $invoice->socid = getDolGlobalString("$constforcompanyid"); - $invoice->date = dol_now(); - $invoice->module_source = 'takepos'; - $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; - $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; - - if ($invoice->socid <= 0) { - $langs->load('errors'); - dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); - } else { - $placeid = $invoice->create($user); - if ($placeid < 0) { - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid); - $db->query($sql); - } -} - -if ($action == "addline") { - $prod = new Product($db); - $prod->fetch($idproduct); - - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - - $qty = GETPOSTISSET('qty') ? GETPOST('qty', 'int') : 1; - $price = $datapriceofproduct['pu_ht']; - $price_ttc = $datapriceofproduct['pu_ttc']; - //$price_min = $datapriceofproduct['price_min']; - $price_base_type = $datapriceofproduct['price_base_type']; - $tva_tx = $datapriceofproduct['tva_tx']; - $tva_npr = $datapriceofproduct['tva_npr']; - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - - if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $cat = new Categorie($db); - $categories = $cat->containing($idproduct, 'product'); - $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id'))); - if ($found !== false) { // If this product is a supplement - $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline"; - $resql = $db->query($sql); - $row = $db->fetch_array($resql); - if ($row[0] == null) { - $parent_line = $selectedline; + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if ($error) { + dol_htmloutput_errors($errormsg, null, 1); + } elseif ($invoice->statut != Facture::STATUS_DRAFT) { + //If invoice is validated but it is not fully paid is not error and make the payment + if ($invoice->getRemainToPay() > 0) { + $res = 1; } else { - $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product + dol_syslog("Sale already validated"); + dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); + } + } elseif (count($invoice->lines) == 0) { + $error++; + dol_syslog('Sale without lines'); + dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); + } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; + $conf->global->STOCK_CALCULATE_ON_BILL = 1; + + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); + $batch_rule = 0; + if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; + } + $res = $invoice->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); + + $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; + } else { + $res = $invoice->validate($user); + if ($res < 0) { + $error++; + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); } } - } - $idoflineadded = 0; - // Group if enabled. Skip group if line already sent to the printer - if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT) && $line->special_code != "4") { - foreach ($invoice->lines as $line) { - if ($line->product_ref == $prod->ref) { - if ($line->special_code==4) continue; // If this line is sended to printer create new line - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + $qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - if ($result < 0) { - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } else { - $idoflineadded = $line->id; + // Restore save values + //if (!empty($sav_FACTURE_ADDON)) + //{ + // $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; + //} + + // Add the payment + if (!$error && $res >= 0) { + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay > 0) { + $payment = new Paiement($db); + $payment->datepaye = $now; + $payment->fk_account = $bankaccount; + $payment->amounts[$invoice->id] = $amountofpayment; + if ($pay == 'LIQ') { + $payment->pos_change = price2num(GETPOST('excess', 'alpha')); } - break; + + // If user has not used change control, add total invoice payment + // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay + if ($amountofpayment == 0 || $amountofpayment > $remaintopay) { + $payment->amounts[$invoice->id] = $remaintopay; + } + + $payment->paiementid = $paiementid; + $payment->num_payment = $invoice->ref; + + if ($pay != "delayed") { + $payment->create($user); + $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); + $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded + } + } + + if ($remaintopay == 0) { + dol_syslog("Invoice is paid, so we set it to status Paid"); + $result = $invoice->setPaid($user); + if ($result > 0) { + $invoice->paye = 1; + } + // set payment method + $invoice->setPaymentMethods($paiementid); + } else { + dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); + } + } else { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } + } + + if ($action == 'creditnote' && $user->rights->facture->creer) { + $creditnote = new Facture($db); + $creditnote->socid = $invoice->socid; + $creditnote->date = dol_now(); + $creditnote->module_source = 'takepos'; + $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; + $creditnote->type = Facture::TYPE_CREDIT_NOTE; + $creditnote->fk_facture_source = $placeid; + $creditnote->remise_absolue = $invoice->remise_absolue; + $creditnote->remise_percent = $invoice->remise_percent; + $creditnote->create($user); + + foreach ($invoice->lines as $line) { + // Extrafields + if (method_exists($line, 'fetch_optionals')) { + // load extrafields + $line->fetch_optionals(); + } + // Reset fk_parent_line for no child products and special product + if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { + $fk_parent_line = 0; + } + if ($invoice->type == Facture::TYPE_SITUATION) { + $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id + $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from + if (!empty($invoice->tab_previous_situation_invoice)) { + // search the last standard invoice in cycle and the possible credit note between this last and invoice + // TODO Move this out of loop of $invoice->lines + $tab_jumped_credit_notes = array(); + $lineIndex = count($invoice->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) { + if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { + $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id; + } + $lineIndex--; // go to previous invoice in cycle + } + } + + $maxPrevSituationPercent = 0; + foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { + if ($prevLine->id == $source_fk_prev_id) { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + + //$line->subprice = $line->subprice - $prevLine->subprice; + $line->total_ht = $line->total_ht - $prevLine->total_ht; + $line->total_tva = $line->total_tva - $prevLine->total_tva; + $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; + $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; + $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; + + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; + } + } + + // prorata + $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; + + //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + + // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) + $maxPrevSituationPercent = 0; + foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { + foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) { + if ($prevLine->fk_prev_id == $source_fk_prev_id) { + $maxPrevSituationPercent = $prevLine->situation_percent; + + $line->total_ht -= $prevLine->total_ht; + $line->total_tva -= $prevLine->total_tva; + $line->total_ttc -= $prevLine->total_ttc; + $line->total_localtax1 -= $prevLine->total_localtax1; + $line->total_localtax2 -= $prevLine->total_localtax2; + + $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; + } + } + } + + // prorata + $line->situation_percent += $maxPrevSituationPercent; + + //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + } + } + + $line->fk_facture = $creditnote->id; + $line->fk_parent_line = $fk_parent_line; + + $line->subprice = -$line->subprice; // invert price for object + $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here + $line->total_ht = -$line->total_ht; + $line->total_tva = -$line->total_tva; + $line->total_ttc = -$line->total_ttc; + $line->total_localtax1 = -$line->total_localtax1; + $line->total_localtax2 = -$line->total_localtax2; + + $line->multicurrency_subprice = -$line->multicurrency_subprice; + $line->multicurrency_total_ht = -$line->multicurrency_total_ht; + $line->multicurrency_total_tva = -$line->multicurrency_total_tva; + $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; + + $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked + + $creditnote->lines[] = $line; // insert new line in current object + + // Defined the new fk_parent_line + if ($result > 0 && $line->product_type == 9) { + $fk_parent_line = $result; } } - } - if ($idoflineadded <= 0) { - $invoice->fetch_thirdparty(); - $idoflineadded = $invoice->addline($prod->description, $price, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', 0, 100, '', null, 0); - if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { - $CUSTOMER_DISPLAY_line1 = $prod->label; - $CUSTOMER_DISPLAY_line2 = price($price_ttc); + $creditnote->update_price(1); + + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; + $conf->global->STOCK_CALCULATE_ON_BILL = 1; + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); + $batch_rule = 0; + if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; + } + $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); + $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; + } else { + $res = $creditnote->validate($user); } } - $invoice->fetch($placeid); -} - -if ($action == "freezone") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - $tva_tx = GETPOST('tva_tx', 'alpha'); - if ($tva_tx != '') { - if (!preg_match('/\((.*)\)/', $tva_tx)) { - $tva_tx = price2num($tva_tx); + if ($action == 'history' || $action == 'creditnote') { + if ($action == 'creditnote') { + $placeid = $creditnote->id; + } else { + $placeid = (int) GETPOST('placeid', 'int'); } - } else { - $tva_tx = get_default_tva($mysoc, $customer); - } - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - - $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); - $invoice->fetch($placeid); -} - -if ($action == "addnote") { - $desc = GETPOST('addnote', 'alpha'); - if ($idline==0) { - $invoice->update_note($desc, '_public'); - } else foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - $result = $invoice->updateline($line->id, $desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - } - } - $invoice->fetch($placeid); -} - -if ($action == "deleteline") { - if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. - $invoice->deleteline($idline); - $invoice->fetch($placeid); - } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC"; - $resql = $db->query($sql); - $row = $db->fetch_array($resql); - $deletelineid = $row[0]; - $invoice->deleteline($deletelineid); + $invoice = new Facture($db); $invoice->fetch($placeid); } - if (count($invoice->lines) == 0) { - $invoice->delete($user); - header("Location: ".DOL_URL_ROOT."/takepos/invoice.php"); - exit; + + if (($action == "addline" || $action == "freezone") && $placeid == 0) { + $invoice->socid = getDolGlobalString("$constforcompanyid"); + $invoice->date = dol_now(); + $invoice->module_source = 'takepos'; + $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; + $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; + + if ($invoice->socid <= 0) { + $langs->load('errors'); + dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); + } else { + $placeid = $invoice->create($user); + if ($placeid < 0) { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid); + $db->query($sql); + } } -} -// Action to delete or discard an invoice -if ($action == "delete") { - // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works. - if ($placeid > 0) { - $result = $invoice->fetch($placeid); + if ($action == "addline") { + $prod = new Product($db); + $prod->fetch($idproduct); - if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) { - $db->begin(); + $customer = new Societe($db); + $customer->fetch($invoice->socid); - // We delete the lines - $resdeletelines = 1; + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); + + $qty = GETPOSTISSET('qty') ? GETPOST('qty', 'int') : 1; + $price = $datapriceofproduct['pu_ht']; + $price_ttc = $datapriceofproduct['pu_ttc']; + //$price_min = $datapriceofproduct['price_min']; + $price_base_type = $datapriceofproduct['price_base_type']; + $tva_tx = $datapriceofproduct['tva_tx']; + $tva_npr = $datapriceofproduct['tva_npr']; + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + + if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $cat = new Categorie($db); + $categories = $cat->containing($idproduct, 'product'); + $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id'))); + if ($found !== false) { // If this product is a supplement + $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline"; + $resql = $db->query($sql); + $row = $db->fetch_array($resql); + if ($row[0] == null) { + $parent_line = $selectedline; + } else { + $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product + } + } + } + + $idoflineadded = 0; + // Group if enabled. Skip group if line already sent to the printer + if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT) && $line->special_code != "4") { foreach ($invoice->lines as $line) { - $tmpres = $invoice->deleteline($line->id); - if ($tmpres < 0) { - $resdeletelines = 0; + if ($line->product_ref == $prod->ref) { + if ($line->special_code==4) continue; // If this line is sended to printer create new line + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + $qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if ($result < 0) { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } else { + $idoflineadded = $line->id; + } break; } } - - $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; - $sql .= " SET fk_soc = ".((int) $conf->global->$varforconst).", "; - $sql .= " datec = '".$db->idate(dol_now())."'"; - $sql .= " WHERE ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; - $resql1 = $db->query($sql); - - if ($resdeletelines && $resql1) { - $db->commit(); - } else { - $db->rollback(); + } + if ($idoflineadded <= 0) { + $invoice->fetch_thirdparty(); + $idoflineadded = $invoice->addline($prod->description, $price, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', 0, 100, '', null, 0); + if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { + $CUSTOMER_DISPLAY_line1 = $prod->label; + $CUSTOMER_DISPLAY_line2 = price($price_ttc); } + } + $invoice->fetch($placeid); + } + + if ($action == "freezone") { + $customer = new Societe($db); + $customer->fetch($invoice->socid); + + $tva_tx = GETPOST('tva_tx', 'alpha'); + if ($tva_tx != '') { + if (!preg_match('/\((.*)\)/', $tva_tx)) { + $tva_tx = price2num($tva_tx); + } + } else { + $tva_tx = get_default_tva($mysoc, $customer); + } + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + + $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + $invoice->fetch($placeid); + } + + if ($action == "addnote") { + $desc = GETPOST('addnote', 'alpha'); + if ($idline==0) { + $invoice->update_note($desc, '_public'); + } else foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + $result = $invoice->updateline($line->id, $desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + } + $invoice->fetch($placeid); + } + + if ($action == "deleteline") { + if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. + $invoice->deleteline($idline); + $invoice->fetch($placeid); + } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC"; + $resql = $db->query($sql); + $row = $db->fetch_array($resql); + $deletelineid = $row[0]; + $invoice->deleteline($deletelineid); $invoice->fetch($placeid); } + if (count($invoice->lines) == 0) { + $invoice->delete($user); + header("Location: ".DOL_URL_ROOT."/takepos/invoice.php"); + exit; + } } -} -if ($action == "updateqty") { - foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) { - dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); - } else { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + // Action to delete or discard an invoice + if ($action == "delete") { + // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works. + if ($placeid > 0) { + $result = $invoice->fetch($placeid); + + if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) { + $db->begin(); + + // We delete the lines + $resdeletelines = 1; + foreach ($invoice->lines as $line) { + $tmpres = $invoice->deleteline($line->id); + if ($tmpres < 0) { + $resdeletelines = 0; + break; + } + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; + $sql .= " SET fk_soc = ".((int) $conf->global->$varforconst).", "; + $sql .= " datec = '".$db->idate(dol_now())."'"; + $sql .= " WHERE ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; + $resql1 = $db->query($sql); + + if ($resdeletelines && $resql1) { + $db->commit(); + } else { + $db->rollback(); + } + + $invoice->fetch($placeid); } } } - $invoice->fetch($placeid); -} - -if ($action == "updateprice") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - $prod = new Product($db); - $prod->fetch($line->fk_product); - $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - $price_min = $datapriceofproduct['price_min']; - $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); - $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU'); - //Check min price - if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { - echo $langs->trans("CantBeLessThanMinPrice"); - } else { - if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { + if ($action == "updateqty") { + foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) { dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); - } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) { - $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } else { - $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } } + + $invoice->fetch($placeid); } - // Reload data - $invoice->fetch($placeid); -} + if ($action == "updateprice") { + $customer = new Societe($db); + $customer->fetch($invoice->socid); -if ($action == "updatereduction") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - dol_syslog("updatereduction Process line ".$line->id.' to apply discount of '.$number.'%'); - - $prod = new Product($db); - $prod->fetch($line->fk_product); - - $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - $price_min = $datapriceofproduct['price_min']; - $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); - - $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU'); - - // Check min price - if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) { - echo $langs->trans("CantBeLessThanMinPrice"); - } else { - if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { - dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + $prod = new Product($db); + $prod->fetch($line->fk_product); + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); + $price_min = $datapriceofproduct['price_min']; + $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); + $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU'); + //Check min price + if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { + echo $langs->trans("CantBeLessThanMinPrice"); } else { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { + dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) { + $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } else { + $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } } } } + + // Reload data + $invoice->fetch($placeid); } - // Reload data - $invoice->fetch($placeid); -} elseif ($action == 'update_reduction_global') { - foreach ($invoice->lines as $line) { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - } + if ($action == "updatereduction") { + $customer = new Societe($db); + $customer->fetch($invoice->socid); - $invoice->fetch($placeid); -} + foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + dol_syslog("updatereduction Process line ".$line->id.' to apply discount of '.$number.'%'); -if ($action == "order" and $placeid != 0) { - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { - require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; - $printer = new dolReceiptPrinter($db); - } + $prod = new Product($db); + $prod->fetch($line->fk_product); - $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); - $resql = $db->query($sql); - $row = $db->fetch_object($resql); - $headerorder = '
'.$langs->trans('Place').' '.$row->label.'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Declaration")."\n"; @@ -164,8 +164,8 @@ if ($action == 'create') { print $langs->trans("AnalysisPeriod"); print ''; - print $formother->select_month($month ? date('M') : $month, 'month', 0, 1, 'widthauto valignmiddle '); - print $formother->select_year($year ? date('Y') : $year, 'year', 0, 3, 3); + print $formother->select_month($month ? date('M') : $month, 'month', 0, 1, 'widthauto valignmiddle ', true); + print $formother->selectyear($year ? date('Y') : $year, 'year', 0, 3, 3, 0, 0, '', '', true); print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print img_picto('', 'currency', 'class="pictofixedwidth"'); print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print '
'; - $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; - $order_receipt_printer1 = ""; - $order_receipt_printer2 = ""; - $order_receipt_printer3 = ""; - $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); - $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); - $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); - $linestoprint = 0; - foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { - continue; + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); + $price_min = $datapriceofproduct['price_min']; + $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); + + $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU'); + + // Check min price + if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) { + echo $langs->trans("CantBeLessThanMinPrice"); + } else { + if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { + dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + } else { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + } + } } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter1, $existing); - $count = count($result); - if (!$line->fk_product) { - $count++; // Print Free-text item (Unassigned printer) to Printer 1 + + // Reload data + $invoice->fetch($placeid); + } elseif ($action == 'update_reduction_global') { + foreach ($invoice->lines as $line) { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 - $db->query($sql); - $order_receipt_printer1 .= ''; - if ($line->fk_product) { - $order_receipt_printer1 .= $line->product_label; + + $invoice->fetch($placeid); + } + + if ($action == "order" and $placeid != 0) { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { + require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; + $printer = new dolReceiptPrinter($db); + } + + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); + $resql = $db->query($sql); + $row = $db->fetch_object($resql); + $headerorder = '
'.$langs->trans('Place').' '.$row->label.'
'; + $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; + $order_receipt_printer1 = ""; + $order_receipt_printer2 = ""; + $order_receipt_printer3 = ""; + $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); + $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); + $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); + $linestoprint = 0; + foreach ($invoice->lines as $line) { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter1, $existing); + $count = count($result); + if (!$line->fk_product) { + $count++; // Print Free-text item (Unassigned printer) to Printer 1 + } + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 + $db->query($sql); + $order_receipt_printer1 .= ''; + if ($line->fk_product) { + $order_receipt_printer1 .= $line->product_label; + } else { + $order_receipt_printer1 .= $line->description; + } + $order_receipt_printer1 .= ''.$line->qty; + if (!empty($line->array_options['options_order_notes'])) { + $order_receipt_printer1 .= "
(".$line->array_options['options_order_notes'].")"; + } + $order_receipt_printer1 .= ''; + } + } + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 1; + echo ""; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed + $linestoprint = 0; + + foreach ($invoice->lines as $line) { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter2, $existing); + $count = count($result); + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 + $db->query($sql); + $order_receipt_printer2 .= ''.$line->product_label.''.$line->qty; + if (!empty($line->array_options['options_order_notes'])) { + $order_receipt_printer2 .= "
(".$line->array_options['options_order_notes'].")"; + } + $order_receipt_printer2 .= ''; + } + } + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 2; + echo ""; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed + $linestoprint = 0; + + foreach ($invoice->lines as $line) { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter3, $existing); + $count = count($result); + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3 + $db->query($sql); + $order_receipt_printer3 .= ''.$line->product_label.''.$line->qty; + if (!empty($line->array_options['options_order_notes'])) { + $order_receipt_printer3 .= "
(".$line->array_options['options_order_notes'].")"; + } + $order_receipt_printer3 .= ''; + } + } + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 3; + echo ""; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed + } + + $sectionwithinvoicelink = ''; + if ($action == "valid" || $action == "history" || $action == 'creditnote') { + $sectionwithinvoicelink .= ''."\n"; + $sectionwithinvoicelink .= ''; + $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay > 0) { + $sectionwithinvoicelink .= $langs->trans('RemainToPay').': '.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).''; + } else { + if ($invoice->paye) { + $sectionwithinvoicelink .= ''.$langs->trans("Paid").''; } else { - $order_receipt_printer1 .= $line->description; + $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); } - $order_receipt_printer1 .= ''.$line->qty; - if (!empty($line->array_options['options_order_notes'])) { - $order_receipt_printer1 .= "
(".$line->array_options['options_order_notes'].")"; + } + $sectionwithinvoicelink .= '

'; + if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { + if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { + $sectionwithinvoicelink .= ' '; + } else { + $sectionwithinvoicelink .= ' '; } - $order_receipt_printer1 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 1; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed - $linestoprint = 0; - - foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { - continue; - } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter2, $existing); - $count = count($result); - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 - $db->query($sql); - $order_receipt_printer2 .= ''.$line->product_label.''.$line->qty; - if (!empty($line->array_options['options_order_notes'])) { - $order_receipt_printer2 .= "
(".$line->array_options['options_order_notes'].")"; - } - $order_receipt_printer2 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 2; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed - $linestoprint = 0; - - foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { - continue; - } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter3, $existing); - $count = count($result); - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3 - $db->query($sql); - $order_receipt_printer3 .= ''.$line->product_label.''.$line->qty; - if (!empty($line->array_options['options_order_notes'])) { - $order_receipt_printer3 .= "
(".$line->array_options['options_order_notes'].")"; - } - $order_receipt_printer3 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 3; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed -} - -$sectionwithinvoicelink = ''; -if ($action == "valid" || $action == "history" || $action == 'creditnote') { - $sectionwithinvoicelink .= ''."\n"; - $sectionwithinvoicelink .= ''; - $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay > 0) { - $sectionwithinvoicelink .= $langs->trans('RemainToPay').': '.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).''; - } else { - if ($invoice->paye) { - $sectionwithinvoicelink .= ''.$langs->trans("Paid").''; + } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { + $sectionwithinvoicelink .= ' '; } else { - $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); + $sectionwithinvoicelink .= ' '; + if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) { + $sectionwithinvoicelink .= ' '; + } + if (getDolGlobalString('TAKEPOS_GIFT_RECEIPT')) { + $sectionwithinvoicelink .= ' '; + } } - } - $sectionwithinvoicelink .= '
'; - if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { - if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { - $sectionwithinvoicelink .= ' '; - } else { - $sectionwithinvoicelink .= ' '; + if (getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) { + $sectionwithinvoicelink .= ' '; } - } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { - $sectionwithinvoicelink .= ' '; - } else { - $sectionwithinvoicelink .= ' '; - if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) { - $sectionwithinvoicelink .= ' '; - } - if (getDolGlobalString('TAKEPOS_GIFT_RECEIPT')) { - $sectionwithinvoicelink .= ' '; - } - } - if (getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) { - $sectionwithinvoicelink .= ' '; - } - if ($remaintopay <= 0 && getDolGlobalString('TAKEPOS_AUTO_PRINT_TICKETS')) { - $sectionwithinvoicelink .= ''; + if ($remaintopay <= 0 && getDolGlobalString('TAKEPOS_AUTO_PRINT_TICKETS')) { + $sectionwithinvoicelink .= ''; + } } } - /* * View */ From ce56dc132c18ce76b36f8ae9f331865e59063707 Mon Sep 17 00:00:00 2001 From: melina Date: Tue, 3 May 2022 09:44:18 +0200 Subject: [PATCH 22/45] add missing class --- htdocs/takepos/invoice.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index f5fb80f8735..9c43214ce0b 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -49,6 +49,7 @@ if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager->initHooks(array('takeposinvoice')); global $mysoc; From 3c85577d91393efbf8bc1b028176d0e367077c1a Mon Sep 17 00:00:00 2001 From: melina Date: Tue, 3 May 2022 09:52:20 +0200 Subject: [PATCH 23/45] fix parameter oh hook --- 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 9c43214ce0b..3a55d82b8ad 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -182,7 +182,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu */ $parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { From b5f887b3e484f95de3c5ceb1f637e8690894092e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 May 2022 11:52:32 +0200 Subject: [PATCH 24/45] Fix DEBUGBAR_USE_LOG_FILE --- htdocs/debugbar/class/DataCollector/DolLogsCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php index dd6fabd508f..d74b0aa5275 100644 --- a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php @@ -72,7 +72,7 @@ class DolLogsCollector extends MessagesCollector { global $conf; - $uselogfile=$conf->global->DEBUGBAR_USE_LOGFILE; + $uselogfile=$conf->global->DEBUGBAR_USE_LOG_FILE; if ($uselogfile) { From affde5516901286ea9d100e2cb24ac0dd9831fbc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 May 2022 12:08:24 +0200 Subject: [PATCH 25/45] FIX deprecated module are not more viewed as external modules Trans debugbar --- htdocs/admin/debugbar.php | 16 +++++++++------- htdocs/core/js/lib_head.js.php | 2 ++ htdocs/core/modules/DolibarrModules.class.php | 4 +++- htdocs/core/modules/modCashDesk.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 ++ 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 19a440520b1..ce3c43bd69d 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -93,15 +93,17 @@ print ''.$langs->trans("Parameter").''.$langs->trans("Value").''; print "\n"; -print ''.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").''; -print ''; // This slow seriously output -print ' '.$langs->trans("WarningValueHigherSlowsDramaticalyOutput"); +print ''.$langs->trans("DEBUGBAR_USE_LOG_FILE").''; +print ''; +print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1); +print ''; +print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower").''; print ''; -print ''.$langs->trans("DEBUGBAR_USE_LOG_FILE").''; -print ''; -print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1); -print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower"); +print ''.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").''; +print ''; // This slow seriously output +print ''; +print ''.$langs->trans("WarningValueHigherSlowsDramaticalyOutput").''; print ''; print ''; diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index b3236ab1dcd..f75018fbdaf 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -963,6 +963,7 @@ function document_preview(file, type, title) img.src = file; } + function show_preview(mode) { /* console.log("mode="+mode+" file="+file+" type="+type+" width="+width+" height="+height); */ var newElem = ''; @@ -977,6 +978,7 @@ function document_preview(file, type, title) } $("#dialogforpopup").html(newElem); + $("#dialogforpopup").dialog({ closeOnEscape: true, resizable: true, diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 3b7cc0d1184..09ba25ce911 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -819,7 +819,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } /** - * Tells if module is core or external + * Tells if module is core or external. + * 'dolibarr' and 'dolibarr_deprecated' is core + * 'experimental' and 'development' is core * * @return string 'core', 'external' or 'unknown' */ diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index a128b92ee29..0128a51c0b8 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -51,7 +51,7 @@ class modCashDesk extends DolibarrModules $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "CashDesk module"; - $this->version = 'deprecated'; + $this->version = 'dolibarr_deprecated'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto = 'cash-register'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2e8d847ad11..bd4b4d8f7a6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2158,3 +2158,5 @@ YouShouldSetThisToOff=You should set this to 0 or off InstallAndUpgradeLockedBy=Install and upgrades are locked by the file %s IfYouUseASecondTaxYouMustSetYouUseTheMainTax=If you want to use a second tax, you must enable also the first sales tax IfYouUseAThirdTaxYouMustSetYouUseTheMainTax=If you want to use a third tax, you must enable also the first sales tax +DEBUGBAR_USE_LOG_FILE=Use the dolibarr.log file to trap Logs +UsingLogFileShowAllRecordOfSubrequestButIsSlower=Use the dolibarr.log file to trap Logs instead of live memory catching. It allows to catch all logs instead of only log of current process (so including the one of ajax subrequests pages) but will make your instance very very slow. Not recommended. From 3515097e4fe1612a6dcbe3b3d674e30a703b4963 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 May 2022 14:05:02 +0200 Subject: [PATCH 26/45] FIX Autoset rank on recuring invoice line was not working. --- htdocs/compta/facture/card-rec.php | 16 ++++++++-------- .../compta/facture/class/facture-rec.class.php | 9 ++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 6d7f7f6010e..ca61eafcc3b 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -641,7 +641,7 @@ if (empty($reshook)) { setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice); if ($result > 0) { // Define output language and generate document @@ -1605,19 +1605,19 @@ if ($action == 'create') { // Lines - print '
- - - - - '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; - print ''; + print '
'; // Show object lines if (!empty($object->lines)) { $canchangeproduct = 1; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 91d0fd0f20a..7058364d1f1 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -945,6 +945,13 @@ class FactureRec extends CommonInvoice $product_type = $product->type; } + // Rank to use + $ranktouse = $rang; + if ($ranktouse == -1) { + $rangmax = $this->line_max(0); + $ranktouse = $rangmax + 1; + } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec ("; $sql .= "fk_facture"; $sql .= ", label"; @@ -1003,7 +1010,7 @@ class FactureRec extends CommonInvoice $sql .= ", ".($fk_fournprice > 0 ? $fk_fournprice : 'null'); $sql .= ", ".($pa_ht ? price2num($pa_ht) : 0); $sql .= ", ".((int) $info_bits); - $sql .= ", ".((int) $rang); + $sql .= ", ".((int) $ranktouse); $sql .= ", ".((int) $special_code); $sql .= ", ".($fk_unit ? ((int) $fk_unit) : "null"); $sql .= ", ".(int) $this->fk_multicurrency; From c87c695d436af12ab66365437539251da320d4cd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 May 2022 14:15:42 +0200 Subject: [PATCH 27/45] Debug v16 --- htdocs/compta/facture/card-rec.php | 24 +++++++++++++----------- htdocs/compta/facture/card.php | 4 ++-- htdocs/core/class/commonobject.class.php | 4 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index ca61eafcc3b..6300e387067 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1034,21 +1034,11 @@ if ($action == 'create') { // Payment mode print ""; - // Project - if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) { - $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; - $langs->load('projects'); - print ''; - } - // Bank account if ($object->fk_account > 0) { print ""; } + // Project + if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) { + $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; + $langs->load('projects'); + print ''; + } + // Model pdf print ""; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8ad3dfd22bc..96a4bdab311 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3607,8 +3607,8 @@ if ($action == 'create') { // Payment mode print ''; // Bank Account diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 94486508788..cb1f0c76a86 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3391,9 +3391,9 @@ abstract class CommonObject * Must be called at end of methods addline or updateline. * * @param int $exclspec >0 = Exclude special product (product_type=9) - * @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force mode total of rounding, '1'=Force mode rounding of total + * @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force mode Total of rounding, '1'=Force mode Rounding of total * @param int $nodatabaseupdate 1=Do not update database. Update only properties of object. - * @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object. + * @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object (used to analyze lines to check corrupted data). * @return int <0 if KO, >0 if OK */ public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) From 420ab9f16ce6d7ed35e021dafafbc5872a5c48ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 May 2022 14:18:48 +0200 Subject: [PATCH 28/45] FIX Too many requets. On large order, fix n(n+1) sql into a n sql. --- htdocs/compta/facture/class/facture.class.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2134570ee2e..d1246c13bb6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -854,7 +854,9 @@ class Facture extends CommonInvoice $newinvoiceline->situation_percent, $newinvoiceline->fk_prev_id, $newinvoiceline->fk_unit, - $newinvoiceline->multicurrency_subprice + $newinvoiceline->multicurrency_subprice, + $newinvoiceline->ref_ext, + 1 ); // Defined the new fk_parent_line @@ -938,7 +940,8 @@ class Facture extends CommonInvoice $line->fk_prev_id, $line->fk_unit, $line->multicurrency_subprice, - $line->ref_ext + $line->ref_ext, + 1 ); if ($result < 0) { $this->error = $this->db->lasterror(); @@ -1035,7 +1038,9 @@ class Facture extends CommonInvoice $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit, - $_facrec->lines[$i]->multicurrency_subprice + $_facrec->lines[$i]->multicurrency_subprice, + $_facrec->lines[$i]->ref_ext, + 1 ); if ($result_insert < 0) { @@ -1047,7 +1052,7 @@ class Facture extends CommonInvoice } if (!$error) { - $result = $this->update_price(1); + $result = $this->update_price(1, 'auto', 0, $mysoc); if ($result > 0) { $action = 'create'; @@ -3237,7 +3242,7 @@ class Facture extends CommonInvoice * @param string $price_base_type 'HT' or 'TTC' * @param double $pu_ttc Unit price with tax (> 0 even for credit note) * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. - * @param int $rang Position of line + * @param int $rang Position of line (-1 means last value + 1) * @param int $special_code Special code (also used by externals modules!) * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id @@ -3251,6 +3256,7 @@ class Facture extends CommonInvoice * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in foreign currency * @param string $ref_ext External reference of the line + * @param int $noupdateafterinsertline No update after insert of line * @return int <0 if KO, Id of line if OK */ public function addline( @@ -3283,7 +3289,8 @@ class Facture extends CommonInvoice $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0, - $ref_ext = '' + $ref_ext = '', + $noupdateafterinsertline = 0 ) { // Deprecation warning if ($label) { @@ -3492,7 +3499,9 @@ class Facture extends CommonInvoice } // Mise a jour informations denormalisees au niveau de la facture meme - $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. + if (empty($noupdateafterinsertline)) { + $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. + } if ($result > 0) { $this->db->commit(); From 30bb2c5c2f22ed1dac394e0e6aae8b90d3bb309a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 May 2022 15:57:17 +0200 Subject: [PATCH 29/45] FIX Too many requets. On large order, fix n(n+1) sql into a n sql. --- htdocs/compta/facture/card.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 96a4bdab311..2b9ad68f241 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1571,8 +1571,15 @@ if (empty($reshook)) { 0, 0, 0, - 0 - //,$langs->trans('Deposit') //Deprecated + 0, + '', + 0, + 100, + 0, + null, + 0, + '', + 1 ); } @@ -1739,7 +1746,10 @@ if (empty($reshook)) { $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, - $lines[$i]->fk_unit + $lines[$i]->fk_unit, + 0, + '', + 1 ); if ($result > 0) { @@ -1762,6 +1772,8 @@ if (empty($reshook)) { } } + $object->update_price(1, 'auto', 0, $mysoc); + // Now we create same links to contact than the ones found on origin object /* Useless, already into the create if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) @@ -1809,9 +1821,11 @@ if (empty($reshook)) { $product->fetch(GETPOST('idprod'.$i, 'int')); $startday = dol_mktime(12, 0, 0, GETPOST('date_start'.$i.'month'), GETPOST('date_start'.$i.'day'), GETPOST('date_start'.$i.'year')); $endday = dol_mktime(12, 0, 0, GETPOST('date_end'.$i.'month'), GETPOST('date_end'.$i.'day'), GETPOST('date_end'.$i.'year')); - $result = $object->addline($product->description, $product->price, price2num(GETPOST('qty'.$i), 'MS'), $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, GETPOST('idprod'.$i, 'int'), price2num(GETPOST('remise_percent'.$i), '', 2), $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit); + $result = $object->addline($product->description, $product->price, price2num(GETPOST('qty'.$i), 'MS'), $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, GETPOST('idprod'.$i, 'int'), price2num(GETPOST('remise_percent'.$i), '', 2), $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit, 0, '', 1); } } + + $object->update_price(1, 'auto', 0, $mysoc); } } } From 3ae6a1d7867f414bc343488188bac5435006075e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 May 2022 16:18:52 +0200 Subject: [PATCH 30/45] Fix preselection of type of invoice --- htdocs/compta/facture/card.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2b9ad68f241..0cf7af2996e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -987,6 +987,10 @@ if (empty($reshook)) { } $selectedLines = GETPOST('toselect', 'array'); + if (GETPOST('type', 'int') === '') { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); + } + $db->begin(); $error = 0; @@ -3176,6 +3180,9 @@ if ($action == 'create') { $i++; } print ''; + + print ajax_combobox("fac_rec"); + // Option to reload page to retrieve customer informations. Note, this clear other input if (empty($conf->global->RELOAD_PAGE_ON_TEMPLATE_CHANGE_DISABLED)) { print ''; if (GETPOST('mode', 'aZ09') == 'remiseforalllines') { print '
'; - print ' %'; + print ''; print ''; print '
'; } From d76e7224d946d74717873217171974fc4583b9ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 May 2022 01:53:45 +0200 Subject: [PATCH 43/45] NEW Can set the max number of attendees for an organized event --- htdocs/core/class/html.form.class.php | 2 +- .../conferenceorbooth_list.php | 36 +++++++++++-------- htdocs/langs/en_US/eventorganization.lang | 3 +- htdocs/projet/class/project.class.php | 12 ++++++- 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d8b5a9e0f57..59540db4f1e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -234,7 +234,7 @@ class Form if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $ret .= ''; - } elseif (preg_match('/^(numeric|amount)/', $typeofdata)) { + } elseif (preg_match('/^(numeric|amount|integer)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $valuetoshow = price2num($editvalue ? $editvalue : $value); $ret .= ''; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 943205adca2..0ba93ea1c82 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -375,46 +375,52 @@ if ($projectid > 0) { print '
".$langs->trans("PaymentMode").""; + print img_picto('', 'payment', 'class="pictofixedwidth"'); print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 0, 0, 1, '', 1); //$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', '', 1); print "
'.$langs->trans('Project').''; - print img_picto('', 'project'); - $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); - print '   thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').''; - print '
".$langs->trans('BankAccount').""; @@ -1056,10 +1046,22 @@ if ($action == 'create') { print "
'.$langs->trans('Project').''; + print img_picto('', 'project', 'class="pictofixedwidth"'); + $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); + print '   thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').''; + print '
".$langs->trans('Model').""; include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; $list = ModelePDFFactures::liste_modeles($db); + print img_picto('', 'generic', 'class="pictofixedwidth"'); print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); print "
'.$langs->trans('PaymentMode').''; - print img_picto('', 'bank', 'class="pictofixedwidth"'); - $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'payment', 'class="pictofixedwidth"'); + print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); print '
'; // Description - print ''; // Categories if ($conf->categorie->enabled) { - print '"; } - print '"; - print '"; - print '"; - print '"; - print '"; + + print '"; // Link to the submit vote/register page - print ''; // Link to the subscribe - print '
'.$langs->trans("Description").''; + print '
'.$langs->trans("Description").''; print nl2br($project->description); print '
'.$langs->trans("Categories").''; + print '
'.$langs->trans("Categories").''; print $form->showCategories($project->id, Categorie::TYPE_PROJECT, 1); print "
'; + print '
'; $typeofdata = 'checkbox:'.($project->accept_conference_suggestions ? ' checked="checked"' : ''); $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); - print ''; + print ''; print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); print "
'; + print '
'; $typeofdata = 'checkbox:'.($project->accept_booth_suggestions ? ' checked="checked"' : ''); $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); - print ''; + print ''; print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); print "
'; + print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); - print ''; + print ''; print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'; + print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); - print ''; + print ''; print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'.$langs->trans("EventOrganizationICSLink").''; + print '
'; + print $form->editfieldkey($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', '', $project, $permissiontoadd, 'integer:3', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', $project->max_attendees, $project, $permissiontoadd, 'integer:3', '', 0, 0, '', 0, '', 'projectid'); + print "
'.$langs->trans("EventOrganizationICSLink").''; // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; @@ -427,11 +433,11 @@ if ($projectid > 0) { print "
'; + print '
'; //print ''; print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage")); //print ''; - print ''; + print ''; $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.((int) $project->id); $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $project->id), 'md5'); $linksuggest .= '&securekey='.urlencode($encodedsecurekey); @@ -444,11 +450,11 @@ if ($projectid > 0) { print '
'; + print '
'; //print ''; print $langs->trans("PublicAttendeeSubscriptionGlobalPage"); //print ''; - print ''; + print ''; $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.((int) $project->id).'&type=global'; $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $project->id), 'md5'); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 9cd52930714..858e0937788 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -165,4 +165,5 @@ EmailAttendee=Attendee email EmailCompanyForInvoice=Company email (for invoice, if different of attendee email) ErrorSeveralCompaniesWithEmailContactUs=Several companies with this email has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation ErrorSeveralCompaniesWithNameContactUs=Several companies with this name has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation -NoPublicActionsAllowedForThisEvent=No public actions are open to public for this event \ No newline at end of file +NoPublicActionsAllowedForThisEvent=No public actions are open to public for this event +MaxNbOfAttendees=Max number of attendees diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 510d7e23e62..98f2fed52b4 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -150,6 +150,11 @@ class Project extends CommonObject */ public $price_booth; + /** + * @var float Max attendees + */ + public $max_attendees; + public $statuts_short; public $statuts_long; @@ -248,6 +253,7 @@ class Project extends CommonObject 'accept_booth_suggestions' =>array('type'=>'integer', 'label'=>'AllowUnknownPeopleSuggestBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>147), 'price_registration' =>array('type'=>'double(24,8)', 'label'=>'PriceOfRegistration', 'enabled'=>1, 'visible'=>-1, 'position'=>148), 'price_booth' =>array('type'=>'double(24,8)', 'label'=>'PriceOfBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>149), + 'max_attendees' =>array('type'=>'integer', 'label'=>'MaxNbOfAttendees', 'enabled'=>1, 'visible'=>-1, 'position'=>150), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreationShort', 'enabled'=>1, 'visible'=>-2, 'position'=>200), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModificationShort', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>205), 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>210), @@ -372,6 +378,7 @@ class Project extends CommonObject $sql .= ", accept_booth_suggestions"; $sql .= ", price_registration"; $sql .= ", price_booth"; + $sql .= ", max_attendees"; $sql .= ", email_msgid"; $sql .= ", note_private"; $sql .= ", note_public"; @@ -399,6 +406,7 @@ class Project extends CommonObject $sql .= ", ".($this->accept_booth_suggestions ? 1 : 0); $sql .= ", ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : 'null'); $sql .= ", ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : 'null'); + $sql .= ", ".(strcmp($this->max_attendees, '') ? ((int) $this->max_attendees) : 'null'); $sql .= ", ".($this->email_msgid ? "'".$this->db->escape($this->email_msgid)."'" : 'null'); $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : 'null'); $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null'); @@ -509,6 +517,7 @@ class Project extends CommonObject $sql .= ", accept_booth_suggestions = ".($this->accept_booth_suggestions ? 1 : 0); $sql .= ", price_registration = ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : "null"); $sql .= ", price_booth = ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : "null"); + $sql .= ", max_attendees = ".(strcmp($this->max_attendees, '') ? price2num($this->max_attendees) : "null"); $sql .= ", entity = ".((int) $this->entity); $sql .= " WHERE rowid = ".((int) $this->id); @@ -595,7 +604,7 @@ class Project extends CommonObject $sql = "SELECT rowid, entity, ref, title, description, public, datec, opp_amount, budget_amount,"; $sql .= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut as status, fk_opp_status, opp_percent,"; $sql .= " note_private, note_public, model_pdf, usage_opportunity, usage_task, usage_bill_time, usage_organize_event, email_msgid,"; - $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth"; + $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth, max_attendees"; $sql .= " FROM ".MAIN_DB_PREFIX."projet"; if (!empty($id)) { $sql .= " WHERE rowid = ".((int) $id); @@ -653,6 +662,7 @@ class Project extends CommonObject $this->accept_booth_suggestions = (int) $obj->accept_booth_suggestions; $this->price_registration = $obj->price_registration; $this->price_booth = $obj->price_booth; + $this->max_attendees = $obj->max_attendees; $this->email_msgid = $obj->email_msgid; $this->db->free($resql); From 1957ebcc351d4691ffa54857983c67b1cee8d3a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 May 2022 02:13:29 +0200 Subject: [PATCH 44/45] Fix restore warning --- htdocs/accountancy/bookkeeping/listbyaccount.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 5650cce8767..cb8a2ee0517 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -653,6 +653,11 @@ if (preg_match('/^asc/i', $sortorder)) { $sortorder = "desc"; } +// Warning to explain why list of record is not consistent with the other list view (missing a lot of lines) +if ($type == 'sub') { + print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded")); +} + $moreforfilter = ''; // Accountancy account From 6813bfb1e871a2d0a0d9dd59983a57981fb4c57b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 May 2022 02:23:24 +0200 Subject: [PATCH 45/45] Trans --- htdocs/langs/en_US/accountancy.lang | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 568263b0ca5..8283da55f41 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -278,10 +278,10 @@ DescVentilExpenseReportMore=If you setup accounting account on type of expense r DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account Closure=Annual closure -DescClosure=Consult here the number of movements by month who are not validated & fiscal years already open -OverviewOfMovementsNotValidated=Step 1/ Overview of movements not validated. (Necessary to close a fiscal year) -AllMovementsWereRecordedAsValidated=All movements were recorded as validated -NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated +DescClosure=Consult here the number of movements by month who are not yet validated & locked +OverviewOfMovementsNotValidated=Overview of movements not validated and locked +AllMovementsWereRecordedAsValidated=All movements were recorded as validated and locked +NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated and locked ValidateMovements=Validate and lock record... DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible