From c789b2d6e6507d1be53cb08bd2e8c27be44a2cbf Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 24 Nov 2020 18:37:32 +0100 Subject: [PATCH 01/65] Update autotranslator.php these sites are defunct: - http://code.google.com/intl/fr/apis/language/translate/overview.html - http://translate.google.com/translate_tools this site http://www.google.com/language_tools is now https://translate.google.com --- dev/translation/autotranslator.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/translation/autotranslator.php b/dev/translation/autotranslator.php index 5e8cc13c3c8..0c994bd591b 100755 --- a/dev/translation/autotranslator.php +++ b/dev/translation/autotranslator.php @@ -21,8 +21,8 @@ * \ingroup dev * \brief This script uses google language ajax api as the translator engine * The main translator function can be found at: - * http://code.google.com/intl/fr/apis/language/translate/overview.html - * http://translate.google.com/translate_tools + * defunct -http://code.google.com/intl/fr/apis/language/translate/overview.html- + * defunct -http://translate.google.com/translate_tools- * https://code.google.com/apis/console */ @@ -58,7 +58,7 @@ $dir=DOL_DOCUMENT_ROOT."/langs"; if (! isset($argv[3])) { print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n"; print "Example: ".$script_file." en_US pt_PT 123456\n"; - print "Rem: lang_code to use can be found on http://www.google.com/language_tools\n"; + print "Rem: lang_code to use can be found on https://translate.google.com\n"; exit; } From c74e952f6471229ae400a56003704127662b5273 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 24 Nov 2020 17:40:28 +0000 Subject: [PATCH 02/65] Fixing style errors. --- dev/translation/autotranslator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/translation/autotranslator.php b/dev/translation/autotranslator.php index 0c994bd591b..fd02febbdcc 100755 --- a/dev/translation/autotranslator.php +++ b/dev/translation/autotranslator.php @@ -21,8 +21,8 @@ * \ingroup dev * \brief This script uses google language ajax api as the translator engine * The main translator function can be found at: - * defunct -http://code.google.com/intl/fr/apis/language/translate/overview.html- - * defunct -http://translate.google.com/translate_tools- + * defunct -http://code.google.com/intl/fr/apis/language/translate/overview.html- + * defunct -http://translate.google.com/translate_tools- * https://code.google.com/apis/console */ From 7eec1155a05e77ce8feab8068341ec3b3d405df5 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 24 Nov 2020 18:58:37 +0100 Subject: [PATCH 03/65] Fix issue #15506 tansfer line extrafield order to expedition --- htdocs/expedition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index f2cb455cc6b..7614ba01df3 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1599,7 +1599,7 @@ if ($action == 'create') $srcLine = new OrderLine($db); $srcLine->id = $line->id; $srcLine->fetch_optionals(); // fetch extrafields also available in orderline - $line->array_options = array_merge($line->array_options, $srcLine->array_options); + $expLine->array_options = array_merge($line->array_options, $srcLine->array_options); print $expLine->showOptionals($extrafields, 'edit', array('style'=>'class="drag drop oddeven"', 'colspan'=>$colspan), $indiceAsked, '', 1); } From d17ecbeccda8265be541758e53e3886daa53f1f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Nov 2020 20:56:11 +0100 Subject: [PATCH 04/65] Fix #15438 --- .../modules/commande/doc/pdf_eratosthene.modules.php | 11 +++++++++++ .../core/modules/facture/doc/pdf_sponge.modules.php | 11 +++++++++++ htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 1910dd0c048..d936fd75a30 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1780,6 +1780,17 @@ class pdf_eratosthene extends ModelePDFCommandes 'border-left' => true, // add left line separator ); + // Adapt dynamically the width of subprice, if text is too long. + $tmpwidth = 0; + $nblines = count($object->lines); + for ($i = 0; $i < $nblines; $i++) { + $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails))); + $tmpwidth = max($tmpwidth, $tmpwidth2); + } + if ($tmpwidth > 10) { + $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10)); + } + $rank = $rank + 10; $this->cols['qty'] = array( 'rank' => $rank, diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 8f48f31fddb..94eeca2a8ab 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2307,6 +2307,17 @@ class pdf_sponge extends ModelePDFFactures 'border-left' => true, // add left line separator ); + // Adapt dynamically the width of subprice, if text is too long. + $tmpwidth = 0; + $nblines = count($object->lines); + for ($i = 0; $i < $nblines; $i++) { + $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails))); + $tmpwidth = max($tmpwidth, $tmpwidth2); + } + if ($tmpwidth > 10) { + $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10)); + } + $rank = $rank + 10; $this->cols['qty'] = array( 'rank' => $rank, diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 1af66ca645e..fce874d7bdf 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1933,6 +1933,17 @@ class pdf_cyan extends ModelePDFPropales 'border-left' => true, // add left line separator ); + // Adapt dynamically the width of subprice, if text is too long. + $tmpwidth = 0; + $nblines = count($object->lines); + for ($i = 0; $i < $nblines; $i++) { + $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails))); + $tmpwidth = max($tmpwidth, $tmpwidth2); + } + if ($tmpwidth > 10) { + $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10)); + } + $rank = $rank + 10; $this->cols['qty'] = array( 'rank' => $rank, From f6eadbbc3f0a58fd1966657fb3b95c3712d2aea7 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Tue, 24 Nov 2020 21:48:08 +0100 Subject: [PATCH 05/65] Order receipt improvements in TakePOS --- htdocs/takepos/invoice.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index c7cfb2c0899..81da82087ec 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -678,7 +678,10 @@ if ($action == "order" and $placeid != 0) $printer = new dolReceiptPrinter($db); } - $headerorder = '
'.$langs->trans('Place').' '.$place.'
'; + $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("Qty").'
'; $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; $order_receipt_printer1 = ""; $order_receipt_printer2 = ""; @@ -695,11 +698,15 @@ if ($action == "order" and $placeid != 0) $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 .= ''.$line->product_label.''.$line->qty; + $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 .= ''; } @@ -1372,4 +1379,4 @@ if ($action == "search") '; } -print ''; +print ''; \ No newline at end of file From 9b1dbf8d2af2ce535f2c701bb0922595111cdad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Tue, 24 Nov 2020 22:10:01 +0100 Subject: [PATCH 06/65] llx_accounting_account_fr.sql: Remove left over field data In commit 86d9622360b6682d9a75b1c9f9fa15dfa2e4805c, the `pcg_subtype` was removed from the inserted values. In commit a85dfaf71e7300d878af0b656de853e77b9bde92, values associated with this field were removed. However, at least two lines in the PCG99-BASE accounting accounts still had that field values. This led to errors when importing the PCG99-BASE accounts. This patch fixes the problem and the accounts can be imported successfully. --- htdocs/install/mysql/data/llx_accounting_account_fr.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_accounting_account_fr.sql b/htdocs/install/mysql/data/llx_accounting_account_fr.sql index 34e8882609d..d49e509a5be 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_fr.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_fr.sql @@ -468,7 +468,7 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 413,'PCG99-BASE','INCOME', '754', '409', 'Ristournes perçues des coopératives (provenant des excédents)', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 414,'PCG99-BASE','INCOME', '755', '409', 'Quotes-parts de résultat sur opérations faites en commun', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 415,'PCG99-BASE','INCOME', '758', '409', 'Produits divers de gestion courante', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 416,'PCG99-BASE','INCOME', 'FIN', '76','1507', 'Produits financiers', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 416,'PCG99-BASE','INCOME', '76','1507', 'Produits financiers', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 417,'PCG99-BASE','INCOME', '761', '416', 'Produits de participations', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 418,'PCG99-BASE','INCOME', '762', '416', 'Produits des autres immobilisations financières', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 419,'PCG99-BASE','INCOME', '763', '416', 'Revenus des autres créances', 1); @@ -476,7 +476,7 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 421,'PCG99-BASE','INCOME', '765', '416', 'Escomptes obtenus', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 422,'PCG99-BASE','INCOME', '766', '416', 'Gains de change', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 423,'PCG99-BASE','INCOME', '767', '416', 'Produits nets sur cessions de valeurs mobilières de placement', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 424,'PCG99-BASE','INCOME', 'FIN', '768', '416', 'Autres produits financiers', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 424,'PCG99-BASE','INCOME', '768', '416', 'Autres produits financiers', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 425,'PCG99-BASE','INCOME', '77','1507', 'Produits exceptionnels', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 426,'PCG99-BASE','INCOME', '771', '425', 'Produits exceptionnels sur opérations de gestion', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 427,'PCG99-BASE','INCOME', '772', '425', '(Compte à la disposition des entités pour enregistrer, en cours d''exercice, les produits sur exercices antérieurs)', 1); From 12ef03f06dbd6c88f127233788b3d75cf5f7eb20 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 25 Nov 2020 10:58:34 +0100 Subject: [PATCH 07/65] fix banck tranfert supplier --- htdocs/compta/prelevement/class/bonprelevement.class.php | 6 +++++- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_prelevement_facture.sql | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index bcf0ce8aa5a..2014710e555 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -164,10 +164,12 @@ class BonPrelevement extends CommonObject $result = 0; } else { $result = -1; + $this->errors[] = get_class($this)."::AddFacture " . $this->db->lasterror; dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { $result = -2; + $this->errors[]=get_class($this)."::AddFacture linedid Empty"; dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { @@ -245,6 +247,7 @@ class BonPrelevement extends CommonObject $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes"); $result = 0; } else { + $this->errors[]=get_class($this)."::addline Error -2 " .$this->db->lasterror; dol_syslog(get_class($this)."::addline Error -2"); $result = -2; } @@ -1121,7 +1124,8 @@ class BonPrelevement extends CommonObject if (!$resql) { $error++; - dol_syslog(__METHOD__."::Update Error=".$this->db->error(), LOG_ERR); + $this->errors[]=$this->db->lasterror(); + dol_syslog(__METHOD__."::Update Error=".$this->db->lasterror(), LOG_ERR); } } } diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 2ad8fb32896..9951375677c 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -35,6 +35,8 @@ ALTER TABLE llx_payment_various MODIFY COLUMN ref varchar(30) NULL; ALTER TABLE llx_prelevement_bons ADD COLUMN type varchar(16) DEFAULT 'debit-order'; +ALTER TABLE llx_prelevement_facture CHANGE COLUMN fk_facture_foun fk_facture_fourn integer NULL; + ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture (fk_facture); ALTER TABLE llx_prelevement_facture_demande ADD INDEX idx_prelevement_facture_demande_fk_facture_fourn (fk_facture_fourn); diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture.sql b/htdocs/install/mysql/tables/llx_prelevement_facture.sql index dbe2cb85f84..53a329f4376 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_facture.sql @@ -20,7 +20,7 @@ create table llx_prelevement_facture ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NULL, - fk_facture_foun integer NULL, + fk_facture_fourn integer NULL, fk_prelevement_lignes integer NOT NULL )ENGINE=innodb; From 73d6266151b0af008ef9fa1781b2428103fc77ee Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 25 Nov 2020 11:22:31 +0100 Subject: [PATCH 08/65] continue fix banktransfert supplier --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 2014710e555..21bf795079a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1320,7 +1320,7 @@ class BonPrelevement extends CommonObject $url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id; if ($this->type == 'bank-transfer') { - $url = DOL_URL_ROOT.'/compta/paymentbybanktransfer/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id; } if ($option != 'nolink') From 4917403365ddbbf0ac51d8a904c9761ba751a245 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Nov 2020 12:46:03 +0100 Subject: [PATCH 09/65] Avoid dynamic var --- htdocs/opensurvey/wizard/create_survey.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 1ae5699500b..b295f007ca8 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -35,15 +35,13 @@ if (!$user->rights->opensurvey->write) accessforbidden(); $langs->load("opensurvey"); -// On teste toutes les variables pour supprimer l'ensemble des warnings PHP -// On transforme en entites html les données afin éviter les failles XSS -$post_var = array('title', 'description', 'mailsonde', 'creation_sondage_date', 'creation_sondage_autre'); -foreach ($post_var as $var) -{ - $$var = GETPOST($var); -} +$title = GETPOST('title'); +$description = GETPOST('description', 'restricthtml'); +$mailsonde = GETPOST('mailsonde'); +$creation_sondage_date = GETPOST('creation_sondage_date'); +$creation_sondage_date = GETPOST('creation_sondage_date'); -// On initialise egalement la session car sinon bonjour les warning :-) +// We init some session variable to avoir warning $session_var = array('title', 'description', 'mailsonde'); foreach ($session_var as $var) { From 62c361dc1a14509b8e2e5057845fca016880e868 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Wed, 25 Nov 2020 13:04:26 +0100 Subject: [PATCH 10/65] fix better delete management (include extrafield too) --- .../class/expensereport.class.php | 111 +++++++++++------- 1 file changed, 70 insertions(+), 41 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index f533d0e7851..cad28c40cfe 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1081,53 +1081,82 @@ class ExpenseReport extends CommonObject */ public function delete(User $fuser = null) { - global $user, $langs, $conf; + global $user, $langs, $conf; - $rowid = $this->id; + $error = 0; - $error = 0; + $this->db->begin(); - // Delete lines - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element_line.' WHERE '.$this->fk_element.' = '.$rowid; - if (!$error && !$this->db->query($sql)) - { - $this->error = $this->db->error()." sql=".$sql; - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $error++; - } + if (!$rowid) $rowid = $this->id; - // Delete llx_ecm_files - if (!$error) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - $error++; - } - } + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element_line.' WHERE '.$this->fk_element.' = '.$rowid; + if ($this->db->query($sql)) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid = '.$rowid; + $resql = ; + if ($this->db->query($sql)) { - // Delete main record - if (!$error) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid = '.$rowid; - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->error()." sql=".$sql; - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - } - } + // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive + $this->deleteEcmFiles(); - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return 1; - } - } + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->expensereport->multidir_output[$this->entity] && !empty($this->ref)) { + $dir = $conf->expensereport->multidir_output[$this->entity]."/".$ref; + $file = $dir."/".$ref.".pdf"; + if (file_exists($file)) { + dol_delete_preview($this); + + if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers + { + $this->error = 'ErrorFailToDeleteFile'; + $this->errors = array('ErrorFailToDeleteFile'); + $this->db->rollback(); + return 0; + } + } + if (file_exists($dir)) { + $res = @dol_delete_dir_recursive($dir); + if (!$res) { + $this->error = 'ErrorFailToDeleteDir'; + $this->errors = array('ErrorFailToDeleteDir'); + $this->db->rollback(); + return 0; + } + } + } + + // Removed extrafields + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + $errorflag = -4; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); + } + } + + if (!$error) { + dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return 0; + } + } else { + $this->error = $this->db->error()." sql=".$sql; + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $this->db->rollback(); + return -6; + } + } else { + $this->error = $this->db->error()." sql=".$sql; + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $this->db->rollback(); + return -4; + } + } /** * Set to status validate From 9da8cf63a2e3a119139410b5524a36e952e6bb7f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 25 Nov 2020 12:07:57 +0000 Subject: [PATCH 11/65] Fixing style errors. --- htdocs/expensereport/class/expensereport.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index cad28c40cfe..b872e0e506c 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1094,7 +1094,6 @@ class ExpenseReport extends CommonObject $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid = '.$rowid; $resql = ; if ($this->db->query($sql)) { - // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive $this->deleteEcmFiles(); From bf7b6ee00d8ad8017af88b12c9c8be151dad08e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Nov 2020 14:15:59 +0100 Subject: [PATCH 12/65] Fix delete of proposal --- htdocs/comm/propal/class/propal.class.php | 158 +++++++++++----------- htdocs/core/class/commonobject.class.php | 15 +- 2 files changed, 90 insertions(+), 83 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index c0b592c28f2..0792760d540 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -357,7 +357,7 @@ class Propal extends CommonObject $this->products = array(); - $this->duree_validite = $conf->global->PROPALE_VALIDITY_DURATION; + $this->duree_validite = ((int) $conf->global->PROPALE_VALIDITY_DURATION); } @@ -1615,7 +1615,7 @@ class Propal extends CommonObject if (isset($this->note_public)) $this->note_public = trim($this->note_public); if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf); if (isset($this->import_key)) $this->import_key = trim($this->import_key); - if (!empty($this->duree_validite)) $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); + if (!empty($this->duree_validite) && is_numeric($this->duree_validite)) $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); // Check parameters // Put here code to add control on parameters values @@ -2921,7 +2921,7 @@ class Propal extends CommonObject * * @param User $user Object user that delete * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int 1 if ok, otherwise if error + * @return int >0 if OK, <=0 if KO */ public function delete($user, $notrigger = 0) { @@ -2932,102 +2932,96 @@ class Propal extends CommonObject $this->db->begin(); - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('PROPAL_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } - if (!$error) - { - $main = MAIN_DB_PREFIX.'propaldet'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = ".$this->id.")"; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; - if ($this->db->query($sqlef) && $this->db->query($sql)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id; - if ($this->db->query($sql)) - { - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + // Delete extrafields of lines and lines + if (!$error && !empty($this->table_element_line)) { + $tabletodelete = $this->table_element_line; + $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE fk_propal = ".$this->id.")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE fk_propal = ".$this->id; + if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); + } + } - // Delete linked contacts - $res = $this->delete_linked_contact(); - if ($res < 0) $error++; + // Removed extrafields of object + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); + } + } - if (!$error) - { - // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + // Delete main record + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id; + $res = $this->db->query($sql); + if (! $res) { + $error++; + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); + } + } - // We remove directory - $ref = dol_sanitizeFileName($this->ref); - if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) - { - $dir = $conf->propal->multidir_output[$this->entity]."/".$ref; - $file = $dir."/".$ref.".pdf"; - if (file_exists($file)) - { - dol_delete_preview($this); + if (! $error) { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + } - if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers - { - $this->error = 'ErrorFailToDeleteFile'; - $this->errors = array('ErrorFailToDeleteFile'); - $this->db->rollback(); - return 0; - } - } - if (file_exists($dir)) - { - $res = @dol_delete_dir_recursive($dir); - if (!$res) - { - $this->error = 'ErrorFailToDeleteDir'; - $this->errors = array('ErrorFailToDeleteDir'); - $this->db->rollback(); - return 0; - } - } - } - } + if (! $error) { + // Delete linked contacts + $res = $this->delete_linked_contact(); + if ($res < 0) $error++; + } - // Removed extrafields - if (!$error) - { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - $errorflag = -4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); - } - } + // Delete record into ECM index and physically + if (!$error) { + $res = $this->deleteEcmFiles(); // Deleting files physically is done later with the dol_delete_dir_recursive + if (! $res) { + $error++; + } + } - if (!$error) - { - dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); + if (!$error) { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) { + $dir = $conf->propal->multidir_output[$this->entity]."/".$ref; + $file = $dir."/".$ref.".pdf"; + if (file_exists($file)) { + dol_delete_preview($this); + + if (!dol_delete_file($file, 0, 0, 0, $this)) { + $this->error = 'ErrorFailToDeleteFile'; + $this->errors = array('ErrorFailToDeleteFile'); + $this->db->rollback(); + return 0; + } + } + if (file_exists($dir)) { + $res = @dol_delete_dir_recursive($dir); + if (!$res) { + $this->error = 'ErrorFailToDeleteDir'; + $this->errors = array('ErrorFailToDeleteDir'); $this->db->rollback(); return 0; } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -3; } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; } + } + + if (!$error) { + dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); + $this->db->commit(); + return 1; } else { $this->db->rollback(); return -1; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ac0900f0c29..27e2225b2a2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8477,9 +8477,22 @@ abstract class CommonObject $element = $this->element; } + // Delete ecm_files extrafields + $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files_extrafields WHERE fk_object IN ("; + $sql .= " SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here + $sql .= ")"; + + if (!$this->db->query($sql)) { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return false; + } + + // Delete ecm_files $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); From a734e1caa7e59722dcea810164962784311c3ee6 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 25 Nov 2020 15:06:07 +0100 Subject: [PATCH 13/65] line is order line not exp line --- htdocs/expedition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 7614ba01df3..12a5e5747b3 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1599,7 +1599,7 @@ if ($action == 'create') $srcLine = new OrderLine($db); $srcLine->id = $line->id; $srcLine->fetch_optionals(); // fetch extrafields also available in orderline - $expLine->array_options = array_merge($line->array_options, $srcLine->array_options); + $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options); print $expLine->showOptionals($extrafields, 'edit', array('style'=>'class="drag drop oddeven"', 'colspan'=>$colspan), $indiceAsked, '', 1); } From 4d90fb22de53f21ee0dbb67b3224e7a62458a910 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Nov 2020 15:07:26 +0100 Subject: [PATCH 14/65] Fix sql syntax error --- htdocs/core/class/commonobject.class.php | 4 +- .../template/test/phpunit/MyObjectTest.php | 50 +++++++++++++++++++ test/phpunit/BOMTest.php | 26 ++++++++++ 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b2e7b696147..9c58ff6d232 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8445,7 +8445,7 @@ abstract class CommonObject /** * Delete related files of object in database * - * @param integer $mode 0=Use path to find record, 1=Use src_object_xxx fields + * @param integer $mode 0=Use path to find record, 1=Use src_object_xxx fields (Mode 1 is recommanded for new objects) * @return bool True if OK, False if KO */ public function deleteEcmFiles($mode = 0) @@ -8503,7 +8503,7 @@ abstract class CommonObject // Delete in database with mode 1 if ($mode == 1) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files_extrafields"; - $sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id.")"; $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->lasterror(); diff --git a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php index fd05890ff48..29721ea171f 100644 --- a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php @@ -122,6 +122,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase /** * A sample test + * * @return bool */ public function testSomething() @@ -139,4 +140,53 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase return $result; } + + /** + * testMyObjectCreate + * + * @return int + */ + public function testMyObjectCreate() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new MyObject($this->savdb); + $localobject->initAsSpecimen(); + $result=$localobject->create($user); + + print __METHOD__." result=".$result."\n"; + $this->assertLessThan($result, 0); + + return $result; + } + + /** + * testMyObjectDelete + * + * @param int $id Id of object + * @return void + * + * @depends testMyObjectCreate + * The depends says test is run only if previous is ok + */ + public function testMyObjectDelete($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new MyObject($this->savdb); + $result=$localobject->fetch($id); + $result=$localobject->delete($user); + + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $result; + } } diff --git a/test/phpunit/BOMTest.php b/test/phpunit/BOMTest.php index 39268bdeaea..872d0b09d18 100644 --- a/test/phpunit/BOMTest.php +++ b/test/phpunit/BOMTest.php @@ -148,4 +148,30 @@ class BOMTest extends PHPUnit\Framework\TestCase return $result; } + + /** + * testBOMDelete + * + * @param int $id Id of object + * @return void + * + * @depends testBOMCreate + * The depends says test is run only if previous is ok + */ + public function testBOMDelete($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new BOM($this->savdb); + $result=$localobject->fetch($id); + $result=$localobject->delete($user); + + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $result; + } } From 944e2a8032ebfaddccd91ebe961d8a6fcebba931 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Nov 2020 15:29:18 +0100 Subject: [PATCH 15/65] Fix delete of expense report --- htdocs/comm/propal/class/propal.class.php | 6 +- .../class/expensereport.class.php | 164 ++++++++++-------- test/phpunit/ExpenseReportTest.php | 12 +- 3 files changed, 102 insertions(+), 80 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0792760d540..50c63137c67 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2942,8 +2942,8 @@ class Propal extends CommonObject // Delete extrafields of lines and lines if (!$error && !empty($this->table_element_line)) { $tabletodelete = $this->table_element_line; - $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE fk_propal = ".$this->id.")"; - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE fk_propal = ".$this->id; + $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); @@ -2962,7 +2962,7 @@ class Propal extends CommonObject // Delete main record if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; $res = $this->db->query($sql); if (! $res) { $error++; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index b872e0e506c..6f6f4bbd010 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1074,87 +1074,115 @@ class ExpenseReport extends CommonObject /** - * delete + * Delete object in database * * @param User $fuser User that delete + * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, >0 if OK */ - public function delete(User $fuser = null) + public function delete(User $fuser = null, $notrigger = false) { - global $user, $langs, $conf; + global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error = 0; + $error = 0; $this->db->begin(); - if (!$rowid) $rowid = $this->id; + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('EXPENSEREPORT_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element_line.' WHERE '.$this->fk_element.' = '.$rowid; - if ($this->db->query($sql)) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid = '.$rowid; - $resql = ; - if ($this->db->query($sql)) { - // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + // Delete extrafields of lines and lines + if (!$error && !empty($this->table_element_line)) { + $tabletodelete = $this->table_element_line; + //$sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; + if (! $this->db->query($sql)) { + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); + } + } - // We remove directory - $ref = dol_sanitizeFileName($this->ref); - if ($conf->expensereport->multidir_output[$this->entity] && !empty($this->ref)) { - $dir = $conf->expensereport->multidir_output[$this->entity]."/".$ref; - $file = $dir."/".$ref.".pdf"; - if (file_exists($file)) { - dol_delete_preview($this); + // Removed extrafields of object + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); + } + } - if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers - { - $this->error = 'ErrorFailToDeleteFile'; - $this->errors = array('ErrorFailToDeleteFile'); - $this->db->rollback(); - return 0; - } - } - if (file_exists($dir)) { - $res = @dol_delete_dir_recursive($dir); - if (!$res) { - $this->error = 'ErrorFailToDeleteDir'; - $this->errors = array('ErrorFailToDeleteDir'); - $this->db->rollback(); - return 0; - } - } - } + // Delete main record + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; + $res = $this->db->query($sql); + if (! $res) { + $error++; + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); + } + } - // Removed extrafields - if (!$error) { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - $errorflag = -4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); - } - } + if (! $error) { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + } - if (!$error) { - dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return 0; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $this->db->rollback(); - return -6; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $this->db->rollback(); - return -4; - } + if (! $error) { + // Delete linked contacts + $res = $this->delete_linked_contact(); + if ($res < 0) $error++; + } + + // Delete record into ECM index and physically + if (!$error) { + $res = $this->deleteEcmFiles(); // Deleting files physically is done later with the dol_delete_dir_recursive + if (! $res) { + $error++; + } + } + + if (!$error) { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) { + $dir = $conf->propal->multidir_output[$this->entity]."/".$ref; + $file = $dir."/".$ref.".pdf"; + if (file_exists($file)) { + dol_delete_preview($this); + + if (!dol_delete_file($file, 0, 0, 0, $this)) { + $this->error = 'ErrorFailToDeleteFile'; + $this->errors = array('ErrorFailToDeleteFile'); + $this->db->rollback(); + return 0; + } + } + if (file_exists($dir)) { + $res = @dol_delete_dir_recursive($dir); + if (!$res) { + $this->error = 'ErrorFailToDeleteDir'; + $this->errors = array('ErrorFailToDeleteDir'); + $this->db->rollback(); + return 0; + } + } + } + } + + if (!$error) { + dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } } /** @@ -2466,7 +2494,7 @@ class ExpenseReport extends CommonObject { $obj = $this->db->fetch_object($resql); $this->db->free($resql); - return $obj->amount; + return (empty($obj->amount) ? 0 : $obj->amount); } else { $this->error = $this->db->lasterror(); return -1; diff --git a/test/phpunit/ExpenseReportTest.php b/test/phpunit/ExpenseReportTest.php index 3f6402262c3..2d6fdca3b27 100644 --- a/test/phpunit/ExpenseReportTest.php +++ b/test/phpunit/ExpenseReportTest.php @@ -281,15 +281,9 @@ class ExpenseReportTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - /*$result=$localobject->setstatus(0); + $result=$localobject->getSumPayments(); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0); - */ - - /*$localobject->info($localobject->id); - print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; - $this->assertNotEquals($localobject->date_creation, ''); - */ + $this->assertGreaterThanOrEqual(0, $result); return $localobject->id; } @@ -316,7 +310,7 @@ class ExpenseReportTest extends PHPUnit\Framework\TestCase $result=$localobject->delete($user); print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); return $result; } } From 551256b77936fc4d24b5f3b7fd93c91603ae1eb0 Mon Sep 17 00:00:00 2001 From: Muhammad Aboelfotoh <> Date: Wed, 25 Nov 2020 15:11:09 +0000 Subject: [PATCH 16/65] FIX #13067 including opening balance in calculation of displayed balance --- htdocs/accountancy/bookkeeping/balance.php | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 456da29d954..ef19a6ae330 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -265,10 +265,16 @@ if ($action != 'export_csv') $total_credit = 0; $sous_total_debit = 0; $sous_total_credit = 0; + $total_opening_balance = 0; + $sous_total_opening_balance = 0; $displayed_account = ""; - $sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity; - $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte"; + $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; + $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features + $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; + $sql .= " GROUP BY t.numero_compte"; + $resql = $db->query($sql); $nrows = $resql->num_rows; $opening_balances = array(); @@ -284,17 +290,19 @@ if ($action != 'export_csv') $total_credit += $line->credit; $description = $object->get_compte_desc($line->numero_compte); // Search description of the account $root_account_description = $object->get_compte_racine($line->numero_compte); + $opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0; + $total_opening_balance += $opening_balance; if (empty($description)) { $link = ''.img_edit_add().''; } print ''; - // Permet d'afficher le compte comptable + // Display the accounting account if (empty($displayed_account) || $root_account_description != $displayed_account) { - // Affiche un Sous-Total par compte comptable + // Display a sub-total per account if ($displayed_account != "") { - print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).''; + print ''.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).''; print " \n"; print ''; } @@ -307,30 +315,32 @@ if ($action != 'export_csv') $displayed_account = $root_account_description; $sous_total_debit = 0; $sous_total_credit = 0; + $sous_total_opening_balance = 0; } // $object->get_compte_racine($line->numero_compte); print ''.length_accountg($line->numero_compte).''; print ''.$description.''; - print ''.price($opening_balances["'".$line->numero_compte."'"]).''; + print ''.price($opening_balance).''; print ''.price($line->debit).''; print ''.price($line->credit).''; - print ''.price($line->debit - $line->credit).''; + print ''.price($opening_balance + $line->debit - $line->credit).''; print ''.$link; print ''; print "\n"; - // Comptabilise le sous-total + // Records the sub-total $sous_total_debit += $line->debit; $sous_total_credit += $line->credit; + $sous_total_opening_balance += $opening_balance; } - print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).''; + print ''.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit)).''; print " \n"; print ''; - print ''.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_debit - $total_credit)).''; + print ''.$langs->trans("AccountBalance").':'.price($total_opening_balance).''.price($total_debit).''.price($total_credit).''.price(price2num($total_opening_balance + $total_debit - $total_credit)).''; print " \n"; print ''; From 7ca1df6d4658285a5ee4099eed09263f635d74ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 25 Nov 2020 17:12:56 +0100 Subject: [PATCH 17/65] remove warning --- htdocs/bom/bom_card.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 913ba862496..208a316c6e1 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -133,7 +133,7 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $idprod = GETPOST('idprod', 'int'); + $idprod = (int) GETPOST('idprod', 'int'); $qty = GETPOST('qty', 'int'); $qty_frozen = GETPOST('qty_frozen', 'int'); $disable_stock_change = GETPOST('disable_stock_change', 'int'); @@ -172,8 +172,7 @@ if (empty($reshook)) $bomline->position = ($ranktouse + 1); $result = $bomline->create($user); - if ($result <= 0) - { + if ($result <= 0) { setEventMessages($bomline->error, $bomline->errors, 'errors'); $action = ''; } else { From 5ff3ab528c3206b9ae428785bfee2dc0a0ff6e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 25 Nov 2020 17:15:06 +0100 Subject: [PATCH 18/65] remove warning --- htdocs/bookmarks/card.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 7cc69ac9a61..ddb043292f6 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -37,8 +37,8 @@ if (!$user->rights->bookmark->lire) { $id = GETPOST("id", 'int'); $action = GETPOST("action", "alpha"); -$title = GETPOST("title", "alpha"); -$url = GETPOST("url", "alpha"); +$title = (string) GETPOST("title", "alpha"); +$url = (string) GETPOST("url", "alpha"); $urlsource = GETPOST("urlsource", "alpha"); $target = GETPOST("target", "alpha"); $userid = GETPOST("userid", "int"); @@ -71,8 +71,9 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') if ($action == 'update') $object->fetch(GETPOST("id", 'int')); // Check if null because user not admin can't set an user and send empty value here. - if (!empty($userid)) + if (!empty($userid)) { $object->fk_user = $userid; + } $object->title = $title; $object->url = $url; $object->target = $target; From 16e3baeff2e7851e1f92a5ddcd8d843e9da82e75 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Nov 2020 17:28:53 +0100 Subject: [PATCH 19/65] FIX filter on project list --- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/projet/list.php | 41 +++++++++++++------------ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e07bbcac70e..0f85d824ca2 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1733,7 +1733,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 1) { $newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list'); - $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); + $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99&search_opp_status=openedopp&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode); } elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 43d0e0b7f7f..2f58c782c24 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -402,28 +402,29 @@ $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -if ($search_all != '') $param .= '&search_all='.$search_all; -if ($search_sday) $param .= '&search_sday='.$search_sday; -if ($search_smonth) $param .= '&search_smonth='.$search_smonth; -if ($search_syear) $param .= '&search_syear='.$search_syear; -if ($search_eday) $param .= '&search_eday='.$search_eday; -if ($search_emonth) $param .= '&search_emonth='.$search_emonth; -if ($search_eyear) $param .= '&search_eyear='.$search_eyear; -if ($socid) $param .= '&socid='.$socid; -if ($search_ref != '') $param .= '&search_ref='.$search_ref; -if ($search_label != '') $param .= '&search_label='.$search_label; -if ($search_societe != '') $param .= '&search_societe='.$search_societe; -if ($search_status >= 0) $param .= '&search_status='.$search_status; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($search_all != '') $param .= '&search_all='.urlencode($search_all); +if ($search_sday) $param .= '&search_sday='.urlencode($search_sday); +if ($search_smonth) $param .= '&search_smonth='.urlencode($search_smonth); +if ($search_syear) $param .= '&search_syear='.urlencode($search_syear); +if ($search_eday) $param .= '&search_eday='.urlencode($search_eday); +if ($search_emonth) $param .= '&search_emonth='.urlencode($search_emonth); +if ($search_eyear) $param .= '&search_eyear='.urlencode($search_eyear); +if ($socid) $param .= '&socid='.urlencode($socid); +if ($search_categ) $param .= '&search_categ='.urlencode($search_categ); +if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref); +if ($search_label != '') $param .= '&search_label='.urlencode($search_label); +if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); +if ($search_status >= 0) $param .= '&search_status='.urlencode($search_status); if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); if ($search_opp_percent != '') $param .= '&search_opp_percent='.urlencode($search_opp_percent); -if ($search_public != '') $param .= '&search_public='.$search_public; -if ($search_project_user != '') $param .= '&search_project_user='.$search_project_user; -if ($search_sale > 0) $param .= '&search_sale='.$search_sale; -if ($search_opp_amount != '') $param .= '&search_opp_amount='.$search_opp_amount; -if ($search_budget_amount != '') $param .= '&search_budget_amount='.$search_budget_amount; -if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if ($search_public != '') $param .= '&search_public='.urlencode($search_public); +if ($search_project_user != '') $param .= '&search_project_user='.urlencode($search_project_user); +if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); +if ($search_opp_amount != '') $param .= '&search_opp_amount='.urlencode($search_opp_amount); +if ($search_budget_amount != '') $param .= '&search_budget_amount='.urlencode($search_budget_amount); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; From 74605cec128d942007add98f3ad1df88645320db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Nov 2020 18:07:52 +0100 Subject: [PATCH 20/65] Fix warning --- htdocs/bom/tpl/objectline_create.tpl.php | 4 ++-- htdocs/bom/tpl/objectline_edit.tpl.php | 2 +- htdocs/bom/tpl/objectline_title.tpl.php | 2 +- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- htdocs/contrat/card.php | 8 ++++---- htdocs/core/class/commondocgenerator.class.php | 2 +- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 10 +++++----- .../core/modules/commande/doc/pdf_einstein.modules.php | 6 +++--- .../modules/commande/doc/pdf_eratosthene.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 +- .../core/modules/product/doc/pdf_standard.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 6 +++--- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 +- .../supplier_invoice/doc/pdf_canelle.modules.php | 2 +- .../modules/supplier_order/doc/pdf_cornas.modules.php | 2 +- .../supplier_order/doc/pdf_muscadet.modules.php | 6 +++--- .../supplier_proposal/doc/pdf_aurore.modules.php | 6 +++--- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- htdocs/core/tpl/objectline_title.tpl.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 2 +- htdocs/core/tpl/originproductline.tpl.php | 2 +- .../mymodule/doc/pdf_standard_myobject.modules.php | 2 +- htdocs/product/card.php | 4 ++-- htdocs/product/fournisseurs.php | 6 +++--- .../pdf_standard_recruitmentjobposition.modules.php | 2 +- 27 files changed, 47 insertions(+), 47 deletions(-) diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index a7bb62c9901..d29cdb7c6bb 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -60,7 +60,7 @@ if ($nolinesbefore) { print '
'.$langs->trans('AddNewLine').''; print ''; print ''.$langs->trans('Qty').''; - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; print ''; @@ -109,7 +109,7 @@ $coldisplay++; print ''; print ''; -if ($conf->global->PRODUCT_USE_UNITS) +if (!empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 873e7d724b2..77638b875ff 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -108,7 +108,7 @@ if (($line->info_bits & 2) != 2) { } print ''; -if ($conf->global->PRODUCT_USE_UNITS) +if (!empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 56e6cb59657..ad9c54a34ea 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -54,7 +54,7 @@ print ''.$langs->trans('Description').''; // Qty print ''.$form->textwithpicto($langs->trans('Qty'), $langs->trans("QtyRequiredIfNoLoss")).''; -if ($conf->global->PRODUCT_USE_UNITS) +if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''.$langs->trans('Unit').''; } diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index ecaf9117aae..87c1a72789d 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -79,7 +79,7 @@ $coldisplay++; echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price print ''; -if ($conf->global->PRODUCT_USE_UNITS) +if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; $label = $tmpproduct->getLabelOfUnit('long'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index deec72912df..68582d2fb33 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1477,7 +1477,7 @@ if ($action == 'create') // print ''.$langs->trans("PriceUHTCurrency").''; //} print ''.$langs->trans("Qty").''; - if ($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans("Unit").''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) print ''.$langs->trans("Unit").''; print ''.$langs->trans("ReductionShort").''; if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''.$langs->trans("BuyingPrice").''; print ' '; @@ -1538,7 +1538,7 @@ if ($action == 'create') // Quantity print ''.$objp->qty.''; // Unit - if ($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) print ''.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).''; // Discount if ($objp->remise_percent > 0) { @@ -1682,7 +1682,7 @@ if ($action == 'create') print ''; // Unit - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; print $form->selectUnits($objp->fk_unit, "unit"); @@ -1706,7 +1706,7 @@ if ($action == 'create') $colspan = 6; if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) $colspan++; - if ($conf->global->PRODUCT_USE_UNITS) $colspan++; + if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; // Ligne dates prevues print ''; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 1cd873c64c6..c25519e151f 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -625,7 +625,7 @@ abstract class CommonDocGenerator ); // Units - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long')); $resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short')); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9c58ff6d232..ace39ade0ef 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4252,7 +4252,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency').''; print ''.$langs->trans('Qty').''; - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''.$langs->trans('Unit').''; } @@ -4395,7 +4395,7 @@ abstract class CommonObject $this->tpl['price'] = price($line->subprice); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; - if ($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; // Is the line strike or not diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a1253aa578b..0c7b9d46f3c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2113,7 +2113,7 @@ class Form $outarray = array(); // Units - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $langs->load('other'); } @@ -2752,7 +2752,7 @@ class Form $langs->load('stocks'); // Units - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $langs->load('other'); } @@ -2761,7 +2761,7 @@ class Form $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; $sql .= " pfp.supplier_reputation"; // Units - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; } if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode"; @@ -2770,7 +2770,7 @@ class Form if ($socid) $sql .= " AND pfp.fk_soc = ".$socid; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; // Units - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; } $sql .= " WHERE p.entity IN (".getEntity('product').")"; @@ -2837,7 +2837,7 @@ class Form // Units $outvalUnits = ''; - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { if (!empty($objp->unit_short)) { $outvalUnits .= ' - '.$objp->unit_short; } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 7f5a18e2521..7b50d24f557 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -166,7 +166,7 @@ class pdf_einstein extends ModelePDFCommandes // Define position of columns $this->posxdesc = $this->marge_gauche + 1; - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->posxtva = 101; $this->posxup = 118; @@ -490,7 +490,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); @@ -1207,7 +1207,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 36374ce66b7..159ff81e33e 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1815,7 +1815,7 @@ class pdf_eratosthene extends ModelePDFCommandes ), 'border-left' => true, // add left line separator ); - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 646b4831697..b295150488b 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2321,7 +2321,7 @@ class pdf_sponge extends ModelePDFFactures ), 'border-left' => true, // add left line separator ); - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 66f17e21e5a..82143123c40 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -656,7 +656,7 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index b88a3d367dd..a5a6b850f7f 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -166,7 +166,7 @@ class pdf_azur extends ModelePDFPropales // Define position of columns $this->posxdesc = $this->marge_gauche + 1; - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->posxtva = 101; $this->posxup = 118; @@ -583,7 +583,7 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); @@ -1381,7 +1381,7 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 91aaa9de4a4..5524460bfc8 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1968,7 +1968,7 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => true, // add left line separator ); - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 2409ffeca54..4ea8fcc585d 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -161,7 +161,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->posxdiscount = 162; $this->postotalht = 174; - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->posxtva = 99; $this->posxup = 114; $this->posxqty = 130; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 6c1b5aef21d..12092153e83 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1562,7 +1562,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders ), 'border-left' => true, // add left line separator ); - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 1595659093c..bc91d690f36 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -162,7 +162,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->posxdiscount = 162; $this->postotalht = 174; - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->posxtva = 95; $this->posxup = 114; @@ -528,7 +528,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); @@ -1057,7 +1057,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 8022bcbae86..3aafb09aa86 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -159,7 +159,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->posxdiscount = 162; $this->postotalht = 174; - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->posxtva = 101; $this->posxup = 118; @@ -521,7 +521,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); @@ -1216,7 +1216,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 401e1079d35..52b50475744 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -105,7 +105,7 @@ if ($nolinesbefore) { trans('Qty'); ?> global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; print ''; diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index cb72107cb89..5f0073a57b2 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -189,7 +189,7 @@ $coldisplay++; global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 1154dd61834..495e0f6ad2b 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -89,7 +89,7 @@ if ($inputalsopricewithtax) print ''.$lang // Qty print ''.$langs->trans('Qty').''; -if ($conf->global->PRODUCT_USE_UNITS) +if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''.$langs->trans('Unit').''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 46baa6a0b83..c6ffe090c52 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -223,7 +223,7 @@ if ((($line->info_bits & 2) != 2) && $line->special_code != 3) { } else print ' '; print ''; -if ($conf->global->PRODUCT_USE_UNITS) +if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''; $label = $line->getLabelOfUnit('short'); diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 1b996556253..bd87008d0f8 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -36,7 +36,7 @@ if (!empty($conf->multicurrency->enabled)) print ''.$this->tpl['multicurrency_price'].''; print ''.$this->tpl['qty'].''; -if ($conf->global->PRODUCT_USE_UNITS) +if (!empty($conf->global->PRODUCT_USE_UNITS)) print ''.$langs->trans($this->tpl['unit']).''; print ''.$this->tpl['remise_percent'].''; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 0771d970985..e8e39ec2adb 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -1300,7 +1300,7 @@ class pdf_standard_myobject extends ModelePDFMyObject ), 'border-left' => true, // add left line separator ); - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 4e71bceb50e..6fdfb82e354 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1151,7 +1151,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Units - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''.$langs->trans('DefaultUnitToShow').''; print ''; @@ -1610,7 +1610,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } } // Units - if ($conf->global->PRODUCT_USE_UNITS) + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''.$langs->trans('DefaultUnitToShow').''; print ''; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 1f5af12d3f2..d30c10408f1 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -519,7 +519,7 @@ if ($id > 0 || $ref) print ''; } // Units - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit = $object->getLabelOfUnit(); if ($unit !== '') { print '  '.$langs->trans($unit); @@ -537,7 +537,7 @@ if ($id > 0 || $ref) print ''; // Units - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit = $object->getLabelOfUnit(); if ($unit !== '') { print '  '.$langs->trans($unit); @@ -1000,7 +1000,7 @@ END; print ''; print $productfourn->fourn_qty; // Units - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit = $object->getLabelOfUnit(); if ($unit !== '') { print '  '.$langs->trans($unit); diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 378376ea799..af62344296b 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -1213,7 +1213,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio ), 'border-left' => true, // add left line separator ); - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $this->cols['unit']['status'] = true; } From 83f6e9dfc260bfb3a4eb14cce0b29758d8f0755d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 25 Nov 2020 18:08:13 +0100 Subject: [PATCH 21/65] doxygen --- htdocs/commande/class/commande.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 9de479dcb52..b2d0c57f4ad 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4036,11 +4036,22 @@ class OrderLine extends CommonOrderLine public $commande_id; public $fk_parent_line; + + /** + * @var int Id of invoice + */ public $fk_facture; + /** + * @var string External ref + */ public $ref_ext; public $fk_remise_except; + + /** + * @var int line rank + */ public $rang = 0; public $fk_fournprice; From d9759c4a54016533eab8940ce9d3522f8f01728e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 25 Nov 2020 18:12:59 +0100 Subject: [PATCH 22/65] doxygen --- htdocs/contrat/class/api_contracts.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 20604f25798..e4479a0a857 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -301,7 +301,7 @@ class Contracts extends DolibarrApi * * @url PUT {id}/lines/{lineid} * - * @return array|bool + * @return Object|bool */ public function putLine($id, $lineid, $request_data = null) { @@ -361,7 +361,7 @@ class Contracts extends DolibarrApi * * @url PUT {id}/lines/{lineid}/activate * - * @return array|bool + * @return Object|bool */ public function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) { @@ -399,7 +399,7 @@ class Contracts extends DolibarrApi * * @url PUT {id}/lines/{lineid}/unactivate * - * @return array|bool + * @return Object|bool */ public function unactivateLine($id, $lineid, $datestart, $comment = null) { From 9e562537047b1c46c9bfd5bb36872684d87ebad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 25 Nov 2020 18:37:03 +0100 Subject: [PATCH 23/65] Update expensereport.class.php --- htdocs/expensereport/class/expensereport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 6f6f4bbd010..bfe7857eb4e 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1091,7 +1091,7 @@ class ExpenseReport extends CommonObject if (!$notrigger) { // Call trigger - $result = $this->call_trigger('EXPENSEREPORT_DELETE', $user); + $result = $this->call_trigger('EXPENSEREPORT_DELETE', $fuser); if ($result < 0) { $error++; } // End call triggers } From f333dffa4bf3fc6239f344f55ba55d74f9a8e980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 25 Nov 2020 18:45:25 +0100 Subject: [PATCH 24/65] doxygen --- htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php index 29721ea171f..234c067bf7a 100644 --- a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php @@ -168,7 +168,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase * testMyObjectDelete * * @param int $id Id of object - * @return void + * @return int * * @depends testMyObjectCreate * The depends says test is run only if previous is ok From d1cded49a9493f44f7b3220d50ebd0a3acca69a8 Mon Sep 17 00:00:00 2001 From: proprum <51385888+proprum@users.noreply.github.com> Date: Wed, 25 Nov 2020 19:47:30 +0100 Subject: [PATCH 25/65] Adding require_once files.lib to fourn/paiement. Bug when there is a calculated extrafield which use "dol_dir_list" for calculating the amount of files attached to a invoice With bonus : the integer calculated extrafield configuration : count(dol_dir_list($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').dol_sanitizeFileName($object->ref),'files',0,'','(\.meta|_preview.*\.png)$')); --- htdocs/fourn/facture/paiement.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index c94a1f95272..8a7e0cc8054 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'banks', 'compta')); From c1a1d4330a21426f99abaa2a8dcd7122cd45f5dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Nov 2020 19:55:11 +0100 Subject: [PATCH 26/65] Update expensereport.class.php --- htdocs/expensereport/class/expensereport.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index bfe7857eb4e..84672d90974 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1076,11 +1076,11 @@ class ExpenseReport extends CommonObject /** * Delete object in database * - * @param User $fuser User that delete + * @param User $user User that delete * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, >0 if OK */ - public function delete(User $fuser = null, $notrigger = false) + public function delete(User $user = null, $notrigger = false) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1091,7 +1091,7 @@ class ExpenseReport extends CommonObject if (!$notrigger) { // Call trigger - $result = $this->call_trigger('EXPENSEREPORT_DELETE', $fuser); + $result = $this->call_trigger('EXPENSEREPORT_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } From 22bcb089504320083a23a85c8a73e93d8358dce7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Nov 2020 23:03:17 +0100 Subject: [PATCH 27/65] Update doc --- ChangeLog | 97 ++++++++++++++++-------------------- htdocs/langs/en_US/main.lang | 1 + 2 files changed, 44 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16811fd8f8b..4745cea7736 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,12 +9,12 @@ For users: ---------- NEW: Add module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files. NEW: Module Reception (for a more accurate management of your receptions) moved from experimental to stable. +NEW: Module Recruitment to manage Job position and applications. NEW: Several security issues after a private bug bounty campaign. -NEW: #15065 Put the product label in bold in the PDF templates if configured NEW: Accountancy - add chart of sub accounts NEW: Accountancy - add options to disable binding on sales, purchases & expense reports independently of the modules NEW: Accountancy balance - add a menu entry to show subtotal by group -NEW: Accountancy - move to real ledger, real journals, menu disposition +NEW: Accountancy - change menu disposition NEW: Accountancy - on transfers, select the periodicity by default NEW: Accountancy - Add export for Gestinum (v3 & v5) NEW: new currency rate editor @@ -29,25 +29,20 @@ NEW: Support documents generation for ticket edition (PDF or ODT) NEW: add column payment term into list of supplier invoices NEW: add column quantity in product margin page NEW: add column vat rate in page to define accounting account on product/service -NEW: add common list function for available app/module page NEW: add costprice in fields of products list NEW: added an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE -NEW: added incoterms data into the substitution array NEW: add employee link in expense report binding page NEW: add EORI No. as ProfID5 -NEW: add export for various payment +NEW: add export for various payments NEW: add Extrafields labels and values in mail on create ticket NEW: add Extrafields support on ECM module NEW: add filter rules "is answer" and "is not answer" in email collector NEW: add focus when editing on product/stock/product.php Close #14548 -NEW: add formConfirm hook on product page NEW: add free text on each terminal of cash desk -NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open NEW: add global search for customer payments and vendor payments NEW: add global search for miscellaneous payments NEW: add helper function for table headers with numbers -NEW: add hooks on stats pages -NEW: add link to edit property from search result of website pages +NEW: add link to edit property from the search result of website pages NEW: add link to reset qty on supplier dispatch page NEW: add MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const to remove header stored by email collector NEW: add Manufacturing Orders attached files into the automatic ECM view @@ -55,9 +50,6 @@ NEW: add margin info in invoice list NEW: add mass action to set category on a list of website pages NEW: add mass deletion for events NEW: add mass deletion for draft invoices -NEW: add __MEMBER_TYPE__ substitution key -NEW: add a message in error_log after detection of SQL or script injection -NEW: add module Credit transfer SEPA to manage payment of supplier using NEW: add more filters on monthly statement list NEW: add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT NEW: add option to define a default warehouse at user level @@ -65,35 +57,27 @@ NEW: add option to include products without alert in replenish NEW: add order by lastname and firstname by default in get sales representatives NEW: add param to not show links when output tags NEW: add PDF document templates for warehouses (list of stock) -NEW: add property cssview when declaring fields of an object -NEW: add prospect status managment for the contact with managment of custom icon +NEW: add a prospect status for the contact with managment of custom icon NEW: add public note on products ; this also partially fix the #14342 -NEW: add quick dropdown menu in top right menu (MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN) +NEW: add quick dropdown menu in top right menu (experimental with MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN) NEW: add region in export companies and contacts NEW: add rights on margin info on invoice list NEW: add search param for close date on order list -NEW: add send context for ticket NEW: add show preview for mail attachement on form mail -NEW: add state origin for product NEW: add State/Province origin for products NEW: add the workflow interaction close intervention on closing ticket NEW: add third order printer to TakePOS NEW: add tracking number in list and search_all items -NEW: add two hooks printFieldListFrom and printFieldSearchParam -NEW: add __TYPE__ substitution key -NEW: add validation of MX domain for emails NEW: add vcard for adherent and user NEW: add week number for month view in agenda -NEW: Algeria data (TVA and forme_juridique) +NEW: Algeria data (VAT and forme_juridique) NEW: allow click on all header numbers on commerce area NEW: allow to reopen interventions (green button) -NEW: allow zero quality on supplier/vendor order line +NEW: allow zero quantity on supplier/vendor order line NEW: appearance tab in TakePOS with more visual parameters NEW: better currency rate editor -NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') ) -NEW: can add event to log into blockedlog module with a constant NEW: can build vendor invoice from vendor orders -NEW: can change a product in line of recurring invoice or contract +NEW: can change a product in lines of a recurring invoice or contract NEW: can change size of logo on PDF documents NEW: can change VAT rate of all lines of a draft object in one step NEW: can define date range of validity of a login during creation @@ -102,47 +86,34 @@ NEW: can edit and set sales representatives directly on thirdparty card NEW: can edit the list of sending email profiles NEW: can enable/disable users in bulk actions NEW: can filter on accounting system ref in export of chart of account -NEW: can filter on container type, language and tags in the list of pages -NEW: can force the antivirus from conf file or autoprepend ini setup +NEW: can filter on container type, language and tags in the list of web pages NEW: can hide eatby, sellby dates with option PRODUCT_DISABLE_SELLBY and PRODUCT_DISABLE_EATBY NEW: can import proposals, sales orders, supplier invoices NEW: can set a dedicated SMTP config for sending email from public ticket interface NEW: can set tags/categories to website pages NEW: can set type of price without tax per default for new sale price creation NEW: can use desired stock of a given warehouse for replenishment -NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode NEW: change thirdparty with barcode scan in TakePOS NEW: common behavior for monthly leave list view -NEW: conf to allow show full arbo in warehouse getnomurl NEW: convert all subscription in datetime -NEW: create thirdparty customer from TakePOS +NEW: can create a thirdparty customer from TakePOS NEW: date shipment from order accepts hours -NEW: declinaison price level compatibility +NEW: price level compatibility for variant NEW: delayed payment in TakePOS -NEW: development of module Recruitment NEW: display date range if exist in TakePOS NEW: display resiliate status in TakePOS for member NEW: display stat for BOM on "object referent"/linked Object product tab -NEW: edit and update a ticket -NEW: edit or delete dispatched lines -NEW: Email configuration - allow auto signed certificat when smtp ssl activated +NEW: Email configuration - allow auto signed certificate when smtp ssl activated NEW: enable free emails input with select2 -NEW: endpoint getContacts and Clean results NEW: Events in agenda for contact -NEW: Field to link website page to an other object -NEW: fill ECM src object fields in dol_add_file_process NEW: filter on progress column in task list NEW: filter product list by country and/or state/province NEW: format tickets sent by mail in public interface -NEW: add juridical status for Algeria NEW: form to add customer/supplier into categories NEW: Framework is ready for CSRF token protection on explicit GET URLs -NEW: get all child recursively -NEW: get contacts list of a given order NEW: helper functions for export with phpspreadsheet NEW: hide closed contract lines NEW: hide label in PDF for variants -NEW: Hook on propal card NEW: if specific help page is available, we change color of icon NEW: include the tag editor of page as a popup into website editor NEW: introduce constant FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM @@ -168,21 +139,17 @@ NEW: rate editor for multicurrency NEW: ref_ext field for Commande lines, order lines, Attributes and Combinations, Invoice lines, payments, order lines NEW: remove new lines in mail on add ticket message NEW: restrict thirdparty to customer in TakePOS -NEW: allow to edit "demand reason" field though API NEW: Rule "email to" accept wildcard * NEW: Save filter of the project homepage -NEW: select-able columns on customer invoice paymnet list +NEW: select-able columns on customer and supplier invoice paymnet list NEW: select-able columns on miscellaneous payments + more data columns NEW: select-able columns on social taxes list -NEW: select-able columns on supplier invoice payment list NEW: send context and remove new lines on create ticket -NEW: set entity when creating invoice on takepos NEW: show available stock in TakePOS NEW: show category filter on lists only when user have rights to read categories -NEW: show header number and make it clickable in warehouse arean, payment area, shipment area +NEW: show header number and make it clickable in warehouse area, payment area, shipment area NEW: show image of user in the combo select of users NEW: show label on batch card -NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER) NEW: show links for select and multi-select in category extra field NEW: show module and permission ids on user/group rights (only admin) NEW: show place from events on import calender @@ -200,19 +167,33 @@ NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding am NEW: ticket classification on create from email collector NEW: Ticket message notifications when edited from public interface NEW: translate classification labels in ticket -NEW: triggers create, modify, delete -NEW: VAT for Algeria -NEW: Use preselect third-party from list on new card -NEW: VAT report - Invert constant to show by default zero vat in reports +NEW: Add VAT and juridical status for Algeria +NEW: VAT report - Invert constant to show by default zero VAT in reports NEW: website page fields selection NEW: Weighing Scale compatibility with TakePOS connector -NEW: when creating a user from a member linked to a thirdparty, you can choose to create if as external or internal user -NEW: add clone functionality on miscellaneous payment +NEW: when creating a user from a member linked to a thirdparty, you can choose to create it as external or internal user +NEW: add clone button on miscellaneous payment +NEW: #15065 Add option to put the product label in bold in the PDF templates if configured For developers: --------------- +NEW: Hook on propal card +NEW: add __MEMBER_TYPE__ substitution key +NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open page into a popup +NEW: add hooks on stats pages +NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER) +NEW: API get contacts list of a given order +NEW: API endpoint getContacts and Clean results +NEW: Add some fields to link website page to an other object +NEW: fill ECM src object fields in dol_add_file_process +NEW: conf to allow to show the full tree in warehouse popup +NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode +NEW: can force the antivirus from conf file or autoprepend ini setup +NEW: can add event to log into blockedlog module with a constant +NEW: add property cssview when declaring fields of an object NEW: Can use dynamic code into the 'enabled' property of DAO fields +NEW: allow to edit "demand reason" field though API NEW: API can update a payment NEW: API get member by thirdparty NEW: API get thirdparty by barcode @@ -230,6 +211,14 @@ NEW: Thirdparty REST API: endpoint to set price level NEW: use new category API for project list view NEW: Triggers Attributes and Attributes values NEW: add hooks on newpayment page to allow external payment modules +NEW: added incoterms data into the substitution array +NEW: add formConfirm hook on product page +NEW: add send context for ticket +NEW: add a message in error_log after detection of SQL or script injection +NEW: add two hooks printFieldListFrom and printFieldSearchParam +NEW: add __TYPE__ substitution key +NEW: add validation of MX domain for emails +NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') ) WARNING: diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b17c3d8b8c5..3ed9bbbae88 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1105,3 +1105,4 @@ SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry=Security token has exp UpToDate=Up-to-date OutOfDate=Out-of-date EventReminder=Event Reminder +UpdateForAllLines=Update for all lines \ No newline at end of file From 55f26179f222cc40a743ee624a080539b6cb3e0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 08:37:52 +0100 Subject: [PATCH 28/65] Fix phpunit --- test/phpunit/CodingPhpTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 727f8cc0ee3..9acb13432d2 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -281,7 +281,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase preg_match_all('/sql.+\s*\'"\s*\.\s*\$(.........)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { - if (! in_array($val[1], array('this->db-', 'this->esc', 'db->escap', 'dbsession->escap', 'db->idate', 'excludeGr', 'includeGr'))) { + if (! in_array($val[1], array('this->db-', 'this->esc', 'db->escap', 'dbsession', 'db->idate', 'excludeGr', 'includeGr'))) { $ok=false; break; } From e272130a6a22b3d804b6459235a630a249f361e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 08:40:08 +0100 Subject: [PATCH 29/65] Fix phpcs --- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/core/class/commonobject.class.php | 14 +++++++------- htdocs/core/lib/phpsessionindb.lib.php | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 299a9700364..097eb38b47f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -630,7 +630,7 @@ else $buttonLabel = $langs->trans("ExportList"); $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { -// Button re-export + // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { $newcardbutton = '' . img_picto($langs->trans("Activated"), 'switch_on') . ' '; } else { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ace39ade0ef..d7c46fba089 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8512,13 +8512,13 @@ abstract class CommonObject } $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files"; - $sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return false; - } + $sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return false; + } } $this->db->commit(); diff --git a/htdocs/core/lib/phpsessionindb.lib.php b/htdocs/core/lib/phpsessionindb.lib.php index 585967965dc..d0e96434d00 100644 --- a/htdocs/core/lib/phpsessionindb.lib.php +++ b/htdocs/core/lib/phpsessionindb.lib.php @@ -163,4 +163,3 @@ function dolSessionGC($max_lifetime) // Call to register user call back functions. session_set_save_handler("dolSessionOpen", "dolSessionClose", "dolSessionRead", "dolSessionWrite", "dolSessionDestroy", "dolSessionGC"); - From 69b06a25e8525cd84aa4e3a376b619afc92661f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 09:16:16 +0100 Subject: [PATCH 30/65] Fix code of deletion of objects --- htdocs/comm/propal/class/propal.class.php | 33 ++--- htdocs/commande/class/commande.class.php | 117 ++++++++---------- htdocs/compta/facture/class/facture.class.php | 5 + .../class/expensereport.class.php | 37 +++--- 4 files changed, 94 insertions(+), 98 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 50c63137c67..bc588f430d9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2947,10 +2947,23 @@ class Propal extends CommonObject if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } + if (!$error) { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + } + + if (!$error) { + // Delete linked contacts + $res = $this->delete_linked_contact(); + if ($res < 0) $error++; + } + // Removed extrafields of object if (!$error) { $result = $this->deleteExtraFields(); @@ -2966,25 +2979,15 @@ class Propal extends CommonObject $res = $this->db->query($sql); if (! $res) { $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (! $error) { - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; - } - - if (! $error) { - // Delete linked contacts - $res = $this->delete_linked_contact(); - if ($res < 0) $error++; - } - // Delete record into ECM index and physically if (!$error) { - $res = $this->deleteEcmFiles(); // Deleting files physically is done later with the dol_delete_dir_recursive + $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive if (! $res) { $error++; } @@ -3001,7 +3004,7 @@ class Propal extends CommonObject if (!dol_delete_file($file, 0, 0, 0, $this)) { $this->error = 'ErrorFailToDeleteFile'; - $this->errors = array('ErrorFailToDeleteFile'); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -3010,7 +3013,7 @@ class Propal extends CommonObject $res = @dol_delete_dir_recursive($dir); if (!$res) { $this->error = 'ErrorFailToDeleteDir'; - $this->errors = array('ErrorFailToDeleteDir'); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b2d0c57f4ad..7166a491118 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3342,106 +3342,95 @@ class Commande extends CommonOrder $this->db->begin(); - if (!$error && !$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('ORDER_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { $error++; } // End call triggers } + // Test we can delete if ($this->nb_expedition() != 0) { $this->errors[] = $langs->trans('SomeShipmentExists'); $error++; } - if (!$error) - { - // Delete extrafields of order details - $main = MAIN_DB_PREFIX.'commandedet'; - $ef = $main."_extrafields"; - $sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")"; - if (!$this->db->query($sql)) - { + // Delete extrafields of lines and lines + if (!$error && !empty($this->table_element_line)) { + $tabletodelete = $this->table_element_line; + $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; + if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { $error++; - $this->errors[] = $this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (!$error) - { - // Delete order details - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = ".$this->id; - if (!$this->db->query($sql)) - { - $error++; - $this->errors[] = $this->db->lasterror(); - } - } - - if (!$error) - { + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; } - if (!$error) - { + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); if ($res < 0) $error++; } - if (!$error) - { - // Remove extrafields + // Removed extrafields of object + if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (!$error) - { - // Delete object - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id; - if (!$this->db->query($sql)) - { + // Delete main record + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; + $res = $this->db->query($sql); + if (! $res) { $error++; - $this->errors[] = $this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (!$error) - { - // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive - $this->deleteEcmFiles(); + // Delete record into ECM index and physically + if (!$error) { + $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive + if (! $res) { + $error++; + } + } - // Remove directory with files - $comref = dol_sanitizeFileName($this->ref); - if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref)) - { - $dir = $conf->commande->multidir_output[$this->entity]."/".$comref; - $file = $conf->commande->multidir_output[$this->entity]."/".$comref."/".$comref.".pdf"; - if (file_exists($file)) // We must delete all files before deleting directory - { + if (!$error) { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref)) { + $dir = $conf->commande->multidir_output[$this->entity]."/".$ref; + $file = $dir."/".$ref.".pdf"; + if (file_exists($file)) { dol_delete_preview($this); - if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers - { + if (!dol_delete_file($file, 0, 0, 0, $this)) { + $this->error = 'ErrorFailToDeleteFile'; + $this->errors[] = $this->error; $this->db->rollback(); return 0; } } - if (file_exists($dir)) - { - if (!dol_delete_dir_recursive($dir)) - { - $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); + if (file_exists($dir)) { + $res = @dol_delete_dir_recursive($dir); + if (!$res) { + $this->error = 'ErrorFailToDeleteDir'; + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -3449,17 +3438,13 @@ class Commande extends CommonOrder } } - if (!$error) - { + if (!$error) { + dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); $this->db->commit(); return 1; } else { - foreach ($this->errors as $errmsg) - { - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } $this->db->rollback(); - return -1 * $error; + return -1; } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 51051625db6..a3d64bb0c2e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2184,6 +2184,7 @@ class Facture extends CommonInvoice if (!$this->db->query($sql)) { $this->error = $this->db->error()." sql=".$sql; + $this->errors[] = $this->error; $this->db->rollback(); return -5; } @@ -2244,6 +2245,7 @@ class Facture extends CommonInvoice { $langs->load("errors"); $this->error = $langs->trans("ErrorFailToDeleteFile", $file); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -2254,6 +2256,7 @@ class Facture extends CommonInvoice { $langs->load("errors"); $this->error = $langs->trans("ErrorFailToDeleteDir", $dir); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -2264,11 +2267,13 @@ class Facture extends CommonInvoice return 1; } else { $this->error = $this->db->lasterror()." sql=".$sql; + $this->errors[] = $this->error; $this->db->rollback(); return -6; } } else { $this->error = $this->db->lasterror()." sql=".$sql; + $this->errors[] = $this->error; $this->db->rollback(); return -4; } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 84672d90974..02c315b8e70 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1104,10 +1104,23 @@ class ExpenseReport extends CommonObject if (! $this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } + if (!$error) { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + } + + if (!$error) { + // Delete linked contacts + $res = $this->delete_linked_contact(); + if ($res < 0) $error++; + } + // Removed extrafields of object if (!$error) { $result = $this->deleteExtraFields(); @@ -1123,25 +1136,15 @@ class ExpenseReport extends CommonObject $res = $this->db->query($sql); if (! $res) { $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; dol_syslog(get_class($this)."::delete error ".$this->error, LOG_ERR); } } - if (! $error) { - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; - } - - if (! $error) { - // Delete linked contacts - $res = $this->delete_linked_contact(); - if ($res < 0) $error++; - } - // Delete record into ECM index and physically if (!$error) { - $res = $this->deleteEcmFiles(); // Deleting files physically is done later with the dol_delete_dir_recursive + $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive if (! $res) { $error++; } @@ -1150,15 +1153,15 @@ class ExpenseReport extends CommonObject if (!$error) { // We remove directory $ref = dol_sanitizeFileName($this->ref); - if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) { - $dir = $conf->propal->multidir_output[$this->entity]."/".$ref; + if ($conf->expensereport->multidir_output[$this->entity] && !empty($this->ref)) { + $dir = $conf->expensereport->multidir_output[$this->entity]."/".$ref; $file = $dir."/".$ref.".pdf"; if (file_exists($file)) { dol_delete_preview($this); if (!dol_delete_file($file, 0, 0, 0, $this)) { $this->error = 'ErrorFailToDeleteFile'; - $this->errors = array('ErrorFailToDeleteFile'); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } @@ -1167,7 +1170,7 @@ class ExpenseReport extends CommonObject $res = @dol_delete_dir_recursive($dir); if (!$res) { $this->error = 'ErrorFailToDeleteDir'; - $this->errors = array('ErrorFailToDeleteDir'); + $this->errors[] = $this->error; $this->db->rollback(); return 0; } From f14058f29ecd4f0f36a3d536b34981fef09ef22e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:09:09 +0100 Subject: [PATCH 31/65] Try conditional build with Travis --- .travis.yml | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 639183de6ff..278e5df88a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,6 @@ os: linux dist: xenial #dist: bionic -# Deprecated: The key sudo has no effect anymore. -#sudo: required language: php @@ -33,10 +31,10 @@ addons: # We need pgloader for import mysql database into pgsql - pgloader -php: -- '5.6' -- '7.4' -- nightly +#php: +#- '5.6' +#- '7.4' +#- nightly env: global: @@ -49,8 +47,6 @@ env: - DB=postgresql # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP #- WS=apache - # See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test - #- WS=nginx jobs: fast_finish: true @@ -58,24 +54,17 @@ jobs: - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: - - php: '7.0' - env: DB=mysql - - php: '7.1' - env: DB=mysql - - php: '7.2' - env: DB=mysql - - php: '7.3' - env: DB=mysql - - php: '7.0' - env: DB=postgresql - - php: '7.1' - env: DB=postgresql - - php: '7.2' - env: DB=postgresql - - php: '7.3' - env: DB=postgresql - php: nightly env: DB=postgresql + include: + - if: type = pull_request + php: '7.4' + - if: type = push + php: + - '5.6' + - '7.4' + - if: type = push AND branch = develop + php: nightly notifications: email: From c7e5b0dcc199d8f7abfe837baa0801b37b8eda6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:12:24 +0100 Subject: [PATCH 32/65] Fix warning --- htdocs/core/lib/pdf.lib.php | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cb5e638ce40..3e2fbf66eaa 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1338,28 +1338,23 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // We add ref of product (and supplier ref if defined) $prefix_prodserv = ""; $ref_prodserv = ""; - if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this - { - if ($prodser->isService()) - { + if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) { // In standard mode, we do not show this + if ($prodser->isService()) { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; } else { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; } } - if (empty($hideref)) - { - if ($issupplierline) - { - if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) - $ref_prodserv = $ref_supplier; - elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) - $ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; - else // Common case - { + if (empty($hideref)) { + if ($issupplierline) { + if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) { // Common case $ref_prodserv = $prodser->ref; // Show local ref if ($ref_supplier) $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : ''); + } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) { + $ref_prodserv = $ref_supplier; + } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) { + $ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; } } else { $ref_prodserv = $prodser->ref; // Show local ref only From 09d0ec391d13335c39ef6c00e7215872b48bb1f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:15:12 +0100 Subject: [PATCH 33/65] Test conditional job with travis --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 278e5df88a4..1a4471905dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,12 +57,10 @@ jobs: - php: nightly env: DB=postgresql include: - - if: type = pull_request - php: '7.4' - if: type = push - php: - - '5.6' - - '7.4' + php: '5.6' + - if: type = pull_request OR type = push + php: '7.4' - if: type = push AND branch = develop php: nightly From 341a059a2bfede95fd8e601ac6f045a9d59b05c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:19:01 +0100 Subject: [PATCH 34/65] Test travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1a4471905dc..a808fedccbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,8 +59,10 @@ jobs: include: - if: type = push php: '5.6' + env: DB=postgresql - if: type = pull_request OR type = push php: '7.4' + env: DB=mysql - if: type = push AND branch = develop php: nightly From 3236b1d74e29a3a40817e6fff3c8b3edba95b29d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 10:21:03 +0100 Subject: [PATCH 35/65] Test travis --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a808fedccbc..ef57f908cdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,11 +40,11 @@ env: global: # Set to true for very verbose output - DEBUG=false - jobs: + #jobs: # MariaDB overrides MySQL installation so it's not possible to test both yet #- DB=mariadb - - DB=mysql - - DB=postgresql + #- DB=mysql + #- DB=postgresql # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP #- WS=apache @@ -65,6 +65,7 @@ jobs: env: DB=mysql - if: type = push AND branch = develop php: nightly + env: DB=mysql notifications: email: From e1a6e8f2fcd7c52549540821bb9fc821dff07216 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 11:09:35 +0100 Subject: [PATCH 36/65] CSS Security: Add param to fight against Clickjacking attacks --- .travis.yml | 18 +------ htdocs/core/lib/admin.lib.php | 54 +++++++++---------- htdocs/core/website.inc.php | 4 +- htdocs/install/default.css | 4 +- htdocs/install/inc.php | 9 ++-- .../install/mysql/migration/12.0.0-13.0.0.sql | 1 + .../install/mysql/tables/llx_website_page.sql | 7 +-- htdocs/install/upgrade.php | 10 ++-- htdocs/install/upgrade2.php | 6 +-- htdocs/langs/en_US/website.lang | 3 +- htdocs/website/class/websitepage.class.php | 7 +++ htdocs/website/index.php | 42 +++++++++------ 12 files changed, 85 insertions(+), 80 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef57f908cdf..2479de608ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,31 +31,15 @@ addons: # We need pgloader for import mysql database into pgsql - pgloader -#php: -#- '5.6' -#- '7.4' -#- nightly - env: global: # Set to true for very verbose output - DEBUG=false - #jobs: - # MariaDB overrides MySQL installation so it's not possible to test both yet - #- DB=mariadb - #- DB=mysql - #- DB=postgresql - # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP - #- WS=apache jobs: fast_finish: true allow_failures: - php: nightly - # We exclude some combinations not usefull to save Travis CPU - exclude: - - php: nightly - env: DB=postgresql include: - if: type = push php: '5.6' @@ -416,7 +400,7 @@ script: php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log # Enable modules not enabled into original dump - php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log echo $? cd - set +e diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 6cab3638eb5..a697fcdfdc5 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -402,36 +402,36 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle } } - if ($error == 0) - { - if (!$silent) { - print ''.$langs->trans("ProcessMigrateScript").''; - print ''.$langs->trans("OK"); - //if (! empty($conf->use_javascript_ajax)) { - print ''; - print ' - '.$langs->trans("ShowHideDetails").''; - //} - print ''."\n"; + if (!$silent) { + print ''.$langs->trans("ProcessMigrateScript").''; + print ''; + if ($error == 0) { + print ''.$langs->trans("OK").''; + } else { + print ''.$langs->trans("Error").''; } + //if (! empty($conf->use_javascript_ajax)) { + print ''; + print ' - '.$langs->trans("ShowHideDetails").''; + //} + print ''."\n"; + } + + if ($error == 0) { $ok = 1; } else { - if (!$silent) { - print ''.$langs->trans("ProcessMigrateScript").''; - print ''.$langs->trans("KO").''; - print ''."\n"; - } $ok = 0; } diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 1e94b690c8f..7fe59ad9903 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -82,11 +82,9 @@ if ($pageid > 0) if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { header("X-Content-Type-Options: nosniff"); - /* TODO Manage allow_frames flag on websitepage. - if (empty($websitepage->allow_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) { + if (empty($websitepage->allowed_in_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) { header("X-Frame-Options: SAMEORIGIN"); } - */ } // A lang was forced, so we change weblangs init diff --git a/htdocs/install/default.css b/htdocs/install/default.css index b7fd69d9ecb..ca397d1ca40 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -233,10 +233,10 @@ table.listofchoices, table.listofchoices tr, table.listofchoices td { /* OK */ div.ok { - color: #114466; + color: #009933; } span.ok { - color: #114466; + color: #009933; } /* Warning */ diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index e770e41e89c..a0890866b51 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -425,9 +425,7 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas { global $conf, $langs; - $langs->load("main"); - $langs->load("other"); - $langs->load("admin"); + $langs->loadLangs(array("main", "other", "admin")); print ''."\n"; print ''."\n"; @@ -437,7 +435,10 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas print '
'; if ($nonext == '2') { - print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : '').'

'; + print ''; + print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"].'&ignoreerrors=1' : ''); + print ''; + print '

'; } print '"'; diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 9951375677c..c83755009ae 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -407,6 +407,7 @@ CREATE TABLE llx_ecm_directories_extrafields ) ENGINE=innodb; ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extrafields (fk_object); +ALTER TABLE llx_website_page ADD COLUMN allowed_in_frames integer DEFAULT 0; ALTER TABLE llx_website_page ADD COLUMN object_type varchar(255); ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255); diff --git a/htdocs/install/mysql/tables/llx_website_page.sql b/htdocs/install/mysql/tables/llx_website_page.sql index 4b1b3045d6b..499bf23d1f5 100644 --- a/htdocs/install/mysql/tables/llx_website_page.sql +++ b/htdocs/install/mysql/tables/llx_website_page.sql @@ -29,7 +29,8 @@ CREATE TABLE llx_website_page image varchar(255), keywords varchar(255), lang varchar(6), - fk_page integer, + fk_page integer, + allowed_in_frames integer DEFAULT 0, htmlheader text, content mediumtext, -- text is not enough in size status integer DEFAULT 1, @@ -40,6 +41,6 @@ CREATE TABLE llx_website_page date_creation datetime, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, import_key varchar(14), -- import key - object_type varchar(255), - fk_object varchar(255) + object_type varchar(255), -- To link page to an object + fk_object varchar(255) -- To link page to an object ) ENGINE=innodb; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index a7addd98547..29b51746a14 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -146,11 +146,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ if ($db->connected) { print ''; - print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.''.$langs->trans("OK").''."\n"; + print $langs->trans("ServerConnection")." : ".$dolibarr_main_db_host.''.$langs->trans("OK").''."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection").": $dolibarr_main_db_host ".$langs->transnoentities("OK")); $ok = 1; } else { - print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->transnoentities("Error")."\n"; + print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->transnoentities("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); $ok = 0; } @@ -160,11 +160,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ if ($db->database_selected) { print ''; - print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.''.$langs->trans("OK")."\n"; + print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name.''.$langs->trans("OK")."\n"; dolibarr_install_syslog("upgrade: Database connection successful: ".$dolibarr_main_db_name); $ok = 1; } else { - print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->trans("Error")."\n"; + print "".$langs->trans("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name).''.$langs->trans("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase", $dolibarr_main_db_name)); $ok = 0; } @@ -196,7 +196,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ && versioncompare($versionarray, $versionmindb) < 0) { // Warning: database version too low. - print "".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))."".$langs->trans("Error")."\n"; + print "".$langs->trans("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb)).''.$langs->trans("Error")."\n"; dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionTooLow", join('.', $versionarray), join('.', $versionmindb))); $ok = 0; } diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index a77606abb3f..2d84e234cf2 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -531,7 +531,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ print ''; } else { print ''; - print ''.$langs->trans('UpgradeExternalModule').': OK'; + print ''.$langs->trans('UpgradeExternalModule').': OK'; print ""; print ''; } @@ -1353,9 +1353,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) if ($insert_resql) { $nb++; - print ''.$langs->trans("OK").''; + print ''.$langs->trans("OK").''; } else { - print 'Error on insert'; + print 'Error on insert'; $error++; } print ''; diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index c32fcd06f09..1d62d1c07f8 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -135,4 +135,5 @@ ReplacementDoneInXPages=Replacement done in %s pages or containers RSSFeed=RSS Feed RSSFeedDesc=You can get a RSS feed of latest articles with type 'blogpost' using this URL PagesRegenerated=%s page(s)/container(s) regenerated -RegenerateWebsiteContent=Regenerate web site cache files \ No newline at end of file +RegenerateWebsiteContent=Regenerate web site cache files +AllowedInFrames=Allowed in Frames \ No newline at end of file diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 5108fe4c25b..ff072827423 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -81,6 +81,7 @@ class WebsitePage extends CommonObject */ public $lang; + public $allowed_in_frames; public $htmlheader; public $content; public $grabbed_from; @@ -160,6 +161,7 @@ class WebsitePage extends CommonObject //'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000), 'fk_website' =>array('type'=>'integer', 'label'=>'WebsiteId', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>40, 'searchall'=>0, 'foreignkey'=>'websitepage.rowid'), 'fk_page' =>array('type'=>'integer', 'label'=>'ParentPageId', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'position'=>45, 'searchall'=>0, 'foreignkey'=>'website.rowid'), + 'allowed_in_frames' =>array('type'=>'integer', 'label'=>'AllowedInFrames', 'enabled'=>1, 'visible'=>-1, 'position'=>48, 'searchall'=>0), 'htmlheader' =>array('type'=>'text', 'label'=>'HtmlHeader', 'enabled'=>1, 'visible'=>0, 'position'=>50, 'searchall'=>0), 'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>0, 'position'=>51, 'searchall'=>0), 'grabbed_from' =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>400, 'comment'=>'URL page content was grabbed from'), @@ -265,6 +267,7 @@ class WebsitePage extends CommonObject $sql .= " t.content,"; $sql .= " t.lang,"; $sql .= " t.fk_page,"; + $sql .= " t.allowed_in_frames,"; $sql .= " t.status,"; $sql .= " t.grabbed_from,"; $sql .= " t.date_creation,"; @@ -325,6 +328,7 @@ class WebsitePage extends CommonObject $this->content = $obj->content; $this->lang = $obj->lang; $this->fk_page = $obj->fk_page; + $this->allowed_in_frames = $obj->allowed_in_frames; $this->status = $obj->status; $this->grabbed_from = $obj->grabbed_from; $this->date_creation = $this->db->jdate($obj->date_creation); @@ -383,6 +387,7 @@ class WebsitePage extends CommonObject $sql .= " t.content,"; $sql .= " t.lang,"; $sql .= " t.fk_page,"; + $sql .= " t.allowed_in_frames,"; $sql .= " t.status,"; $sql .= " t.grabbed_from,"; $sql .= " t.date_creation,"; @@ -453,6 +458,7 @@ class WebsitePage extends CommonObject $record->content = $obj->content; $record->lang = $obj->lang; $record->fk_page = $obj->fk_page; + $record->allowed_in_frames = $obj->allowed_in_frames; $record->status = $obj->status; $record->grabbed_from = $obj->grabbed_from; $record->date_creation = $this->db->jdate($obj->date_creation); @@ -839,6 +845,7 @@ class WebsitePage extends CommonObject $this->description = 'This is my page'; $this->image = ''; $this->keywords = 'keyword1, keyword2'; + $this->allowed_in_frames = 1; $this->htmlheader = ''; $this->content = 'This is a html content'; $this->status = ''; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 2a073aded73..d8f93da3ba1 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -940,6 +940,7 @@ if ($action == 'addcontainer') $objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma'); $objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); $objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); + $objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); $objectpage->htmlheader = GETPOST('htmlheader', 'none'); $objectpage->author_alias = GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml'); $objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS'); @@ -1562,7 +1563,7 @@ if ($action == 'setashome') } } -// Update page (meta) +// Update page properties (meta) if ($action == 'updatemeta') { $db->begin(); @@ -1656,6 +1657,7 @@ if ($action == 'updatemeta') $objectpage->description = str_replace(array('<', '>'), '', GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml')); $objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); $objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); + $objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); $objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0); $objectpage->author_alias = trim(GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml')); @@ -2831,7 +2833,6 @@ if (!GETPOST('hide_websitemenu')) print ''; // end websitehelp - if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { // Adding jquery code to change on the fly url of preview ext @@ -2887,7 +2888,6 @@ if (!GETPOST('hide_websitemenu')) } - $head = array(); @@ -3279,7 +3279,7 @@ if ($action == 'importsite') print '
'; } -if ($action == 'editmeta' || $action == 'createcontainer') +if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of a web site OR properties of a web page { print '
'; @@ -3366,6 +3366,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') $pageimage = $objectpage->image; $pagekeywords = $objectpage->keywords; $pagelang = $objectpage->lang; + $pageallowedinframes = $objectpage->allowed_in_frames; $pagehtmlheader = $objectpage->htmlheader; $pagedatecreation = $objectpage->date_creation; $pagedatemodification = $objectpage->date_modification; @@ -3389,6 +3390,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage = GETPOST('WEBSITE_IMAGE', 'alpha'); if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); + if (GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09')) $pageallowedinframes = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none'); if ($action != 'createcontainer') @@ -3542,6 +3544,15 @@ if ($action == 'editmeta' || $action == 'createcontainer') } print ''; + // Allowed in frames + print ''; + print $langs->trans('AllowedInFrames'); + //$htmlhelp = $langs->trans("AllowedInFramesDesc"); + //print $form->textwithpicto($langs->trans('AllowedInFrames'), $htmlhelp, 1, 'help', '', 0, 2, 'allowedinframestooltip'); + print ''; + print ''; + print ''; + // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { @@ -3566,18 +3577,19 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ""; } - print ''; - print 'ObjectClass'; - print ''; - print ''; - print ''; - - print ''; - print 'ObjectID'; - print ''; - print ''; - print ''; + if (!empty($conf->global->WEBSITE_PAGE_SHOW_INTERNAL_LINKS_TO_OBJECT)) { + print ''; + print 'ObjectClass'; + print ''; + print ''; + print ''; + print ''; + print 'ObjectID'; + print ''; + print ''; + print ''; + } $fuser = new User($db); From 5d0a54c0de1adc2fccfd96747988046b611c1cf2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Nov 2020 12:07:01 +0100 Subject: [PATCH 37/65] Fix var not defined --- htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php | 1 - htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 159ff81e33e..a84e6fed4a2 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -635,7 +635,6 @@ class pdf_eratosthene extends ModelePDFCommandes } - $nexY = max($pdf->GetY(), $posYAfterImage); diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 4ea8fcc585d..5e2e4380a0b 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -400,6 +400,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pageposbefore = $pdf->getPage(); $showpricebeforepagebreak = 1; + $posYAfterImage = 0; // Description of product line $curX = $this->posxdesc - 1; From 906669a54265931e1626e472315379ea3daa5c01 Mon Sep 17 00:00:00 2001 From: Thatoo Date: Thu, 26 Nov 2020 13:54:44 +0100 Subject: [PATCH 38/65] Update sync_members_types_dolibarr2ldap.php Solve following error : "Object of class AdherentType could not be converted to string in /var/www/html/dolibarr/scripts/members/sync_members_types_dolibarr2ldap.php on line 88" --- scripts/members/sync_members_types_dolibarr2ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php index 0a22469ec80..d0cf6ae7f04 100755 --- a/scripts/members/sync_members_types_dolibarr2ldap.php +++ b/scripts/members/sync_members_types_dolibarr2ldap.php @@ -89,7 +89,7 @@ if ($resql) { $membertype->id = $obj->rowid; $membertype->fetch($membertype->id); - print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype - label; + print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype->label; $oldobject = $membertype; From 17e13eb82127a0ce951c4c2b63df53e02fa5b066 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 26 Nov 2020 14:12:02 +0100 Subject: [PATCH 39/65] NEW show stock in supplier product select list --- htdocs/core/class/html.form.class.php | 42 ++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0c7b9d46f3c..41e0487e973 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2743,7 +2743,7 @@ class Form public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') { // phpcs:enable - global $langs, $conf, $db; + global $langs, $conf, $db, $user; $out = ''; $outarray = array(); @@ -2757,6 +2757,9 @@ class Form } $sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type,"; + if (!empty($conf->stock->enabled)) { + $sql .= " p.stock,"; + } $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; $sql .= " pfp.supplier_reputation"; @@ -2974,6 +2977,43 @@ class Form } } + if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) + { + if (!empty($user->rights->stock->lire)) { + $optlabel .= ' - '.$langs->trans("Stock").':'.$objp->stock; + + if ($objp->stock > 0) { + $outval .= ' - '; + } elseif ($objp->stock <= 0) { + $outval .= ' - '; + } + $outval .= $langs->transnoentities("Stock").':'.$objp->stock; + $outval .= ''; + if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation + { + $langs->load("stocks"); + + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after) + $tmpproduct->load_virtual_stock(); + $virtualstock = $tmpproduct->stock_theorique; + + $optlabel .= ' - '.$langs->trans("VirtualStock").':'.$virtualstock; + + $outval .= ' - '.$langs->transnoentities("VirtualStock").':'; + if ($virtualstock > 0) { + $outval .= ''; + } elseif ($virtualstock <= 0) { + $outval .= ''; + } + $outval .= $virtualstock; + $outval .= ''; + + unset($tmpproduct); + } + } + } + $opt = '