From 8548715a1806f39d378d5ae47513e234fe6ec599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 27 Feb 2021 15:48:41 +0100 Subject: [PATCH 001/233] add experimental repair script to utf8mb4 --- htdocs/install/repair.php | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 2a9c2bb11f2..85b425e22a5 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,6 +95,7 @@ print 'Option repair_link_dispatch_lines_supplier_order_lines, (\'test\' or \'co print 'Option set_empty_time_spent_amount (\'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount', 'alpha') ?GETPOST('set_empty_time_spent_amount', 'alpha') : 'undefined').'
'."\n"; // Structure print 'Option force_utf8_on_tables, for mysql/mariadb only (\'test\' or \'confirmed\') is '.(GETPOST('force_utf8_on_tables', 'alpha') ?GETPOST('force_utf8_on_tables', 'alpha') : 'undefined').'
'."\n"; +print "Option force_utf8mb4_on_tables (EXPERIMENTAL!), for mysql/mariadb only ('test' or 'confirmed') is ".(GETPOST('force_utf8mb4_on_tables', 'alpha') ? GETPOST('force_utf8mb4_on_tables', 'alpha') : 'undefined')."
\n"; print '
'; print ''; @@ -1253,6 +1255,54 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) { } } +// force utf8mb4 on tables EXPERIMENTAL ! +if ($ok && GETPOST('force_utf8mb4_on_tables', 'alpha')) { + print ''; + + if ($db->type == "mysql" || $db->type == "mysqli") { + $force_utf8mb4_on_tables = GETPOST('force_utf8mb4_on_tables', 'alpha'); + + $listoftables = $db->DDLListTables($db->database_name); + + // Disable foreign key checking for avoid errors + if ($force_utf8mb4_on_tables == 'confirmed') { + $sql = 'SET FOREIGN_KEY_CHECKS=0'; + print ''; + $resql = $db->query($sql); + } + + foreach ($listoftables as $table) { + // do not convert llx_const if mysql encrypt/decrypt is used + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) { + continue; + } + + print ''; + flush(); + ob_flush(); + } + + // Enable foreign key checking + if ($force_utf8mb4_on_tables == 'confirmed') { + $sql = 'SET FOREIGN_KEY_CHECKS=1'; + print ''; + $resql = $db->query($sql); + } + } else { + print ''; + } +} + // if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { /* From cb507a61b965838e329cb19ad86ab05006758986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 09:54:52 +0100 Subject: [PATCH 002/233] backup with utf8mb4 --- htdocs/core/class/utils.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 3806e5bda4d..d91428d11bb 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -194,6 +194,7 @@ class Utils { global $db, $conf, $langs, $dolibarr_main_data_root; global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass; + global $dolibarr_main_db_character_set; $langs->load("admin"); @@ -314,7 +315,12 @@ class Utils } else { $param .= " -d"; // No row information (no data) } - $param .= " --default-character-set=utf8"; // We always save output into utf8 charset + if ($dolibarr_main_db_character_set == 'utf8mb4') { + // We save output into utf8mb4 charset + $param .= " --default-character-set=utf8mb4"; + } else { + $param .= " --default-character-set=utf8"; // We always save output into utf8 charset + } $paramcrypted = $param; $paramclear = $param; if (!empty($dolibarr_main_db_pass)) { From 4c81f0a52adcda855b33f29652fd84884dc7156e Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Fri, 5 Mar 2021 10:46:26 +0100 Subject: [PATCH 003/233] Add fields property to ProductFournisseur class --- .../fourn/class/fournisseur.product.class.php | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 6ae9a3491ab..f15b300346d 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -134,7 +134,43 @@ class ProductFournisseur extends Product public $packaging; - + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,), + 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>-1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>25, 'notnull'=>1, 'visible'=>-1,), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), + 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), + 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), + 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), + 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), + 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), + 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), + 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), + 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), + 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), + 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), + 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), + 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), + 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), + 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>900, 'notnull'=>0, 'visible'=>-2,), + 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), + 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), + 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), + 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), + 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), + 'barcode' => array('type'=>'varchar(180)', 'label'=>'Barcode', 'enabled'=>'1', 'position'=>170, 'notnull'=>0, 'visible'=>-1,), + 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), + 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), + ); /** * Constructor * From 5a47e4b7ec9b99796f458551e7a3666e3b6b564e Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Fri, 5 Mar 2021 10:59:11 +0100 Subject: [PATCH 004/233] add standard fetchAll method on ProductFournisseur --- .../fourn/class/fournisseur.product.class.php | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index f15b300346d..c334e939a74 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1277,4 +1277,81 @@ class ProductFournisseur extends Product return 1; } } + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList(); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; + + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } } From 76858f06cd03bbb6f7f20e066e4b2721b893b036 Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 16:49:04 +0100 Subject: [PATCH 005/233] ProductFournisseur fields update to reflect Product Class inheritance --- .../fourn/class/fournisseur.product.class.php | 71 +++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index c334e939a74..0234c5c8cd7 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -134,43 +134,6 @@ class ProductFournisseur extends Product public $packaging; - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,), - 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>-1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>25, 'notnull'=>1, 'visible'=>-1,), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>900, 'notnull'=>0, 'visible'=>-2,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'barcode' => array('type'=>'varchar(180)', 'label'=>'Barcode', 'enabled'=>'1', 'position'=>170, 'notnull'=>0, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - ); /** * Constructor * @@ -183,6 +146,37 @@ class ProductFournisseur extends Product $this->db = $db; $langs->load("suppliers"); $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); + $this->fields = array_merge($this->fields, array( + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), + 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), + 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), + 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), + 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), + 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), + 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), + 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), + 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), + 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), + 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), + 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), + 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), + 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), + 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), + 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), + 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), + 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), + 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), + 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), + 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), + 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), + )) } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1354,4 +1348,7 @@ class ProductFournisseur extends Product return -1; } } + public function getFieldList() { + return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') + } } From 0986f1082ca009e492f0565d50b55ba528ef6d09 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 8 Mar 2021 15:49:39 +0000 Subject: [PATCH 006/233] Fixing style errors. --- htdocs/fourn/class/fournisseur.product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 0234c5c8cd7..aee2a284610 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1348,7 +1348,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') } } From c0b5ba4bb56162f72f1d7b537ab12b8b4d1a9815 Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 16:51:55 +0100 Subject: [PATCH 007/233] correct mistakes --- htdocs/fourn/class/fournisseur.product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 0234c5c8cd7..371a5581c55 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -176,7 +176,7 @@ class ProductFournisseur extends Product 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )) + )); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1349,6 +1349,6 @@ class ProductFournisseur extends Product } } public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') + return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); } } From 8b71418c0a54a77b06065e4fded66261d72396c7 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 8 Mar 2021 15:54:15 +0000 Subject: [PATCH 008/233] Fixing style errors. --- .../fourn/class/fournisseur.product.class_20210308165002.php | 3 ++- .../fourn/class/fournisseur.product.class_20210308165033.php | 3 ++- .../fourn/class/fournisseur.product.class_20210308165051.php | 3 ++- .../fourn/class/fournisseur.product.class_20210308165324.php | 3 ++- htdocs/fourn/class/fournisseur.product.class.php | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php index 06713c4dc73..d445e2b2a50 100644 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php +++ b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php @@ -1338,7 +1338,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') } } diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php index 8c0a23b14d7..93677623bbf 100644 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php +++ b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php @@ -1338,7 +1338,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') } } diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php index 885ce24f01f..6d440236388 100644 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php +++ b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php @@ -1338,7 +1338,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); } } diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php index 371a5581c55..6c6ddc2509d 100644 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php +++ b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php @@ -1348,7 +1348,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); } } diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 371a5581c55..6c6ddc2509d 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1348,7 +1348,8 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { + public function getFieldList() + { return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); } } From ae5a581175bc68612175945c9c1eca9615229bd1 Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 16:59:13 +0100 Subject: [PATCH 009/233] correct mistakes --- ...urnisseur.product.class_20210308165002.php | 1344 ---------------- ...urnisseur.product.class_20210308165033.php | 1344 ---------------- ...urnisseur.product.class_20210308165051.php | 1344 ---------------- ...urnisseur.product.class_20210308165324.php | 1354 ----------------- .../fourn/class/fournisseur.product.class.php | 10 +- 5 files changed, 8 insertions(+), 5388 deletions(-) delete mode 100644 .history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php delete mode 100644 .history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php delete mode 100644 .history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php delete mode 100644 .history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php deleted file mode 100644 index 06713c4dc73..00000000000 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165002.php +++ /dev/null @@ -1,1344 +0,0 @@ - - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/fourn/class/fournisseur.product.class.php - * \ingroup produit - * \brief File of class to manage predefined suppliers products - */ - -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - - -/** - * Class to manage predefined suppliers products - */ -class ProductFournisseur extends Product -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $product_fourn_price_id; // id of ligne product-supplier - - /** - * @var int ID - */ - public $id; - - /** - * @deprecated - * @see $ref_supplier - */ - public $fourn_ref; - - public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) - public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - - public $product_id; - public $product_ref; - - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - - public $product_fourn_id; // product-supplier id - public $product_fourn_entity; - - /** - * @var int ID user_id - user who created/updated supplier price - */ - public $user_id; - - /** - * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay) - */ - public $fk_availability; - - public $fourn_unitprice; - public $fourn_tva_tx; - public $fourn_tva_npr; - - /** - * @var int ID - */ - public $fk_supplier_price_expression; - - public $supplier_reputation; // reputation of supplier - public $reputations = array(); // list of available supplier reputations - - // Multicurreny - public $fourn_multicurrency_id; - public $fourn_multicurrency_code; - public $fourn_multicurrency_tx; - public $fourn_multicurrency_price; - public $fourn_multicurrency_unitprice; - - /** - * @deprecated - * @see $supplier_barcode - */ - public $fourn_barcode; - - /** - * @var string $supplier_barcode - Supplier barcode - */ - public $supplier_barcode; - - /** - * @deprecated - * @see $supplier_fk_barcode_type - */ - public $fourn_fk_barcode_type; - - /** - * @var string $supplier_fk_barcode_type - Supplier barcode type - */ - public $supplier_fk_barcode_type; - - public $packaging; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs; - - $this->db = $db; - $langs->load("suppliers"); - $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); - $this->fields = array_merge($this->fields, array( - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )) - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove all prices for this couple supplier-product - * - * @param int $id_fourn Supplier Id - * @return int < 0 if error, > 0 if ok - */ - public function remove_fournisseur($id_fourn) - { - // phpcs:enable - $ok = 1; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; - - dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2 = $this->db->query($sql); - if (!$resql2) - { - $this->error = $this->db->lasterror(); - $ok = 0; - } - - if ($ok) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove a price for a couple supplier-product - * - * @param int $rowid Line id of price - * @return int <0 if KO, >0 if OK - */ - public function remove_product_fournisseur_price($rowid) - { - // phpcs:enable - global $conf, $user; - - $error = 0; - - $this->db->begin(); - - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - - if (empty($error)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - - if (empty($error)) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Modify the purchase price for a supplier - * - * @param float $qty Min quantity for which price is valid - * @param float $buyprice Purchase price for the quantity min - * @param User $user Object user user made changes - * @param string $price_base_type HT or TTC - * @param Societe $fourn Supplier - * @param int $availability Product availability - * @param string $ref_fourn Supplier ref - * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) - * @param string $charges costs affering to product - * @param float $remise_percent Discount regarding qty (percent) - * @param float $remise Discount regarding qty (amount) - * @param int $newnpr Set NPR or not - * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. - * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param string $multicurrency_price_base_type HT or TTC in currency - * @param float $multicurrency_tx Rate currency - * @param string $multicurrency_code Currency code - * @param string $desc_fourn Custom description for product_fourn_price - * @param string $barcode Barcode - * @param int $fk_barcode_type Barcode type - * @return int <0 if KO, >=0 if OK - */ - public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '') - { - // phpcs:enable - global $conf, $langs; - //global $mysoc; - - // Clean parameter - if (empty($qty)) $qty = 0; - if (empty($buyprice)) $buyprice = 0; - if (empty($charges)) $charges = 0; - if (empty($availability)) $availability = 0; - if (empty($remise_percent)) $remise_percent = 0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; - if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; - if ($price_base_type == 'TTC') - { - $ttx = $tva_tx; - $buyprice = $buyprice / (1 + ($ttx / 100)); - } - - // Multicurrency - $multicurrency_unitBuyPrice = null; - $fk_multicurrency = null; - if (!empty($conf->multicurrency->enabled)) { - if (empty($multicurrency_tx)) $multicurrency_tx = 1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if ($multicurrency_price_base_type == 'TTC') - { - $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); - } - $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - - $buyprice = $multicurrency_buyprice / $multicurrency_tx; - $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); - } - - $buyprice = price2num($buyprice, 'MU'); - $charges = price2num($charges, 'MU'); - $qty = price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - - $packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); - - $error = 0; - $now = dol_now(); - - $newvat = $tva_tx; - - if (count($localtaxes_array) > 0) - { - $localtaxtype1 = $localtaxes_array['0']; - $localtax1 = $localtaxes_array['1']; - $localtaxtype2 = $localtaxes_array['2']; - $localtax2 = $localtaxes_array['3']; - } else { // old method. deprecated because ot can't retrieve type - $localtaxtype1 = '0'; - $localtax1 = get_localtax($newvat, 1); - $localtaxtype2 = '0'; - $localtax2 = get_localtax($newvat, 2); - } - if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 - if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 - - // Check parameters - if ($buyprice != '' && !is_numeric($buyprice)) - { - } - - $this->db->begin(); - - if ($this->product_fourn_price_id > 0) - { - // check if price already logged, if not first log current price - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id); - if (is_array($logPrices) && count($logPrices) == 0) - { - $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); - if ($result > 0 && $currentPfp->fourn_price != 0) - { - $currentPfpUser = new User($this->db); - $result = $currentPfpUser->fetch($currentPfp->user_id); - if ($result > 0) { - $currentPfp->logPrice( - $currentPfpUser, - $currentPfp->date_creation, - $currentPfp->fourn_price, - $currentPfp->fourn_qty, - $currentPfp->fourn_multicurrency_price, - $currentPfp->fourn_multicurrency_unitprice, - $currentPfp->fourn_multicurrency_tx, - $currentPfp->fourn_multicurrency_id, - $currentPfp->fourn_multicurrency_code - ); - } - } - } - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; - $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; - $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; - $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " entity = ".$conf->entity.","; - $sql .= " tva_tx = ".price2num($tva_tx).","; - // TODO Add localtax1 and localtax2 - //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; - //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; - //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; - //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; - $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - // TODO Add price_base_type and price_ttc - - dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); - if ($result < 0) $error++; - // End call triggers - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - if (empty($error)) - { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); - - // Delete price for this quantity - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - // Add price for this quantity to supplier - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; - $sql .= " values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " ".$this->id.","; - $sql .= " ".$fourn->id.","; - $sql .= " '".$this->db->escape($ref_fourn)."',"; - $sql .= " '".$this->db->escape($desc_fourn)."',"; - $sql .= " ".$user->id.","; - $sql .= " ".$buyprice.","; - $sql .= " ".$qty.","; - $sql .= " ".$remise_percent.","; - $sql .= " ".$remise.","; - $sql .= " ".$unitBuyPrice.","; - $sql .= " ".$tva_tx.","; - $sql .= " ".$charges.","; - $sql .= " ".$availability.","; - $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " ".$newnpr.","; - $sql .= $conf->entity.","; - $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); - $sql .= ")"; - - $this->product_fourn_price_id = 0; - - $resql = $this->db->query($sql); - if ($resql) { - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); - } else { - $error++; - } - - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { - // Add record into log table - // $this->product_fourn_price_id must be set - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - - if (!$error) { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); - if ($result < 0) - $error++; - // End call triggers - - if (empty($error)) { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Loads the price information of a provider - * - * @param int $rowid Line id - * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead - * @return int < 0 if KO, 0 if OK but not found, > 0 if OK - */ - public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; - $sql .= " p.ref as product_ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; - $sql .= " WHERE pfp.rowid = ".(int) $rowid; - $sql .= " AND pfp.fk_product = p.rowid"; - - dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) - { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; - - $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; - $this->product_ref = $obj->product_ref; - - $this->fourn_id = $obj->fk_soc; - $this->fourn_ref = $obj->ref_fourn; // deprecated - $this->ref_supplier = $obj->ref_fourn; - $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated - $this->fourn_qty = $obj->quantity; - $this->fourn_remise_percent = $obj->remise_percent; - $this->fourn_remise = $obj->remise; - $this->fourn_unitprice = $obj->unitprice; - $this->fourn_tva_tx = $obj->tva_tx; - $this->fourn_tva_npr = $obj->fourn_tva_npr; - // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; - $this->supplier_reputation = $obj->supplier_reputation; - $this->default_vat_code = $obj->default_vat_code; - $this->user_id = $obj->fk_user; - $this->date_creation = $this->db->jdate($obj->datec); - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->barcode->enabled)) { - $this->fourn_barcode = $obj->barcode; // deprecated - $this->fourn_fk_barcode_type = $obj->fk_barcode_type; // deprecated - $this->supplier_barcode = $obj->barcode; - $this->supplier_fk_barcode_type = $obj->fk_barcode_type; - } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty; - } - - if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) - { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($this); - if ($price_result >= 0) { - $this->fourn_price = $price_result; - //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty != 0) - { - $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); - } else { - $this->fourn_unitprice = ""; - } - } - } - - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * List all supplier prices of a product - * - * @param int $prodid Id of product - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Products with new properties to define supplier price - */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref,"; - $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected - $sql .= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($record = $this->db->fetch_array($resql)) - { - //define base attribute - $prodfourn = new ProductFournisseur($this->db); - - $prodfourn->product_ref = $record["product_ref"]; - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->product_fourn_entity = $record["entity"]; - $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; - $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; - $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; - $prodfourn->fk_availability = $record["fk_availability"]; - $prodfourn->delivery_time_days = $record["delivery_time_days"]; - $prodfourn->id = $prodid; - $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; - $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); - $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); - - $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; - $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; - $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty; - } - - if (!empty($conf->barcode->enabled)) { - $prodfourn->supplier_barcode = $record["barcode"]; - $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; - } - - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prodfourn); - if ($price_result >= 0) { - $prodfourn->fourn_price = $price_result; - $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed... - } - } - - if (!isset($prodfourn->fourn_unitprice)) - { - if ($prodfourn->fourn_qty != 0) - { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); - } else { - $prodfourn->fourn_unitprice = ""; - } - } - - $retarray[] = $prodfourn; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load properties for minimum price - * - * @param int $prodid Product id - * @param int $qty Minimum quantity - * @param int $socid get min price for specific supplier - * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK - */ - public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) - { - // phpcs:enable - global $conf; - - if (empty($prodid)) - { - dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); - return 0; - } - - $this->product_fourn_price_id = ''; - $this->product_fourn_id = ''; - $this->fourn_ref = ''; - $this->fourn_price = ''; - $this->fourn_qty = ''; - $this->fourn_remise_percent = ''; - $this->fourn_remise = ''; - $this->fourn_unitprice = ''; - $this->fourn_id = ''; - $this->fourn_name = ''; - $this->delivery_time_days = ''; - $this->id = ''; - - $this->fourn_multicurrency_price = ''; - $this->fourn_multicurrency_unitprice = ''; - $this->fourn_multicurrency_tx = ''; - $this->fourn_multicurrency_id = ''; - $this->fourn_multicurrency_code = ''; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - $sql .= " AND pfp.entity = ".$conf->entity; // only current entity - $sql .= " AND pfp.fk_product = ".$prodid; - $sql .= " AND pfp.fk_soc = s.rowid"; - $sql .= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; - - dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $record_array = array(); - - //Store each record to array for later search of min - while ($record = $this->db->fetch_array($resql)) - { - $record_array[] = $record; - } - - if (count($record_array) == 0) - { - $this->db->free($resql); - return 0; - } else { - $min = -1; - foreach ($record_array as $record) - { - $fourn_price = $record["price"]; - // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { - $prod_supplier = new ProductFournisseur($this->db); - $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; - $prod_supplier->id = $prodid; - $prod_supplier->fourn_qty = $record["quantity"]; - $prod_supplier->fourn_tva_tx = $record["tva_tx"]; - $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prod_supplier); - if ($price_result >= 0) { - $fourn_price = price2num($price_result, 'MU'); - if ($record["quantity"] != 0) - { - $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); - } else { - $fourn_unitprice = $fourn_price; - } - } - } - if ($fourn_unitprice < $min || $min == -1) - { - $this->product_fourn_price_id = $record["product_fourn_price_id"]; - $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated - $this->fourn_price = $fourn_price; - $this->fourn_qty = $record["quantity"]; - $this->fourn_remise_percent = $record["remise_percent"]; - $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_tva_tx = $record["tva_tx"]; - $this->fourn_id = $record["fourn_id"]; - $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $this->id = $prodid; - $this->fourn_multicurrency_price = $record["multicurrency_price"]; - $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $this->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $this->fourn_multicurrency_id = $record["fk_multicurrency"]; - $this->fourn_multicurrency_code = $record["multicurrency_code"]; - $min = $fourn_unitprice; - } - } - } - - $this->db->free($resql); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Sets the supplier price expression - * - * @param int $expression_id Expression - * @return int <0 if KO, >0 if OK - */ - public function setSupplierPriceExpression($expression_id) - { - global $conf; - - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; - - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - - dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - - /** - * Display supplier of product - * - * @param int $withpicto Add picto - * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @return string String with supplier price - * TODO Remove this method. Use getNomUrl directly. - */ - public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) - { - $thirdparty = new Fournisseur($this->db); - $thirdparty->fetch($this->fourn_id); - - return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display price of product - * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price - */ - public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) - { - // phpcs:enable - global $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournList) > 0) { - $out .= '

*** Force page code and collation of tables into utf8mb4/utf8mb4_unicode_ci (for mysql/mariadb only)
'; + print $table; + $sql = 'ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'; + print ''; + if ($force_utf8mb4_on_tables == 'confirmed') { + $resql = $db->query($sql); + print ' - Done ('.($resql ? 'OK' : 'KO').')'; + } else { + print ' - Disabled'; + } + print '
Not available with database type '.$db->type.'
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - foreach ($productFournList as $productFourn) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - } - $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; - } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); - } - return $out; - } - - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'product_fournisseur_price' - ); - - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } - - /** - * List supplier prices log of a supplier price - * - * @param int $product_fourn_price_id Id of supplier price - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Log prices - */ - public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - $sql = "SELECT"; - $sql .= " u.lastname,"; - $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,"; - $sql .= " pfpl.price, pfpl.quantity,"; - $sql .= " pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl,"; - $sql .= " ".MAIN_DB_PREFIX."product_fournisseur_price as pfp,"; - $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql .= " AND pfpl.fk_user = u.rowid"; - $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($obj = $this->db->fetch_object($resql)) - { - $tmparray = array(); - $tmparray['rowid'] = $obj->rowid; - $tmparray['supplier_ref'] = $obj->supplier_ref; - $tmparray['datec'] = $this->db->jdate($obj->datec); - $tmparray['lastname'] = $obj->lastname; - $tmparray['price'] = $obj->price; - $tmparray['quantity'] = $obj->quantity; - $tmparray['fk_multicurrency'] = $obj->fk_multicurrency; - $tmparray['multicurrency_code'] = $obj->multicurrency_code; - $tmparray['multicurrency_tx'] = $obj->multicurrency_tx; - $tmparray['multicurrency_price'] = $obj->multicurrency_price; - $tmparray['multicurrency_unitprice'] = $obj->multicurrency_unitprice; - - $retarray[] = $tmparray; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Display log price of product supplier price - * - * @param array $productFournLogList list of ProductFournisseur price log objects - * to display in table format. - * @return string HTML String with supplier price - */ - public function displayPriceProductFournisseurLog($productFournLogList = array()) - { - global $conf, $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournLogList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - //$out .= ''; - $out .= ''; - foreach ($productFournLogList as $productFournLog) { - $out .= ''; - $out .= ''; - //$out.= ''; - $out .= ''; - } - $out .= '
'.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("QtyMin").''.$langs->trans("User").'
'.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').''.price($productFournLog['price'], 0, $langs, 1, -1, -1, $conf->currency); - if ($productFournLog['multicurrency_code'] != $conf->currency) { - $out .= ' ('.price($productFournLog['multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog['multicurrency_code']).')'; - } - $out .= ''.$productFournLog['quantity'].''.$productFournLog['lastname'].'
'; - } - return $out; - } - - - /** - * Return a link to the object card (with optionaly the picto). - * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl(). - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - - $result = ''; - - if (!empty($this->entity)) { - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { - $label .= '
'; - $label .= $tmpphoto; - $label .= '
'; - } - } - - if ($this->type == Product::TYPE_PRODUCT) { - $label .= img_picto('', 'product').' '.$langs->trans("Product").''; - } elseif ($this->type == Product::TYPE_SERVICE) { - $label .= img_picto('', 'service').' '.$langs->trans("Service").''; - } - if (isset($this->status) && isset($this->status_buy)) { - $label .= ' '.$this->getLibStatut(5, 0); - $label .= ' '.$this->getLibStatut(5, 1); - } - - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('ProductRef').': '.($this->ref ? $this->ref : $this->product_ref); - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; - } - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - - if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (!empty($conf->productbatch->enabled)) { - $langs->load("productbatch"); - $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); - } - } - if (!empty($conf->barcode->enabled)) { - $label .= '
'.$langs->trans('BarCode').': '.$this->barcode; - } - - if ($this->type == Product::TYPE_PRODUCT) - { - if ($this->weight) { - $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); - } - $labelsize = ""; - if ($this->length) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); - } - if ($this->width) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); - } - if ($this->height) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); - } - if ($labelsize) $label .= "
".$labelsize; - - $labelsurfacevolume = ""; - if ($this->surface) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); - } - if ($this->volume) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); - } - if ($labelsurfacevolume) $label .= "
".$labelsurfacevolume; - } - - if (!empty($conf->accounting->enabled) && $this->status) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - } - if (!empty($conf->accounting->enabled) && $this->status_buy) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - } - - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here - if (is_array($logPrices) && count($logPrices) > 0) { - $label .= '

'; - $label .= ''.$langs->trans("History").''; - $label .= $this->displayPriceProductFournisseurLog($logPrices); - } - - $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; - - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } - - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("SupplierRef"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - - $linkstart = ''; - $linkend = ''; - - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - return $result; - } - - /** - * Private function to log price history - * - * @param User $user Object user who adds/changes price - * @param integer $datec date create - * @param float $buyprice price for qty - * @param float $qty qty for price - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency - * @param float $multicurrency_tx Rate currency - * @param int $fk_multicurrency key multi currency - * @param string $multicurrency_code Currency code - * - * @return int < 0 NOK > 0 OK - */ - private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) - { - // Add record into log table - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; - $sql .= "values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= "'".$this->db->idate($datec)."',"; - $sql .= " ".$this->product_fourn_price_id.","; - $sql .= " ".$user->id.","; - $sql .= " ".price2num($buyprice).","; - $sql .= " ".$qty; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { - return -1; - } else { - return 1; - } - } - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = 'SELECT '; - $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') - } -} diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php deleted file mode 100644 index 8c0a23b14d7..00000000000 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165033.php +++ /dev/null @@ -1,1344 +0,0 @@ - - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/fourn/class/fournisseur.product.class.php - * \ingroup produit - * \brief File of class to manage predefined suppliers products - */ - -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - - -/** - * Class to manage predefined suppliers products - */ -class ProductFournisseur extends Product -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $product_fourn_price_id; // id of ligne product-supplier - - /** - * @var int ID - */ - public $id; - - /** - * @deprecated - * @see $ref_supplier - */ - public $fourn_ref; - - public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) - public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - - public $product_id; - public $product_ref; - - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - - public $product_fourn_id; // product-supplier id - public $product_fourn_entity; - - /** - * @var int ID user_id - user who created/updated supplier price - */ - public $user_id; - - /** - * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay) - */ - public $fk_availability; - - public $fourn_unitprice; - public $fourn_tva_tx; - public $fourn_tva_npr; - - /** - * @var int ID - */ - public $fk_supplier_price_expression; - - public $supplier_reputation; // reputation of supplier - public $reputations = array(); // list of available supplier reputations - - // Multicurreny - public $fourn_multicurrency_id; - public $fourn_multicurrency_code; - public $fourn_multicurrency_tx; - public $fourn_multicurrency_price; - public $fourn_multicurrency_unitprice; - - /** - * @deprecated - * @see $supplier_barcode - */ - public $fourn_barcode; - - /** - * @var string $supplier_barcode - Supplier barcode - */ - public $supplier_barcode; - - /** - * @deprecated - * @see $supplier_fk_barcode_type - */ - public $fourn_fk_barcode_type; - - /** - * @var string $supplier_fk_barcode_type - Supplier barcode type - */ - public $supplier_fk_barcode_type; - - public $packaging; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs; - - $this->db = $db; - $langs->load("suppliers"); - $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); - $this->fields = array_merge($this->fields, array( - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove all prices for this couple supplier-product - * - * @param int $id_fourn Supplier Id - * @return int < 0 if error, > 0 if ok - */ - public function remove_fournisseur($id_fourn) - { - // phpcs:enable - $ok = 1; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; - - dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2 = $this->db->query($sql); - if (!$resql2) - { - $this->error = $this->db->lasterror(); - $ok = 0; - } - - if ($ok) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove a price for a couple supplier-product - * - * @param int $rowid Line id of price - * @return int <0 if KO, >0 if OK - */ - public function remove_product_fournisseur_price($rowid) - { - // phpcs:enable - global $conf, $user; - - $error = 0; - - $this->db->begin(); - - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - - if (empty($error)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - - if (empty($error)) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Modify the purchase price for a supplier - * - * @param float $qty Min quantity for which price is valid - * @param float $buyprice Purchase price for the quantity min - * @param User $user Object user user made changes - * @param string $price_base_type HT or TTC - * @param Societe $fourn Supplier - * @param int $availability Product availability - * @param string $ref_fourn Supplier ref - * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) - * @param string $charges costs affering to product - * @param float $remise_percent Discount regarding qty (percent) - * @param float $remise Discount regarding qty (amount) - * @param int $newnpr Set NPR or not - * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. - * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param string $multicurrency_price_base_type HT or TTC in currency - * @param float $multicurrency_tx Rate currency - * @param string $multicurrency_code Currency code - * @param string $desc_fourn Custom description for product_fourn_price - * @param string $barcode Barcode - * @param int $fk_barcode_type Barcode type - * @return int <0 if KO, >=0 if OK - */ - public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '') - { - // phpcs:enable - global $conf, $langs; - //global $mysoc; - - // Clean parameter - if (empty($qty)) $qty = 0; - if (empty($buyprice)) $buyprice = 0; - if (empty($charges)) $charges = 0; - if (empty($availability)) $availability = 0; - if (empty($remise_percent)) $remise_percent = 0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; - if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; - if ($price_base_type == 'TTC') - { - $ttx = $tva_tx; - $buyprice = $buyprice / (1 + ($ttx / 100)); - } - - // Multicurrency - $multicurrency_unitBuyPrice = null; - $fk_multicurrency = null; - if (!empty($conf->multicurrency->enabled)) { - if (empty($multicurrency_tx)) $multicurrency_tx = 1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if ($multicurrency_price_base_type == 'TTC') - { - $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); - } - $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - - $buyprice = $multicurrency_buyprice / $multicurrency_tx; - $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); - } - - $buyprice = price2num($buyprice, 'MU'); - $charges = price2num($charges, 'MU'); - $qty = price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - - $packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); - - $error = 0; - $now = dol_now(); - - $newvat = $tva_tx; - - if (count($localtaxes_array) > 0) - { - $localtaxtype1 = $localtaxes_array['0']; - $localtax1 = $localtaxes_array['1']; - $localtaxtype2 = $localtaxes_array['2']; - $localtax2 = $localtaxes_array['3']; - } else { // old method. deprecated because ot can't retrieve type - $localtaxtype1 = '0'; - $localtax1 = get_localtax($newvat, 1); - $localtaxtype2 = '0'; - $localtax2 = get_localtax($newvat, 2); - } - if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 - if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 - - // Check parameters - if ($buyprice != '' && !is_numeric($buyprice)) - { - } - - $this->db->begin(); - - if ($this->product_fourn_price_id > 0) - { - // check if price already logged, if not first log current price - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id); - if (is_array($logPrices) && count($logPrices) == 0) - { - $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); - if ($result > 0 && $currentPfp->fourn_price != 0) - { - $currentPfpUser = new User($this->db); - $result = $currentPfpUser->fetch($currentPfp->user_id); - if ($result > 0) { - $currentPfp->logPrice( - $currentPfpUser, - $currentPfp->date_creation, - $currentPfp->fourn_price, - $currentPfp->fourn_qty, - $currentPfp->fourn_multicurrency_price, - $currentPfp->fourn_multicurrency_unitprice, - $currentPfp->fourn_multicurrency_tx, - $currentPfp->fourn_multicurrency_id, - $currentPfp->fourn_multicurrency_code - ); - } - } - } - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; - $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; - $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; - $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " entity = ".$conf->entity.","; - $sql .= " tva_tx = ".price2num($tva_tx).","; - // TODO Add localtax1 and localtax2 - //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; - //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; - //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; - //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; - $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - // TODO Add price_base_type and price_ttc - - dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); - if ($result < 0) $error++; - // End call triggers - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - if (empty($error)) - { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); - - // Delete price for this quantity - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - // Add price for this quantity to supplier - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; - $sql .= " values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " ".$this->id.","; - $sql .= " ".$fourn->id.","; - $sql .= " '".$this->db->escape($ref_fourn)."',"; - $sql .= " '".$this->db->escape($desc_fourn)."',"; - $sql .= " ".$user->id.","; - $sql .= " ".$buyprice.","; - $sql .= " ".$qty.","; - $sql .= " ".$remise_percent.","; - $sql .= " ".$remise.","; - $sql .= " ".$unitBuyPrice.","; - $sql .= " ".$tva_tx.","; - $sql .= " ".$charges.","; - $sql .= " ".$availability.","; - $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " ".$newnpr.","; - $sql .= $conf->entity.","; - $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); - $sql .= ")"; - - $this->product_fourn_price_id = 0; - - $resql = $this->db->query($sql); - if ($resql) { - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); - } else { - $error++; - } - - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { - // Add record into log table - // $this->product_fourn_price_id must be set - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - - if (!$error) { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); - if ($result < 0) - $error++; - // End call triggers - - if (empty($error)) { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Loads the price information of a provider - * - * @param int $rowid Line id - * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead - * @return int < 0 if KO, 0 if OK but not found, > 0 if OK - */ - public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; - $sql .= " p.ref as product_ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; - $sql .= " WHERE pfp.rowid = ".(int) $rowid; - $sql .= " AND pfp.fk_product = p.rowid"; - - dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) - { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; - - $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; - $this->product_ref = $obj->product_ref; - - $this->fourn_id = $obj->fk_soc; - $this->fourn_ref = $obj->ref_fourn; // deprecated - $this->ref_supplier = $obj->ref_fourn; - $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated - $this->fourn_qty = $obj->quantity; - $this->fourn_remise_percent = $obj->remise_percent; - $this->fourn_remise = $obj->remise; - $this->fourn_unitprice = $obj->unitprice; - $this->fourn_tva_tx = $obj->tva_tx; - $this->fourn_tva_npr = $obj->fourn_tva_npr; - // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; - $this->supplier_reputation = $obj->supplier_reputation; - $this->default_vat_code = $obj->default_vat_code; - $this->user_id = $obj->fk_user; - $this->date_creation = $this->db->jdate($obj->datec); - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->barcode->enabled)) { - $this->fourn_barcode = $obj->barcode; // deprecated - $this->fourn_fk_barcode_type = $obj->fk_barcode_type; // deprecated - $this->supplier_barcode = $obj->barcode; - $this->supplier_fk_barcode_type = $obj->fk_barcode_type; - } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty; - } - - if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) - { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($this); - if ($price_result >= 0) { - $this->fourn_price = $price_result; - //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty != 0) - { - $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); - } else { - $this->fourn_unitprice = ""; - } - } - } - - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * List all supplier prices of a product - * - * @param int $prodid Id of product - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Products with new properties to define supplier price - */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref,"; - $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected - $sql .= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($record = $this->db->fetch_array($resql)) - { - //define base attribute - $prodfourn = new ProductFournisseur($this->db); - - $prodfourn->product_ref = $record["product_ref"]; - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->product_fourn_entity = $record["entity"]; - $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; - $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; - $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; - $prodfourn->fk_availability = $record["fk_availability"]; - $prodfourn->delivery_time_days = $record["delivery_time_days"]; - $prodfourn->id = $prodid; - $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; - $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); - $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); - - $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; - $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; - $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty; - } - - if (!empty($conf->barcode->enabled)) { - $prodfourn->supplier_barcode = $record["barcode"]; - $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; - } - - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prodfourn); - if ($price_result >= 0) { - $prodfourn->fourn_price = $price_result; - $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed... - } - } - - if (!isset($prodfourn->fourn_unitprice)) - { - if ($prodfourn->fourn_qty != 0) - { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); - } else { - $prodfourn->fourn_unitprice = ""; - } - } - - $retarray[] = $prodfourn; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load properties for minimum price - * - * @param int $prodid Product id - * @param int $qty Minimum quantity - * @param int $socid get min price for specific supplier - * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK - */ - public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) - { - // phpcs:enable - global $conf; - - if (empty($prodid)) - { - dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); - return 0; - } - - $this->product_fourn_price_id = ''; - $this->product_fourn_id = ''; - $this->fourn_ref = ''; - $this->fourn_price = ''; - $this->fourn_qty = ''; - $this->fourn_remise_percent = ''; - $this->fourn_remise = ''; - $this->fourn_unitprice = ''; - $this->fourn_id = ''; - $this->fourn_name = ''; - $this->delivery_time_days = ''; - $this->id = ''; - - $this->fourn_multicurrency_price = ''; - $this->fourn_multicurrency_unitprice = ''; - $this->fourn_multicurrency_tx = ''; - $this->fourn_multicurrency_id = ''; - $this->fourn_multicurrency_code = ''; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - $sql .= " AND pfp.entity = ".$conf->entity; // only current entity - $sql .= " AND pfp.fk_product = ".$prodid; - $sql .= " AND pfp.fk_soc = s.rowid"; - $sql .= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; - - dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $record_array = array(); - - //Store each record to array for later search of min - while ($record = $this->db->fetch_array($resql)) - { - $record_array[] = $record; - } - - if (count($record_array) == 0) - { - $this->db->free($resql); - return 0; - } else { - $min = -1; - foreach ($record_array as $record) - { - $fourn_price = $record["price"]; - // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { - $prod_supplier = new ProductFournisseur($this->db); - $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; - $prod_supplier->id = $prodid; - $prod_supplier->fourn_qty = $record["quantity"]; - $prod_supplier->fourn_tva_tx = $record["tva_tx"]; - $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prod_supplier); - if ($price_result >= 0) { - $fourn_price = price2num($price_result, 'MU'); - if ($record["quantity"] != 0) - { - $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); - } else { - $fourn_unitprice = $fourn_price; - } - } - } - if ($fourn_unitprice < $min || $min == -1) - { - $this->product_fourn_price_id = $record["product_fourn_price_id"]; - $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated - $this->fourn_price = $fourn_price; - $this->fourn_qty = $record["quantity"]; - $this->fourn_remise_percent = $record["remise_percent"]; - $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_tva_tx = $record["tva_tx"]; - $this->fourn_id = $record["fourn_id"]; - $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $this->id = $prodid; - $this->fourn_multicurrency_price = $record["multicurrency_price"]; - $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $this->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $this->fourn_multicurrency_id = $record["fk_multicurrency"]; - $this->fourn_multicurrency_code = $record["multicurrency_code"]; - $min = $fourn_unitprice; - } - } - } - - $this->db->free($resql); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Sets the supplier price expression - * - * @param int $expression_id Expression - * @return int <0 if KO, >0 if OK - */ - public function setSupplierPriceExpression($expression_id) - { - global $conf; - - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; - - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - - dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - - /** - * Display supplier of product - * - * @param int $withpicto Add picto - * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @return string String with supplier price - * TODO Remove this method. Use getNomUrl directly. - */ - public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) - { - $thirdparty = new Fournisseur($this->db); - $thirdparty->fetch($this->fourn_id); - - return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display price of product - * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price - */ - public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) - { - // phpcs:enable - global $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - foreach ($productFournList as $productFourn) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - } - $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; - } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); - } - return $out; - } - - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'product_fournisseur_price' - ); - - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } - - /** - * List supplier prices log of a supplier price - * - * @param int $product_fourn_price_id Id of supplier price - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Log prices - */ - public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - $sql = "SELECT"; - $sql .= " u.lastname,"; - $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,"; - $sql .= " pfpl.price, pfpl.quantity,"; - $sql .= " pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl,"; - $sql .= " ".MAIN_DB_PREFIX."product_fournisseur_price as pfp,"; - $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql .= " AND pfpl.fk_user = u.rowid"; - $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($obj = $this->db->fetch_object($resql)) - { - $tmparray = array(); - $tmparray['rowid'] = $obj->rowid; - $tmparray['supplier_ref'] = $obj->supplier_ref; - $tmparray['datec'] = $this->db->jdate($obj->datec); - $tmparray['lastname'] = $obj->lastname; - $tmparray['price'] = $obj->price; - $tmparray['quantity'] = $obj->quantity; - $tmparray['fk_multicurrency'] = $obj->fk_multicurrency; - $tmparray['multicurrency_code'] = $obj->multicurrency_code; - $tmparray['multicurrency_tx'] = $obj->multicurrency_tx; - $tmparray['multicurrency_price'] = $obj->multicurrency_price; - $tmparray['multicurrency_unitprice'] = $obj->multicurrency_unitprice; - - $retarray[] = $tmparray; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Display log price of product supplier price - * - * @param array $productFournLogList list of ProductFournisseur price log objects - * to display in table format. - * @return string HTML String with supplier price - */ - public function displayPriceProductFournisseurLog($productFournLogList = array()) - { - global $conf, $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournLogList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - //$out .= ''; - $out .= ''; - foreach ($productFournLogList as $productFournLog) { - $out .= ''; - $out .= ''; - //$out.= ''; - $out .= ''; - } - $out .= '
'.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("QtyMin").''.$langs->trans("User").'
'.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').''.price($productFournLog['price'], 0, $langs, 1, -1, -1, $conf->currency); - if ($productFournLog['multicurrency_code'] != $conf->currency) { - $out .= ' ('.price($productFournLog['multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog['multicurrency_code']).')'; - } - $out .= ''.$productFournLog['quantity'].''.$productFournLog['lastname'].'
'; - } - return $out; - } - - - /** - * Return a link to the object card (with optionaly the picto). - * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl(). - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - - $result = ''; - - if (!empty($this->entity)) { - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { - $label .= '
'; - $label .= $tmpphoto; - $label .= '
'; - } - } - - if ($this->type == Product::TYPE_PRODUCT) { - $label .= img_picto('', 'product').' '.$langs->trans("Product").''; - } elseif ($this->type == Product::TYPE_SERVICE) { - $label .= img_picto('', 'service').' '.$langs->trans("Service").''; - } - if (isset($this->status) && isset($this->status_buy)) { - $label .= ' '.$this->getLibStatut(5, 0); - $label .= ' '.$this->getLibStatut(5, 1); - } - - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('ProductRef').': '.($this->ref ? $this->ref : $this->product_ref); - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; - } - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - - if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (!empty($conf->productbatch->enabled)) { - $langs->load("productbatch"); - $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); - } - } - if (!empty($conf->barcode->enabled)) { - $label .= '
'.$langs->trans('BarCode').': '.$this->barcode; - } - - if ($this->type == Product::TYPE_PRODUCT) - { - if ($this->weight) { - $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); - } - $labelsize = ""; - if ($this->length) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); - } - if ($this->width) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); - } - if ($this->height) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); - } - if ($labelsize) $label .= "
".$labelsize; - - $labelsurfacevolume = ""; - if ($this->surface) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); - } - if ($this->volume) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); - } - if ($labelsurfacevolume) $label .= "
".$labelsurfacevolume; - } - - if (!empty($conf->accounting->enabled) && $this->status) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - } - if (!empty($conf->accounting->enabled) && $this->status_buy) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - } - - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here - if (is_array($logPrices) && count($logPrices) > 0) { - $label .= '

'; - $label .= ''.$langs->trans("History").''; - $label .= $this->displayPriceProductFournisseurLog($logPrices); - } - - $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; - - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } - - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("SupplierRef"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - - $linkstart = ''; - $linkend = ''; - - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - return $result; - } - - /** - * Private function to log price history - * - * @param User $user Object user who adds/changes price - * @param integer $datec date create - * @param float $buyprice price for qty - * @param float $qty qty for price - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency - * @param float $multicurrency_tx Rate currency - * @param int $fk_multicurrency key multi currency - * @param string $multicurrency_code Currency code - * - * @return int < 0 NOK > 0 OK - */ - private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) - { - // Add record into log table - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; - $sql .= "values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= "'".$this->db->idate($datec)."',"; - $sql .= " ".$this->product_fourn_price_id.","; - $sql .= " ".$user->id.","; - $sql .= " ".price2num($buyprice).","; - $sql .= " ".$qty; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { - return -1; - } else { - return 1; - } - } - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = 'SELECT '; - $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging') - } -} diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php deleted file mode 100644 index 885ce24f01f..00000000000 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165051.php +++ /dev/null @@ -1,1344 +0,0 @@ - - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/fourn/class/fournisseur.product.class.php - * \ingroup produit - * \brief File of class to manage predefined suppliers products - */ - -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - - -/** - * Class to manage predefined suppliers products - */ -class ProductFournisseur extends Product -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $product_fourn_price_id; // id of ligne product-supplier - - /** - * @var int ID - */ - public $id; - - /** - * @deprecated - * @see $ref_supplier - */ - public $fourn_ref; - - public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) - public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - - public $product_id; - public $product_ref; - - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - - public $product_fourn_id; // product-supplier id - public $product_fourn_entity; - - /** - * @var int ID user_id - user who created/updated supplier price - */ - public $user_id; - - /** - * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay) - */ - public $fk_availability; - - public $fourn_unitprice; - public $fourn_tva_tx; - public $fourn_tva_npr; - - /** - * @var int ID - */ - public $fk_supplier_price_expression; - - public $supplier_reputation; // reputation of supplier - public $reputations = array(); // list of available supplier reputations - - // Multicurreny - public $fourn_multicurrency_id; - public $fourn_multicurrency_code; - public $fourn_multicurrency_tx; - public $fourn_multicurrency_price; - public $fourn_multicurrency_unitprice; - - /** - * @deprecated - * @see $supplier_barcode - */ - public $fourn_barcode; - - /** - * @var string $supplier_barcode - Supplier barcode - */ - public $supplier_barcode; - - /** - * @deprecated - * @see $supplier_fk_barcode_type - */ - public $fourn_fk_barcode_type; - - /** - * @var string $supplier_fk_barcode_type - Supplier barcode type - */ - public $supplier_fk_barcode_type; - - public $packaging; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs; - - $this->db = $db; - $langs->load("suppliers"); - $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); - $this->fields = array_merge($this->fields, array( - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove all prices for this couple supplier-product - * - * @param int $id_fourn Supplier Id - * @return int < 0 if error, > 0 if ok - */ - public function remove_fournisseur($id_fourn) - { - // phpcs:enable - $ok = 1; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; - - dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2 = $this->db->query($sql); - if (!$resql2) - { - $this->error = $this->db->lasterror(); - $ok = 0; - } - - if ($ok) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove a price for a couple supplier-product - * - * @param int $rowid Line id of price - * @return int <0 if KO, >0 if OK - */ - public function remove_product_fournisseur_price($rowid) - { - // phpcs:enable - global $conf, $user; - - $error = 0; - - $this->db->begin(); - - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - - if (empty($error)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - - if (empty($error)) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Modify the purchase price for a supplier - * - * @param float $qty Min quantity for which price is valid - * @param float $buyprice Purchase price for the quantity min - * @param User $user Object user user made changes - * @param string $price_base_type HT or TTC - * @param Societe $fourn Supplier - * @param int $availability Product availability - * @param string $ref_fourn Supplier ref - * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) - * @param string $charges costs affering to product - * @param float $remise_percent Discount regarding qty (percent) - * @param float $remise Discount regarding qty (amount) - * @param int $newnpr Set NPR or not - * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. - * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param string $multicurrency_price_base_type HT or TTC in currency - * @param float $multicurrency_tx Rate currency - * @param string $multicurrency_code Currency code - * @param string $desc_fourn Custom description for product_fourn_price - * @param string $barcode Barcode - * @param int $fk_barcode_type Barcode type - * @return int <0 if KO, >=0 if OK - */ - public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '') - { - // phpcs:enable - global $conf, $langs; - //global $mysoc; - - // Clean parameter - if (empty($qty)) $qty = 0; - if (empty($buyprice)) $buyprice = 0; - if (empty($charges)) $charges = 0; - if (empty($availability)) $availability = 0; - if (empty($remise_percent)) $remise_percent = 0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; - if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; - if ($price_base_type == 'TTC') - { - $ttx = $tva_tx; - $buyprice = $buyprice / (1 + ($ttx / 100)); - } - - // Multicurrency - $multicurrency_unitBuyPrice = null; - $fk_multicurrency = null; - if (!empty($conf->multicurrency->enabled)) { - if (empty($multicurrency_tx)) $multicurrency_tx = 1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if ($multicurrency_price_base_type == 'TTC') - { - $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); - } - $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - - $buyprice = $multicurrency_buyprice / $multicurrency_tx; - $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); - } - - $buyprice = price2num($buyprice, 'MU'); - $charges = price2num($charges, 'MU'); - $qty = price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - - $packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); - - $error = 0; - $now = dol_now(); - - $newvat = $tva_tx; - - if (count($localtaxes_array) > 0) - { - $localtaxtype1 = $localtaxes_array['0']; - $localtax1 = $localtaxes_array['1']; - $localtaxtype2 = $localtaxes_array['2']; - $localtax2 = $localtaxes_array['3']; - } else { // old method. deprecated because ot can't retrieve type - $localtaxtype1 = '0'; - $localtax1 = get_localtax($newvat, 1); - $localtaxtype2 = '0'; - $localtax2 = get_localtax($newvat, 2); - } - if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 - if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 - - // Check parameters - if ($buyprice != '' && !is_numeric($buyprice)) - { - } - - $this->db->begin(); - - if ($this->product_fourn_price_id > 0) - { - // check if price already logged, if not first log current price - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id); - if (is_array($logPrices) && count($logPrices) == 0) - { - $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); - if ($result > 0 && $currentPfp->fourn_price != 0) - { - $currentPfpUser = new User($this->db); - $result = $currentPfpUser->fetch($currentPfp->user_id); - if ($result > 0) { - $currentPfp->logPrice( - $currentPfpUser, - $currentPfp->date_creation, - $currentPfp->fourn_price, - $currentPfp->fourn_qty, - $currentPfp->fourn_multicurrency_price, - $currentPfp->fourn_multicurrency_unitprice, - $currentPfp->fourn_multicurrency_tx, - $currentPfp->fourn_multicurrency_id, - $currentPfp->fourn_multicurrency_code - ); - } - } - } - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; - $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; - $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; - $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " entity = ".$conf->entity.","; - $sql .= " tva_tx = ".price2num($tva_tx).","; - // TODO Add localtax1 and localtax2 - //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; - //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; - //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; - //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; - $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - // TODO Add price_base_type and price_ttc - - dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); - if ($result < 0) $error++; - // End call triggers - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - if (empty($error)) - { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); - - // Delete price for this quantity - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - // Add price for this quantity to supplier - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; - $sql .= " values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " ".$this->id.","; - $sql .= " ".$fourn->id.","; - $sql .= " '".$this->db->escape($ref_fourn)."',"; - $sql .= " '".$this->db->escape($desc_fourn)."',"; - $sql .= " ".$user->id.","; - $sql .= " ".$buyprice.","; - $sql .= " ".$qty.","; - $sql .= " ".$remise_percent.","; - $sql .= " ".$remise.","; - $sql .= " ".$unitBuyPrice.","; - $sql .= " ".$tva_tx.","; - $sql .= " ".$charges.","; - $sql .= " ".$availability.","; - $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " ".$newnpr.","; - $sql .= $conf->entity.","; - $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); - $sql .= ")"; - - $this->product_fourn_price_id = 0; - - $resql = $this->db->query($sql); - if ($resql) { - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); - } else { - $error++; - } - - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { - // Add record into log table - // $this->product_fourn_price_id must be set - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - - if (!$error) { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); - if ($result < 0) - $error++; - // End call triggers - - if (empty($error)) { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Loads the price information of a provider - * - * @param int $rowid Line id - * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead - * @return int < 0 if KO, 0 if OK but not found, > 0 if OK - */ - public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; - $sql .= " p.ref as product_ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; - $sql .= " WHERE pfp.rowid = ".(int) $rowid; - $sql .= " AND pfp.fk_product = p.rowid"; - - dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) - { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; - - $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; - $this->product_ref = $obj->product_ref; - - $this->fourn_id = $obj->fk_soc; - $this->fourn_ref = $obj->ref_fourn; // deprecated - $this->ref_supplier = $obj->ref_fourn; - $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated - $this->fourn_qty = $obj->quantity; - $this->fourn_remise_percent = $obj->remise_percent; - $this->fourn_remise = $obj->remise; - $this->fourn_unitprice = $obj->unitprice; - $this->fourn_tva_tx = $obj->tva_tx; - $this->fourn_tva_npr = $obj->fourn_tva_npr; - // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; - $this->supplier_reputation = $obj->supplier_reputation; - $this->default_vat_code = $obj->default_vat_code; - $this->user_id = $obj->fk_user; - $this->date_creation = $this->db->jdate($obj->datec); - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->barcode->enabled)) { - $this->fourn_barcode = $obj->barcode; // deprecated - $this->fourn_fk_barcode_type = $obj->fk_barcode_type; // deprecated - $this->supplier_barcode = $obj->barcode; - $this->supplier_fk_barcode_type = $obj->fk_barcode_type; - } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty; - } - - if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) - { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($this); - if ($price_result >= 0) { - $this->fourn_price = $price_result; - //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty != 0) - { - $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); - } else { - $this->fourn_unitprice = ""; - } - } - } - - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * List all supplier prices of a product - * - * @param int $prodid Id of product - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Products with new properties to define supplier price - */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref,"; - $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected - $sql .= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($record = $this->db->fetch_array($resql)) - { - //define base attribute - $prodfourn = new ProductFournisseur($this->db); - - $prodfourn->product_ref = $record["product_ref"]; - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->product_fourn_entity = $record["entity"]; - $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; - $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; - $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; - $prodfourn->fk_availability = $record["fk_availability"]; - $prodfourn->delivery_time_days = $record["delivery_time_days"]; - $prodfourn->id = $prodid; - $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; - $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); - $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); - - $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; - $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; - $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty; - } - - if (!empty($conf->barcode->enabled)) { - $prodfourn->supplier_barcode = $record["barcode"]; - $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; - } - - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prodfourn); - if ($price_result >= 0) { - $prodfourn->fourn_price = $price_result; - $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed... - } - } - - if (!isset($prodfourn->fourn_unitprice)) - { - if ($prodfourn->fourn_qty != 0) - { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); - } else { - $prodfourn->fourn_unitprice = ""; - } - } - - $retarray[] = $prodfourn; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load properties for minimum price - * - * @param int $prodid Product id - * @param int $qty Minimum quantity - * @param int $socid get min price for specific supplier - * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK - */ - public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) - { - // phpcs:enable - global $conf; - - if (empty($prodid)) - { - dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); - return 0; - } - - $this->product_fourn_price_id = ''; - $this->product_fourn_id = ''; - $this->fourn_ref = ''; - $this->fourn_price = ''; - $this->fourn_qty = ''; - $this->fourn_remise_percent = ''; - $this->fourn_remise = ''; - $this->fourn_unitprice = ''; - $this->fourn_id = ''; - $this->fourn_name = ''; - $this->delivery_time_days = ''; - $this->id = ''; - - $this->fourn_multicurrency_price = ''; - $this->fourn_multicurrency_unitprice = ''; - $this->fourn_multicurrency_tx = ''; - $this->fourn_multicurrency_id = ''; - $this->fourn_multicurrency_code = ''; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - $sql .= " AND pfp.entity = ".$conf->entity; // only current entity - $sql .= " AND pfp.fk_product = ".$prodid; - $sql .= " AND pfp.fk_soc = s.rowid"; - $sql .= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; - - dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $record_array = array(); - - //Store each record to array for later search of min - while ($record = $this->db->fetch_array($resql)) - { - $record_array[] = $record; - } - - if (count($record_array) == 0) - { - $this->db->free($resql); - return 0; - } else { - $min = -1; - foreach ($record_array as $record) - { - $fourn_price = $record["price"]; - // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { - $prod_supplier = new ProductFournisseur($this->db); - $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; - $prod_supplier->id = $prodid; - $prod_supplier->fourn_qty = $record["quantity"]; - $prod_supplier->fourn_tva_tx = $record["tva_tx"]; - $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prod_supplier); - if ($price_result >= 0) { - $fourn_price = price2num($price_result, 'MU'); - if ($record["quantity"] != 0) - { - $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); - } else { - $fourn_unitprice = $fourn_price; - } - } - } - if ($fourn_unitprice < $min || $min == -1) - { - $this->product_fourn_price_id = $record["product_fourn_price_id"]; - $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated - $this->fourn_price = $fourn_price; - $this->fourn_qty = $record["quantity"]; - $this->fourn_remise_percent = $record["remise_percent"]; - $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_tva_tx = $record["tva_tx"]; - $this->fourn_id = $record["fourn_id"]; - $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $this->id = $prodid; - $this->fourn_multicurrency_price = $record["multicurrency_price"]; - $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $this->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $this->fourn_multicurrency_id = $record["fk_multicurrency"]; - $this->fourn_multicurrency_code = $record["multicurrency_code"]; - $min = $fourn_unitprice; - } - } - } - - $this->db->free($resql); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Sets the supplier price expression - * - * @param int $expression_id Expression - * @return int <0 if KO, >0 if OK - */ - public function setSupplierPriceExpression($expression_id) - { - global $conf; - - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; - - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - - dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - - /** - * Display supplier of product - * - * @param int $withpicto Add picto - * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @return string String with supplier price - * TODO Remove this method. Use getNomUrl directly. - */ - public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) - { - $thirdparty = new Fournisseur($this->db); - $thirdparty->fetch($this->fourn_id); - - return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display price of product - * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price - */ - public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) - { - // phpcs:enable - global $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - foreach ($productFournList as $productFourn) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - } - $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; - } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); - } - return $out; - } - - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'product_fournisseur_price' - ); - - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } - - /** - * List supplier prices log of a supplier price - * - * @param int $product_fourn_price_id Id of supplier price - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Log prices - */ - public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - $sql = "SELECT"; - $sql .= " u.lastname,"; - $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,"; - $sql .= " pfpl.price, pfpl.quantity,"; - $sql .= " pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl,"; - $sql .= " ".MAIN_DB_PREFIX."product_fournisseur_price as pfp,"; - $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql .= " AND pfpl.fk_user = u.rowid"; - $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($obj = $this->db->fetch_object($resql)) - { - $tmparray = array(); - $tmparray['rowid'] = $obj->rowid; - $tmparray['supplier_ref'] = $obj->supplier_ref; - $tmparray['datec'] = $this->db->jdate($obj->datec); - $tmparray['lastname'] = $obj->lastname; - $tmparray['price'] = $obj->price; - $tmparray['quantity'] = $obj->quantity; - $tmparray['fk_multicurrency'] = $obj->fk_multicurrency; - $tmparray['multicurrency_code'] = $obj->multicurrency_code; - $tmparray['multicurrency_tx'] = $obj->multicurrency_tx; - $tmparray['multicurrency_price'] = $obj->multicurrency_price; - $tmparray['multicurrency_unitprice'] = $obj->multicurrency_unitprice; - - $retarray[] = $tmparray; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Display log price of product supplier price - * - * @param array $productFournLogList list of ProductFournisseur price log objects - * to display in table format. - * @return string HTML String with supplier price - */ - public function displayPriceProductFournisseurLog($productFournLogList = array()) - { - global $conf, $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournLogList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - //$out .= ''; - $out .= ''; - foreach ($productFournLogList as $productFournLog) { - $out .= ''; - $out .= ''; - //$out.= ''; - $out .= ''; - } - $out .= '
'.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("QtyMin").''.$langs->trans("User").'
'.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').''.price($productFournLog['price'], 0, $langs, 1, -1, -1, $conf->currency); - if ($productFournLog['multicurrency_code'] != $conf->currency) { - $out .= ' ('.price($productFournLog['multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog['multicurrency_code']).')'; - } - $out .= ''.$productFournLog['quantity'].''.$productFournLog['lastname'].'
'; - } - return $out; - } - - - /** - * Return a link to the object card (with optionaly the picto). - * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl(). - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - - $result = ''; - - if (!empty($this->entity)) { - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { - $label .= '
'; - $label .= $tmpphoto; - $label .= '
'; - } - } - - if ($this->type == Product::TYPE_PRODUCT) { - $label .= img_picto('', 'product').' '.$langs->trans("Product").''; - } elseif ($this->type == Product::TYPE_SERVICE) { - $label .= img_picto('', 'service').' '.$langs->trans("Service").''; - } - if (isset($this->status) && isset($this->status_buy)) { - $label .= ' '.$this->getLibStatut(5, 0); - $label .= ' '.$this->getLibStatut(5, 1); - } - - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('ProductRef').': '.($this->ref ? $this->ref : $this->product_ref); - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; - } - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - - if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (!empty($conf->productbatch->enabled)) { - $langs->load("productbatch"); - $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); - } - } - if (!empty($conf->barcode->enabled)) { - $label .= '
'.$langs->trans('BarCode').': '.$this->barcode; - } - - if ($this->type == Product::TYPE_PRODUCT) - { - if ($this->weight) { - $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); - } - $labelsize = ""; - if ($this->length) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); - } - if ($this->width) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); - } - if ($this->height) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); - } - if ($labelsize) $label .= "
".$labelsize; - - $labelsurfacevolume = ""; - if ($this->surface) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); - } - if ($this->volume) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); - } - if ($labelsurfacevolume) $label .= "
".$labelsurfacevolume; - } - - if (!empty($conf->accounting->enabled) && $this->status) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - } - if (!empty($conf->accounting->enabled) && $this->status_buy) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - } - - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here - if (is_array($logPrices) && count($logPrices) > 0) { - $label .= '

'; - $label .= ''.$langs->trans("History").''; - $label .= $this->displayPriceProductFournisseurLog($logPrices); - } - - $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; - - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } - - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("SupplierRef"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - - $linkstart = ''; - $linkend = ''; - - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - return $result; - } - - /** - * Private function to log price history - * - * @param User $user Object user who adds/changes price - * @param integer $datec date create - * @param float $buyprice price for qty - * @param float $qty qty for price - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency - * @param float $multicurrency_tx Rate currency - * @param int $fk_multicurrency key multi currency - * @param string $multicurrency_code Currency code - * - * @return int < 0 NOK > 0 OK - */ - private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) - { - // Add record into log table - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; - $sql .= "values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= "'".$this->db->idate($datec)."',"; - $sql .= " ".$this->product_fourn_price_id.","; - $sql .= " ".$user->id.","; - $sql .= " ".price2num($buyprice).","; - $sql .= " ".$qty; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { - return -1; - } else { - return 1; - } - } - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = 'SELECT '; - $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); - } -} diff --git a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php b/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php deleted file mode 100644 index 371a5581c55..00000000000 --- a/.history/htdocs/fourn/class/fournisseur.product.class_20210308165324.php +++ /dev/null @@ -1,1354 +0,0 @@ - - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2019-2021 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/fourn/class/fournisseur.product.class.php - * \ingroup produit - * \brief File of class to manage predefined suppliers products - */ - -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - - -/** - * Class to manage predefined suppliers products - */ -class ProductFournisseur extends Product -{ - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - public $product_fourn_price_id; // id of ligne product-supplier - - /** - * @var int ID - */ - public $id; - - /** - * @deprecated - * @see $ref_supplier - */ - public $fourn_ref; - - public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) - public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - - public $product_id; - public $product_ref; - - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - - public $product_fourn_id; // product-supplier id - public $product_fourn_entity; - - /** - * @var int ID user_id - user who created/updated supplier price - */ - public $user_id; - - /** - * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay) - */ - public $fk_availability; - - public $fourn_unitprice; - public $fourn_tva_tx; - public $fourn_tva_npr; - - /** - * @var int ID - */ - public $fk_supplier_price_expression; - - public $supplier_reputation; // reputation of supplier - public $reputations = array(); // list of available supplier reputations - - // Multicurreny - public $fourn_multicurrency_id; - public $fourn_multicurrency_code; - public $fourn_multicurrency_tx; - public $fourn_multicurrency_price; - public $fourn_multicurrency_unitprice; - - /** - * @deprecated - * @see $supplier_barcode - */ - public $fourn_barcode; - - /** - * @var string $supplier_barcode - Supplier barcode - */ - public $supplier_barcode; - - /** - * @deprecated - * @see $supplier_fk_barcode_type - */ - public $fourn_fk_barcode_type; - - /** - * @var string $supplier_fk_barcode_type - Supplier barcode type - */ - public $supplier_fk_barcode_type; - - public $packaging; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - global $langs; - - $this->db = $db; - $langs->load("suppliers"); - $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); - $this->fields = array_merge($this->fields, array( - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove all prices for this couple supplier-product - * - * @param int $id_fourn Supplier Id - * @return int < 0 if error, > 0 if ok - */ - public function remove_fournisseur($id_fourn) - { - // phpcs:enable - $ok = 1; - - $this->db->begin(); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; - - dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2 = $this->db->query($sql); - if (!$resql2) - { - $this->error = $this->db->lasterror(); - $ok = 0; - } - - if ($ok) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove a price for a couple supplier-product - * - * @param int $rowid Line id of price - * @return int <0 if KO, >0 if OK - */ - public function remove_product_fournisseur_price($rowid) - { - // phpcs:enable - global $conf, $user; - - $error = 0; - - $this->db->begin(); - - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - - if (empty($error)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - - if (empty($error)) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Modify the purchase price for a supplier - * - * @param float $qty Min quantity for which price is valid - * @param float $buyprice Purchase price for the quantity min - * @param User $user Object user user made changes - * @param string $price_base_type HT or TTC - * @param Societe $fourn Supplier - * @param int $availability Product availability - * @param string $ref_fourn Supplier ref - * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string) - * @param string $charges costs affering to product - * @param float $remise_percent Discount regarding qty (percent) - * @param float $remise Discount regarding qty (amount) - * @param int $newnpr Set NPR or not - * @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined. - * @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER) - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param string $multicurrency_price_base_type HT or TTC in currency - * @param float $multicurrency_tx Rate currency - * @param string $multicurrency_code Currency code - * @param string $desc_fourn Custom description for product_fourn_price - * @param string $barcode Barcode - * @param int $fk_barcode_type Barcode type - * @return int <0 if KO, >=0 if OK - */ - public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '') - { - // phpcs:enable - global $conf, $langs; - //global $mysoc; - - // Clean parameter - if (empty($qty)) $qty = 0; - if (empty($buyprice)) $buyprice = 0; - if (empty($charges)) $charges = 0; - if (empty($availability)) $availability = 0; - if (empty($remise_percent)) $remise_percent = 0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; - if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; - if ($price_base_type == 'TTC') - { - $ttx = $tva_tx; - $buyprice = $buyprice / (1 + ($ttx / 100)); - } - - // Multicurrency - $multicurrency_unitBuyPrice = null; - $fk_multicurrency = null; - if (!empty($conf->multicurrency->enabled)) { - if (empty($multicurrency_tx)) $multicurrency_tx = 1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if ($multicurrency_price_base_type == 'TTC') - { - $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); - } - $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - - $buyprice = $multicurrency_buyprice / $multicurrency_tx; - $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); - } - - $buyprice = price2num($buyprice, 'MU'); - $charges = price2num($charges, 'MU'); - $qty = price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - - $packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); - - $error = 0; - $now = dol_now(); - - $newvat = $tva_tx; - - if (count($localtaxes_array) > 0) - { - $localtaxtype1 = $localtaxes_array['0']; - $localtax1 = $localtaxes_array['1']; - $localtaxtype2 = $localtaxes_array['2']; - $localtax2 = $localtaxes_array['3']; - } else { // old method. deprecated because ot can't retrieve type - $localtaxtype1 = '0'; - $localtax1 = get_localtax($newvat, 1); - $localtaxtype2 = '0'; - $localtax2 = get_localtax($newvat, 2); - } - if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 - if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 - - // Check parameters - if ($buyprice != '' && !is_numeric($buyprice)) - { - } - - $this->db->begin(); - - if ($this->product_fourn_price_id > 0) - { - // check if price already logged, if not first log current price - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id); - if (is_array($logPrices) && count($logPrices) == 0) - { - $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); - if ($result > 0 && $currentPfp->fourn_price != 0) - { - $currentPfpUser = new User($this->db); - $result = $currentPfpUser->fetch($currentPfp->user_id); - if ($result > 0) { - $currentPfp->logPrice( - $currentPfpUser, - $currentPfp->date_creation, - $currentPfp->fourn_price, - $currentPfp->fourn_qty, - $currentPfp->fourn_multicurrency_price, - $currentPfp->fourn_multicurrency_unitprice, - $currentPfp->fourn_multicurrency_tx, - $currentPfp->fourn_multicurrency_id, - $currentPfp->fourn_multicurrency_code - ); - } - } - } - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; - $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; - $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; - $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " entity = ".$conf->entity.","; - $sql .= " tva_tx = ".price2num($tva_tx).","; - // TODO Add localtax1 and localtax2 - //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; - //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; - //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; - //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; - $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - // TODO Add price_base_type and price_ttc - - dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); - if ($result < 0) $error++; - // End call triggers - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) - { - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - if (empty($error)) - { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); - - // Delete price for this quantity - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - // Add price for this quantity to supplier - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging"; - $sql .= " values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " ".$this->id.","; - $sql .= " ".$fourn->id.","; - $sql .= " '".$this->db->escape($ref_fourn)."',"; - $sql .= " '".$this->db->escape($desc_fourn)."',"; - $sql .= " ".$user->id.","; - $sql .= " ".$buyprice.","; - $sql .= " ".$qty.","; - $sql .= " ".$remise_percent.","; - $sql .= " ".$remise.","; - $sql .= " ".$unitBuyPrice.","; - $sql .= " ".$tva_tx.","; - $sql .= " ".$charges.","; - $sql .= " ".$availability.","; - $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " ".$newnpr.","; - $sql .= $conf->entity.","; - $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)); - $sql .= ")"; - - $this->product_fourn_price_id = 0; - - $resql = $this->db->query($sql); - if ($resql) { - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); - } else { - $error++; - } - - if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { - // Add record into log table - // $this->product_fourn_price_id must be set - $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); - if ($result < 0) { - $error++; - } - } - - if (!$error) { - // Call trigger - $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); - if ($result < 0) - $error++; - // End call triggers - - if (empty($error)) { - $this->db->commit(); - return $this->product_fourn_price_id; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Loads the price information of a provider - * - * @param int $rowid Line id - * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead - * @return int < 0 if KO, 0 if OK but not found, > 0 if OK - */ - public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging,"; - $sql .= " p.ref as product_ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p"; - $sql .= " WHERE pfp.rowid = ".(int) $rowid; - $sql .= " AND pfp.fk_product = p.rowid"; - - dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) - { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; - - $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; - $this->product_ref = $obj->product_ref; - - $this->fourn_id = $obj->fk_soc; - $this->fourn_ref = $obj->ref_fourn; // deprecated - $this->ref_supplier = $obj->ref_fourn; - $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated - $this->fourn_qty = $obj->quantity; - $this->fourn_remise_percent = $obj->remise_percent; - $this->fourn_remise = $obj->remise; - $this->fourn_unitprice = $obj->unitprice; - $this->fourn_tva_tx = $obj->tva_tx; - $this->fourn_tva_npr = $obj->fourn_tva_npr; - // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; - $this->supplier_reputation = $obj->supplier_reputation; - $this->default_vat_code = $obj->default_vat_code; - $this->user_id = $obj->fk_user; - $this->date_creation = $this->db->jdate($obj->datec); - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; - if (!empty($conf->barcode->enabled)) { - $this->fourn_barcode = $obj->barcode; // deprecated - $this->fourn_fk_barcode_type = $obj->fk_barcode_type; // deprecated - $this->supplier_barcode = $obj->barcode; - $this->supplier_fk_barcode_type = $obj->fk_barcode_type; - } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty; - } - - if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) - { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($this); - if ($price_result >= 0) { - $this->fourn_price = $price_result; - //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty != 0) - { - $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); - } else { - $this->fourn_unitprice = ""; - } - } - } - - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * List all supplier prices of a product - * - * @param int $prodid Id of product - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Products with new properties to define supplier price - */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - // phpcs:enable - global $conf; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref,"; - $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected - $sql .= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($record = $this->db->fetch_array($resql)) - { - //define base attribute - $prodfourn = new ProductFournisseur($this->db); - - $prodfourn->product_ref = $record["product_ref"]; - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->product_fourn_entity = $record["entity"]; - $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; - $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; - $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; - $prodfourn->fk_availability = $record["fk_availability"]; - $prodfourn->delivery_time_days = $record["delivery_time_days"]; - $prodfourn->id = $prodid; - $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; - $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); - $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); - - $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"]; - $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; - $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty; - } - - if (!empty($conf->barcode->enabled)) { - $prodfourn->supplier_barcode = $record["barcode"]; - $prodfourn->supplier_fk_barcode_type = $record["fk_barcode_type"]; - } - - if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prodfourn); - if ($price_result >= 0) { - $prodfourn->fourn_price = $price_result; - $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed... - } - } - - if (!isset($prodfourn->fourn_unitprice)) - { - if ($prodfourn->fourn_qty != 0) - { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); - } else { - $prodfourn->fourn_unitprice = ""; - } - } - - $retarray[] = $prodfourn; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load properties for minimum price - * - * @param int $prodid Product id - * @param int $qty Minimum quantity - * @param int $socid get min price for specific supplier - * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK - */ - public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) - { - // phpcs:enable - global $conf; - - if (empty($prodid)) - { - dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); - return 0; - } - - $this->product_fourn_price_id = ''; - $this->product_fourn_id = ''; - $this->fourn_ref = ''; - $this->fourn_price = ''; - $this->fourn_qty = ''; - $this->fourn_remise_percent = ''; - $this->fourn_remise = ''; - $this->fourn_unitprice = ''; - $this->fourn_id = ''; - $this->fourn_name = ''; - $this->delivery_time_days = ''; - $this->id = ''; - - $this->fourn_multicurrency_price = ''; - $this->fourn_multicurrency_unitprice = ''; - $this->fourn_multicurrency_tx = ''; - $this->fourn_multicurrency_id = ''; - $this->fourn_multicurrency_code = ''; - - $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - $sql .= " AND pfp.entity = ".$conf->entity; // only current entity - $sql .= " AND pfp.fk_product = ".$prodid; - $sql .= " AND pfp.fk_soc = s.rowid"; - $sql .= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; - - dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $record_array = array(); - - //Store each record to array for later search of min - while ($record = $this->db->fetch_array($resql)) - { - $record_array[] = $record; - } - - if (count($record_array) == 0) - { - $this->db->free($resql); - return 0; - } else { - $min = -1; - foreach ($record_array as $record) - { - $fourn_price = $record["price"]; - // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; - if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { - $prod_supplier = new ProductFournisseur($this->db); - $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; - $prod_supplier->id = $prodid; - $prod_supplier->fourn_qty = $record["quantity"]; - $prod_supplier->fourn_tva_tx = $record["tva_tx"]; - $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProductSupplier($prod_supplier); - if ($price_result >= 0) { - $fourn_price = price2num($price_result, 'MU'); - if ($record["quantity"] != 0) - { - $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); - } else { - $fourn_unitprice = $fourn_price; - } - } - } - if ($fourn_unitprice < $min || $min == -1) - { - $this->product_fourn_price_id = $record["product_fourn_price_id"]; - $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated - $this->fourn_price = $fourn_price; - $this->fourn_qty = $record["quantity"]; - $this->fourn_remise_percent = $record["remise_percent"]; - $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_tva_tx = $record["tva_tx"]; - $this->fourn_id = $record["fourn_id"]; - $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $this->id = $prodid; - $this->fourn_multicurrency_price = $record["multicurrency_price"]; - $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; - $this->fourn_multicurrency_tx = $record["multicurrency_tx"]; - $this->fourn_multicurrency_id = $record["fk_multicurrency"]; - $this->fourn_multicurrency_code = $record["multicurrency_code"]; - $min = $fourn_unitprice; - } - } - } - - $this->db->free($resql); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Sets the supplier price expression - * - * @param int $expression_id Expression - * @return int <0 if KO, >0 if OK - */ - public function setSupplierPriceExpression($expression_id) - { - global $conf; - - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; - - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; - - dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } - } - - /** - * Display supplier of product - * - * @param int $withpicto Add picto - * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @return string String with supplier price - * TODO Remove this method. Use getNomUrl directly. - */ - public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) - { - $thirdparty = new Fournisseur($this->db); - $thirdparty->fetch($this->fourn_id); - - return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display price of product - * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price - */ - public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) - { - // phpcs:enable - global $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - foreach ($productFournList as $productFourn) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - } - $out .= '
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; - } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); - } - return $out; - } - - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'product_fournisseur_price' - ); - - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } - - /** - * List supplier prices log of a supplier price - * - * @param int $product_fourn_price_id Id of supplier price - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit - * @param int $offset Offset - * @return array Array of Log prices - */ - public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) - { - $sql = "SELECT"; - $sql .= " u.lastname,"; - $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,"; - $sql .= " pfpl.price, pfpl.quantity,"; - $sql .= " pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl,"; - $sql .= " ".MAIN_DB_PREFIX."product_fournisseur_price as pfp,"; - $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql .= " AND pfpl.fk_user = u.rowid"; - $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; - else $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $retarray = array(); - - while ($obj = $this->db->fetch_object($resql)) - { - $tmparray = array(); - $tmparray['rowid'] = $obj->rowid; - $tmparray['supplier_ref'] = $obj->supplier_ref; - $tmparray['datec'] = $this->db->jdate($obj->datec); - $tmparray['lastname'] = $obj->lastname; - $tmparray['price'] = $obj->price; - $tmparray['quantity'] = $obj->quantity; - $tmparray['fk_multicurrency'] = $obj->fk_multicurrency; - $tmparray['multicurrency_code'] = $obj->multicurrency_code; - $tmparray['multicurrency_tx'] = $obj->multicurrency_tx; - $tmparray['multicurrency_price'] = $obj->multicurrency_price; - $tmparray['multicurrency_unitprice'] = $obj->multicurrency_unitprice; - - $retarray[] = $tmparray; - } - - $this->db->free($resql); - return $retarray; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Display log price of product supplier price - * - * @param array $productFournLogList list of ProductFournisseur price log objects - * to display in table format. - * @return string HTML String with supplier price - */ - public function displayPriceProductFournisseurLog($productFournLogList = array()) - { - global $conf, $langs; - - $out = ''; - $langs->load("suppliers"); - if (count($productFournLogList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - //$out .= ''; - $out .= ''; - foreach ($productFournLogList as $productFournLog) { - $out .= ''; - $out .= ''; - //$out.= ''; - $out .= ''; - } - $out .= '
'.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("QtyMin").''.$langs->trans("User").'
'.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').''.price($productFournLog['price'], 0, $langs, 1, -1, -1, $conf->currency); - if ($productFournLog['multicurrency_code'] != $conf->currency) { - $out .= ' ('.price($productFournLog['multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog['multicurrency_code']).')'; - } - $out .= ''.$productFournLog['quantity'].''.$productFournLog['lastname'].'
'; - } - return $out; - } - - - /** - * Return a link to the object card (with optionaly the picto). - * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl(). - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - - if (!empty($conf->dol_no_mouse_hover)) { - $notooltip = 1; // Force disable tooltips - } - - $result = ''; - $label = ''; - - if (!empty($this->entity)) { - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { - $label .= '
'; - $label .= $tmpphoto; - $label .= '
'; - } - } - - if ($this->type == Product::TYPE_PRODUCT) { - $label .= img_picto('', 'product').' '.$langs->trans("Product").''; - } elseif ($this->type == Product::TYPE_SERVICE) { - $label .= img_picto('', 'service').' '.$langs->trans("Service").''; - } - if (isset($this->status) && isset($this->status_buy)) { - $label .= ' '.$this->getLibStatut(5, 0); - $label .= ' '.$this->getLibStatut(5, 1); - } - - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('ProductRef').': '.($this->ref ? $this->ref : $this->product_ref); - } - if (!empty($this->label)) { - $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; - } - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - - if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (!empty($conf->productbatch->enabled)) { - $langs->load("productbatch"); - $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); - } - } - if (!empty($conf->barcode->enabled)) { - $label .= '
'.$langs->trans('BarCode').': '.$this->barcode; - } - - if ($this->type == Product::TYPE_PRODUCT) { - if ($this->weight) { - $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); - } - $labelsize = ""; - if ($this->length) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); - } - if ($this->width) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); - } - if ($this->height) { - $labelsize .= ($labelsize ? " - " : "")."".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); - } - if ($labelsize) $label .= "
".$labelsize; - - $labelsurfacevolume = ""; - if ($this->surface) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); - } - if ($this->volume) { - $labelsurfacevolume .= ($labelsurfacevolume ? " - " : "")."".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); - } - if ($labelsurfacevolume) $label .= "
".$labelsurfacevolume; - } - - if (!empty($conf->accounting->enabled) && $this->status) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); - } - if (!empty($conf->accounting->enabled) && $this->status_buy) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); - $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); - } - - $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here - if (is_array($logPrices) && count($logPrices) > 0) { - $label .= '

'; - $label .= ''.$langs->trans("History").''; - $label .= $this->displayPriceProductFournisseurLog($logPrices); - } - - $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; - - if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { - $add_save_lastsearch_values = 1; - } - if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; - } - } - - $linkclose = ''; - if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label = $langs->trans("SupplierRef"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - } - - $linkstart = ''; - $linkend = ''; - - $result .= $linkstart; - if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - } - if ($withpicto != 2) { - $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); - } - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - return $result; - } - - /** - * Private function to log price history - * - * @param User $user Object user who adds/changes price - * @param integer $datec date create - * @param float $buyprice price for qty - * @param float $qty qty for price - * @param float $multicurrency_buyprice Purchase price for the quantity min in currency - * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency - * @param float $multicurrency_tx Rate currency - * @param int $fk_multicurrency key multi currency - * @param string $multicurrency_code Currency code - * - * @return int < 0 NOK > 0 OK - */ - private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) - { - // Add record into log table - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; - $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; - $sql .= "values("; - $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; - $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; - $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; - $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; - $sql .= "'".$this->db->idate($datec)."',"; - $sql .= " ".$this->product_fourn_price_id.","; - $sql .= " ".$user->id.","; - $sql .= " ".price2num($buyprice).","; - $sql .= " ".$qty; - $sql .= ")"; - - $resql = $this->db->query($sql); - if (!$resql) { - return -1; - } else { - return 1; - } - } - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = 'SELECT '; - $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); - } -} diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 371a5581c55..0f39005a708 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1348,7 +1348,13 @@ class ProductFournisseur extends Product return -1; } } - public function getFieldList() { - return array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); + /** + * Function to concat keys of fields + * + * @return string + */ + protected function getFieldList() { + $keys = array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); + return implode(',', $keys); } } From e7f24e21099b8b358cb4387f1ed7d945408c16ad Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 8 Mar 2021 16:00:49 +0000 Subject: [PATCH 010/233] Fixing style errors. --- htdocs/fourn/class/fournisseur.product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 0f39005a708..836ae7b6d8c 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1353,7 +1353,8 @@ class ProductFournisseur extends Product * * @return string */ - protected function getFieldList() { + protected function getFieldList() + { $keys = array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); return implode(',', $keys); } From 061e797d6499fe76c2a500d6b2608d861d5dc4de Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 17:35:12 +0100 Subject: [PATCH 011/233] correct product fournisseur class fetchAll --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 836ae7b6d8c..6b3c309ceb4 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1293,7 +1293,7 @@ class ProductFournisseur extends Product $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as t'; $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; // Manage filter From cfc56da26312106a59364207ea65ff518753438a Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Mon, 8 Mar 2021 17:59:58 +0100 Subject: [PATCH 012/233] fournisseur product class - update style code --- htdocs/fourn/class/fournisseur.product.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 6b3c309ceb4..d826183d93f 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1355,7 +1355,12 @@ class ProductFournisseur extends Product */ protected function getFieldList() { - $keys = array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', 'fk_barcode_type', 'packaging'); + $keys = array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', + 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', + 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', + 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', + 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', + 'fk_barcode_type', 'packaging'); return implode(',', $keys); } } From 4a185ba063095269b08941f8966e82316b25eb11 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 12 Mar 2021 12:47:58 +0100 Subject: [PATCH 013/233] add warehouse quabtity + fix input new quantity --- htdocs/product/inventory/inventory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index dea3b46c946..6c8f6ab5256 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -505,10 +505,10 @@ if ($object->id > 0) { } print ''; - print 'TODO'; + print $obj->qty_stock; print ''; print ''; - print 'rowid).'">'; + print 'rowid).'">'; print ''; print ''; print ''.img_delete().''; From 60086276d99bbb16ce35ad31895e716145c6f084 Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Fri, 19 Mar 2021 15:53:41 +0100 Subject: [PATCH 014/233] add product fournisseur price crud class --- .../class/productfournisseurprice.class.php | 880 ++++++++++++++++++ 1 file changed, 880 insertions(+) create mode 100644 htdocs/product/class/productfournisseurprice.class.php diff --git a/htdocs/product/class/productfournisseurprice.class.php b/htdocs/product/class/productfournisseurprice.class.php new file mode 100644 index 00000000000..4173e56a648 --- /dev/null +++ b/htdocs/product/class/productfournisseurprice.class.php @@ -0,0 +1,880 @@ + + * Copyright (C) 2021 Alexis LAURIER + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file class/productfournisseurprice.class.php + * \ingroup buypricehistory + * \brief This file is a CRUD class file for ProductFournisseurPrice (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + +/** + * Class for ProductFournisseurPrice + */ +class ProductFournisseurPrice extends CommonObject +{ + /** + * @var string ID to identify managed object. + */ + public $element = 'productfournisseurprice'; + + /** + * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. + */ + public $table_element = 'product_fournisseur_price'; + + /** + * @var int Does this object support multicompany module ? + * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 1; + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for productfournisseurprice. Must be the part after the 'object_' into object_productfournisseurprice.png + */ + public $picto = 'productfournisseurprice@buypricehistory'; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + const STATUS_CANCELED = 9; + + + /** + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'picto' is code of a picto to show before value in forms + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200' + * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,), + 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>-1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>25, 'notnull'=>1, 'visible'=>-1,), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), + 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), + 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), + 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), + 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), + 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), + 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), + 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), + 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), + 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), + 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), + 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), + 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), + 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), + 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>900, 'notnull'=>0, 'visible'=>-2,), + 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), + 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), + 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), + 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), + 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), + 'barcode' => array('type'=>'varchar(180)', 'label'=>'Barcode', 'enabled'=>'1', 'position'=>170, 'notnull'=>0, 'visible'=>-1,), + 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), + 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), + ); + public $rowid; + public $entity; + public $datec; + public $tms; + public $fk_product; + public $fk_soc; + public $ref_fourn; + public $desc_fourn; + public $fk_availability; + public $price; + public $quantity; + public $remise_percent; + public $remise; + public $unitprice; + public $charges; + public $default_vat_code; + public $tva_tx; + public $info_bits; + public $fk_user; + public $fk_supplier_price_expression; + public $import_key; + public $delivery_time_days; + public $supplier_reputation; + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_tx; + public $multicurrency_price; + public $multicurrency_unitprice; + public $localtax1_tx; + public $localtax1_type; + public $localtax2_tx; + public $localtax2_type; + public $barcode; + public $fk_barcode_type; + public $packaging; + // END MODULEBUILDER PROPERTIES + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + if (property_exists($object, 'ref')) $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + if (property_exists($object, 'label')) $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + if (property_exists($object, 'status')) { $object->status = self::STATUS_DRAFT; } + if (property_exists($object, 'date_creation')) { $object->date_creation = dol_now(); } + if (property_exists($object, 'date_modification')) { $object->date_modification = null; } + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->table_element); + foreach ($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + if (!$error) + { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) + { + $error++; + } + } + + if (!$error) + { + // copy external contacts if same company + if (property_exists($this, 'socid') && $this->socid == $object->socid) + { + if ($this->copy_linked_contact($object, 'external') < 0) + $error++; + } + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id) + { + return $this->fetchCommon($id); + } + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList(); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; + else $sql .= ' WHERE 1 = 1'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) + { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } + + /** + * Validate object + * + * @param User $user User making status change + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <=0 if OK, 0=Nothing done, >0 if KO + */ + public function validate($user, $notrigger = 0) + { + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error = 0; + + // Protection + if ($this->status == self::STATUS_VALIDATED) + { + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); + return 0; + } + + $now = dol_now(); + + $this->db->begin(); + + // Define new ref + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + { + $num = $this->getNextNumRef(); + } else { + $num = $this->ref; + } + $this->newref = $num; + + if (!empty($num)) { + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED; + if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."'"; + if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('PRODUCTFOURNISSEURPRICE_VALIDATE', $user); + if ($result < 0) $error++; + // End call triggers + } + } + + if (!$error) + { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'productfournisseurprice/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'productfournisseurprice/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$oldref; + $dirdest = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref; + if (!$error && file_exists($dirsource)) + { + dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) + { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Set new ref and current status + if (!$error) + { + $this->ref = $num; + $this->status = self::STATUS_VALIDATED; + } + + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) + { + return 0; + } + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PRODUCTFOURNISSEURPRICE_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) + { + return 0; + } + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PRODUCTFOURNISSEURPRICE_CANCEL'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) + { + return 0; + } + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'PRODUCTFOURNISSEURPRICE_REOPEN'); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + + $result = ''; + + $label = img_picto('', $this->picto).' '.$langs->trans("ProductFournisseurPrice").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + + $url = dol_buildpath('/buypricehistory/productfournisseurprice_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } + + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowProductFournisseurPrice"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + + $linkstart = ''; + $linkend = ''; + + $result .= $linkstart; + + if (empty($this->showphoto_on_popup)) { + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if (!empty($filename)) { + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + $result .= '
No photo
'; + } else { + $result .= '
No photo
'; + } + + $result .= ''; + } else { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } + } + + if ($withpicto != 2) $result .= $this->ref; + + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action, $hookmanager; + $hookmanager->initHooks(array('productfournisseurpricedao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) + { + global $langs; + //$langs->load("buypricehistory@buypricehistory"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled'); + } + + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_CANCELED) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + /** + * Returns the reference to the following non used object depending on the active numbering module. + * + * @return string Object free reference + */ + public function getNextNumRef() + { + global $langs, $conf; + $langs->load("buypricehistory@buypricehistory"); + + if (empty($conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON)) { + $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON = 'mod_productfournisseurprice_standard'; + } + + if (!empty($conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON)) + { + $mybool = false; + + $file = $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON.".php"; + $classname = $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $dir = dol_buildpath($reldir."core/modules/buypricehistory/"); + + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; + } + + if ($mybool === false) + { + dol_print_error('', "Failed to include file ".$file); + return ''; + } + + if (class_exists($classname)) { + $obj = new $classname(); + $numref = $obj->getNextValue($this); + + if ($numref != '' && $numref != '-1') + { + return $numref; + } else { + $this->error = $obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + return ""; + } + } else { + print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; + return ""; + } + } else { + print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); + return ""; + } + } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; + + $result = 0; + $includedocgeneration = 0; + + $langs->load("buypricehistory@buypricehistory"); + + if (!dol_strlen($modele)) { + $modele = 'standard_productfournisseurprice'; + + if (!empty($this->model_pdf)) { + $modele = $this->model_pdf; + } elseif (!empty($conf->global->PRODUCTFOURNISSEURPRICE_ADDON_PDF)) { + $modele = $conf->global->PRODUCTFOURNISSEURPRICE_ADDON_PDF; + } + } + + $modelpath = "core/modules/buypricehistory/doc/"; + + if ($includedocgeneration && !empty($modele)) { + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + + return $result; + } +} From c3366ccd61f30775b91fa43990dfb47fcb212fe9 Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Fri, 19 Mar 2021 16:04:07 +0100 Subject: [PATCH 015/233] remove moved methods and properties from fournisseurproduct --- .../fourn/class/fournisseur.product.class.php | 123 ------------------ 1 file changed, 123 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index d826183d93f..6d7e3500b25 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -146,37 +146,6 @@ class ProductFournisseur extends Product $this->db = $db; $langs->load("suppliers"); $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); - $this->fields = array_merge($this->fields, array( - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), - 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), - 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), - 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), - 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), - 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), - 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), - 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), - 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), - 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), - 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), - 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), - 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), - 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), - 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), - 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), - 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), - 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), - 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), - 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), - 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), - 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), - 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), - )); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1271,96 +1240,4 @@ class ProductFournisseur extends Product return 1; } } - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = 'SELECT '; - $sql .= $this->getFieldList(); - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('productsupplierprice').')'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - /** - * Function to concat keys of fields - * - * @return string - */ - protected function getFieldList() - { - $keys = array('rowid', 'entity', 'datec', 'tms', 'fk_product', 'fk_soc', 'ref_fourn', 'desc_fourn', - 'fk_availability', 'price', 'quantity', 'remise_percent', 'remise', 'unitprice', 'charges', 'default_vat_code', - 'tva_tx', 'info_bits', 'fk_user', 'fk_supplier_price_expression', 'import_key', 'delivery_time_days', - 'supplier_reputation', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', 'multicurrency_price', - 'multicurrency_unitprice', 'localtax1_tx', 'localtax1_type', 'localtax2_tx', 'localtax2_type', 'barcode', - 'fk_barcode_type', 'packaging'); - return implode(',', $keys); - } } From 4a90584ce15cf4eac007a4412338261dd72dc18c Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Fri, 19 Mar 2021 16:07:52 +0100 Subject: [PATCH 016/233] product fournisseur price - clean --- htdocs/fourn/class/fournisseur.product.class.php | 1 + htdocs/product/class/productfournisseurprice.class.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 6d7e3500b25..6ae9a3491ab 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -134,6 +134,7 @@ class ProductFournisseur extends Product public $packaging; + /** * Constructor * diff --git a/htdocs/product/class/productfournisseurprice.class.php b/htdocs/product/class/productfournisseurprice.class.php index 4173e56a648..71e25b0c4e1 100644 --- a/htdocs/product/class/productfournisseurprice.class.php +++ b/htdocs/product/class/productfournisseurprice.class.php @@ -18,7 +18,7 @@ /** * \file class/productfournisseurprice.class.php - * \ingroup buypricehistory + * \ingroup product * \brief This file is a CRUD class file for ProductFournisseurPrice (Create/Read/Update/Delete) */ From 6ba878725e4a25d27e4a94da3d5e7865627d601b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 22 Mar 2021 07:28:16 +0100 Subject: [PATCH 017/233] Fix #16794 V13 order by status instead of statut --- htdocs/core/class/html.formother.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index c71029769f2..b6ae7cdbfc2 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -474,7 +474,7 @@ class FormOther //Add hook to filter on user (for exemple on usergroup define in custom modules) if (!empty($reshook)) $sql_usr .= $hookmanager->resArray[1]; } - $sql_usr .= " ORDER BY statut DESC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION. + $sql_usr .= " ORDER BY status DESC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION. //print $sql_usr;exit; $resql_usr = $this->db->query($sql_usr); From b1215875824c2fd4f38a34926ef5f07ecc93e27e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 22 Mar 2021 15:39:54 +0100 Subject: [PATCH 018/233] change to GETPOST --- htdocs/projet/tasks/time.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ffb214e3830..3cd49eb7d9e 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -175,10 +175,10 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) $action = 'createtime'; $error++; } else { - $object->timespent_note = $_POST["timespent_note"]; + $object->timespent_note = GETPOST('timespent_note','alpha'); if (GETPOST('progress', 'int') > 0) $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value - $object->timespent_duration = $_POST["timespent_durationhour"] * 60 * 60; // We store duration in seconds - $object->timespent_duration += ($_POST["timespent_durationmin"] ? $_POST["timespent_durationmin"] : 0) * 60; // We store duration in seconds + $object->timespent_duration = (int) GETPOST("timespent_durationhour",'int') * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOST('timespent_durationmin','int') ? (int) GETPOST('timespent_durationmin','int') : 0) * 60; // We store duration in seconds if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timehour"), GETPOST("timemin"), 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); @@ -224,10 +224,10 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $result = $object->delTimeSpent($user); $object->fetch($id, $ref); - $object->timespent_note = $_POST["timespent_note_line"]; - $object->timespent_old_duration = $_POST["old_duration"]; - $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds - $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds + $object->timespent_note = GETPOST('timespent_note_line','alpha'); + $object->timespent_old_duration = GETPOST("old_duration"); + $object->timespent_duration = (int) GETPOST("new_durationhour", 'int') * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOST("new_durationmin", 'int') ? (int) GETPOST('new_durationmin', 'int') : 0) * 60; // We store duration in seconds if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); @@ -248,11 +248,11 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->fetch($id, $ref); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) - $object->timespent_id = $_POST["lineid"]; - $object->timespent_note = $_POST["timespent_note_line"]; - $object->timespent_old_duration = $_POST["old_duration"]; - $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds - $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds + $object->timespent_id = GETPOST("lineid" , 'int'); + $object->timespent_note = GETPOST('timespent_note_line','alpha'); + $object->timespent_old_duration = GETPOST("old_duration"); + $object->timespent_duration = (int) GETPOST("new_durationhour", 'int') * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOST("new_durationmin", 'int') ? (int) GETPOST('new_durationmin', 'int') : 0) * 60; // We store duration in seconds if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); @@ -260,7 +260,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } else { $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); } - $object->timespent_fk_user = $_POST["userid_line"]; + $object->timespent_fk_user = GETPOST("userid_line" , 'int'); $result = $object->updateTimeSpent($user); if ($result >= 0) From ba66eaeb188f45f553f595d743a861d3115a0ca5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 22 Mar 2021 14:42:31 +0000 Subject: [PATCH 019/233] Fixing style errors. --- htdocs/projet/tasks/time.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 3cd49eb7d9e..eeca9e34cd1 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -175,10 +175,10 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) $action = 'createtime'; $error++; } else { - $object->timespent_note = GETPOST('timespent_note','alpha'); + $object->timespent_note = GETPOST('timespent_note', 'alpha'); if (GETPOST('progress', 'int') > 0) $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value - $object->timespent_duration = (int) GETPOST("timespent_durationhour",'int') * 60 * 60; // We store duration in seconds - $object->timespent_duration += (GETPOST('timespent_durationmin','int') ? (int) GETPOST('timespent_durationmin','int') : 0) * 60; // We store duration in seconds + $object->timespent_duration = (int) GETPOST("timespent_durationhour", 'int') * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOST('timespent_durationmin', 'int') ? (int) GETPOST('timespent_durationmin', 'int') : 0) * 60; // We store duration in seconds if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timehour"), GETPOST("timemin"), 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); @@ -224,7 +224,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $result = $object->delTimeSpent($user); $object->fetch($id, $ref); - $object->timespent_note = GETPOST('timespent_note_line','alpha'); + $object->timespent_note = GETPOST('timespent_note_line', 'alpha'); $object->timespent_old_duration = GETPOST("old_duration"); $object->timespent_duration = (int) GETPOST("new_durationhour", 'int') * 60 * 60; // We store duration in seconds $object->timespent_duration += (GETPOST("new_durationmin", 'int') ? (int) GETPOST('new_durationmin', 'int') : 0) * 60; // We store duration in seconds @@ -248,8 +248,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->fetch($id, $ref); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) - $object->timespent_id = GETPOST("lineid" , 'int'); - $object->timespent_note = GETPOST('timespent_note_line','alpha'); + $object->timespent_id = GETPOST("lineid", 'int'); + $object->timespent_note = GETPOST('timespent_note_line', 'alpha'); $object->timespent_old_duration = GETPOST("old_duration"); $object->timespent_duration = (int) GETPOST("new_durationhour", 'int') * 60 * 60; // We store duration in seconds $object->timespent_duration += (GETPOST("new_durationmin", 'int') ? (int) GETPOST('new_durationmin', 'int') : 0) * 60; // We store duration in seconds @@ -260,7 +260,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } else { $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); } - $object->timespent_fk_user = GETPOST("userid_line" , 'int'); + $object->timespent_fk_user = GETPOST("userid_line", 'int'); $result = $object->updateTimeSpent($user); if ($result >= 0) From af593099dfe25a913ab2b3a14ae00bcef23ae2f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Mar 2021 23:52:14 +0100 Subject: [PATCH 020/233] Clean string --- htdocs/core/modules/societe/doc/doc_generic_odt.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 2a7e0cf287f..7926ea06cc5 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -243,6 +243,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) { $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp; + $newfiletmp = preg_replace('/__+/', '_', $newfiletmp); // Replace repeated _ into one _ (to avoid string with substitution syntax) } if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { From bc1a412d1bd4e21864cb49feae6192e686420854 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 23 Mar 2021 11:45:17 +0100 Subject: [PATCH 021/233] ongoing --- htdocs/langs/en_US/eventorganization.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 5444ed59e3d..9d7301fc465 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -50,6 +50,8 @@ EventOrganizationConfOrBooth= Conference Or Booth ManageOrganizeEvent = Manage event organisation ConferenceOrBooth = Conference Or Booth ConferenceOrBoothTab = Conference Or Booth +AmountOfSubscriptionPaid = Amount of subscription paid +DateSubscription = Date of subscription # # Template Mail From 4f693b86c2954434d252a8e448897f471d5e2269 Mon Sep 17 00:00:00 2001 From: ATM john Date: Tue, 23 Mar 2021 19:27:40 +0100 Subject: [PATCH 022/233] shhhhhh ! There is nothing here... --- htdocs/core/tpl/login.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 403c4daefe9..5e78b77dce8 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -289,9 +289,9 @@ if (! empty($_SESSION['dol_loginmesg'])) if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; if (substr($langs->defaultlang, 0, 2)=='fr') { - $resgetcommitstrip = getURLContent("http://www.commitstrip.com/fr/feed/"); + $resgetcommitstrip = getURLContent("https://www.commitstrip.com/fr/feed/"); } else { - $resgetcommitstrip = getURLContent("http://www.commitstrip.com/en/feed/"); + $resgetcommitstrip = getURLContent("https://www.commitstrip.com/en/feed/"); } if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200') { From 05419441aaa232a6224b4f0ca3e7b06bccbc312b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 23 Mar 2021 19:58:15 +0100 Subject: [PATCH 023/233] FIX missing return edit if update error --- htdocs/adherents/card.php | 106 ++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index a3fe601ae6e..7199423669a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -303,7 +303,9 @@ if (empty($reshook)) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } // Check if we need to also synchronize user information $nosyncuser = 0; @@ -317,62 +319,66 @@ if (empty($reshook)) { if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass = 1; // Disable synchronizing } - $result = $object->update($user, 0, $nosyncuser, $nosyncuserpass); + if (!$error) { + $result = $object->update($user, 0, $nosyncuser, $nosyncuserpass); - if ($result >= 0 && !count($object->errors)) { - $categories = GETPOST('memcats', 'array'); - $object->setCategories($categories); + if ($result >= 0 && !count($object->errors)) { + $categories = GETPOST('memcats', 'array'); + $object->setCategories($categories); - // Logo/Photo save - $dir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos'; - $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if ($file_OK) { - if (GETPOST('deletephoto')) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileimg = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo; - $dirthumbs = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); - } + // Logo/Photo save + $dir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos'; + $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); + if ($file_OK) { + if (GETPOST('deletephoto')) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $fileimg = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo; + $dirthumbs = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + } - if (image_format_supported($_FILES['photo']['name']) > 0) { - dol_mkdir($dir); + if (image_format_supported($_FILES['photo']['name']) > 0) { + dol_mkdir($dir); - if (@is_dir($dir)) { - $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { - setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); - } else { - // Create thumbs - $object->addThumbs($newfile); - } - } - } else { - setEventMessages("ErrorBadImageFormat", null, 'errors'); - } - } else { - switch ($_FILES['photo']['error']) { - case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini - case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form - $errors[] = "ErrorFileSizeTooLarge"; - break; - case 3: //uploaded file was only partially uploaded - $errors[] = "ErrorFilePartiallyUploaded"; - break; - } - } + if (@is_dir($dir)) { + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { + setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); + } else { + // Create thumbs + $object->addThumbs($newfile); + } + } + } else { + setEventMessages("ErrorBadImageFormat", null, 'errors'); + } + } else { + switch ($_FILES['photo']['error']) { + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $errors[] = "ErrorFileSizeTooLarge"; + break; + case 3: //uploaded file was only partially uploaded + $errors[] = "ErrorFilePartiallyUploaded"; + break; + } + } - $rowid = $object->id; - $id = $object->id; - $action = ''; + $rowid = $object->id; + $id = $object->id; + $action = ''; - if (!empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; + $action = 'edit'; } } else { $action = 'edit'; From cc78e7c6851688e7f9b67db03d088c396b1d1f11 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 23 Mar 2021 21:04:38 +0100 Subject: [PATCH 024/233] add field on conf or booth tabs --- htdocs/core/class/html.form.class.php | 8 ++- .../conferenceorbooth_list.php | 58 +++++++++++++++++++ htdocs/langs/en_US/eventorganization.lang | 1 + htdocs/projet/class/project.class.php | 33 +++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 848b07bd450..3a36950608a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -96,7 +96,7 @@ class Form * @param string $preselected Value to show/edit (not used in this function) * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), '+:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) * @param string $moreparam More param to add on a href URL. * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' ' @@ -237,6 +237,9 @@ class Form $tmp = explode(':', $typeofdata); $valuetoshow = price2num($editvalue ? $editvalue : $value); $ret .= ''; + } elseif (preg_match('/^(checkbox)/', $typeofdata)) { + $tmp = explode(':', $typeofdata); + $ret .= ''; } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { // if wysiwyg is enabled $typeofdata = 'ckeditor' $tmp = explode(':', $typeofdata); $cols = $tmp[2]; @@ -298,6 +301,9 @@ class Form $ret .= dol_print_email($value, 0, 0, 0, 0, 1); } elseif (preg_match('/^(amount|numeric)/', $typeofdata)) { $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); + } elseif (preg_match('/^(checkbox)/', $typeofdata)) { + $tmp = explode(':', $typeofdata); + $ret .= ''; } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { $ret .= dol_htmlentitiesbr($value); } elseif (preg_match('/^safehtmlstring/', $typeofdata)) { diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 89e614cc3ba..eaf45a4e801 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -144,6 +144,28 @@ $result = restrictedArea($user, 'eventorganization'); * Actions */ + +if (preg_match('/^set/', $action) && $projectid > 0) { + $project = new Project($db); + //If "set" fields keys is in projects fields + $project_attr=preg_replace('/^set/', '', $action); + if (array_key_exists($project_attr, $project->fields)) { + $result = $project->fetch($projectid); + if ($result < 0) { + setEventMessages(null, $project->errors, 'errors'); + } else { + $project->{$project_attr}=GETPOST($project_attr); + $result=$project->update($user); + if ($result < 0) { + setEventMessages(null, $project->errors, 'errors'); + } + } + } +} +/*if ($action=='setaccept_conference_suggestions' && !empty(GETPOST('cancel', 'alpha'))) { + +}*/ +//setaccept_booth_suggestions if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; @@ -152,6 +174,9 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } + + + $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -362,6 +387,39 @@ if ($projectid > 0) { print ""; } + print ''; + $typeofdata = 'checkbox:'.($project->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + $typeofdata = 'checkbox:'.($project->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''.$langs->trans("EventOrganizationICSLink").''; + print ''; + print ""; + + print ''; print ''; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index cfa2d63196e..148b2762e0b 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -77,6 +77,7 @@ PriceOfRegistrationHelp=Price of registration PriceOfBooth=Price of subscription PriceOfBoothHelp=Price of subscription EventOrganizationICSLink=Link ICS for events +ConferenceOrBoothInformation=Conference Or Booth informations # # Status diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8bf9c727f4e..acfa92d6804 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -104,9 +104,42 @@ class Project extends CommonObject */ public $user_close_id; public $public; //!< Tell if this is a public or private project + + /** + * @var float budget Amount + */ public $budget_amount; + + /** + * @var boolean Use to bill task spend time + */ public $usage_bill_time; // Is the time spent on project must be invoiced or not + /** + * @var boolean Event organization: Use Event Organization + */ + public $usage_organize_event; + + /** + * @var boolean Event organization: Allow unknown people to suggest conferences + */ + public $accept_conference_suggestions; + + /** + * @var boolean Event organization: Allow unknown people to suggest booth + */ + public $accept_booth_suggestions; + + /** + * @var float Event organization: registration price + */ + public $price_registration; + + /** + * @var float Event organization: booth price + */ + public $price_booth; + public $statuts_short; public $statuts_long; From ebe0b503f699890074561fd811894784e4d5f611 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 23 Mar 2021 22:12:20 +0100 Subject: [PATCH 025/233] working on attendees --- .../modules/modEventOrganization.class.php | 143 +------- .../class/conferenceorbooth.class.php | 2 +- .../conferenceorbooth_agenda.php | 306 ------------------ .../conferenceorbooth_card.php | 40 +-- .../conferenceorbooth_contact.php | 216 ------------- .../conferenceorbooth_document.php | 251 -------------- .../conferenceorbooth_note.php | 206 ------------ ...ventorganization_conferenceorbooth.lib.php | 28 +- htdocs/langs/en_US/eventorganization.lang | 2 +- 9 files changed, 37 insertions(+), 1157 deletions(-) delete mode 100644 htdocs/eventorganization/conferenceorbooth_agenda.php delete mode 100644 htdocs/eventorganization/conferenceorbooth_contact.php delete mode 100644 htdocs/eventorganization/conferenceorbooth_document.php delete mode 100644 htdocs/eventorganization/conferenceorbooth_note.php diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index 244b4f41cab..9ee0cb1b74f 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -219,25 +219,8 @@ class modEventOrganization extends DolibarrModules // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - // 0 => array( - // 'label' => 'MyJob label', - // 'jobtype' => 'method', - // 'class' => '/eventorganization/class/conferenceorbooth.class.php', - // 'objectname' => 'ConferenceOrBooth', - // 'method' => 'doScheduledJob', - // 'parameters' => '', - // 'comment' => 'Comment', - // 'frequency' => 2, - // 'unitfrequency' => 3600, - // 'status' => 0, - // 'test' => '$conf->eventorganization->enabled', - // 'priority' => 50, - // ), ); - // Example: $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->eventorganization->enabled', 'priority'=>50), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->eventorganization->enabled', 'priority'=>50) - // ); + // Permissions provided by this module $this->rights = array(); @@ -256,21 +239,6 @@ class modEventOrganization extends DolibarrModules $this->rights[$r][1] = 'Delete objects of EventOrganization'; // Permission label $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) $r++; - /*$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read objects of EventOrganization - Conference Or Booth'; // Permission label - $this->rights[$r][4] = 'conferenceorbooth'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update objects of EventOrganization - Conference Or Booth'; // Permission label - $this->rights[$r][4] = 'conferenceorbooth'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete objects of EventOrganization - Conference Or Booth'; // Permission label - $this->rights[$r][4] = 'conferenceorbooth'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $r++;*/ /* END MODULEBUILDER PERMISSIONS */ // Main menu entries to add @@ -278,65 +246,8 @@ class modEventOrganization extends DolibarrModules $r = 0; // Add here entries to declare new menus /* BEGIN MODULEBUILDER TOPMENU */ - /*$this->menu[$r++] = array( - 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Top menu entry - 'titre'=>'ModuleEventOrganizationName', - 'mainmenu'=>'eventorganization', - 'leftmenu'=>'', - 'url'=>'/eventorganization/eventorganizationindex.php', - 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000 + $r, - 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->eventorganization->conferenceorbooth->read' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - );*/ /* END MODULEBUILDER TOPMENU */ - /* BEGIN MODULEBUILDER LEFTMENU CONFERENCEORBOOTH - $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=eventorganization', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Top menu entry - 'titre'=>'ConferenceOrBooth', - 'mainmenu'=>'eventorganization', - 'leftmenu'=>'conferenceorbooth', - 'url'=>'/eventorganization/eventorganizationindex.php', - 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->eventorganization->conferenceorbooth->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - ); - $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=eventorganization,fk_leftmenu=conferenceorbooth', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'List_ConferenceOrBooth', - 'mainmenu'=>'eventorganization', - 'leftmenu'=>'eventorganization_conferenceorbooth_list', - 'url'=>'/eventorganization/conferenceorbooth_list.php', - 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->eventorganization->conferenceorbooth->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - ); - $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=eventorganization,fk_leftmenu=conferenceorbooth', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'New_ConferenceOrBooth', - 'mainmenu'=>'eventorganization', - 'leftmenu'=>'eventorganization_conferenceorbooth_new', - 'url'=>'/eventorganization/conferenceorbooth_card.php?action=create', - 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->eventorganization->conferenceorbooth->write', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - ); - */ + /* BEGIN MODULEBUILDER LEFTMENU CONFERENCEORBOOTH*/ $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=project', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry @@ -419,52 +330,11 @@ class modEventOrganization extends DolibarrModules // Exports profiles provided by this module $r = 1; /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTH */ - /* - $langs->load("eventorganization@eventorganization"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='ConferenceOrBoothLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='conferenceorbooth@eventorganization'; - // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array - $keyforclass = 'ConferenceOrBooth'; $keyforclassfile='/eventorganization/class/conferenceorbooth.class.php'; $keyforelement='conferenceorbooth@eventorganization'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text'; - //unset($this->export_fields_array[$r]['t.fieldtoremove']); - //$keyforclass = 'ConferenceOrBoothLine'; $keyforclassfile='/eventorganization/class/conferenceorbooth.class.php'; $keyforelement='conferenceorboothline@eventorganization'; $keyforalias='tl'; - //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='conferenceorbooth'; $keyforaliasextra='extra'; $keyforelement='conferenceorbooth@eventorganization'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$keyforselect='conferenceorboothline'; $keyforaliasextra='extraline'; $keyforelement='conferenceorboothline@eventorganization'; - //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r] = array('conferenceorboothline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - //$this->export_special_array[$r] = array('t.field'=>'...'); - //$this->export_examplevalues_array[$r] = array('t.field'=>'Example'); - //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp'); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'conferenceorbooth as t'; - //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'conferenceorbooth_line as tl ON tl.fk_conferenceorbooth = t.rowid'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('conferenceorbooth').')'; - $r++; */ /* END MODULEBUILDER EXPORT CONFERENCEORBOOTH */ // Imports profiles provided by this module $r = 1; /* BEGIN MODULEBUILDER IMPORT CONFERENCEORBOOTH */ - /* - $langs->load("eventorganization@eventorganization"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='ConferenceOrBoothLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='conferenceorbooth@eventorganization'; - $keyforclass = 'ConferenceOrBooth'; $keyforclassfile='/eventorganization/class/conferenceorbooth.class.php'; $keyforelement='conferenceorbooth@eventorganization'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='conferenceorbooth'; $keyforaliasextra='extra'; $keyforelement='conferenceorbooth@eventorganization'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'conferenceorbooth as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('conferenceorbooth').')'; - $r++; */ /* END MODULEBUILDER IMPORT CONFERENCEORBOOTH */ } @@ -485,15 +355,6 @@ class modEventOrganization extends DolibarrModules return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') } - // Create extrafields during init - //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - //$extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('eventorganization_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - //$result2=$extrafields->addExtraField('eventorganization_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - //$result3=$extrafields->addExtraField('eventorganization_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - //$result4=$extrafields->addExtraField('eventorganization_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - //$result5=$extrafields->addExtraField('eventorganization_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - // Permissions $this->remove($options); diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index d91181d0c51..18bbd47f393 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -117,7 +117,7 @@ class ConferenceOrBooth extends ActionComm 'fk_user_author' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), 'fk_user_mod' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'EvntOrgDraft', '1'=>'EvntOrgSuggested', '2'=> 'EvntOrgConfirmed', '3' =>'EvntOrgNotQualified', '4' =>'EvntOrgDone', '9'=>'EvntOrgCancelled'),), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'EvntOrgDraft', '1'=>'EvntOrgSuggested', '2'=> 'EvntOrgConfirmed', '3' =>'EvntOrgNotQualified', '4' =>'EvntOrgDone', '9'=>'EvntOrgCancelled'),), ); public $rowid; public $id; diff --git a/htdocs/eventorganization/conferenceorbooth_agenda.php b/htdocs/eventorganization/conferenceorbooth_agenda.php deleted file mode 100644 index bd50df31a91..00000000000 --- a/htdocs/eventorganization/conferenceorbooth_agenda.php +++ /dev/null @@ -1,306 +0,0 @@ - - * Copyright (C) ---Put here your own copyright and developer email--- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file conferenceorbooth_agenda.php - * \ingroup eventorganization - * \brief Tab of events on ConferenceOrBooth - */ - -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); - - -// Load translation files required by the page -$langs->loadLangs(array("eventorganization@eventorganization", "other")); - -// Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); - -if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); -} -$search_agenda_label = GETPOST('search_agenda_label'); - -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (!$sortfield) { - $sortfield = 'a.datep,a.id'; -} -if (!$sortorder) { - $sortorder = 'DESC,DESC'; -} - -// Initialize technical objects -$object = new ConferenceOrBooth($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('conferenceorboothagenda', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->eventorganization->multidir_output[$object->entity]."/".$object->id; -} - -// Security check -if ($user->socid > 0) { - accessforbidden(); -} -$isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); -$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - -$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php - - - -/* - * Actions - */ - -$parameters = array('id'=>$id); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $actioncode = ''; - $search_agenda_label = ''; - } -} - - - -/* - * View - */ - -$form = new Form($db); - -if ($object->id > 0) { - $title = $langs->trans("Agenda"); - //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = ''; - llxHeader('', $title, $help_url); - - if (!empty($conf->notification->enabled)) { - $langs->load("mails"); - } - $head = conferenceorboothPrepareHead($object); - - - print dol_get_fiche_head($head, 'agenda', $langs->trans("ConferenceOrBooth"), -1, $object->picto); - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - } - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - print '
'; - - $object->info($object->id); - dol_print_object_info($object, 1); - - print '
'; - - print dol_get_fiche_end(); - - - - // Actions buttons - - $objthirdparty = $object; - $objcon = new stdClass(); - - $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id); - $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; - $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - //$out.='trans("AddAnAction"),'filenew'); - //$out.=""; - } - - - print '
'; - - if (!empty($conf->agenda->enabled)) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { - print ''.$langs->trans("AddAction").''; - } else { - print ''.$langs->trans("AddAction").''; - } - } - - print '
'; - - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $param = '&id='.$object->id.'&socid='.$socid; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); - } - - - //print load_fiche_titre($langs->trans("ActionsOnConferenceOrBooth"), '', ''); - - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; - - // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); - } -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 495d0334a10..2108ddaad2a 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -449,24 +449,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle'); } - // Back to draft - if ($object->status == $object::STATUS_CONFIRMED) { - print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd); - } - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit', '', $permissiontoadd); - // Validate - if ($object->status == $object::STATUS_DRAFT) { - if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd); - } else { - $langs->load("errors"); - //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0); - print ''.$langs->trans("Validate").''; - } - } - // Clone print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); @@ -503,7 +487,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print ''; // ancre - $includedocgeneration = 0; + $includedocgeneration = 1; // Documents if ($includedocgeneration) { @@ -511,9 +495,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->eventorganization->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->eventorganization->conferenceorbooth->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->eventorganization->conferenceorbooth->write; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('eventorganization:ConferenceOrBooth', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + $genallowed = $user->rights->eventorganization->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->eventorganization->write; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('eventorganization', $object->element.'/'.$objref, $filedir, $urlsource, 0, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } // Show links to link elements @@ -521,20 +505,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
'; - - $MAXEVENT = 10; - - $morehtmlright = ''; - $morehtmlright .= $langs->trans("SeeAll"); - $morehtmlright .= ''; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); - - print '
'; + print '
'; + print '
'; } //Select mail models is same action as presend diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php deleted file mode 100644 index d42cc78adcb..00000000000 --- a/htdocs/eventorganization/conferenceorbooth_contact.php +++ /dev/null @@ -1,216 +0,0 @@ - - * Copyright (C) ---Put here your own copyright and developer email--- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file conferenceorbooth_contact.php - * \ingroup eventorganization - * \brief Tab for contacts linked to ConferenceOrBooth - */ - -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); - -// Load translation files required by the page -$langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails")); - -$id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility -$ref = GETPOST('ref', 'alpha'); -$lineid = GETPOST('lineid', 'int'); -$socid = GETPOST('socid', 'int'); -$action = GETPOST('action', 'aZ09'); - -// Initialize technical objects -$object = new ConferenceOrBooth($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('conferenceorboothcontact', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals - -// Security check -if ($user->socid > 0) { - accessforbidden(); -} -$isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); -$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - -$permission = $user->rights->eventorganization->conferenceorbooth->write; - - -/* - * Actions - */ - -if ($action == 'addcontact' && $permission) { // Add a new contact - $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } -} elseif ($action == 'swapstatut' && $permission) { - // Toggle the status of a contact - $result = $object->swapContactStatus(GETPOST('ligne')); -} elseif ($action == 'deletecontact' && $permission) { - // Deletes a contact - $result = $object->delete_contact($lineid); - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - dol_print_error($db); - } -} - - -/* - * View - */ - -$title = $langs->trans('ConferenceOrBooth')." - ".$langs->trans('ContactsAddresses'); -$help_url = ''; -//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('', $title, $help_url); - -$form = new Form($db); -$formcompany = new FormCompany($db); -$contactstatic = new Contact($db); -$userstatic = new User($db); - - -/* *************************************************************************** */ -/* */ -/* View and edit mode */ -/* */ -/* *************************************************************************** */ - -if ($object->id) { - /* - * Show tabs - */ - $head = conferenceorboothPrepareHead($object); - - print dol_get_fiche_head($head, 'contact', $langs->trans("ConferenceOrBooth"), -1, $object->picto); - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - - print dol_get_fiche_end(); - - print '
'; - - // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach ($dirtpls as $reldir) { - $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) { - break; - } - } -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php deleted file mode 100644 index 1f354453fd1..00000000000 --- a/htdocs/eventorganization/conferenceorbooth_document.php +++ /dev/null @@ -1,251 +0,0 @@ - - * Copyright (C) ---Put here your own copyright and developer email--- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file conferenceorbooth_document.php - * \ingroup eventorganization - * \brief Tab for documents linked to ConferenceOrBooth - */ - -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); - -// Load translation files required by the page -$langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails")); - - -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm'); -$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); -$ref = GETPOST('ref', 'alpha'); - -// Get parameters -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$offset = $liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "name"; -} -//if (! $sortfield) $sortfield="position_name"; - -// Initialize technical objects -$object = new ConferenceOrBooth($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('conferenceorboothdocument', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals - -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->eventorganization->multidir_output[$object->entity ? $object->entity : $conf->entity]."/conferenceorbooth/".get_exdir(0, 0, 0, 1, $object); -} - -$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php - -// Security check -if ($user->socid > 0) { - accessforbidden(); -} -$isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); -$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - - -/* - * Actions - */ - -include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; - - -/* - * View - */ - -$form = new Form($db); - -$title = $langs->trans("ConferenceOrBooth").' - '.$langs->trans("Files"); -$help_url = ''; -//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('', $title, $help_url); - -if ($object->id) { - /* - * Show tabs - */ - $head = conferenceorboothPrepareHead($object); - - print dol_get_fiche_head($head, 'document', $langs->trans("ConferenceOrBooth"), -1, $object->picto); - - - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) { - $totalsize += $file['size']; - } - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - - print '
'; - print ''; - - // Number of files - print ''; - - // Total size - print ''; - - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - - print '
'; - - print dol_get_fiche_end(); - - $modulepart = 'eventorganization'; - //$permission = $user->rights->eventorganization->conferenceorbooth->write; - $permission = 1; - //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write; - $permtoedit = 1; - $param = '&id='.$object->id; - - //$relativepathwithnofile='conferenceorbooth/' . dol_sanitizeFileName($object->id).'/'; - $relativepathwithnofile = 'conferenceorbooth/'.dol_sanitizeFileName($object->ref).'/'; - - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { - accessforbidden('', 0, 1); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/eventorganization/conferenceorbooth_note.php b/htdocs/eventorganization/conferenceorbooth_note.php deleted file mode 100644 index 634877d82fe..00000000000 --- a/htdocs/eventorganization/conferenceorbooth_note.php +++ /dev/null @@ -1,206 +0,0 @@ - - * Copyright (C) ---Put here your own copyright and developer email--- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file conferenceorbooth_note.php - * \ingroup eventorganization - * \brief Tab for notes on ConferenceOrBooth - */ - -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); - -// Load translation files required by the page -$langs->loadLangs(array("eventorganization@eventorganization", "companies")); - -// Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); - -// Initialize technical objects -$object = new ConferenceOrBooth($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('conferenceorboothnote', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -// Security check - Protection if external user -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'eventorganization', $id); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->eventorganization->multidir_output[$object->entity]."/".$object->id; -} - -$permissionnote = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php - -// Security check -if ($user->socid > 0) { - accessforbidden(); -} -$isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); -$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - - -/* - * Actions - */ - -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - - -/* - * View - */ - -$form = new Form($db); - -//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; -$help_url = ''; -llxHeader('', $langs->trans('ConferenceOrBooth'), $help_url); - -if ($id > 0 || !empty($ref)) { - $object->fetch_thirdparty(); - - $head = conferenceorboothPrepareHead($object); - - print dol_get_fiche_head($head, 'note', $langs->trans("ConferenceOrBooth"), -1, $object->picto); - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - - print '
'; - print '
'; - - - $cssclass = "titlefield"; - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - - print '
'; - - print dol_get_fiche_end(); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index 541915fc953..16f1f850396 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -31,7 +31,7 @@ function conferenceorboothPrepareHead($object) { global $db, $langs, $conf; - $langs->load("eventorganization@eventorganization"); + $langs->load("eventorganization"); $h = 0; $head = array(); @@ -41,6 +41,32 @@ function conferenceorboothPrepareHead($object) $head[$h][2] = 'card'; $h++; + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Attendees"); + $head[$h][2] = 'attendees'; + $nbAttendees = 0; + // Enable caching of project count Contacts + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_attendees_conferenceorbooth_'.$object->id; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $nbAttendees = $dataretrieved; + } else { + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + $attendees=new ConferenceOrBoothAttendee($db); + $result = $attendees->fetchAll('', '', 0, 0, array('fk_actioncomm'=>$object->id)); + if (!is_array($result) && $result<1) { + setEventMessages($attendees->error, $attendees->errors, 'errors'); + } else { + $nbAttendees = count($result); + } + dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result. + } + if ($nbAttendees > 0) { + $head[$h][1] .= ''.$nbAttendees.''; + } + $h++; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->eventorganization->dir_output."/conferenceorbooth/".dol_sanitizeFileName($object->ref); diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 148b2762e0b..b1849cbb6b3 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -78,7 +78,7 @@ PriceOfBooth=Price of subscription PriceOfBoothHelp=Price of subscription EventOrganizationICSLink=Link ICS for events ConferenceOrBoothInformation=Conference Or Booth informations - +Attendees = Attendee(s) # # Status # From 26cffd139d580b8fde45bd81c5c5cc5df78ebdad Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 23 Mar 2021 22:12:30 +0100 Subject: [PATCH 026/233] working on attendees --- .../conferenceorboothattendee_extrafields.php | 141 +++ .../class/conferenceorboothattendee.class.php | 1072 +++++++++++++++++ .../conferenceorboothattendee.class.php.back | 1071 ++++++++++++++++ .../conferenceorbooth_document.php | 251 ++++ .../conferenceorboothattendee_card.php | 597 +++++++++ .../conferenceorboothattendee_list.php | 664 ++++++++++ .../conferenceorboothattendee_note.php | 200 +++ .../img/object_conferenceorboothattendee.png | Bin 0 -> 219 bytes htdocs/eventorganization/img/object_ttruc.png | Bin 0 -> 219 bytes ...nization_conferenceorboothattendee.key.sql | 31 + ...organization_conferenceorboothattendee.sql | 39 + ...ization_conferenceorboothattendee.sql.back | 38 + ...ferenceorboothattendee_extrafields.key.sql | 19 + ..._conferenceorboothattendee_extrafields.sql | 23 + 14 files changed, 4146 insertions(+) create mode 100644 htdocs/eventorganization/admin/conferenceorboothattendee_extrafields.php create mode 100644 htdocs/eventorganization/class/conferenceorboothattendee.class.php create mode 100644 htdocs/eventorganization/class/conferenceorboothattendee.class.php.back create mode 100644 htdocs/eventorganization/conferenceorbooth_document.php create mode 100644 htdocs/eventorganization/conferenceorboothattendee_card.php create mode 100644 htdocs/eventorganization/conferenceorboothattendee_list.php create mode 100644 htdocs/eventorganization/conferenceorboothattendee_note.php create mode 100644 htdocs/eventorganization/img/object_conferenceorboothattendee.png create mode 100644 htdocs/eventorganization/img/object_ttruc.png create mode 100644 htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.key.sql create mode 100644 htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.sql create mode 100644 htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.sql.back create mode 100644 htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee_extrafields.key.sql create mode 100644 htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee_extrafields.sql diff --git a/htdocs/eventorganization/admin/conferenceorboothattendee_extrafields.php b/htdocs/eventorganization/admin/conferenceorboothattendee_extrafields.php new file mode 100644 index 00000000000..927520a013b --- /dev/null +++ b/htdocs/eventorganization/admin/conferenceorboothattendee_extrafields.php @@ -0,0 +1,141 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file admin/conferenceorboothattendee_extrafields.php + * \ingroup eventorganization + * \brief Page to setup extra fields of conferenceorboothattendee + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once '../lib/eventorganization.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('eventorganization@eventorganization', 'admin')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} + +$action = GETPOST('action', 'aZ09'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'eventorganization_conferenceorboothattendee'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) { + accessforbidden(); +} + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + + +llxHeader('', $langs->trans("EventOrganizationSetup"), $help_url); + + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("EventOrganizationSetup"), $linkback, 'title_setup'); + + +$head = eventorganizationAdminPrepareHead(); + +print dol_get_fiche_head($head, 'conferenceorboothattendee_extrafields', $langs->trans("ConferenceOrBoothAttendeeExtraFields"), -1, 'account'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +print dol_get_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') { + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* + * Creation of an optional field + */ +if ($action == 'create') { + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* + * Edition of an optional field + */ +if ($action == 'edit' && !empty($attrname)) { + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php new file mode 100644 index 00000000000..f6a1ff382b5 --- /dev/null +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -0,0 +1,1072 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file class/conferenceorboothattendee.class.php + * \ingroup eventorganization + * \brief This file is a CRUD class file for ConferenceOrBoothAttendee (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for ConferenceOrBoothAttendee + */ +class ConferenceOrBoothAttendee extends CommonObject +{ + /** + * @var string ID of module. + */ + public $module = 'eventorganization'; + + /** + * @var string ID to identify managed object. + */ + public $element = 'conferenceorboothattendee'; + + /** + * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. + */ + public $table_element = 'eventorganization_conferenceorboothattendee'; + + /** + * @var int Does this object support multicompany module ? + * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for conferenceorboothattendee. Must be the part after the 'object_' into object_conferenceorboothattendee.png + */ + public $picto = 'conferenceorboothattendee@eventorganization'; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + const STATUS_CANCELED = 9; + + + /** + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'picto' is code of a picto to show before value in forms + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200' + * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0, 'index'=>1, 'comment'=>"Reference of object"), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), + 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,), + 'email' => array('type'=>'text', 'label'=>'email', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1, 'index'=>1,), + 'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), + 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), + 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), + 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), + 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'),), + ); + public $rowid; + public $ref; + public $fk_soc; + public $fk_project; + public $fk_actioncomm; + public $email; + public $date_subscription; + public $amount; + public $datep; + public $note_public; + public $note_private; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $last_main_doc; + public $import_key; + public $model_pdf; + public $status; + // END MODULEBUILDER PROPERTIES + + + // If this object has a subtable with lines + + // /** + // * @var string Name of subtable line + // */ + // public $table_element_line = 'eventorganization_conferenceorboothattendeeline'; + + // /** + // * @var string Field with ID of parent key if this object has a parent + // */ + // public $fk_element = 'fk_conferenceorboothattendee'; + + // /** + // * @var string Name of subtable class that manage subtable lines + // */ + // public $class_element_line = 'ConferenceOrBoothAttendeeline'; + + // /** + // * @var array List of child tables. To test if we can delete object. + // */ + // protected $childtables = array(); + + // /** + // * @var array List of child tables. To know object to delete on cascade. + // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will + // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object + // */ + // protected $childtablesoncascade = array('eventorganization_conferenceorboothattendeedet'); + + // /** + // * @var ConferenceOrBoothAttendeeLine[] Array of subtable lines + // */ + // public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } + + // Example to show how to set values of fields definition dynamically + /*if ($user->rights->eventorganization->conferenceorboothattendee->read) { + $this->fields['myfield']['visible'] = 1; + $this->fields['myfield']['noteditable'] = 0; + }*/ + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); + } + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + if (property_exists($object, 'ref')) { + $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + } + if (property_exists($object, 'label')) { + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + } + if (property_exists($object, 'status')) { + $object->status = self::STATUS_DRAFT; + } + if (property_exists($object, 'date_creation')) { + $object->date_creation = dol_now(); + } + if (property_exists($object, 'date_modification')) { + $object->date_modification = null; + } + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) { + $extrafields->fetch_name_optionals_label($this->table_element); + foreach ($object->array_options as $key => $option) { + $shortkey = preg_replace('/options_/', '', $key); + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + if (!$error) { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) { + $error++; + } + } + + if (!$error) { + // copy external contacts if same company + if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { + $error++; + } + } + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchLines() + { + $this->lines = array(); + + $result = $this->fetchLinesCommon(); + return $result; + } + + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList('t'); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Delete a line of object in database + * + * @param User $user User that delete + * @param int $idline Id of line to delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int >0 if OK, <0 if KO + */ + public function deleteLine(User $user, $idline, $notrigger = false) + { + if ($this->status < 0) { + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; + return -2; + } + + return $this->deleteLineCommon($user, $idline, $notrigger); + } + + + /** + * Validate object + * + * @param User $user User making status change + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <=0 if OK, 0=Nothing done, >0 if KO + */ + public function validate($user, $notrigger = 0) + { + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error = 0; + + // Protection + if ($this->status == self::STATUS_VALIDATED) { + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorboothattendee->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorboothattendee->conferenceorboothattendee_advance->validate)))) + { + $this->error='NotEnoughPermissions'; + dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); + return -1; + }*/ + + $now = dol_now(); + + $this->db->begin(); + + // Define new ref + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life + $num = $this->getNextNumRef(); + } else { + $num = $this->ref; + } + $this->newref = $num; + + if (!empty($num)) { + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED; + if (!empty($this->fields['date_validation'])) { + $sql .= ", date_validation = '".$this->db->idate($now)."'"; + } + if (!empty($this->fields['fk_user_valid'])) { + $sql .= ", fk_user_valid = ".$user->id; + } + $sql .= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('CONFERENCEORBOOTHATTENDEE_VALIDATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + } + + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'conferenceorboothattendee/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'conferenceorboothattendee/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->error = $this->db->lasterror(); + } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$oldref; + $dirdest = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref; + if (!$error && file_exists($dirsource)) { + dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Set new ref and current status + if (!$error) { + $this->ref = $num; + $this->status = self::STATUS_VALIDATED; + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'CONFERENCEORBOOTHATTENDEE_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_CANCEL'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_REOPEN'); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } + + $result = ''; + + $label = img_picto('', $this->picto).' '.$langs->trans("ConferenceOrBoothAttendee").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + + $url = dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } + } + + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowConferenceOrBoothAttendee"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + if ($option == 'nolink') { + $linkstart = ''; + if ($option == 'nolink') { + $linkend = ''; + } else { + $linkend = ''; + } + + $result .= $linkstart; + + if (empty($this->showphoto_on_popup)) { + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if (!empty($filename)) { + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + $result .= '
No photo
'; + } else { + $result .= '
No photo
'; + } + + $result .= ''; + } else { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } + } + + if ($withpicto != 2) { + $result .= $this->ref; + } + + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action, $hookmanager; + $hookmanager->initHooks(array('conferenceorboothattendeedao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + + return $result; + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("eventorganization@eventorganization"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled'); + } + + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_CANCELED) { + $statusType = 'status6'; + } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.((int) $id); + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + /** + * Create an array of lines + * + * @return array|int array of lines if OK, <0 if KO + */ + public function getLinesArray() + { + $this->lines = array(); + + $objectline = new ConferenceOrBoothAttendeeLine($this->db); + $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorboothattendee = '.$this->id)); + + if (is_numeric($result)) { + $this->error = $this->error; + $this->errors = $this->errors; + return $result; + } else { + $this->lines = $result; + return $this->lines; + } + } + + /** + * Returns the reference to the following non used object depending on the active numbering module. + * + * @return string Object free reference + */ + public function getNextNumRef() + { + global $langs, $conf; + $langs->load("eventorganization@eventorganization"); + + if (empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON)) { + $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON = 'mod_conferenceorboothattendee_standard'; + } + + if (!empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON)) { + $mybool = false; + + $file = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON.".php"; + $classname = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/eventorganization/"); + + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; + } + + if ($mybool === false) { + dol_print_error('', "Failed to include file ".$file); + return ''; + } + + if (class_exists($classname)) { + $obj = new $classname(); + $numref = $obj->getNextValue($this); + + if ($numref != '' && $numref != '-1') { + return $numref; + } else { + $this->error = $obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + return ""; + } + } else { + print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; + return ""; + } + } else { + print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); + return ""; + } + } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; + + $result = 0; + $includedocgeneration = 0; + + $langs->load("eventorganization@eventorganization"); + + if (!dol_strlen($modele)) { + $modele = 'standard_conferenceorboothattendee'; + + if (!empty($this->model_pdf)) { + $modele = $this->model_pdf; + } elseif (!empty($conf->global->CONFERENCEORBOOTHATTENDEE_ADDON_PDF)) { + $modele = $conf->global->CONFERENCEORBOOTHATTENDEE_ADDON_PDF; + } + } + + $modelpath = "core/modules/eventorganization/doc/"; + + if ($includedocgeneration && !empty($modele)) { + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + + return $result; + } + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' + * Use public function doScheduledJob($param1, $param2, ...) to get parameters + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function doScheduledJob() + { + global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error = ''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} + + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; + +/** + * Class ConferenceOrBoothAttendeeLine. You can also remove this and generate a CRUD class for lines objects. + */ +class ConferenceOrBoothAttendeeLine extends CommonObjectLine +{ + // To complete with content of an object ConferenceOrBoothAttendeeLine + // We should have a field rowid, fk_conferenceorboothattendee and position + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } +} diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php.back b/htdocs/eventorganization/class/conferenceorboothattendee.class.php.back new file mode 100644 index 00000000000..472c62b1e55 --- /dev/null +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php.back @@ -0,0 +1,1071 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file class/conferenceorboothattendee.class.php + * \ingroup eventorganization + * \brief This file is a CRUD class file for ConferenceOrBoothAttendee (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for ConferenceOrBoothAttendee + */ +class ConferenceOrBoothAttendee extends CommonObject +{ + /** + * @var string ID of module. + */ + public $module = 'eventorganization'; + + /** + * @var string ID to identify managed object. + */ + public $element = 'conferenceorboothattendee'; + + /** + * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. + */ + public $table_element = 'eventorganization_conferenceorboothattendee'; + + /** + * @var int Does this object support multicompany module ? + * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for conferenceorboothattendee. Must be the part after the 'object_' into object_conferenceorboothattendee.png + */ + public $picto = 'conferenceorboothattendee@eventorganization'; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + const STATUS_CANCELED = 9; + + + /** + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'picto' is code of a picto to show before value in forms + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200' + * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0, 'index'=>1, 'comment'=>"Reference of object"), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), + 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,), + 'email' => array('type'=>'text', 'label'=>'email', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1, 'index'=>1,), + 'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), + 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), + 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), + 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), + 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'),), + ); + public $rowid; + public $ref; + public $fk_soc; + public $fk_project; + public $email; + public $date_subscription; + public $amount; + public $datep; + public $note_public; + public $note_private; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $last_main_doc; + public $import_key; + public $model_pdf; + public $status; + // END MODULEBUILDER PROPERTIES + + + // If this object has a subtable with lines + + // /** + // * @var string Name of subtable line + // */ + // public $table_element_line = 'eventorganization_conferenceorboothattendeeline'; + + // /** + // * @var string Field with ID of parent key if this object has a parent + // */ + // public $fk_element = 'fk_conferenceorboothattendee'; + + // /** + // * @var string Name of subtable class that manage subtable lines + // */ + // public $class_element_line = 'ConferenceOrBoothAttendeeline'; + + // /** + // * @var array List of child tables. To test if we can delete object. + // */ + // protected $childtables = array(); + + // /** + // * @var array List of child tables. To know object to delete on cascade. + // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will + // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object + // */ + // protected $childtablesoncascade = array('eventorganization_conferenceorboothattendeedet'); + + // /** + // * @var ConferenceOrBoothAttendeeLine[] Array of subtable lines + // */ + // public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } + + // Example to show how to set values of fields definition dynamically + /*if ($user->rights->eventorganization->conferenceorboothattendee->read) { + $this->fields['myfield']['visible'] = 1; + $this->fields['myfield']['noteditable'] = 0; + }*/ + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); + } + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + if (property_exists($object, 'ref')) { + $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + } + if (property_exists($object, 'label')) { + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + } + if (property_exists($object, 'status')) { + $object->status = self::STATUS_DRAFT; + } + if (property_exists($object, 'date_creation')) { + $object->date_creation = dol_now(); + } + if (property_exists($object, 'date_modification')) { + $object->date_modification = null; + } + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) { + $extrafields->fetch_name_optionals_label($this->table_element); + foreach ($object->array_options as $key => $option) { + $shortkey = preg_replace('/options_/', '', $key); + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + if (!$error) { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) { + $error++; + } + } + + if (!$error) { + // copy external contacts if same company + if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { + $error++; + } + } + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchLines() + { + $this->lines = array(); + + $result = $this->fetchLinesCommon(); + return $result; + } + + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList('t'); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Delete a line of object in database + * + * @param User $user User that delete + * @param int $idline Id of line to delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int >0 if OK, <0 if KO + */ + public function deleteLine(User $user, $idline, $notrigger = false) + { + if ($this->status < 0) { + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; + return -2; + } + + return $this->deleteLineCommon($user, $idline, $notrigger); + } + + + /** + * Validate object + * + * @param User $user User making status change + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <=0 if OK, 0=Nothing done, >0 if KO + */ + public function validate($user, $notrigger = 0) + { + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error = 0; + + // Protection + if ($this->status == self::STATUS_VALIDATED) { + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorboothattendee->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorboothattendee->conferenceorboothattendee_advance->validate)))) + { + $this->error='NotEnoughPermissions'; + dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); + return -1; + }*/ + + $now = dol_now(); + + $this->db->begin(); + + // Define new ref + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life + $num = $this->getNextNumRef(); + } else { + $num = $this->ref; + } + $this->newref = $num; + + if (!empty($num)) { + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED; + if (!empty($this->fields['date_validation'])) { + $sql .= ", date_validation = '".$this->db->idate($now)."'"; + } + if (!empty($this->fields['fk_user_valid'])) { + $sql .= ", fk_user_valid = ".$user->id; + } + $sql .= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('CONFERENCEORBOOTHATTENDEE_VALIDATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + } + + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'conferenceorboothattendee/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'conferenceorboothattendee/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->error = $this->db->lasterror(); + } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$oldref; + $dirdest = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref; + if (!$error && file_exists($dirsource)) { + dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Set new ref and current status + if (!$error) { + $this->ref = $num; + $this->status = self::STATUS_VALIDATED; + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'CONFERENCEORBOOTHATTENDEE_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_CANCEL'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_REOPEN'); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } + + $result = ''; + + $label = img_picto('', $this->picto).' '.$langs->trans("ConferenceOrBoothAttendee").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + + $url = dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } + } + + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowConferenceOrBoothAttendee"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + if ($option == 'nolink') { + $linkstart = ''; + if ($option == 'nolink') { + $linkend = ''; + } else { + $linkend = ''; + } + + $result .= $linkstart; + + if (empty($this->showphoto_on_popup)) { + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if (!empty($filename)) { + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + $result .= '
No photo
'; + } else { + $result .= '
No photo
'; + } + + $result .= ''; + } else { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } + } + + if ($withpicto != 2) { + $result .= $this->ref; + } + + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action, $hookmanager; + $hookmanager->initHooks(array('conferenceorboothattendeedao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + + return $result; + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("eventorganization@eventorganization"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled'); + } + + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_CANCELED) { + $statusType = 'status6'; + } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.((int) $id); + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + /** + * Create an array of lines + * + * @return array|int array of lines if OK, <0 if KO + */ + public function getLinesArray() + { + $this->lines = array(); + + $objectline = new ConferenceOrBoothAttendeeLine($this->db); + $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorboothattendee = '.$this->id)); + + if (is_numeric($result)) { + $this->error = $this->error; + $this->errors = $this->errors; + return $result; + } else { + $this->lines = $result; + return $this->lines; + } + } + + /** + * Returns the reference to the following non used object depending on the active numbering module. + * + * @return string Object free reference + */ + public function getNextNumRef() + { + global $langs, $conf; + $langs->load("eventorganization@eventorganization"); + + if (empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON)) { + $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON = 'mod_conferenceorboothattendee_standard'; + } + + if (!empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON)) { + $mybool = false; + + $file = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON.".php"; + $classname = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/eventorganization/"); + + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; + } + + if ($mybool === false) { + dol_print_error('', "Failed to include file ".$file); + return ''; + } + + if (class_exists($classname)) { + $obj = new $classname(); + $numref = $obj->getNextValue($this); + + if ($numref != '' && $numref != '-1') { + return $numref; + } else { + $this->error = $obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + return ""; + } + } else { + print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; + return ""; + } + } else { + print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); + return ""; + } + } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; + + $result = 0; + $includedocgeneration = 0; + + $langs->load("eventorganization@eventorganization"); + + if (!dol_strlen($modele)) { + $modele = 'standard_conferenceorboothattendee'; + + if (!empty($this->model_pdf)) { + $modele = $this->model_pdf; + } elseif (!empty($conf->global->CONFERENCEORBOOTHATTENDEE_ADDON_PDF)) { + $modele = $conf->global->CONFERENCEORBOOTHATTENDEE_ADDON_PDF; + } + } + + $modelpath = "core/modules/eventorganization/doc/"; + + if ($includedocgeneration && !empty($modele)) { + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + + return $result; + } + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' + * Use public function doScheduledJob($param1, $param2, ...) to get parameters + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function doScheduledJob() + { + global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error = ''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} + + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; + +/** + * Class ConferenceOrBoothAttendeeLine. You can also remove this and generate a CRUD class for lines objects. + */ +class ConferenceOrBoothAttendeeLine extends CommonObjectLine +{ + // To complete with content of an object ConferenceOrBoothAttendeeLine + // We should have a field rowid, fk_conferenceorboothattendee and position + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } +} diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php new file mode 100644 index 00000000000..1f354453fd1 --- /dev/null +++ b/htdocs/eventorganization/conferenceorbooth_document.php @@ -0,0 +1,251 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorbooth_document.php + * \ingroup eventorganization + * \brief Tab for documents linked to ConferenceOrBooth + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); +dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails")); + + +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$ref = GETPOST('ref', 'alpha'); + +// Get parameters +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} +//if (! $sortfield) $sortfield="position_name"; + +// Initialize technical objects +$object = new ConferenceOrBooth($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothdocument', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->eventorganization->multidir_output[$object->entity ? $object->entity : $conf->entity]."/conferenceorbooth/".get_exdir(0, 0, 0, 1, $object); +} + +$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php + +// Security check +if ($user->socid > 0) { + accessforbidden(); +} +$isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; + + +/* + * View + */ + +$form = new Form($db); + +$title = $langs->trans("ConferenceOrBooth").' - '.$langs->trans("Files"); +$help_url = ''; +//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('', $title, $help_url); + +if ($object->id) { + /* + * Show tabs + */ + $head = conferenceorboothPrepareHead($object); + + print dol_get_fiche_head($head, 'document', $langs->trans("ConferenceOrBooth"), -1, $object->picto); + + + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { + $totalsize += $file['size']; + } + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($permissiontoadd) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + }*/ + $morehtmlref .= '
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + // Number of files + print ''; + + // Total size + print ''; + + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print '
'; + + print dol_get_fiche_end(); + + $modulepart = 'eventorganization'; + //$permission = $user->rights->eventorganization->conferenceorbooth->write; + $permission = 1; + //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write; + $permtoedit = 1; + $param = '&id='.$object->id; + + //$relativepathwithnofile='conferenceorbooth/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile = 'conferenceorbooth/'.dol_sanitizeFileName($object->ref).'/'; + + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; +} else { + accessforbidden('', 0, 1); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php new file mode 100644 index 00000000000..e301581565b --- /dev/null +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -0,0 +1,597 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorboothattendee_card.php + * \ingroup eventorganization + * \brief Page to create/edit/view conferenceorboothattendee + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +dol_include_once('/eventorganization/class/conferenceorboothattendee.class.php'); +dol_include_once('/eventorganization/lib/eventorganization_conferenceorboothattendee.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothattendeecard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +// Initialize technical objects +$object = new ConferenceOrBoothAttendee($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothattendeecard', 'globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } +} + +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + + +$permissiontoread = $user->rights->eventorganization->conferenceorboothattendee->read; +$permissiontoadd = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->eventorganization->conferenceorboothattendee->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1]; + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); +//$result = restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + +//if (empty($permissiontoread)) accessforbidden(); + + +/* + * Actions + */ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + $error = 0; + + $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php', 1); + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } + } + } + + $triggermodname = 'EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; + + // Action to build doc + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + if ($action == 'set_thirdparty' && $permissiontoadd) { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); + } + if ($action == 'classin' && $permissiontoadd) { + $object->setProject(GETPOST('projectid', 'int')); + } + + // Actions to send emails + $triggersendname = 'EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_CONFERENCEORBOOTHATTENDEE_TO'; + $trackid = 'conferenceorboothattendee'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + * + * Put here all code to build page + */ + +$form = new Form($db); +$formfile = new FormFile($db); +$formproject = new FormProjets($db); + +$title = $langs->trans("ConferenceOrBoothAttendee"); +$help_url = ''; +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + + +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")), '', 'object_'.$object->picto); + + print '
'; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(array(), ''); + + // Set some default values + //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + print dol_get_fiche_end(); + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; + + //dol_set_focus('input[name="ref"]'); +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("ConferenceOrBoothAttendee"), '', 'object_'.$object->picto); + + print '
'; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + $res = $object->fetch_optionals(); + + $head = conferenceorboothattendeePrepareHead($object); + print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteConferenceOrBoothAttendee'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') { + $formquestion = array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project') . ' '; + if ($permissiontoadd) { + //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; + $morehtmlref .= ' : '; + if ($action == 'classify') { + //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + }*/ + $morehtmlref .= '
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + + /* + * Lines + */ + + if (!empty($object->table_element_line)) { + // Show object lines + $result = $object->getLinesArray(); + + print '
+ + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print ''; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add products/services form + $object->formAddObjectLine(1, $mysoc, $soc); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; + + print "
\n"; + } + + + // Buttons for actions + + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (empty($reshook)) { + // Send + if (empty($user->socid)) { + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle'); + } + + // Back to draft + if ($object->status == $object::STATUS_VALIDATED) { + print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd); + } + + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit', '', $permissiontoadd); + + // Validate + if ($object->status == $object::STATUS_DRAFT) { + if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { + print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd); + } else { + $langs->load("errors"); + //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0); + print ''.$langs->trans("Validate").''; + } + } + + // Clone + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); + + /* + if ($permissiontoadd) { + if ($object->status == $object::STATUS_ENABLED) { + print ''.$langs->trans("Disable").''."\n"; + } else { + print ''.$langs->trans("Enable").''."\n"; + } + } + if ($permissiontoadd) { + if ($object->status == $object::STATUS_VALIDATED) { + print ''.$langs->trans("Cancel").''."\n"; + } else { + print ''.$langs->trans("Re-Open").''."\n"; + } + } + */ + + // Delete (need delete permission, or if draft, just need create/modify permission) + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') { + print '
'; + print ''; // ancre + + $includedocgeneration = 0; + + // Documents + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->eventorganization->dir_output.'/'.$object->element.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->eventorganization->conferenceorboothattendee->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->eventorganization->conferenceorboothattendee->write; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('eventorganization:ConferenceOrBoothAttendee', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + } + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('conferenceorboothattendee')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); + + print '
'; + } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'conferenceorboothattendee'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->eventorganization->dir_output; + $trackid = 'conferenceorboothattendee'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php new file mode 100644 index 00000000000..2e396260b8f --- /dev/null +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -0,0 +1,664 @@ + + * Copyright (C) 2021 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorboothattendee_list.php + * \ingroup eventorganization + * \brief List page for conferenceorboothattendee + */ + +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + +// load eventorganization libraries +require_once __DIR__.'/class/conferenceorboothattendee.class.php'; + +// for other modules +//dol_include_once('/othermodule/class/otherobject.class.php'); + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization", "other")); + +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothattendeelist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id', 'int'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +// Initialize technical objects +$object = new ConferenceOrBoothAttendee($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothattendeelist')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); +//$extrafields->fetch_name_optionals_label($object->table_element_line); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (!$sortfield) { + reset($object->fields); // Reset is required to avoid key() to return null. + $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} + +// Initialize array of search criterias +$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); + } +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } +} + +// Definition of array of fields for columns +$arrayfields = array(); +foreach ($object->fields as $key => $val) { + // If $val['visible']==0, then we never show the field + if (!empty($val['visible'])) { + $visible = (int) dol_eval($val['visible'], 1); + $arrayfields['t.'.$key] = array( + 'label'=>$val['label'], + 'checked'=>(($visible < 0) ? 0 : 1), + 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)), + 'position'=>$val['position'], + 'help'=>$val['help'] + ); + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; + +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + +//$permissiontoread = $user->rights->eventorganization->conferenceorboothattendee->read; +$permissiontoread = $user->rights->eventorganization->read; +//$permissiontoadd = $user->rights->eventorganization->conferenceorboothattendee->write; +$permissiontoadd = $user->rights->eventorganization->write; +$permissiontodelete = $user->rights->eventorganization->delete; + +// Security check +if (empty($conf->eventorganization->enabled)) { + accessforbidden('Module not enabled'); +} +$socid = 0; +if ($user->socid > 0) { // Protection if external user + //$socid = $user->socid; + accessforbidden(); +} +//$result = restrictedArea($user, 'eventorganization', $id, ''); +//if (!$permissiontoread) accessforbidden(); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + foreach ($object->fields as $key => $val) { + $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } + } + $toselect = ''; + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass = 'ConferenceOrBoothAttendee'; + $objectlabel = 'ConferenceOrBoothAttendee'; + $uploaddir = $conf->eventorganization->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + */ + +$form = new Form($db); + +$now = dol_now(); + +//$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee"; +$help_url = ''; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBoothAttendees")); +$morejs = array(); +$morecss = array(); + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +$sql .= $object->getFieldList('t'); +// Add fields from extrafields +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + } +} +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +} +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} +foreach ($search as $key => $val) { + if (array_key_exists($key, $object->fields)) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0)) { + if ($search[$key] == '-1' || $search[$key] === '0') { + $search[$key] = ''; + } + $mode_search = 2; + } + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } + } else { + if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { + $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); + if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { + if (preg_match('/_dtstart$/', $key)) { + $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'"; + } + if (preg_match('/_dtend$/', $key)) { + $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + } + } + } + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +} +//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY "; +foreach($object->fields as $key => $val) { + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +} +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/,\s*$/','', $sql); +*/ + +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { + $num = $nbtotalofrecords; +} else { + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } + + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Direct jump if only one record found +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); + +// Example : Adding jquery code +print ''; + +$arrayofselected = is_array($toselect) ? $toselect : array(); + +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +foreach ($search as $key => $val) { + if (is_array($search[$key]) && count($search[$key])) { + foreach ($search[$key] as $skey) { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } + } else { + $param .= '&search_'.$key.'='.urlencode($search[$key]); + } +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; + +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>$langs->trans("Validate"), + //'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), +); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + +print '
'."\n"; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail = "SendConferenceOrBoothAttendeeRef"; +$modelmail = "conferenceorboothattendee"; +$objecttmp = new ConferenceOrBoothAttendee($db); +$trackid = 'xxxx'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
';*/ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine = 0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } + } +} + + +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$totalarray = array(); +while ($i < ($limit ? min($num, $limit) : $num)) { + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } + + // Store properties in $object + $object->setVarsFromFetchObj($obj); + + // Show here line of result + print ''; + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') { + print $object->getLibStatut(5); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + $totalarray['val']['t.'.$key] += $object->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + + print ''."\n"; + + $i++; +} + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; +} + + +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { + print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); + } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print ''; + } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + } + print '
'; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; + + print $formfile->showdocuments('massfilesarea_eventorganization', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/conferenceorboothattendee_note.php b/htdocs/eventorganization/conferenceorboothattendee_note.php new file mode 100644 index 00000000000..46620112311 --- /dev/null +++ b/htdocs/eventorganization/conferenceorboothattendee_note.php @@ -0,0 +1,200 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorboothattendee_note.php + * \ingroup eventorganization + * \brief Tab for notes on ConferenceOrBoothAttendee + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +dol_include_once('/eventorganization/class/conferenceorboothattendee.class.php'); +dol_include_once('/eventorganization/lib/eventorganization_conferenceorboothattendee.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization@eventorganization", "companies")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object = new ConferenceOrBoothAttendee($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothattendeenote', 'globalcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$result = restrictedArea($user, 'eventorganization', $id); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->eventorganization->multidir_output[$object->entity]."/".$object->id; +} + +$permissionnote = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_addupdatedelete.inc.php + + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + + +/* + * View + */ + +$form = new Form($db); + +//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; +$help_url = ''; +llxHeader('', $langs->trans('ConferenceOrBoothAttendee'), $help_url); + +if ($id > 0 || !empty($ref)) { + $object->fetch_thirdparty(); + + $head = conferenceorboothattendeePrepareHead($object); + + print dol_get_fiche_head($head, 'note', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto); + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($permissiontoadd) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + }*/ + $morehtmlref .= '
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + + + $cssclass = "titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/img/object_conferenceorboothattendee.png b/htdocs/eventorganization/img/object_conferenceorboothattendee.png new file mode 100644 index 0000000000000000000000000000000000000000..b421fe3c9e046e26f6f64e996d0ac6f914fb40ed GIT binary patch literal 219 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0y_MV>B>Ar*{EFEO$)If}G@TqVsS z;K?HKQqEDJWWfRk&j}*Ij$9LWIdjZaEt_fgC(v|WZuyVE{Cnveqq!8H1nE3^Q+P=1 z>J6pzHFFOi7dG`V>~V=z*^%*0c-;qwr`mTC(p&lbdG0-v^)cLdNGff|;x#+nmA!Ac zG}*~K+qK>KZ`=d6{%iJ$(wftDofmsm&tGc%WKH2wLA_6M?iSg{#s5F~RKfV2apH@l TuYZ$(u4V9a^>bP0l+XkK_svvh literal 0 HcmV?d00001 diff --git a/htdocs/eventorganization/img/object_ttruc.png b/htdocs/eventorganization/img/object_ttruc.png new file mode 100644 index 0000000000000000000000000000000000000000..b421fe3c9e046e26f6f64e996d0ac6f914fb40ed GIT binary patch literal 219 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0y_MV>B>Ar*{EFEO$)If}G@TqVsS z;K?HKQqEDJWWfRk&j}*Ij$9LWIdjZaEt_fgC(v|WZuyVE{Cnveqq!8H1nE3^Q+P=1 z>J6pzHFFOi7dG`V>~V=z*^%*0c-;qwr`mTC(p&lbdG0-v^)cLdNGff|;x#+nmA!Ac zG}*~K+qK>KZ`=d6{%iJ$(wftDofmsm&tGc%WKH2wLA_6M?iSg{#s5F~RKfV2apH@l TuYZ$(u4V9a^>bP0l+XkK_svvh literal 0 HcmV?d00001 diff --git a/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.key.sql b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.key.sql new file mode 100644 index 00000000000..10616ac359a --- /dev/null +++ b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.key.sql @@ -0,0 +1,31 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_project (fk_project); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_eventorganization_conferenceorboothattendee_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_eventorganization_conferenceorboothattendee_fk_field FOREIGN KEY (fk_field) REFERENCES llx_eventorganization_myotherobject(rowid); + diff --git a/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.sql b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.sql new file mode 100644 index 00000000000..4df836ccf5b --- /dev/null +++ b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.sql @@ -0,0 +1,39 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +CREATE TABLE llx_eventorganization_conferenceorboothattendee( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + fk_soc integer, + fk_project integer, + fk_actioncomm integer NOT NULL, + email text, + date_subscription datetime, + amount double DEFAULT NULL, + datep datetime, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + last_main_doc varchar(255), + import_key varchar(14), + model_pdf varchar(255), + status smallint NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.sql.back b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.sql.back new file mode 100644 index 00000000000..c0a80dee739 --- /dev/null +++ b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.sql.back @@ -0,0 +1,38 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +CREATE TABLE llx_eventorganization_conferenceorboothattendee( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + fk_soc integer, + fk_project integer, + email text, + date_subscription datetime, + amount double DEFAULT NULL, + datep datetime, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + last_main_doc varchar(255), + import_key varchar(14), + model_pdf varchar(255), + status smallint NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee_extrafields.key.sql b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee_extrafields.key.sql new file mode 100644 index 00000000000..5fa3554fae3 --- /dev/null +++ b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee_extrafields.key.sql @@ -0,0 +1,19 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_eventorganization_conferenceorboothattendee_extrafields ADD INDEX idx_conferenceorboothattendee_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee_extrafields.sql b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee_extrafields.sql new file mode 100644 index 00000000000..5455314ff06 --- /dev/null +++ b/htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +create table llx_eventorganization_conferenceorboothattendee_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + From 373a52063d5e2be89b280222f2b97e09aa6335b5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 24 Mar 2021 20:13:30 +0100 Subject: [PATCH 027/233] add commit --- ...ization_confboothattendee_extrafields.php} | 34 +----- htdocs/core/lib/eventorganization.lib.php | 5 + htdocs/core/lib/project.lib.php | 24 +++- .../class/conferenceorbooth.class.php | 3 +- .../class/conferenceorboothattendee.class.php | 10 +- .../conferenceorboothattendee.class.php.back | 10 +- .../conferenceorbooth_card.php | 3 +- .../conferenceorbooth_list.php | 68 ++--------- .../conferenceorboothattendee_card.php | 112 +++++------------- .../conferenceorboothattendee_list.php | 94 +++++++++------ ...ventorganization_conferenceorbooth.lib.php | 7 +- ...ization_conferenceorboothattendee.sql.back | 38 ------ .../install/mysql/migration/13.0.0-14.0.0.sql | 1 + ...nization_conferenceorboothattendee.key.sql | 6 +- ...organization_conferenceorboothattendee.sql | 3 +- ...ferenceorboothattendee_extrafields.key.sql | 0 ..._conferenceorboothattendee_extrafields.sql | 0 htdocs/langs/en_US/eventorganization.lang | 2 +- 18 files changed, 152 insertions(+), 268 deletions(-) rename htdocs/{eventorganization/admin/conferenceorboothattendee_extrafields.php => admin/eventorganization_confboothattendee_extrafields.php} (71%) delete mode 100644 htdocs/eventorganization/sql/llx_eventorganization_conferenceorboothattendee.sql.back rename htdocs/{eventorganization/sql => install/mysql/tables}/llx_eventorganization_conferenceorboothattendee.key.sql (72%) rename htdocs/{eventorganization/sql => install/mysql/tables}/llx_eventorganization_conferenceorboothattendee.sql (97%) rename htdocs/{eventorganization/sql => install/mysql/tables}/llx_eventorganization_conferenceorboothattendee_extrafields.key.sql (100%) rename htdocs/{eventorganization/sql => install/mysql/tables}/llx_eventorganization_conferenceorboothattendee_extrafields.sql (100%) diff --git a/htdocs/eventorganization/admin/conferenceorboothattendee_extrafields.php b/htdocs/admin/eventorganization_confboothattendee_extrafields.php similarity index 71% rename from htdocs/eventorganization/admin/conferenceorboothattendee_extrafields.php rename to htdocs/admin/eventorganization_confboothattendee_extrafields.php index 927520a013b..d9dd448bb42 100644 --- a/htdocs/eventorganization/admin/conferenceorboothattendee_extrafields.php +++ b/htdocs/admin/eventorganization_confboothattendee_extrafields.php @@ -25,40 +25,12 @@ * \ingroup eventorganization * \brief Page to setup extra fields of conferenceorboothattendee */ - -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/eventorganization.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -require_once '../lib/eventorganization.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('eventorganization@eventorganization', 'admin')); +$langs->loadLangs(array('eventorganization', 'admin')); $extrafields = new ExtraFields($db); $form = new Form($db); diff --git a/htdocs/core/lib/eventorganization.lib.php b/htdocs/core/lib/eventorganization.lib.php index 80dc72b50e5..2f8ea573c1f 100644 --- a/htdocs/core/lib/eventorganization.lib.php +++ b/htdocs/core/lib/eventorganization.lib.php @@ -46,6 +46,11 @@ function eventorganizationAdminPrepareHead() $head[$h][2] = 'eventorganization_extrafields'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/eventorganization_confboothattendee_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Attendees").")"; + $head[$h][2] = 'conferenceorboothattendee_extrafields'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line //$this->tabs = array( diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 8fef0916ff8..e97d4a01904 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -206,11 +206,29 @@ function project_prepare_head(Project $project) if ($conf->eventorganization->enabled) { $langs->load('eventorganization'); - //TODO : Count - $nbConfOrBooth = 1; $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_list.php?projectid=' . $project->id; $head[$h][1] = $langs->trans("ConferenceOrBoothTab"); - if ($nbContact > 0) { + + // Enable caching of conf or booth count + $nbConfOrBooth = 0; + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_conferenceorbooth_'.$project->id; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $nbConfOrBooth = $dataretrieved; + } else { + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; + $conforbooth=new ConferenceOrBooth($db); + $result = $conforbooth->fetchAll('', '', 0, 0, array('t.fk_project'=>$project->id)); + //, + if (!is_array($result) && $result<0) { + setEventMessages($conforbooth->error, $conforbooth->errors, 'errors'); + } else { + $nbConfOrBooth = count($result); + } + dol_setcache($cachekey, $nbConfOrBooth, 120); // If setting cache fails, this is not a problem, so we do not test result. + } + if ($nbConfOrBooth > 0) { $head[$h][1] .= '' . $nbConfOrBooth . ''; } $head[$h][2] = 'eventorganisation'; diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 18bbd47f393..f4661a1d2ab 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -272,6 +272,7 @@ class ConferenceOrBooth extends ActionComm $sql = 'SELECT '; $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; } else { @@ -281,7 +282,7 @@ class ConferenceOrBooth extends ActionComm $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key == 't.id') { + if ($key == 't.id' || $key == 't.fk_project' || $key == 't.fk_soc' || $key == 't.fk_action') { $sqlwhere[] = $key.'='.$value; } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index f6a1ff382b5..3abf2b3f4bf 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -103,12 +103,11 @@ class ConferenceOrBoothAttendee extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0, 'index'=>1, 'comment'=>"Reference of object"), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), - 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,), - 'email' => array('type'=>'text', 'label'=>'email', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1, 'index'=>1,), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>4, 'index'=>1,), + 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>4, 'index'=>1,), + 'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1, 'index'=>1,), 'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), - 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), - 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), + 'amount' => array('type'=>'price', 'label'=>'AmountOfSubscriptionPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -128,7 +127,6 @@ class ConferenceOrBoothAttendee extends CommonObject public $email; public $date_subscription; public $amount; - public $datep; public $note_public; public $note_private; public $date_creation; diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php.back b/htdocs/eventorganization/class/conferenceorboothattendee.class.php.back index 472c62b1e55..593b89b9b76 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php.back +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php.back @@ -103,12 +103,11 @@ class ConferenceOrBoothAttendee extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0, 'index'=>1, 'comment'=>"Reference of object"), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), - 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,), - 'email' => array('type'=>'text', 'label'=>'email', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1, 'index'=>1,), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>4, 'index'=>1,), + 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>4, 'index'=>1,), + 'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1, 'index'=>1,), 'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), - 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), - 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), + 'amount' => array('type'=>'price', 'label'=>'AmountOfSubscriptionPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -124,6 +123,7 @@ class ConferenceOrBoothAttendee extends CommonObject public $ref; public $fk_soc; public $fk_project; + public $fk_actioncomm; public $email; public $date_subscription; public $amount; diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 2108ddaad2a..840905b6031 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -319,7 +319,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + http://dolibarr.local/eventorganization/conferenceorbooth_list.php?projectid=7 + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; /* diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index eaf45a4e801..d2bffd27a93 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2021 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -132,19 +132,20 @@ $permissiontoadd = $user->rights->eventorganization->write; $permissiontodelete = $user->rights->eventorganization->delete; // Security check -//$socid = 0; +if (empty($conf->eventorganization->enabled)) { + accessforbidden('Module not enabled'); +} +$socid = 0; if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; accessforbidden(); } $result = restrictedArea($user, 'eventorganization'); - +if (!$permissiontoread) accessforbidden(); /* * Actions */ - - if (preg_match('/^set/', $action) && $projectid > 0) { $project = new Project($db); //If "set" fields keys is in projects fields @@ -387,39 +388,6 @@ if ($projectid > 0) { print ""; } - print ''; - $typeofdata = 'checkbox:'.($project->accept_conference_suggestions ? ' checked="checked"' : ''); - $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); - print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); - print ''; - print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); - print ""; - - print ''; - $typeofdata = 'checkbox:'.($project->accept_booth_suggestions ? ' checked="checked"' : ''); - $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); - print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); - print ''; - print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); - print ""; - - print ''; - print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); - print ''; - print $form->editfieldval('PriceOfRegistration', 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); - print ""; - - print ''; - print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); - print ''; - print $form->editfieldval('PriceOfBooth', 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); - print ""; - - print ''.$langs->trans("EventOrganizationICSLink").''; - print ''; - print ""; - - print ''; print '
'; @@ -461,10 +429,11 @@ if ($object->ismultientitymanaged == 1) { } else { $sql .= " WHERE 1 = 1"; } - +if ($projectid > 0) { + $sql .= ' AND t.fk_project='.$project->id; +} foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { - //var_dump($key,$object->fields); if ($key == 'status' && $search[$key] == -1) { continue; } @@ -479,7 +448,6 @@ foreach ($search as $key => $val) { $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } } else { - //var_dump($key,$object->fields); if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { @@ -505,22 +473,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -/* If a group by is required -$sql.= " GROUP BY "; -foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; -} -// Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); -} -// Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/','', $sql); -*/ - $sql .= $db->order($sortfield, $sortorder); // Count total nb of records diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index e301581565b..432028417f7 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -22,66 +22,17 @@ * \brief Page to create/edit/view conferenceorboothattendee */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -dol_include_once('/eventorganization/class/conferenceorboothattendee.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorboothattendee.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + // Load translation files required by the page -$langs->loadLangs(array("eventorganization@eventorganization", "other")); +$langs->loadLangs(array("eventorganization", "other")); // Get parameters $id = GETPOST('id', 'int'); @@ -94,12 +45,25 @@ $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); //$lineid = GETPOST('lineid', 'int'); +$conf_or_booth_id = GETPOST('conforboothid', 'int'); + // Initialize technical objects $object = new ConferenceOrBoothAttendee($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothattendeecard', 'globalcard')); // Note that conf->hooks_modules contains array +if ($conf_or_booth_id > 0) { + $confOrBooth = new ConferenceOrBooth($db); + $result = $confOrBooth->fetch($conf_or_booth_id); + if ($result < 0) { + setEventMessages(null, $confOrBooth->errors, 'errors'); + } else { + $object->fk_actioncomm = $confOrBooth->id; + $object->fk_project = $confOrBooth->fk_project; + } +} + // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -122,22 +86,13 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = $user->rights->eventorganization->conferenceorboothattendee->read; -$permissiontoadd = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->eventorganization->conferenceorboothattendee->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_dellink.inc.php +$permissiontoread = $user->rights->eventorganization->read; +$permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1]; -// Security check - Protection if external user -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); -//$result = restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - -//if (empty($permissiontoread)) accessforbidden(); - - /* * Actions */ @@ -211,28 +166,17 @@ $title = $langs->trans("ConferenceOrBoothAttendee"); $help_url = ''; llxHeader('', $title, $help_url); -// Example : Adding jquery code -print ''; - - // Part to create if ($action == 'create') { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")), '', 'object_'.$object->picto); print '
'; print ''; + + if ($confOrBooth->id > 0) { + print ''; + } + print ''; if ($backtopage) { print ''; diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 2e396260b8f..4ffb3ca513c 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -27,15 +27,20 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +if ($conf->categorie->enabled) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // load eventorganization libraries -require_once __DIR__.'/class/conferenceorboothattendee.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); // Load translation files required by the page -$langs->loadLangs(array("eventorganization@eventorganization", "other")); +$langs->loadLangs(array("eventorganization", "other")); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) @@ -48,6 +53,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); +$conf_or_booth_id = GETPOST('conforboothid', 'int'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -124,9 +130,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -//$permissiontoread = $user->rights->eventorganization->conferenceorboothattendee->read; $permissiontoread = $user->rights->eventorganization->read; -//$permissiontoadd = $user->rights->eventorganization->conferenceorboothattendee->write; $permissiontoadd = $user->rights->eventorganization->write; $permissiontodelete = $user->rights->eventorganization->delete; @@ -139,9 +143,8 @@ if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; accessforbidden(); } -//$result = restrictedArea($user, 'eventorganization', $id, ''); -//if (!$permissiontoread) accessforbidden(); - +$result = restrictedArea($user, 'eventorganization'); +if (!$permissiontoread) accessforbidden(); /* @@ -200,12 +203,6 @@ $form = new Form($db); $now = dol_now(); -//$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee"; -$help_url = ''; -$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBoothAttendees")); -$morejs = array(); -$morecss = array(); - // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; @@ -213,7 +210,7 @@ $sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key.', ' : ''); } } // Add fields from hooks @@ -223,7 +220,7 @@ $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.id = ef.fk_object)"; } // Add table from hooks $parameters = array(); @@ -274,21 +271,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -/* If a group by is required -$sql.= " GROUP BY "; -foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; -} -// Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); -} -// Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/','', $sql); -*/ $sql .= $db->order($sortfield, $sortorder); @@ -331,8 +313,51 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- +//$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee"; +$help_url = ''; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBoothAttendees")); +//$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBooths")); +$morejs = array(); +$morecss = array(); llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); +if ($conf_or_booth_id > 0) { + $confOrBooth = new ConferenceOrBooth($db); + $result = $confOrBooth->fetch($conf_or_booth_id); + if ($result < 0) { + setEventMessages(null, $confOrBooth->errors, 'errors'); + } + + $head = conferenceorboothPrepareHead($confOrBooth); + print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto); + + + //$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; + $title = $langs->trans("ConferenceOrBooths") . ' - ' . $langs->trans("ConferenceOrBoothsAttendees") . ' - ' . $confOrBooth->id; + + $object_evt=$object; + $object=$confOrBooth; + + dol_banner_tab($object, 'ref', '', 0); + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + $object=$object_evt; + print '
'; + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); +} // Example : Adding jquery code print '';*/ - - // Part to create if ($action == 'create') { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBooth")), '', 'object_'.$object->picto); diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index 432028417f7..dae9ca32a01 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; - +require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; // Load translation files required by the page $langs->loadLangs(array("eventorganization", "other")); @@ -221,6 +221,12 @@ if (($id || $ref) && $action == 'edit') { print ''; print ''; print ''; + if ($confOrBooth->id > 0) { + print ''; + } + if ($object->fk_actioncomm > 0) { + print ''; + } if ($backtopage) { print ''; } @@ -254,7 +260,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $res = $object->fetch_optionals(); $head = conferenceorboothattendeePrepareHead($object); - print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto); + print dol_get_fiche_head(array(), 'card', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto); $formconfirm = ''; diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 4ffb3ca513c..8a6c510f255 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -219,8 +219,9 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.id = ef.fk_object)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } // Add table from hooks $parameters = array(); @@ -358,20 +359,6 @@ if ($conf_or_booth_id > 0) { print dol_get_fiche_end(); } -// Example : Adding jquery code -print ''; $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -430,7 +417,7 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:''), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index dc61d978169..2c65ebbe5db 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -55,7 +55,7 @@ function conferenceorboothPrepareHead($object) } else { require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; $attendees=new ConferenceOrBoothAttendee($db); - $result = $attendees->fetchAll('', '', 0, 0, array('fk_actioncomm'=>$object->id)); + $result = $attendees->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$object->id)); if (!is_array($result) && $result<0) { setEventMessages($attendees->error, $attendees->errors, 'errors'); } else { @@ -95,3 +95,25 @@ function conferenceorboothPrepareHead($object) return $head; } + + +/** + * Prepare array of tabs for ConferenceOrBoothAttendees + * + * @param ConferenceOrBoothAttendee $object ConferenceOrBoothAttendee + * @return array Array of tabs + */ +function conferenceorboothattendeePrepareHead($object) +{ + global $db, $langs, $conf; + + $langs->load("eventorganization"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_card.php", 1).'?id='.$object->id.'&conforboothid='.$object->fk_actioncomm; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; +} diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 9a0f0826c54..c83dca01d7a 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -279,3 +279,48 @@ DELETE FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ti -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_nb_tickets_type.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_nb_tickets_type.php' AND entity = 1); -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_new_vs_close_ticket.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_new_vs_close_ticket.php' AND entity = 1); + +CREATE TABLE llx_eventorganization_conferenceorboothattendee( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + fk_soc integer, + fk_project integer, + fk_actioncomm integer NOT NULL, + email varchar(100), + date_subscription datetime, + amount double DEFAULT NULL, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + last_main_doc varchar(255), + import_key varchar(14), + model_pdf varchar(255), + status smallint NOT NULL +) ENGINE=innodb; + +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_project (fk_project); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_project FOREIGN KEY (fk_project) REFERENCES llx_projet(rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm(id); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_eventorganization_conferenceorboothattendee_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_project, fk_actioncomm, email); + +create table llx_eventorganization_conferenceorboothattendee_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_eventorganization_conferenceorboothattendee_extrafields ADD INDEX idx_conferenceorboothattendee_fk_object(fk_object); + diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql index f66bb7f76c8..b4ee98e3aa9 100644 --- a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql @@ -28,6 +28,6 @@ ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_e ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status); -- END MODULEBUILDER INDEXES -ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee_soc_proj_action(fk_soc, fk_project, fk_actioncomm); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_project, fk_actioncomm, email); From 53a9fd58232cabb7c62f2e796326d1cac1a31709 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 24 Mar 2021 22:21:31 +0100 Subject: [PATCH 029/233] almost done --- .../class/conferenceorbooth.class.php | 2 +- .../class/conferenceorboothattendee.class.php | 6 ++- .../conferenceorbooth_list.php | 2 + .../conferenceorboothattendee_card.php | 38 +++---------------- .../conferenceorboothattendee_list.php | 24 ++++++------ ...ventorganization_conferenceorbooth.lib.php | 6 +++ 6 files changed, 32 insertions(+), 46 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index f4661a1d2ab..4f3fa42b51f 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -574,7 +574,7 @@ class ConferenceOrBooth extends ActionComm $label = $langs->trans("ShowConferenceOrBooth"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + //$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index dbc1e853d2a..4def01d2c7f 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -61,7 +61,7 @@ class ConferenceOrBoothAttendee extends CommonObject /** * @var string String with name of icon for conferenceorboothattendee. Must be the part after the 'object_' into object_conferenceorboothattendee.png */ - public $picto = 'conferenceorboothattendee@eventorganization'; + public $picto = 'contact'; const STATUS_DRAFT = 0; @@ -736,6 +736,10 @@ class ConferenceOrBoothAttendee extends CommonObject if ($add_save_lastsearch_values) { $url .= '&save_lastsearch_values=1'; } + + if ($option == 'conforboothid') { + $url .= '&conforboothid='.$this->fk_actioncomm; + } } $linkclose = ''; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index d2bffd27a93..85bdd52905f 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -735,6 +735,8 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print ''; if ($key == 'status') { print $object->getLibStatut(5); + } elseif ($key == 'ref') { + print $object->getNomUrl(1); } else { print $object->showOutputField($val, $key, $object->$key, ''); } diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index dae9ca32a01..7b012a42d8e 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -260,7 +260,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $res = $object->fetch_optionals(); $head = conferenceorboothattendeePrepareHead($object); - print dol_get_fiche_head(array(), 'card', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto); + print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto); $formconfirm = ''; @@ -310,7 +310,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; /* @@ -439,24 +439,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($user->socid)) { print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle'); } - - // Back to draft - if ($object->status == $object::STATUS_VALIDATED) { - print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd); - } - - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit', '', $permissiontoadd); - - // Validate - if ($object->status == $object::STATUS_DRAFT) { - if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd); - } else { - $langs->load("errors"); - //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0); - print ''.$langs->trans("Validate").''; - } - } + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&conforboothid='.$confOrBooth->id.'&action=edit', '', $permissiontoadd); // Clone print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); @@ -512,20 +495,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
'; + print '
'; - $MAXEVENT = 10; - - $morehtmlright = ''; - $morehtmlright .= $langs->trans("SeeAll"); - $morehtmlright .= ''; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); - - print '
'; + print ''; } //Select mail models is same action as presend diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 8a6c510f255..66e1ce86b5f 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -202,6 +202,13 @@ if (empty($reshook)) { $form = new Form($db); $now = dol_now(); +$confOrBooth = new ConferenceOrBooth($db); +if ($conf_or_booth_id > 0) { + $result = $confOrBooth->fetch($conf_or_booth_id); + if ($result < 0) { + setEventMessages(null, $confOrBooth->errors, 'errors'); + } +} // Build and execute select // -------------------------------------------------------------------- @@ -219,7 +226,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm AND a.id=".$confOrBooth->id; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } @@ -316,25 +323,18 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ //$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee"; $help_url = ''; -$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBoothAttendees")); -//$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBooths")); +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")); $morejs = array(); $morecss = array(); llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); -if ($conf_or_booth_id > 0) { - $confOrBooth = new ConferenceOrBooth($db); - $result = $confOrBooth->fetch($conf_or_booth_id); - if ($result < 0) { - setEventMessages(null, $confOrBooth->errors, 'errors'); - } - +if ($confOrBooth->id > 0) { $head = conferenceorboothPrepareHead($confOrBooth); print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto); //$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; - $title = $langs->trans("ConferenceOrBooths") . ' - ' . $langs->trans("ConferenceOrBoothsAttendees") . ' - ' . $confOrBooth->id; + $title = $langs->trans("ConferenceOrBooth") . ' - ' . $langs->trans("Attendees") . ' - ' . $confOrBooth->id; $object_evt=$object; $object=$confOrBooth; @@ -588,6 +588,8 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print ''; if ($key == 'status') { print $object->getLibStatut(5); + } elseif ($key == 'ref') { + print $object->getNomUrl(1, 'conforboothid'); } else { print $object->showOutputField($val, $key, $object->$key, ''); } diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index 2c65ebbe5db..f43eaa83f1a 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -116,4 +116,10 @@ function conferenceorboothattendeePrepareHead($object) $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization', 'remove'); + + return $head; } From 443fd544be8fc5dad558d22936eb12f1c31be42f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Mar 2021 01:07:29 +0100 Subject: [PATCH 030/233] Update time.php --- htdocs/projet/tasks/time.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index eeca9e34cd1..534a7ec09f5 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -177,8 +177,8 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } else { $object->timespent_note = GETPOST('timespent_note', 'alpha'); if (GETPOST('progress', 'int') > 0) $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value - $object->timespent_duration = (int) GETPOST("timespent_durationhour", 'int') * 60 * 60; // We store duration in seconds - $object->timespent_duration += (GETPOST('timespent_durationmin', 'int') ? (int) GETPOST('timespent_durationmin', 'int') : 0) * 60; // We store duration in seconds + $object->timespent_duration = GETPOSTINT("timespent_durationhour") * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOSTINT('timespent_durationmin') ? GETPOSTINT('timespent_durationmin') : 0) * 60; // We store duration in seconds if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timehour"), GETPOST("timemin"), 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); @@ -226,8 +226,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->fetch($id, $ref); $object->timespent_note = GETPOST('timespent_note_line', 'alpha'); $object->timespent_old_duration = GETPOST("old_duration"); - $object->timespent_duration = (int) GETPOST("new_durationhour", 'int') * 60 * 60; // We store duration in seconds - $object->timespent_duration += (GETPOST("new_durationmin", 'int') ? (int) GETPOST('new_durationmin', 'int') : 0) * 60; // We store duration in seconds + $object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); @@ -251,8 +251,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_id = GETPOST("lineid", 'int'); $object->timespent_note = GETPOST('timespent_note_line', 'alpha'); $object->timespent_old_duration = GETPOST("old_duration"); - $object->timespent_duration = (int) GETPOST("new_durationhour", 'int') * 60 * 60; // We store duration in seconds - $object->timespent_duration += (GETPOST("new_durationmin", 'int') ? (int) GETPOST('new_durationmin', 'int') : 0) * 60; // We store duration in seconds + $object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); From ccd6d28f6fee8b6e1a427219e274cf601ec55ac8 Mon Sep 17 00:00:00 2001 From: ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Thu, 25 Mar 2021 14:39:42 +0100 Subject: [PATCH 031/233] FIX #16843 https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4 fa-mail-forward => fa-share --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b63f9d72f26..2a57a983496 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3337,7 +3337,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt', - 'uparrow'=>'mail-forward', 'vcard'=>'address-card', + 'uparrow'=>'share', 'vcard'=>'address-card', 'jabber'=>'comment-o', 'website'=>'globe-americas' ); From 512a570b631c988b868d0d192910acd679a3d56b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Mar 2021 01:37:19 +0100 Subject: [PATCH 032/233] FIX error for duplicate thirdparty found correctly returned by ws --- htdocs/webservices/server_supplier_invoice.php | 1 - htdocs/webservices/server_thirdparty.php | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/webservices/server_supplier_invoice.php b/htdocs/webservices/server_supplier_invoice.php index 507095ac78b..8ba70409806 100644 --- a/htdocs/webservices/server_supplier_invoice.php +++ b/htdocs/webservices/server_supplier_invoice.php @@ -329,7 +329,6 @@ function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '') * @param array $authentication Array of authentication information * @param int $idthirdparty Id thirdparty * @return array Array result - * */ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) { diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index d7ded82cc3f..c81b6bc6f63 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -298,14 +298,16 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') // Init and check authentication $objectresp = array(); - $errorcode = ''; $errorlabel = ''; + $errorcode = ''; + $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) { $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; + $errorcode = 'BAD_PARAMETERS'; + $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } if (!$error) @@ -316,8 +318,7 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') { $thirdparty = new Societe($db); $result = $thirdparty->fetch($id, $ref, $ref_ext); - if ($result > 0) - { + if ($result > 0) { $thirdparty_result_fields = array( 'id' => $thirdparty->id, 'ref' => $thirdparty->name, @@ -380,8 +381,10 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'thirdparty'=>$thirdparty_result_fields); - } - else { + } elseif ($result == -2) { + $error++; + $errorcode = 'DUPLICATE_FOUND'; $errorlabel = 'Object found several times for id='.$id.' or ref='.$ref.' or ref_ext='.$ref_ext; + } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; } From 8a2e49d6e7e67b08a72013028e830245d1e1bb9c Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 26 Mar 2021 17:44:41 +0100 Subject: [PATCH 033/233] NEW date and user signature on proposal (Issue 16062) --- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 112 +++++++++++++++++- htdocs/core/lib/functions2.lib.php | 55 +++++++++ .../install/mysql/migration/13.0.0-14.0.0.sql | 6 + .../install/mysql/tables/llx_propal.key.sql | 2 + htdocs/install/mysql/tables/llx_propal.sql | 4 +- htdocs/langs/fr_FR/main.lang | 1 + htdocs/langs/fr_FR/other.lang | 1 + 8 files changed, 179 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index cecb4fff28a..dc923e4e1dc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -642,7 +642,7 @@ if (empty($reshook)) { if ($object->statut == $object::STATUS_VALIDATED) { $db->begin(); - $result = $object->cloture($user, GETPOST('statut', 'int'), GETPOST('note_private', 'restricthtml')); + $result = $object->signature($user, GETPOST('statut', 'int'), GETPOST('note_private', 'restricthtml')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3674356af20..c9f736fcfff 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -140,6 +140,16 @@ class Propal extends CommonObject */ public $date_validation; + /** + * @var integer|string $date_signature; + */ + public $date_signature; + + /** + * @var User $user_signature + */ + public $user_signature; + /** * @var integer|string date of the quote; */ @@ -2489,6 +2499,97 @@ class Propal extends CommonObject } } + /** + * Sign the commercial proposal + * + * @param User $user Object user that close + * @param int $statut Status + * @param string $note Complete private note with this note + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + function signature($user, $statut, $note = '', $notrigger = 0) + { + global $langs,$conf; + + $error = 0; + $now = dol_now(); + + $this->db->begin(); + + $newprivatenote = dol_concatdesc($this->note_private, $note); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql .= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($newprivatenote)."', date_signature='".$this->db->idate($now)."', fk_user_signature=".$user->id; + $sql .= " WHERE rowid = ".$this->id; + + $resql = $this->db->query($sql); + if ($resql) { + $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->model_pdf; + $trigger_name = 'PROPAL_CLOSE_REFUSED'; + + if ($statut == self::STATUS_SIGNED) { + $trigger_name = 'PROPAL_CLOSE_SIGNED'; + $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->model_pdf; + + // The connected company is classified as a client + $soc=new Societe($this->db); + $soc->id = $this->socid; + $result = $soc->set_as_client(); + + if ($result < 0) { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (!empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id','aZ09') ? GETPOST('lang_id','aZ09') : $this->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs); + } + + if (!$error) { + $this->oldcopy= clone $this; + $this->statut = $statut; + $this->date_signature = $now; + $this->note_private = $newprivatenote; + } + + if (!$notrigger && empty($error)) { + // Call trigger + $result=$this->call_trigger($trigger_name, $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + if (!$error ) { + $this->db->commit(); + return 1; + } else { + $this->statut = $this->oldcopy->statut; + $this->date_signature = $this->oldcopy->date_signature; + $this->note_private = $this->oldcopy->note_private; + + $this->db->rollback(); + return -1; + } + } else { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } /** * Close the commercial proposal @@ -3113,8 +3214,8 @@ class Propal extends CommonObject public function info($id) { $sql = "SELECT c.rowid, "; - $sql .= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; - $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; + $sql .= " c.datec, c.date_valid as datev, c.date_signature, c.date_cloture as dateo,"; + $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_signature, c.fk_user_cloture"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; $sql .= " WHERE c.rowid = ".((int) $id); @@ -3128,6 +3229,7 @@ class Propal extends CommonObject $this->date_creation = $this->db->jdate($obj->datec); $this->date_validation = $this->db->jdate($obj->datev); + $this->date_signature = $this->db->jdate($obj->date_signature); $this->date_cloture = $this->db->jdate($obj->dateo); $cuser = new User($this->db); @@ -3140,6 +3242,12 @@ class Propal extends CommonObject $this->user_validation = $vuser; } + if ($obj->fk_user_signature) { + $user_signature = new User($this->db); + $user_signature->fetch($obj->fk_user_signature); + $this->user_signature = $user_signature; + } + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 0703df95255..3f7e02b9bad 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -507,6 +507,61 @@ function dol_print_object_info($object, $usetable = 0) } } + // User signature + if (!empty($object->user_signature)) { + if ($usetable) { + print ''; + } + print $langs->trans('SignedBy'); + if ($usetable) { + print ''; + } else { + print ': '; + } + if (is_object($object->user_signature)) { + if ($object->user_signature->id) { + print $object->user_signature->getNomUrl(-1, '', 0, 0, 0); + } else { + print $langs->trans('Unknown'); + } + } else { + $userstatic = new User($db); + $userstatic->fetch($object->user_signature); + if ($userstatic->id) { + print $userstatic->getNomUrl(-1, '', 0, 0, 0); + } else { + print $langs->trans('Unknown'); + } + } + if ($usetable) { + print ''; + } else { + print '
'; + } + } + + // Date signature + if (!empty($object->date_signature)) { + if ($usetable) { + print ''; + } + print $langs->trans('DateSigning'); + if ($usetable) { + print ''; + } else { + print ': '; + } + print dol_print_date($object->date_signature, 'dayhour'); + if ($deltadateforuser) { + print ' '.$langs->trans('CurrentHour').'   /   '.dol_print_date($object->date_signature,'dayhour', 'tzuserrel').'  '.$langs->trans('ClientHour'); + } + if ($usetable) { + print ''; + } else { + print '
'; + } + } + // User close if (!empty($object->user_cloture) || !empty($object->user_closing)) { if (isset($object->user_cloture) && !empty($object->user_cloture)) { diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 772f0e51bdf..0c71b94f4f1 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -282,5 +282,11 @@ DELETE FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ti ALTER TABLE llx_c_ticket_category ADD COLUMN public integer DEFAULT 0; +ALTER TABLE llx_propal ADD COLUMN date_signature datetime AFTER date_valid; +ALTER TABLE llx_propal ADD COLUMN fk_user_signature integer AFTER fk_user_valid; +ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (fk_user_signature) REFERENCES llx_user (rowid); +UPDATE llx_propal SET fk_user_signature = fk_user_cloture WHERE fk_user_signature IS NULL AND fk_user_cloture IS NOT NULL; +UPDATE llx_propal SET date_signature = date_cloture WHERE date_signature IS NULL AND date_cloture IS NOT NULL; + diff --git a/htdocs/install/mysql/tables/llx_propal.key.sql b/htdocs/install/mysql/tables/llx_propal.key.sql index 89a0c54ad83..d0265e6fcdf 100644 --- a/htdocs/install/mysql/tables/llx_propal.key.sql +++ b/htdocs/install/mysql/tables/llx_propal.key.sql @@ -24,6 +24,7 @@ ALTER TABLE llx_propal ADD UNIQUE INDEX uk_propal_ref (ref, entity); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_soc (fk_soc); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_author (fk_user_author); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_valid (fk_user_valid); +ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_signature (fk_user_signature); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_cloture (fk_user_cloture); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_projet (fk_projet); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_account(fk_account); @@ -33,6 +34,7 @@ ALTER TABLE llx_propal ADD INDEX idx_propal_fk_warehouse(fk_warehouse); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); +ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (fk_user_signature) REFERENCES llx_user (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_cloture FOREIGN KEY (fk_user_cloture) REFERENCES llx_user (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); --ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid); diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 004bb027d35..7c94086b3b9 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -37,11 +37,13 @@ create table llx_propal datep date, -- date de la propal fin_validite datetime, -- date de fin de validite date_valid datetime, -- date de validation + date_signature datetime, -- date signature date_cloture datetime, -- date de cloture fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change fk_user_valid integer, -- user validating - fk_user_cloture integer, -- user closing (signed or not) + fk_user_signature integer, -- user signing (signed or not) + fk_user_cloture integer, -- user closing fk_statut smallint DEFAULT 0 NOT NULL, -- 0=draft, 1=validated, 2=accepted, 3=refused, 4=billed/closed price real DEFAULT 0, -- (obsolete) remise_percent real DEFAULT 0, -- remise globale relative en pourcent (obsolete) diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 86ba2247682..a8b13c7e914 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -278,6 +278,7 @@ DateModificationShort=Date modif. IPModification=Modification IP DateLastModification=Date de dernière modification DateValidation=Date validation +DateSigning=Date signature DateClosing=Date clôture DateDue=Date échéance DateValue=Date valeur diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 3023cd7216e..a8078129464 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -114,6 +114,7 @@ DemoCompanyAll=Société avec de multiples activités (tous les modules principa CreatedBy=Créé par %s ModifiedBy=Modifié par %s ValidatedBy=Validé par %s +SignedBy=Signé par %s ClosedBy=Clôturé par %s CreatedById=Id utilisateur créateur ModifiedById=Id utilisateur du dernier changement From 05bf3cdab184ab8b1921afbec57d079c44f8ced4 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 26 Mar 2021 17:59:16 +0100 Subject: [PATCH 034/233] FIX stickler-ci errors --- htdocs/comm/propal/class/propal.class.php | 4 ++-- htdocs/core/lib/functions2.lib.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index c9f736fcfff..d9f1654e37c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2508,7 +2508,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function signature($user, $statut, $note = '', $notrigger = 0) + public function signature($user, $statut, $note = '', $notrigger = 0) { global $langs,$conf; @@ -2549,7 +2549,7 @@ class Propal extends CommonObject $outputlangs = $langs; if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id','aZ09') ? GETPOST('lang_id','aZ09') : $this->thirdparty->default_lang); + $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 3f7e02b9bad..e279ced2a3d 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -553,7 +553,7 @@ function dol_print_object_info($object, $usetable = 0) } print dol_print_date($object->date_signature, 'dayhour'); if ($deltadateforuser) { - print ' '.$langs->trans('CurrentHour').'   /   '.dol_print_date($object->date_signature,'dayhour', 'tzuserrel').'  '.$langs->trans('ClientHour'); + print ' '.$langs->trans('CurrentHour').'   /   '.dol_print_date($object->date_signature, 'dayhour', 'tzuserrel').'  '.$langs->trans('ClientHour'); } if ($usetable) { print ''; From 32246e4d69b3ebffe59d3d59b109328804af71e5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 18:29:06 +0100 Subject: [PATCH 035/233] workiong attendees --- .../eventorganization/class/conferenceorbooth.class.php | 8 +------- htdocs/eventorganization/conferenceorbooth_card.php | 6 ------ .../lib/eventorganization_conferenceorbooth.lib.php | 2 ++ 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 4f3fa42b51f..c7118d7c589 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -109,7 +109,7 @@ class ConferenceOrBooth extends ActionComm 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1::eventorganization', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'default'=>'', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -152,12 +152,6 @@ class ConferenceOrBooth extends ActionComm $this->fields['entity']['enabled'] = 0; } - // Example to show how to set values of fields definition dynamically - /*if ($user->rights->eventorganization->conferenceorbooth->read) { - $this->fields['myfield']['visible'] = 1; - $this->fields['myfield']['noteditable'] = 0; - }*/ - // Unset fields that are disabled foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 4ca3457b4fa..90c47b4806a 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -72,12 +72,6 @@ if (empty($action) && empty($id) && empty($ref)) { // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - -/*$permissiontoread = $user->rights->eventorganization->conferenceorbooth->read; -$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->eventorganization->conferenceorbooth->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_dellink.inc.php*/ $permissiontoread = $user->rights->eventorganization->read; $permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index f43eaa83f1a..0a1ddd27dce 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -117,6 +117,8 @@ function conferenceorboothattendeePrepareHead($object) $head[$h][2] = 'card'; $h++; + //TODO : Note and docuement + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization', 'remove'); From 3e12820f0e93d6b99999eb67e10f52b8db88cd66 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 18:37:11 +0100 Subject: [PATCH 036/233] fix comment --- htdocs/core/class/html.form.class.php | 2 +- htdocs/eventorganization/class/conferenceorbooth.class.php | 2 +- htdocs/eventorganization/conferenceorbooth_list.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 779e89c1f9f..df79fcfca7c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -96,7 +96,7 @@ class Form * @param string $preselected Value to show/edit (not used in this function) * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), '+:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'checkbox:ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) * @param string $moreparam More param to add on a href URL. * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' ' diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index c7118d7c589..ddc75a034d0 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -109,7 +109,7 @@ class ConferenceOrBooth extends ActionComm 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1::eventorganization', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'default'=>'', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'default'=>'', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=> 1, 'visible'=>1,), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 85bdd52905f..96c67e09c0b 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2021 Florian Henry * * This program is free software; you can redistribute it and/or modify From a8b486c7b9b6c73b113e765e705bdd9ae6367e17 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:00:56 +0100 Subject: [PATCH 037/233] fix error translation --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- htdocs/eventorganization/class/conferenceorbooth.class.php | 2 +- htdocs/langs/en_US/errors.lang | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 4bef5ddcd16..03ca6ae0369 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -407,7 +407,7 @@ class ActionComm extends CommonObject // Check parameters if (!isset($this->userownerid) || $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) of > 0 dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); - $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; + $this->errors[] = 'ErrorActionCommPropertyUserowneridNotDefined'; return -1; } @@ -478,7 +478,7 @@ class ActionComm extends CommonObject $this->type_id = $cactioncomm->id; $this->type_code = $cactioncomm->code; } elseif ($result == 0) { - $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; + $this->error = $langs->trans('ErrorActionCommBadType', $this->type_id, $this->type_code); return -1; } else { $this->error = $cactioncomm->error; diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index ddc75a034d0..ecd2fcd191f 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -109,7 +109,7 @@ class ConferenceOrBooth extends ActionComm 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1::eventorganization', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'default'=>'', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=> 1, 'visible'=>1,), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1,), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index bb5e7c5e287..002aa63fa62 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -293,4 +293,6 @@ WarningFailedToAddFileIntoDatabaseIndex=Warning, failed to add file entry into E WarningTheHiddenOptionIsOn=Warning, the hidden option %s is on. WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection. -WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. \ No newline at end of file +WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. +ErrorActionCommPropertyUserowneridNotDefined=User's owner is required +ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Event Type dictionary From a254bbcc02912845c03ca347f50c7e3145419d98 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:05:55 +0100 Subject: [PATCH 038/233] fix translation --- htdocs/install/mysql/data/llx_c_email_templates.sql | 2 +- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- htdocs/langs/en_US/eventorganization.lang | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index 713a7f31a4f..fabbbf2e700 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -36,5 +36,5 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index e2aed6fe5f9..8e75870b233 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -197,7 +197,7 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendes', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); ALTER TABLE llx_projet ADD COLUMN accept_conference_suggestions integer DEFAULT 0; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index dfb1b4faee5..33d74affd3e 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -62,7 +62,7 @@ EventOrganizationEmailAskConf = Request for conference EventOrganizationEmailAskBooth = Request for booth EventOrganizationEmailSubsBooth = Subscription for booth EventOrganizationEmailSubsEvent = Subscription for an event -EventOrganizationMassEmailAttendees = Communication to attendes +EventOrganizationMassEmailAttendees = Communication to attendees EventOrganizationMassEmailSpeakers = Communication to speakers # From 47675d28d79f4e6ac03b12122cf9d2ed6430899e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:47:48 +0100 Subject: [PATCH 039/233] add filter for select list attendees --- htdocs/admin/eventorganization.php | 36 +++++++++++-------- htdocs/langs/en_US/eventorganization.lang | 2 ++ htdocs/modulebuilder/template/admin/setup.php | 15 ++++++++ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 23fc463f3b5..743da034060 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -52,6 +52,8 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TASK_LABEL'=>array('type'=>'textarea','enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + 'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + 'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), @@ -144,7 +146,7 @@ if ($action == 'updateMask') { } } } -} elseif ($action == 'setdoc') { +}/* elseif ($action == 'setdoc') { // Set or unset default model $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { @@ -167,7 +169,7 @@ if ($action == 'updateMask') { $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; dolibarr_del_const($db, $constforval, $conf->entity); } -} +}*/ @@ -177,7 +179,7 @@ if ($action == 'updateMask') { $form = new Form($db); -$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); +//$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $page_name = "EventOrganizationSetup"; llxHeader('', $langs->trans($page_name)); @@ -249,6 +251,10 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($db); + print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); } else { print ''; } @@ -309,6 +315,16 @@ if ($action == 'edit') { } print '
    ' . implode(' ', $toprint) . '
'; } + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + if ($conf->global->{$constname}==2) { + print $langs->trans("Prospect"); + } elseif ($conf->global->{$constname}==3) { + print $langs->trans("ProspectCustomer"); + } elseif ($conf->global->{$constname}==1) { + print $langs->trans("Customer"); + } elseif ($conf->global->{$constname}==0) { + print $langs->trans("NorProspectNorCustomer"); + } } else { print $conf->global->{$constname}; } @@ -327,7 +343,7 @@ if ($action == 'edit') { } -$moduledir = 'eventorganization'; +/*$moduledir = 'eventorganization'; $myTmpObjects = array(); $myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0); @@ -337,9 +353,6 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { continue; } if ($myTmpObjectArray['includerefgeneration']) { - /* - * Orders Numbering model - */ $setupnotempty++; print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', ''); @@ -444,9 +457,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { } if ($myTmpObjectArray['includedocgeneration']) { - /* - * Document templates generators - */ + $setupnotempty++; $type = strtolower($myTmpObjectKey); @@ -588,10 +599,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print ''; } } - -if (empty($setupnotempty)) { - print '
'.$langs->trans("NothingToSetup"); -} +*/ // Page end print dol_get_fiche_end(); diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 33d74affd3e..c242904b074 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -42,6 +42,8 @@ EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH = Template of email to send aft EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT = Template of email to send after a subscription to an event has been paid. EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER = Template of email of massaction to attendes EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction to speakers +EVENTORGANIZATION_FILTERATTENDEES_CAT=Categories to filter thirdpartie's select list in attendees creation card/form +EVENTORGANIZATION_FILTERATTENDEES_TYPE=Thirdparty type to filter thirdpartie's select list in attendees creation card/form # # Object diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 06b169863f5..2e00c5c7cf9 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -80,6 +80,7 @@ $arrayofparameters = array( //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), + //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), ); $error = 0; @@ -271,6 +272,10 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($db); + print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); } else { print ''; } @@ -327,6 +332,16 @@ if ($action == 'edit') { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; } print '
      ' . implode(' ', $toprint) . '
    '; + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + if ($conf->global->{$constname}==2) { + print $langs->trans("Prospect"); + } elseif ($conf->global->{$constname}==3) { + print $langs->trans("ProspectCustomer"); + } elseif ($conf->global->{$constname}==1) { + print $langs->trans("Customer"); + } elseif ($conf->global->{$constname}==0) { + print $langs->trans("NorProspectNorCustomer"); + } } else { print $conf->global->{$constname}; } From 639942352629ee538cb1de2e0601750fa2e38630 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:56:06 +0100 Subject: [PATCH 040/233] fix translation --- htdocs/langs/en_US/eventorganization.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index c242904b074..180e04e6ccd 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -42,8 +42,8 @@ EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH = Template of email to send aft EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT = Template of email to send after a subscription to an event has been paid. EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER = Template of email of massaction to attendes EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction to speakers -EVENTORGANIZATION_FILTERATTENDEES_CAT=Categories to filter thirdpartie's select list in attendees creation card/form -EVENTORGANIZATION_FILTERATTENDEES_TYPE=Thirdparty type to filter thirdpartie's select list in attendees creation card/form +EVENTORGANIZATION_FILTERATTENDEES_CAT = Filter thirdpartie's select list in attendees creation card/form with catagories +EVENTORGANIZATION_FILTERATTENDEES_TYPE = Filter thirdpartie's select list in attendees creation card/form with customer type # # Object From 7a6cc742a6981c31e8bac70b9277e0f8934ddc98 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 19:57:20 +0100 Subject: [PATCH 041/233] fix translation --- htdocs/langs/en_US/eventorganization.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 180e04e6ccd..57106492f12 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -42,7 +42,7 @@ EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH = Template of email to send aft EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT = Template of email to send after a subscription to an event has been paid. EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER = Template of email of massaction to attendes EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction to speakers -EVENTORGANIZATION_FILTERATTENDEES_CAT = Filter thirdpartie's select list in attendees creation card/form with catagories +EVENTORGANIZATION_FILTERATTENDEES_CAT = Filter thirdpartie's select list in attendees creation card/form with category EVENTORGANIZATION_FILTERATTENDEES_TYPE = Filter thirdpartie's select list in attendees creation card/form with customer type # From aa9d4342cd5088920e77166f9f43b1f2fb82ed86 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 20:18:22 +0100 Subject: [PATCH 042/233] fix translation --- .../class/conferenceorboothattendee.class.php | 7 +++++++ htdocs/langs/en_US/eventorganization.lang | 1 + 2 files changed, 8 insertions(+) diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 4def01d2c7f..c8cec4172c7 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -194,6 +194,13 @@ class ConferenceOrBoothAttendee extends CommonObject $this->fields['entity']['enabled'] = 0; } + if (!empty($conf->global->EVENTORGANIZATION_FILTERATTENDEES_CAT)) { + $this->fields['fk_soc']['type'] .= ' AND rowid IN (SELECT DISTINCT c.fk_soc FROM '.MAIN_DB_PREFIX.'categorie_societe as c WHERE c.fk_categorie='.(int) $conf->global->EVENTORGANIZATION_FILTERATTENDEES_CAT.')'; + } + if ($conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE!=='') { + $this->fields['fk_soc']['type'] .= ' AND client='.(int) $conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE; + } + // Example to show how to set values of fields definition dynamically /*if ($user->rights->eventorganization->conferenceorboothattendee->read) { $this->fields['myfield']['visible'] = 1; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 57106492f12..8dadf5fdb97 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -54,6 +54,7 @@ ConferenceOrBooth = Conference Or Booth ConferenceOrBoothTab = Conference Or Booth AmountOfSubscriptionPaid = Amount of subscription paid DateSubscription = Date of subscription +ConferenceOrBoothAttendee = Conference Or Booth Attendee # # Template Mail From 1382323f77bc8642d6665ee61b33c4036bf87942 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 27 Mar 2021 06:56:34 +0100 Subject: [PATCH 043/233] FIX Start hour on ACCOUNTING_DATE_START_BINDING --- htdocs/accountancy/admin/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 64ebf2d1ab0..2febe354f2e 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -84,7 +84,7 @@ if ($action == 'update') { $constvalue = GETPOST($constname, 'alpha'); if ($constname == 'ACCOUNTING_DATE_START_BINDING') { - $constvalue = dol_mktime(12, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int')); + $constvalue = dol_mktime(0, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int')); } if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { From 56ae51375ddc12d1d94431423ca0e1bc2e700d72 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 27 Mar 2021 07:11:28 +0100 Subject: [PATCH 044/233] FIX Search on date in accountancy --- htdocs/accountancy/bookkeeping/list.php | 8 ++++---- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 7ada77d0bd6..28a3ac4e11c 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -42,14 +42,14 @@ $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_doc_type = GETPOST("search_doc_type", 'alpha'); $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); -$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmonth', 'int'), GETPOST('date_creation_startday', 'int'), GETPOST('date_creation_startyear', 'int')); -$search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int')); +$search_date_creation_end = dol_mktime(23, 59, 59, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int')); $search_date_modification_start = dol_mktime(0, 0, 0, GETPOST('date_modification_startmonth', 'int'), GETPOST('date_modification_startday', 'int'), GETPOST('date_modification_startyear', 'int')); -$search_date_modification_end = dol_mktime(0, 0, 0, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int')); +$search_date_modification_end = dol_mktime(23, 59, 59, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int')); $search_date_export_start = dol_mktime(0, 0, 0, GETPOST('date_export_startmonth', 'int'), GETPOST('date_export_startday', 'int'), GETPOST('date_export_startyear', 'int')); -$search_date_export_end = dol_mktime(0, 0, 0, GETPOST('date_export_endmonth', 'int'), GETPOST('date_export_endday', 'int'), GETPOST('date_export_endyear', 'int')); +$search_date_export_end = dol_mktime(23, 59, 59, GETPOST('date_export_endmonth', 'int'), GETPOST('date_export_endday', 'int'), GETPOST('date_export_endyear', 'int')); //var_dump($search_date_start);exit; if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index bacfdcb714a..18f6a5b8f16 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -42,7 +42,7 @@ $sortorder = GETPOST("sortorder"); $sortfield = GETPOST("sortfield"); $action = GETPOST('action', 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); -$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_accountancy_code = GETPOST("search_accountancy_code"); From e0551f1e32202e418771d7f548ac8889ebe4a1ee Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 27 Mar 2021 17:29:06 +0100 Subject: [PATCH 045/233] Add ADHERENT_DEFAULT_CREATE_THIRDPARTY --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index b75bce38ca9..1d007bf654b 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -207,7 +207,7 @@ if (empty($reshook)) { } // Create third party from a member - if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { + if (($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) || (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY))) { if ($result > 0) { // User creation $company = new Societe($db); From 6fdff2c3abe71c0273195d077464920ff3c2d2b8 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 28 Mar 2021 19:19:40 +0200 Subject: [PATCH 046/233] autoaffect individual status for thirdparty --- htdocs/adherents/card.php | 43 +++++++++++++++++++++----- htdocs/societe/class/societe.class.php | 15 ++++++--- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 1d007bf654b..a934f9ca607 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -207,7 +207,7 @@ if (empty($reshook)) { } // Create third party from a member - if (($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) || (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY))) { + if (($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)) { if ($result > 0) { // User creation $company = new Societe($db); @@ -550,7 +550,7 @@ if (empty($reshook)) { $db->commit(); $rowid = $object->id; $id = $object->id; - $action = ''; + } else { $db->rollback(); @@ -559,12 +559,41 @@ if (empty($reshook)) { } else { setEventMessages($object->error, $object->errors, 'errors'); } - - $action = 'create'; } - } else { - $action = 'create'; - } + // Auto-create thirdparty on member creation + if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) { + if ($result > 0) { + // User creation + $company = new Societe($db); + + $companyalias = ''; + $fullname = $object->getFullName($langs); + + if ($object->morphy == 'mor') { + $companyname = $object->company; + if (!empty($fullname)) { + $companyalias = $fullname; + } + } else { + $companyname = $fullname; + if (!empty($object->company)) { + $companyalias = $object->company; + } + } + + $result = $company->create_from_member($object, $companyname, $companyalias); + + if ($result < 0) { + $langs->load("errors"); + setEventMessages($langs->trans($company->error), null, 'errors'); + setEventMessages($company->error, $company->errors, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + $action = ($result < 0 || !$error) ? '' : 'create'; } if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c141290d9e9..7fb7d51377d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -868,6 +868,7 @@ class Societe extends CommonObject $sql .= ", name_alias"; $sql .= ", entity"; $sql .= ", datec"; + $sql .= ", fk_typent"; $sql .= ", fk_user_creat"; $sql .= ", canvas"; $sql .= ", status"; @@ -882,6 +883,7 @@ class Societe extends CommonObject $sql .= ", accountancy_code_sell"; $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null"); + $sql .= ", ".(!empty($this->typent_id) ? ((int) $this->typent_id) : "null"); $sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null"); $sql .= ", ".$this->status; $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); @@ -958,7 +960,7 @@ class Societe extends CommonObject * @param array $tags Array of tag to affect to contact * @return int <0 if KO, >0 if OK */ - public function create_individual(User $user, $no_email, $tags = array()) + public function create_individual(User $user, $no_email = 0, $tags = array()) { global $conf; @@ -3793,21 +3795,24 @@ class Societe extends CommonObject $this->client = 1; // A member is a customer by default $this->code_client = ($customercode ? $customercode : -1); $this->code_fournisseur = -1; - + $this->typent_id = ($member->morphy == 'phy' ? 8 : 0); // The type of thirdparty is private (individual) if the member is human (phy) + $this->db->begin(); - + // Cree et positionne $this->id $result = $this->create($user); + if ($result >= 0) { // Auto-create contact on thirdparty creation - if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { + if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { // Fill fields needed by contact - $this->name_bis = $member->lastname; + $this->name_bis = $member->lastname; $this->firstname = $member->firstname; $this->civility_id = $member->civility_id; dol_syslog("We ask to create a contact/address too", LOG_DEBUG); $result = $this->create_individual($user); + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); $this->db->rollback(); From 1ae0e2a920072cd9ffd4fc64dde90c6173c250aa Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 28 Mar 2021 19:38:20 +0200 Subject: [PATCH 047/233] fix stafix style errorsle fix stale errorfix style errors --- htdocs/adherents/card.php | 3 +-- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index a934f9ca607..d8931602557 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -549,8 +549,7 @@ if (empty($reshook)) { $db->commit(); $rowid = $object->id; - $id = $object->id; - + $id = $object->id; } else { $db->rollback(); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7fb7d51377d..dd73cb6e16c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3798,7 +3798,7 @@ class Societe extends CommonObject $this->typent_id = ($member->morphy == 'phy' ? 8 : 0); // The type of thirdparty is private (individual) if the member is human (phy) $this->db->begin(); - + // Cree et positionne $this->id $result = $this->create($user); From b7045ef3a031c76f40759d71eb0493290c0e4578 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 28 Mar 2021 17:42:18 +0000 Subject: [PATCH 048/233] Fixing style errors. --- htdocs/adherents/card.php | 62 +++++++++++++------------- htdocs/societe/class/societe.class.php | 10 ++--- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index d8931602557..12f0c2050ee 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -549,7 +549,7 @@ if (empty($reshook)) { $db->commit(); $rowid = $object->id; - $id = $object->id; + $id = $object->id; } else { $db->rollback(); @@ -561,37 +561,37 @@ if (empty($reshook)) { } // Auto-create thirdparty on member creation if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) { - if ($result > 0) { - // User creation - $company = new Societe($db); - - $companyalias = ''; - $fullname = $object->getFullName($langs); - - if ($object->morphy == 'mor') { - $companyname = $object->company; - if (!empty($fullname)) { - $companyalias = $fullname; - } - } else { - $companyname = $fullname; - if (!empty($object->company)) { - $companyalias = $object->company; - } - } - - $result = $company->create_from_member($object, $companyname, $companyalias); - - if ($result < 0) { - $langs->load("errors"); - setEventMessages($langs->trans($company->error), null, 'errors'); - setEventMessages($company->error, $company->errors, 'errors'); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result > 0) { + // User creation + $company = new Societe($db); + + $companyalias = ''; + $fullname = $object->getFullName($langs); + + if ($object->morphy == 'mor') { + $companyname = $object->company; + if (!empty($fullname)) { + $companyalias = $fullname; + } + } else { + $companyname = $fullname; + if (!empty($object->company)) { + $companyalias = $object->company; + } + } + + $result = $company->create_from_member($object, $companyname, $companyalias); + + if ($result < 0) { + $langs->load("errors"); + setEventMessages($langs->trans($company->error), null, 'errors'); + setEventMessages($company->error, $company->errors, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } - } + } $action = ($result < 0 || !$error) ? '' : 'create'; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index dd73cb6e16c..d23c2cdf06c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3796,23 +3796,23 @@ class Societe extends CommonObject $this->code_client = ($customercode ? $customercode : -1); $this->code_fournisseur = -1; $this->typent_id = ($member->morphy == 'phy' ? 8 : 0); // The type of thirdparty is private (individual) if the member is human (phy) - + $this->db->begin(); // Cree et positionne $this->id $result = $this->create($user); - + if ($result >= 0) { // Auto-create contact on thirdparty creation - if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { + if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { // Fill fields needed by contact - $this->name_bis = $member->lastname; + $this->name_bis = $member->lastname; $this->firstname = $member->firstname; $this->civility_id = $member->civility_id; dol_syslog("We ask to create a contact/address too", LOG_DEBUG); $result = $this->create_individual($user); - + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); $this->db->rollback(); From d9733b395e1aa90b6c76adbd651701cd0029e8d3 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sun, 28 Mar 2021 22:30:47 +0200 Subject: [PATCH 049/233] Copyright in adherents/card.php --- htdocs/adherents/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 12f0c2050ee..4267a801df5 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2012-2020 Philippe Grand * Copyright (C) 2015-2018 Alexandre Spangaro * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -207,7 +208,7 @@ if (empty($reshook)) { } // Create third party from a member - if (($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)) { + if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { if ($result > 0) { // User creation $company = new Societe($db); From b6d03dcad08b373896cfe3f1c7741ad0fdfabc11 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 29 Mar 2021 03:27:02 +0200 Subject: [PATCH 050/233] Update copyright --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 4267a801df5..7a17937e051 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -7,7 +7,7 @@ * Copyright (C) 2012-2020 Philippe Grand * Copyright (C) 2015-2018 Alexandre Spangaro * Copyright (C) 2018-2020 Frédéric France - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 2970f1a96890aed3cd378bdaa744dcf1fc69b23e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 29 Mar 2021 12:07:47 +0200 Subject: [PATCH 051/233] retreive missing fileds... --- .../conferenceorbooth_list.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 96c67e09c0b..baa3ba6e69e 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -388,6 +388,39 @@ if ($projectid > 0) { print ""; } + print ''; + $typeofdata = 'checkbox:'.($project->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + $typeofdata = 'checkbox:'.($project->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''.$langs->trans("EventOrganizationICSLink").''; + print ''; + print ""; + + print ''; print ''; From 966d3a6f30abb899216fdbe3d7a913586e8a36b8 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 29 Mar 2021 15:18:34 +0200 Subject: [PATCH 052/233] add setrecorded and commit to db --- htdocs/langs/en_US/stocks.lang | 3 +- .../inventory/class/inventory.class.php | 21 +++++ htdocs/product/inventory/inventory.php | 89 ++++++++++++++++--- 3 files changed, 102 insertions(+), 11 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 8e949661c49..a7205207cf9 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -242,4 +242,5 @@ InventoryRealQtyHelp=Set value to 0 to reset qty
    Keep field empty, or remove UpdateByScaning=Update by scaning UpdateByScaningProductBarcode=Update by scan (product barcode) UpdateByScaningLot=Update by scan (lot|serial barcode) -DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. \ No newline at end of file +DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. +LabelOfInventoryMovemement=Inventory %s \ No newline at end of file diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index ce585c51a10..dc1b46331fc 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -359,6 +359,27 @@ class Inventory extends CommonObject } } + /** + * Set to Recorded + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function setRecorded(User $user, $notrigger = false) + { + $this->db->begin(); + + $result = $this->setStatut($this::STATUS_RECORDED, null, '', 'INVENTORY_RECORDED'); + + if ($result > 0) { + $this->db->commit(); + } else { + $this->db->rollback(); + return -1; + } + } + /** * Clone and object into another one * diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 6c8f6ab5256..d8e76489ffc 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -27,6 +27,7 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; // Load translation files required by the page $langs->loadLangs(array("stocks", "other", "productbatch")); @@ -98,6 +99,67 @@ $now = dol_now(); * Actions */ +if ($action == 'update' && $user->rights->stock->mouvement->creer) { + $stockmovment = new MouvementStock($db); + $stockmovment->origin = $object; + + $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; + $sql .= ' WHERE id.fk_inventory = '.$object->id; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $totalarray = array(); + while ($i < $num) { + $line = $db->fetch_object($resql); + $qty_view = $line->qty_view; + $qty_stock = $line->qty_stock; + $stock_movement_qty = $qty_view - $qty_stock; + if ($stock_movement_qty != 0) { + if ($stock_movement_qty < 0) { + $movement_type = 1; + } else { + $movement_type = 0; + } + $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, 0, $langs->trans('LabelOfInventoryMovemement', $object->id), 'INV'.$object->id); + if ($idstockmove < 0) { + $error++; + setEventMessages($stockmovment->error, $stockmovment->errors, 'errors'); + } + } + $i++; + } + if (!$error) { + $object->setRecorded($user); + } + } +} + +if ($action =='updateinventorylines' && $permissiontoadd) { + $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; + $sql .= ' WHERE id.fk_inventory = '.$object->id; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $totalarray = array(); + while ($i < $num) { + $line = $db->fetch_object($resql); + $lineid = $line->rowid; + $inventoryline = new InventoryLine($db); + $inventoryline->fetch($lineid); + $inventoryline->qty_view = GETPOST("id_".$inventoryline->id); + $inventoryline->update($user); + $i++; + } + } +} + $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -419,10 +481,12 @@ if ($object->id > 0) { print ''; print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); print ''; - // Actions - print ''; - print ''; - print ''; + if ($object->status == $object::STATUS_VALIDATED) { + // Actions + print ''; + print ''; + print ''; + } // Line to add a new line in inventory if ($object->status == $object::STATUS_VALIDATED) { @@ -508,12 +572,17 @@ if ($object->id > 0) { print $obj->qty_stock; print ''; print ''; - print 'rowid).'">'; - print ''; - print ''; - print ''.img_delete().''; - print ''; - + if ($object->status == $object::STATUS_VALIDATED) { + $qty_view = GETPOST("id_".$obj->rowid) ? GETPOST("id_".$obj->rowid) : $obj->qty_view; + print ''; + print ''; + print ''; + print ''.img_delete().''; + print ''; + } else { + print $obj->qty_view; + print ''; + } print ''; $i++; From e18c010490af1469bd68a64ccb51f1e976c8dd17 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 29 Mar 2021 16:25:34 +0200 Subject: [PATCH 053/233] fix bug on list --- htdocs/core/lib/functions.lib.php | 4 ++-- .../class/conferenceorbooth.class.php | 14 ++++++------- .../conferenceorbooth_document.php | 21 ------------------- htdocs/langs/en_US/eventorganization.lang | 4 ++-- htdocs/societe/list.php | 6 +++--- 5 files changed, 13 insertions(+), 36 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2b85004d862..3d241547bdb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3540,7 +3540,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_asset', 'object_barcode', 'object_bill', 'object_billr', 'object_billa', 'object_billd', 'object_bom', - 'object_category', 'conferenceorbooth', 'object_conversation', 'object_bookmark', 'object_bug', 'object_building', 'object_clock', 'object_collab', 'object_dolly', 'object_dollyrevert', + 'object_category', 'object_conferenceorbooth', 'object_conversation', 'object_bookmark', 'object_bug', 'object_building', 'object_clock', 'object_collab', 'object_dolly', 'object_dollyrevert', 'object_folder', 'object_folder-open','object_generic', 'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', 'object_cash-register', 'object_company', 'object_contact', 'object_contract', 'object_cron', 'object_donation', 'object_dynamicprice', 'object_establishment', @@ -3565,7 +3565,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'user-cog', 'website', - 'conferenceorbooth', 'eventorganization', 'object_eventorganization' + 'conferenceorbooth', 'eventorganization' ))) { $pictowithouttext = str_replace('object_', '', $pictowithouttext); diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index ecd2fcd191f..01523a78a90 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -582,25 +582,23 @@ class ConferenceOrBooth extends ActionComm if (empty($this->showphoto_on_popup)) { if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $picto = img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + // var_dump($picto); + $result .= $picto; } } else { if ($withpicto) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - list($class, $module) = explode('@', $this->picto); - $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + //list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->eventorganisation->multidir_output[$conf->entity]."/".dol_sanitizeFileName($this->ref); $filearray = dol_dir_list($upload_dir, "files"); $filename = $filearray[0]['name']; if (!empty($filename)) { $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { - $result .= '
    No photo
    '; - } else { - $result .= '
    No photo
    '; - } + $result .= '
    No photo
    '; $result .= ''; } else { diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php index 1f354453fd1..bf27dad789c 100644 --- a/htdocs/eventorganization/conferenceorbooth_document.php +++ b/htdocs/eventorganization/conferenceorbooth_document.php @@ -22,27 +22,6 @@ * \brief Tab for documents linked to ConferenceOrBooth */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 8dadf5fdb97..c0ff5e8e281 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -77,8 +77,8 @@ AllowUnknownPeopleSuggestBooth=Allow unknown people to suggest booth AllowUnknownPeopleSuggestBoothHelp=Allow unknown people to suggest booth PriceOfRegistration=Price of registration PriceOfRegistrationHelp=Price of registration -PriceOfBooth=Price of subscription -PriceOfBoothHelp=Price of subscription +PriceOfBooth=Subscription price to stand a booth +PriceOfBoothHelp=Subscription price to stand a booth EventOrganizationICSLink=Link ICS for events ConferenceOrBoothInformation=Conference Or Booth informations Attendees = Attendees diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 74a04f34858..ef2fbccf490 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -463,7 +463,7 @@ $sql .= " country.code as country_code, country.label as country_label,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " region.code_region as region_code, region.nom as region_name"; // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) -if ($search_sale) { +if ($search_sale && $search_sale != '-1') { $sql .= ", sc.fk_soc, sc.fk_user"; } // We'll need these fields in order to filter by categ @@ -505,7 +505,7 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; if ($search_sale == -2) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} elseif ($search_sale || (empty($user->rights->societe->client->voir) && !$socid)) { +} elseif (!empty($search_sale) && $search_sale != '-1' || (empty($user->rights->societe->client->voir) && !$socid)) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.entity IN (".getEntity('societe').")"; @@ -513,7 +513,7 @@ $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -if ($search_sale && $search_sale != -2) { +if ($search_sale && $search_sale != '-1' && $search_sale != '-2') { $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } if (!$user->rights->fournisseur->lire) { From 14a90a3a9dd275441ce0cfcf1cdbdeff312ccd16 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 29 Mar 2021 17:26:43 +0200 Subject: [PATCH 054/233] on goung --- htdocs/admin/eventorganization.php | 4 +- htdocs/core/actions_setmoduleoptions.inc.php | 12 +- .../class/conferenceorboothattendee.class.php | 2 - .../conferenceorbooth_card.php | 153 +++++++++++++++++- ...ventorganization_conferenceorbooth.lib.php | 4 + .../install/mysql/migration/13.0.0-14.0.0.sql | 1 - ...organization_conferenceorboothattendee.sql | 3 +- htdocs/projet/card.php | 2 +- 8 files changed, 168 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 743da034060..e142acedf8f 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -52,8 +52,8 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TASK_LABEL'=>array('type'=>'textarea','enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - 'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - 'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1), + //'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + //'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 5f0d6823978..797bb8e4cb7 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -33,7 +33,17 @@ if ($action == 'update' && is_array($arrayofparameters)) { foreach ($arrayofparameters as $key => $val) { // Modify constant only if key was posted (avoid resetting key to the null value) if (GETPOSTISSET($key)) { - $result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); + if (preg_match('/category:/', $val['type'])) { + if (GETPOST($key, 'int') == '-1') { + $val_const = ''; + } else { + $val_const = GETPOST($key, 'int'); + } + } else { + $val_const = GETPOST($key, 'alpha'); + } + + $result = dolibarr_set_const($db, $key, $val_const, 'chaine', 0, '', $conf->entity); if ($result < 0) { $error++; break; diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index c8cec4172c7..3b0795ef2a0 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -103,7 +103,6 @@ class ConferenceOrBoothAttendee extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>0, 'index'=>1,), 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,), 'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1, 'index'=>1,), 'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), @@ -122,7 +121,6 @@ class ConferenceOrBoothAttendee extends CommonObject public $rowid; public $ref; public $fk_soc; - public $fk_project; public $fk_actioncomm; public $email; public $date_subscription; diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 45f0c75a2de..6628fde0703 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -27,6 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; @@ -43,11 +44,13 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); +$withproject = GETPOST('withproject', 'int'); +$project_ref = GETPOST('project_ref', 'alpha'); // Initialize technical objects $object = new ConferenceOrBooth($db); $extrafields = new ExtraFields($db); +$projectstatic = new Project($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothcard', 'globalcard')); // Note that conf->hooks_modules contains array @@ -147,9 +150,6 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } - - - /* * View * @@ -243,6 +243,151 @@ if (($id || $ref) && $action == 'edit') { if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); + $result = $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } + + $object->project = clone $projectstatic; + + if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; + } + + $head = conferenceorboothPrepareHead($object); print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBooth"), -1, $object->picto); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index 0a1ddd27dce..55b9f8dc2b7 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -41,6 +41,10 @@ function conferenceorboothPrepareHead($object) $head[$h][2] = 'card'; $h++; + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_contact.php", 1).'?conforboothid='.$object->id; + $head[$h][1] = $langs->trans("Contact/Adress"); + $head[$h][2] = 'attendees'; + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?conforboothid='.$object->id; $head[$h][1] = $langs->trans("Attendees"); $head[$h][2] = 'attendees'; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 8e75870b233..30607713b70 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -284,7 +284,6 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, ref varchar(128) NOT NULL, fk_soc integer, - fk_project integer, fk_actioncomm integer NOT NULL, email varchar(100), date_subscription datetime, diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql index da8d7443a7a..c6ff6dedf66 100644 --- a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql @@ -18,8 +18,7 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, ref varchar(128) NOT NULL, - fk_soc integer, - fk_project integer, + fk_soc integer, fk_actioncomm integer NOT NULL, email varchar(100), date_subscription datetime, diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 916f23eb056..ffd3d4e2b58 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -840,7 +840,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print '
    '; } if (!empty($conf->eventorganization->enabled)) { - print ' '; + print 'usage_organize_event ? ' checked="checked"' : '')) . '"> '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); } From bbc263f4b3fc66f5686f9edb2de4a21838bd428e Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 29 Mar 2021 18:39:22 +0200 Subject: [PATCH 055/233] llx_product batch_mask definition --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 3 +-- htdocs/install/mysql/tables/llx_product.sql | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 772f0e51bdf..bffdcf213ee 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -282,5 +282,4 @@ DELETE FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ti ALTER TABLE llx_c_ticket_category ADD COLUMN public integer DEFAULT 0; - - +ALTER TABLE llx_product ADD COLUMN batch_mask VARCHAR(32); diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 2431c884c62..0cae99c3507 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -51,7 +51,7 @@ create table llx_product recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT localtax1_tx double(6,3) DEFAULT 0, localtax1_type varchar(10) NOT NULL DEFAULT '0', - localtax2_tx double(6,3) DEFAULT 0, + localtax2_tx double(6,3) DEFAULT 0, localtax2_type varchar(10) NOT NULL DEFAULT '0', fk_user_author integer DEFAULT NULL, -- user making creation fk_user_modif integer, -- user making last change @@ -59,6 +59,7 @@ create table llx_product tobuy tinyint DEFAULT 1, -- Product you buy onportal tinyint DEFAULT 0, -- If it is a product you sell and you want to sell it on portal (module website must be on) tobatch tinyint DEFAULT 0 NOT NULL, -- Is it a product that need a batch management (eat-by or lot management) + batch mask varchar(32), -- If the product has batch feature, you may want to use a batch mask per product fk_product_type integer DEFAULT 0, -- Type of product: 0 for regular product, 1 for service, 9 for other (used by external module) duration varchar(6), seuil_stock_alerte float DEFAULT NULL, From 1f08e37a030cd7303fbf328229e5b7adbf1899f4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 29 Mar 2021 20:28:29 +0200 Subject: [PATCH 056/233] more feature --- .../class/conferenceorbooth.class.php | 7 +- .../conferenceorbooth_card.php | 457 ++++++++---------- .../conferenceorbooth_contact.php | 135 +++++- .../conferenceorbooth_document.php | 269 ++++++++--- .../conferenceorbooth_list.php | 4 +- .../conferenceorboothattendee_list.php | 193 +++++++- ...ventorganization_conferenceorbooth.lib.php | 22 +- .../install/mysql/migration/13.0.0-14.0.0.sql | 5 +- ...nization_conferenceorboothattendee.key.sql | 4 +- 9 files changed, 737 insertions(+), 359 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 01523a78a90..52c6ef7c311 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -560,6 +560,9 @@ class ConferenceOrBooth extends ActionComm if ($add_save_lastsearch_values) { $url .= '&save_lastsearch_values=1'; } + if ($option=='withproject') { + $url .= '&withproject=1'; + } } $linkclose = ''; @@ -597,8 +600,8 @@ class ConferenceOrBooth extends ActionComm if (!empty($filename)) { $pospoint = strpos($filearray[0]['name'], '.'); - $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - $result .= '
    No photo
    '; + $pathtophoto = '/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + $result .= '
    No photo
    '; $result .= ''; } else { diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 6628fde0703..bcdb2001194 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -28,8 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; // Load translation files required by the page @@ -164,6 +164,188 @@ $title = $langs->trans("ConferenceOrBooth"); $help_url = ''; llxHeader('', $title, $help_url); +if ($action == 'create') { + $result = $projectstatic->fetch(GETPOST('fk_project')); +} else { + $result = $projectstatic->fetch($object->fk_project); +} +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); +} +if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); +} + +$withProjectUrl=''; +$object->project = clone $projectstatic; + +if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $withProjectUrl="&withproject=1"; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; +} + // Part to create if ($action == 'create') { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBooth")), '', 'object_'.$object->picto); @@ -209,6 +391,9 @@ if (($id || $ref) && $action == 'edit') { print ''; print ''; + if (!empty($withProjectUrl)) { + print ''; + } print ''; print ''; if ($backtopage) { @@ -243,172 +428,24 @@ if (($id || $ref) && $action == 'edit') { if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); - $result = $projectstatic->fetch($object->fk_project); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } - - $object->project = clone $projectstatic; - - if (!empty($withproject)) { - // Tabs for project - $tab = 'eventorganisation'; - $head = project_prepare_head($projectstatic); - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); - - $param = ($mode == 'mine' ? '&mode=mine' : ''); - - // Project card - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
    '; - // Title - $morehtmlref .= $projectstatic->title; - // Thirdparty - if ($projectstatic->thirdparty->id > 0) { - $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); - } - $morehtmlref .= '
    '; - - // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) { - $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; - } - - dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
    '; - print '
    '; - print '
    '; - - print ''; - - // Usage - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { - print ''; - print ''; - } - - // Visibility - print ''; - - // Date start - end - print ''; - - // Budget - print ''; - - // Other attributes - $cols = 2; - //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
    '; - print $langs->trans("Usage"); - print ''; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowOpportunity"); - print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); - print '
    '; - } - if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '
    '; - } - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '
    '; - } - if (!empty($conf->eventorganization->enabled)) { - print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("EventOrganizationDescriptionLong"); - print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); - } - print '
    '.$langs->trans("Visibility").''; - if ($projectstatic->public) { - print $langs->trans('SharedProject'); - } else { - print $langs->trans('PrivateProject'); - } - print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; - $start = dol_print_date($projectstatic->date_start, 'day'); - print ($start ? $start : '?'); - $end = dol_print_date($projectstatic->date_end, 'day'); - print ' - '; - print ($end ? $end : '?'); - if ($projectstatic->hasDelay()) { - print img_warning("Late"); - } - print '
    '.$langs->trans("Budget").''; - if (strcmp($projectstatic->budget_amount, '')) { - print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); - } - print '
    '; - - print '
    '; - - print '
    '; - print '
    '; - print '
    '; - - print ''; - - // Description - print ''; - - // Categories - if ($conf->categorie->enabled) { - print '"; - } - - print '
    '.$langs->trans("Description").''; - print nl2br($projectstatic->description); - print '
    '.$langs->trans("Categories").''; - print $form->showCategories($projectstatic->id, 'project', 1); - print "
    '; - - print '
    '; - print '
    '; - print '
    '; - - print '
    '; - - print dol_get_fiche_end(); - - print '
    '; - } - - - $head = conferenceorboothPrepareHead($object); + $head = conferenceorboothPrepareHead($object, $withproject); print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBooth"), -1, $object->picto); $formconfirm = ''; // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteConferenceOrBooth'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); - } - // Confirmation to delete line - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl, $langs->trans('DeleteConferenceOrBooth'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); } // Clone confirmation if ($action == 'clone') { // Create an array for form $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Confirmation of action xxxx + //TODO Send mass email if ($action == 'xxx') { $formquestion = array(); /* @@ -425,7 +462,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $formconfirm .= $hookmanager->resPrint; @@ -436,53 +473,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Print form confirm print $formconfirm; - // Object card // ------------------------------------------------------------ http://dolibarr.local/eventorganization/conferenceorbooth_list.php?projectid=7 - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
    '.$langs->trans('Project') . ' '; - if ($permissiontoadd) { - //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ $morehtmlref .= '
    '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
    '; print '
    '; print '
    '; @@ -505,55 +506,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - - print '
    - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
    '; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc); - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - } - } - - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
    '; - } - print '
    '; - - print "
    \n"; - } - - // Buttons for actions if ($action != 'presend' && $action != 'editline') { @@ -567,33 +519,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send if (empty($user->socid)) { - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle'); + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=presend&mode=init#formmailbeforetitle'); } - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit', '', $permissiontoadd); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=edit', '', $permissiontoadd); // Clone - print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); - - /* - if ($permissiontoadd) { - if ($object->status == $object::STATUS_ENABLED) { - print ''.$langs->trans("Disable").''."\n"; - } else { - print ''.$langs->trans("Enable").''."\n"; - } - } - if ($permissiontoadd) { - if ($object->status == $object::STATUS_VALIDATED) { - print ''.$langs->trans("Cancel").''."\n"; - } else { - print ''.$langs->trans("Re-Open").''."\n"; - } - } - */ + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); // Delete (need delete permission, or if draft, just need create/modify permission) - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); } print '
    '."\n"; } diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php index d93c76576a6..4efd404d78d 100644 --- a/htdocs/eventorganization/conferenceorbooth_contact.php +++ b/htdocs/eventorganization/conferenceorbooth_contact.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2021 Florian HENRY * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -144,6 +144,139 @@ $userstatic = new User($db); /* View and edit mode */ /* */ /* *************************************************************************** */ +if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; +} if ($object->id) { /* diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php index bf27dad789c..fc3673d618f 100644 --- a/htdocs/eventorganization/conferenceorbooth_document.php +++ b/htdocs/eventorganization/conferenceorbooth_document.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2021 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,52 +22,27 @@ * \brief Tab for documents linked to ConferenceOrBooth */ -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails")); - +$langs->loadLangs(array("eventorganization", "companies", "other", "mails")); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); +$withproject = GETPOST('withproject', 'int'); +$project_ref = GETPOST('project_ref', 'alpha'); + // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -91,6 +66,7 @@ if (!$sortfield) { // Initialize technical objects $object = new ConferenceOrBooth($db); $extrafields = new ExtraFields($db); +$projectstatic = new Project($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothdocument', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels @@ -131,11 +107,187 @@ $help_url = ''; //$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); +$result = $projectstatic->fetch($object->fk_project); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); +} +if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); +} + +$withProjectUrl=''; +$object->project = clone $projectstatic; + +if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + //TODO fill with ics + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; +} + if ($object->id) { /* * Show tabs */ - $head = conferenceorboothPrepareHead($object); + $head = conferenceorboothPrepareHead($object, $withproject); print dol_get_fiche_head($head, 'document', $langs->trans("ConferenceOrBooth"), -1, $object->picto); @@ -148,47 +300,11 @@ if ($object->id) { } // Object card - // ------------------------------------------------------------ + // ------------- + //----------------------------------------------- $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ $morehtmlref .= '
    '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -216,7 +332,10 @@ if ($object->id) { //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write; $permtoedit = 1; $param = '&id='.$object->id; - + //$param = ''; + if ($withproject) { + $param .= '&withproject=1'; + } //$relativepathwithnofile='conferenceorbooth/' . dol_sanitizeFileName($object->id).'/'; $relativepathwithnofile = 'conferenceorbooth/'.dol_sanitizeFileName($object->ref).'/'; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index baa3ba6e69e..814a61ae894 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -597,7 +597,7 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?action=create'.(!empty($project->id)?'&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?action=create'.(!empty($project->id)?'&withproject=1&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -769,7 +769,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'ref') { - print $object->getNomUrl(1); + print $object->getNomUrl(1, 0, '', (($projectid > 0)?'withproject':'')); } else { print $object->showOutputField($val, $key, $object->$key, ''); } diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 66e1ce86b5f..d62830de925 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -27,6 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; if ($conf->categorie->enabled) { @@ -55,6 +57,11 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' $id = GETPOST('id', 'int'); $conf_or_booth_id = GETPOST('conforboothid', 'int'); +$withproject = GETPOST('withproject', 'int'); +$project_ref = GETPOST('project_ref', 'alpha'); + +$withProjectUrl=''; + // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -70,6 +77,7 @@ $pagenext = $page + 1; // Initialize technical objects $object = new ConferenceOrBoothAttendee($db); $extrafields = new ExtraFields($db); +$projectstatic = new Project($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothattendeelist')); // Note that conf->hooks_modules contains array @@ -329,7 +337,185 @@ $morecss = array(); llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); if ($confOrBooth->id > 0) { - $head = conferenceorboothPrepareHead($confOrBooth); + $result = $projectstatic->fetch($confOrBooth->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } + + $withProjectUrl=''; + $object->project = clone $projectstatic; + + if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $withProjectUrl="&withproject=1"; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; + } + + $head = conferenceorboothPrepareHead($confOrBooth, $withproject); print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto); @@ -379,8 +565,9 @@ foreach ($search as $key => $val) { } } if ($confOrBooth->id > 0) { - $param .= '&conforboothid='.urlencode($confOrBooth->id); + $param .= '&conforboothid='.urlencode($confOrBooth->id).$withProjectUrl; } + if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -417,7 +604,7 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:''), '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl, '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index 55b9f8dc2b7..f822bdea743 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -25,9 +25,10 @@ * Prepare array of tabs for ConferenceOrBooth * * @param ConferenceOrBooth $object ConferenceOrBooth + * @param int $with_project Add project id to URL * @return array Array of tabs */ -function conferenceorboothPrepareHead($object) +function conferenceorboothPrepareHead($object, $with_project = 0) { global $db, $langs, $conf; @@ -36,19 +37,24 @@ function conferenceorboothPrepareHead($object) $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_card.php", 1).'?id='.$object->id; + $withProjectUrl=''; + if ($with_project>0) { + $withProjectUrl="&withproject=1"; + } + + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_card.php", 1).'?id='.$object->id.$withProjectUrl; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; - $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_contact.php", 1).'?conforboothid='.$object->id; - $head[$h][1] = $langs->trans("Contact/Adress"); - $head[$h][2] = 'attendees'; + //$head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_contact.php", 1).'?conforboothid='.$object->id.$withProjectUrl; + //$head[$h][1] = $langs->trans("Contact/Adress"); + //$head[$h][2] = 'attendees'; + //$h++; - $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?conforboothid='.$object->id; + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?conforboothid='.$object->id.$withProjectUrl; $head[$h][1] = $langs->trans("Attendees"); $head[$h][2] = 'attendees'; - // Enable caching of conf or booth count attendees $nbAttendees = 0; require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; @@ -77,7 +83,7 @@ function conferenceorboothPrepareHead($object) $upload_dir = $conf->eventorganization->dir_output."/conferenceorbooth/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_document.php", 1).'?id='.$object->id; + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_document.php", 1).'?id='.$object->id.$withProjectUrl; $head[$h][1] = $langs->trans('Documents'); if (($nbFiles + $nbLinks) > 0) { $head[$h][1] .= ''.($nbFiles + $nbLinks).''; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 30607713b70..7139449f588 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -303,15 +303,12 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee( ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc); -ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); -ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_project (fk_project); -ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_project FOREIGN KEY (fk_project) REFERENCES llx_projet(rowid); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm(id); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_eventorganization_conferenceorboothattendee_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status); -ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_project, fk_actioncomm, email); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_actioncomm, email); create table llx_eventorganization_conferenceorboothattendee_extrafields ( diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql index b4ee98e3aa9..2314221b41d 100644 --- a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql @@ -19,8 +19,6 @@ ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_evento ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); -ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_project (fk_project); -ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_project FOREIGN KEY (fk_project) REFERENCES llx_projet(rowid); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm(id); ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email); @@ -28,6 +26,6 @@ ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_e ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status); -- END MODULEBUILDER INDEXES -ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_project, fk_actioncomm, email); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_actioncomm, email); From ae0468e107aa0f29ac68ed3bab861c6bc68b11c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 21:04:33 +0200 Subject: [PATCH 057/233] FIX #yogosha5765 --- htdocs/adherents/note.php | 2 +- htdocs/core/class/html.formcompany.class.php | 2 +- htdocs/main.inc.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 91946094a9a..cc216d794d1 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -97,7 +97,7 @@ if ($id) { print dol_get_fiche_head($head, 'note', $langs->trans("Member"), -1, 'user'); - print "
    "; + print ''; print ''; $linkback = ''.$langs->trans("BackToList").''; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 2af5cae96f6..7b82e5be253 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -713,7 +713,7 @@ class FormCompany extends Form if ($resql) { print ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
    '; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref = '
    '; + // Ref customer + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
    '.$langs->trans('Project').' '; + if ($user->rights->propal->creer) { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
    '; } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; } } - $morehtmlref .= '
    '; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
    '; - print '
    '; - - $cssclass = "titlefield"; - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - - print '
    '; - - print dol_get_fiche_end(); } + $morehtmlref .= '
    '; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + + $cssclass = "titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '
    '; + + print dol_get_fiche_end(); } } diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 4ae18df12f8..c0d92908aab 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -38,12 +38,6 @@ $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; -if ($mode == 'customer' && !$user->rights->propale->lire) { - accessforbidden(); -} -if ($mode == 'supplier' && !$user->rights->supplier_proposal->lire) { - accessforbidden(); -} $object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); @@ -66,6 +60,13 @@ $endyear = $year; // Load translation files required by the page $langs->loadLangs(array('orders', 'companies', 'other', 'suppliers', 'supplier_proposal')); +if ($mode == 'customer' && !$user->rights->propale->lire) { + accessforbidden(); +} +if ($mode == 'supplier' && !$user->rights->supplier_proposal->lire) { + accessforbidden(); +} + /* * View diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index ea44682b4a3..3aacd070ae4 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -30,11 +30,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; // Load translation files required by the page $langs->load("propal"); - if ($user->socid > 0) { $socid = $user->socid; } +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $action = ''; + $socid = $user->socid; +} +$result = restrictedArea($user, 'propal', $socid, ''); + + /* * View diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php deleted file mode 100644 index 4656574fb47..00000000000 --- a/htdocs/comm/prospect/recap-prospect.php +++ /dev/null @@ -1,90 +0,0 @@ - - * Copyright (C) 2004-2010 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/comm/prospect/recap-prospect.php - * \ingroup societe - * \brief Page with prospect summary - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array('companies', 'other')); -if (!empty($conf->facture->enabled)) { - $langs->load("bills"); -} - -// Security check -$socid = GETPOST("socid", 'int'); -if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; -} - - -/* - * View - */ - -llxHeader(); - -if ($socid > 0) { - $societe = new Societe($db); - $societe->fetch($socid); - - /* - * Affichage onglets - */ - $head = societe_prepare_head($societe); - - print dol_get_fiche_head($head, 'prospect', $langs->trans("ThirdParty"), 0, 'company'); - - - print "\n"; - print '
    '; - - print ''; - - // Name - print ''; - - // Prefix - if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field - print ''; - } - - print "
    '.$langs->trans("Thirdpary").''.$societe->getNomUrl(1).'
    '.$langs->trans("Prefix").''; - print ($societe->prefix_comm ? $societe->prefix_comm : ' '); - print '
    "; - - print "
    \n"; - - print ''; - - - print $langs->trans("FeatureNotYetAvailable"); -} else { - dol_print_error($db); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index 6e82cc16c19..ee32c0dd016 100644 --- a/htdocs/comm/recap-client.php +++ b/htdocs/comm/recap-client.php @@ -33,12 +33,12 @@ if (!empty($conf->facture->enabled)) { } // Security check -$socid = $_GET["socid"]; +$socid = GETPOST("socid", 'int'); if ($user->socid > 0) { $action = ''; - $socid = $user->socid; + $id = $user->socid; } - +$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); /* diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 541983775a7..93876fdde96 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -74,6 +74,12 @@ if (GETPOST('action', 'aZ09') == 'setremise') { } } +// Security check +if ($user->socid > 0) { + $id = $user->socid; +} +$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); + /* * View @@ -83,7 +89,6 @@ $form = new Form($db); llxHeader(); - /********************************************************************************* * * Mode fiche diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 66d45f6a278..9abf348095e 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -46,6 +46,12 @@ if ($user->socid > 0) { $socid = $user->socid; } +// Security check +if ($user->socid > 0) { + $id = $user->socid; +} +$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); + /* * Actions From 81437473c25f544d4a83416082afa71185e86f80 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 29 Mar 2021 22:46:46 +0200 Subject: [PATCH 077/233] Create index.html --- htdocs/bom/tpl/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/bom/tpl/index.html diff --git a/htdocs/bom/tpl/index.html b/htdocs/bom/tpl/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/bom/tpl/index.html @@ -0,0 +1 @@ + From 6e331fd45fd3216640c9072068db0469e897519b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 22:51:36 +0200 Subject: [PATCH 078/233] Fix CSRF for GET --- htdocs/main.inc.php | 2 +- htdocs/societe/class/societe.class.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f9b8aa637d2..a6b7a024af3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -438,7 +438,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl 'confirm_create_user', 'confirm_create_thirdparty', 'confirm_purge', 'confirm_reject_check', 'delete', 'deletefilter', 'deleteoperation', 'deleteprof', 'deletepayment', 'disable', 'doprev', 'donext', 'dvprev', 'dvnext', - 'enable' + 'enable', 'setpricelevel' ); $sensitiveget = false; if (in_array(GETPOST('action', 'aZ09'), $arrayofactiontoforcetokencheck)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 15454f47e2c..b2387314b94 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2285,8 +2285,8 @@ class Societe extends CommonObject $now = dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql .= " SET price_level = '".$this->db->escape($price_level)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " SET price_level = ".((int) $price_level); + $sql .= " WHERE rowid = ".((int) $this->id); if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -2295,7 +2295,7 @@ class Societe extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_prices"; $sql .= " (datec, fk_soc, price_level, fk_user_author)"; - $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($price_level)."', ".$user->id.")"; + $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", ".((int) $price_level).", ".$user->id.")"; if (!$this->db->query($sql)) { dol_print_error($this->db); From b702d2b5341ee9d5e9efda619da0c6798ac87278 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 22:51:36 +0200 Subject: [PATCH 079/233] Fix CSRF for more GET --- htdocs/commande/card.php | 4 ++-- htdocs/commande/class/commande.class.php | 6 +++--- htdocs/compta/facture/class/facture.class.php | 4 ++-- htdocs/main.inc.php | 4 ++-- htdocs/societe/class/societe.class.php | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 8e0dc91756c..4585c2dffb2 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -501,7 +501,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setremise' && $usercancreate) { - $result = $object->setDiscount($user, GETPOST('remise')); + $result = $object->setDiscount($user, price2num(GETPOST('remise'), 2)); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -515,7 +515,7 @@ if (empty($reshook)) { } } elseif ($action == 'setdate' && $usercancreate) { // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); + $date = dol_mktime(0, 0, 0, GETPOST('order_month', 'int'), GETPOST('order_day', 'int'), GETPOST('order_year', 'int')); $result = $object->set_date($user, $date); if ($result < 0) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ea97dcbf233..d6a63f83f27 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2413,10 +2413,10 @@ class Commande extends CommonOrder $this->db->begin(); - $remise = price2num($remise); + $remise = price2num($remise, 2); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql .= ' SET remise_percent = '.$remise; + $sql .= ' SET remise_percent = '.((float) $remise); $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; dol_syslog(__METHOD__, LOG_DEBUG); @@ -2867,7 +2867,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET'; - $sql .= ' ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); + $sql .= ' ref_client = '.(empty($ref_client) ? 'NULL' : "'".$this->db->escape($ref_client)."'"); $sql .= ' WHERE rowid = '.$this->id; dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a74d78df84e..960ff8f413f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3735,14 +3735,14 @@ class Facture extends CommonInvoice } if ($user->rights->facture->creer) { - $remise = price2num($remise); + $remise = price2num($remise, 2); $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql .= ' SET remise_percent = '.$remise; + $sql .= ' SET remise_percent = '.((float) $remise); $sql .= ' WHERE rowid = '.$this->id; $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f9b8aa637d2..a5d485d1b14 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -438,13 +438,13 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl 'confirm_create_user', 'confirm_create_thirdparty', 'confirm_purge', 'confirm_reject_check', 'delete', 'deletefilter', 'deleteoperation', 'deleteprof', 'deletepayment', 'disable', 'doprev', 'donext', 'dvprev', 'dvnext', - 'enable' + 'enable', 'setpricelevel' ); $sensitiveget = false; if (in_array(GETPOST('action', 'aZ09'), $arrayofactiontoforcetokencheck)) { $sensitiveget = true; } - if (preg_match('/^(disable_|enable_)/', GETPOST('action', 'aZ09'))) { + if (preg_match('/^(disable_|enable_|setremise)/', GETPOST('action', 'aZ09'))) { $sensitiveget = true; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 15454f47e2c..b2387314b94 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2285,8 +2285,8 @@ class Societe extends CommonObject $now = dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql .= " SET price_level = '".$this->db->escape($price_level)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " SET price_level = ".((int) $price_level); + $sql .= " WHERE rowid = ".((int) $this->id); if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -2295,7 +2295,7 @@ class Societe extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_prices"; $sql .= " (datec, fk_soc, price_level, fk_user_author)"; - $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($price_level)."', ".$user->id.")"; + $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", ".((int) $price_level).", ".$user->id.")"; if (!$this->db->query($sql)) { dol_print_error($this->db); From ed1107f0955b3c8e0bdfb692334cb2cb10857428 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 29 Mar 2021 23:01:35 +0200 Subject: [PATCH 080/233] Update llx_20_c_departements.sql Argentina --- .../mysql/data/llx_20_c_departements.sql | 64 +++++++++++-------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index c1999a1834b..266f9d2524a 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -36,6 +36,14 @@ -- NOTES ---------------------------------- -- Departements/Cantons/Provinces/States -- +-- Algeria +-- Andorra +-- Argentina +-- Australia +-- Austria +-- Belgium +-- Canada +-- -- TEMPLATE ------------------------------------------------------------------------------------------------------------- @@ -103,6 +111,35 @@ INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-008', 'AD700', NULL, NULL, 'Escaldes-Engordany'); +-- Argentina Provinces / provincias (id country=23) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2301', '', 0, 'CATAMARCA', 'Catamarca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2302', '', 0, 'JUJUY', 'Jujuy'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2303', '', 0, 'TUCAMAN', 'Tucamán'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2304', '', 0, 'SANTIAGO DEL ESTERO', 'Santiago del Estero'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2305', '', 0, 'SALTA', 'Salta'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2306', '', 0, 'CHACO', 'Chaco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2307', '', 0, 'CORRIENTES', 'Corrientes'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2308', '', 0, 'ENTRE RIOS', 'Entre Ríos'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2309', '', 0, 'FORMOSA', 'Formosa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2310', '', 0, 'SANTA FE', 'Santa Fe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2303, '2311', '', 0, 'LA RIOJA', 'La Rioja'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2303, '2312', '', 0, 'MENDOZA', 'Mendoza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2303, '2313', '', 0, 'SAN JUAN', 'San Juan'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2303, '2314', '', 0, 'SAN LUIS', 'San Luis'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2304, '2315', '', 0, 'CORDOBA', 'Córdoba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2304, '2316', '', 0, 'BUENOS AIRES', 'Buenos Aires'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2304, '2317', '', 0, 'CABA', 'Caba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2318', '', 0, 'LA PAMPA', 'La Pampa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2319', '', 0, 'NEUQUEN', 'Neuquén'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2320', '', 0, 'RIO NEGRO', 'Río Negro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2321', '', 0, 'CHUBUT', 'Chubut'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2322', '', 0, 'SANTA CRUZ', 'Santa Cruz'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2323', '', 0, 'TIERRA DEL FUEGO', 'Tierra del Fuego'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2324', '', 0, 'ISLAS MALVINAS', 'Islas Malvinas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2325', '', 0, 'ANTARTIDA', 'Antártida'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2326', '', 0, 'MISIONES', 'Misiones'); + + -- Australia States & Territories (id country=28) insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'NSW','',1,'','New South Wales'); insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'VIC','',1,'','Victoria'); @@ -969,33 +1006,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SV', 8601, '', 0, '', 'San Vicente', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CU', 8601, '', 0, '', 'Cuscatlan', 1); --- Provinces Argentina (id country=23) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2301', 2301, '', 0, 'CATAMARCA', 'Catamarca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2302', 2301, '', 0, 'JUJUY', 'Jujuy', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2303', 2301, '', 0, 'TUCAMAN', 'Tucamán', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2304', 2301, '', 0, 'SANTIAGO DEL ESTERO', 'Santiago del Estero', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2305', 2301, '', 0, 'SALTA', 'Salta', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2306', 2302, '', 0, 'CHACO', 'Chaco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2307', 2302, '', 0, 'CORRIENTES', 'Corrientes', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2308', 2302, '', 0, 'ENTRE RIOS', 'Entre Ríos', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2309', 2302, '', 0, 'FORMOSA', 'Formosa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2310', 2302, '', 0, 'SANTA FE', 'Santa Fe', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2311', 2303, '', 0, 'LA RIOJA', 'La Rioja', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2312', 2303, '', 0, 'MENDOZA', 'Mendoza', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2313', 2303, '', 0, 'SAN JUAN', 'San Juan', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2314', 2303, '', 0, 'SAN LUIS', 'San Luis', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2315', 2304, '', 0, 'CORDOBA', 'Córdoba', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2316', 2304, '', 0, 'BUENOS AIRES', 'Buenos Aires', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2317', 2304, '', 0, 'CABA', 'Caba', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2318', 2305, '', 0, 'LA PAMPA', 'La Pampa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2319', 2305, '', 0, 'NEUQUEN', 'Neuquén', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2320', 2305, '', 0, 'RIO NEGRO', 'Río Negro', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2321', 2305, '', 0, 'CHUBUT', 'Chubut', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2322', 2305, '', 0, 'SANTA CRUZ', 'Santa Cruz', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2323', 2305, '', 0, 'TIERRA DEL FUEGO', 'Tierra del Fuego', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2324', 2305, '', 0, 'ISLAS MALVINAS', 'Islas Malvinas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2325', 2305, '', 0, 'ANTARTIDA', 'Antártida', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2326', 2305, '', 0, 'MISIONES', 'Misiones', 1); -- Parish Barbados (id country=46) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CC', 4601, 'Oistins', 0, 'CC', 'Christ Church', 1); From f2e0e54024b29b7b80d09cc590313513e2ade81c Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 29 Mar 2021 23:06:14 +0200 Subject: [PATCH 081/233] Update llx_10_c_regions.sql Argentina --- htdocs/install/mysql/data/llx_10_c_regions.sql | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 284dc77b8e8..ab5e78a6329 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -60,6 +60,14 @@ insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 0 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 13, 1301, '', 0, 'Algerie'); +-- Argentina Regions (id country=23) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2301, '', 0, 'Norte'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2302, '', 0, 'Litoral'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2303, '', 0, 'Cuyana'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2304, '', 0, 'Central'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2305, '', 0, 'Patagonia'); + + -- Austria Regions (id country=41) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 41, 4101, '', 0, 'Österreich'); @@ -200,12 +208,6 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) va -- Regions The Netherlands (id country=17) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 17, 1701, '', 0,'Provincies van Nederland ', 1); --- Regions Argentina (id country=23) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2301, '', 0, 'Norte', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2302, '', 0, 'Litoral', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2303, '', 0, 'Cuyana', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2304, '', 0, 'Central', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2305, '', 0, 'Patagonia', 1); -- Regions Australia (id country=28) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 28, 2801, '', 0, 'Australia', 1); From 32bec565293e215601d2c2f1db35cd5ad79bbaa6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 23:14:42 +0200 Subject: [PATCH 082/233] Using " for html is better --- htdocs/compta/bank/annuel.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 686b14362cc..d771b307234 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -138,10 +138,11 @@ $head = bank_prepare_head($object); print dol_get_fiche_head($head, 'annual', $langs->trans("FinancialAccount"), 0, 'account'); $title = $langs->trans("FinancialAccount")." : ".$object->label; -$link = ($year_start ? "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"')."" : ""); +$link = ($year_start ? ''.img_previous('', 'class="valignbottom"')." ".$langs->trans("Year").' '.img_next('', 'class="valignbottom"').'' : ''); $linkback = ''.$langs->trans("BackToList").''; +$morehtmlref = ''; if (!empty($id)) { if (!preg_match('/,/', $id)) { From 3616d2ba4479c67b36a6680dfff02761a0a36f4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 23:24:52 +0200 Subject: [PATCH 083/233] FIX #yogosha5770 --- htdocs/core/class/commonobject.class.php | 14 +++++++------- htdocs/ticket/card.php | 14 +++++++------- htdocs/ticket/class/ticket.class.php | 11 +++++------ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f4ad69cfc59..622682060cb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -358,7 +358,7 @@ abstract class CommonObject /** * @var string * @deprecated - * @see model_pdf + * @see $model_pdf */ public $modelpdf; @@ -2201,22 +2201,22 @@ abstract class CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; if (!empty($this->fields['fk_project'])) { // Common case if ($projectid) { - $sql .= ' SET fk_project = '.$projectid; + $sql .= ' SET fk_project = '.((int) $projectid); } else { $sql .= ' SET fk_project = NULL'; } - $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.((int) $this->id); } elseif ($this->table_element == 'actioncomm') { // Special case for actioncomm if ($projectid) { - $sql .= ' SET fk_project = '.$projectid; + $sql .= ' SET fk_project = '.((int) $projectid); } else { $sql .= ' SET fk_project = NULL'; } - $sql .= ' WHERE id = '.$this->id; + $sql .= ' WHERE id = '.((int) $this->id); } else // Special case for old architecture objects { if ($projectid) { - $sql .= ' SET fk_projet = '.$projectid; + $sql .= ' SET fk_projet = '.((int) $projectid); } else { $sql .= ' SET fk_projet = NULL'; } @@ -2225,7 +2225,7 @@ abstract class CommonObject dol_syslog(get_class($this)."::setProject", LOG_DEBUG); if ($this->db->query($sql)) { - $this->fk_project = $projectid; + $this->fk_project = ((int) $projectid); return 1; } else { dol_print_error($this->db); diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 98bcccd4ca1..e6f3f21050c 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -186,7 +186,7 @@ if (empty($reshook)) { $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1; - $object->fk_project = GETPOST('projectid', 'int'); + $object->fk_project = $projectid; $id = $object->create($user); if ($id <= 0) { @@ -205,9 +205,9 @@ if (empty($reshook)) { $result = $object->add_contact($contactid, $typeid, 'external'); } - // altairis: link ticket to project - if (GETPOST('projectid') > 0) { - $object->setProject(GETPOST('projectid')); + // Link ticket to project + if ($projectid > 0) { + $object->setProject($projectid); } // Auto assign user @@ -236,7 +236,7 @@ if (empty($reshook)) { if ($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE) { $fichinter = new Fichinter($db); $fichinter->socid = $object->fk_soc; - $fichinter->fk_project = GETPOST('projectid', 'int'); + $fichinter->fk_project = $projectid; $fichinter->fk_contrat = $contractid; $fichinter->author = $user->id; $fichinter->model_pdf = 'soleil'; @@ -534,7 +534,7 @@ if (empty($reshook)) { } elseif ($action == 'classin' && $user->rights->ticket->write) { // Categorisation dans projet if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $object->setProject(GETPOST('projectid', 'int')); + $object->setProject($projectid); $url = 'card.php?action=view&track_id='.$object->track_id; header("Location: ".$url); exit(); @@ -778,7 +778,7 @@ if ($action == 'create' || $action == 'presend') { } // project info - if ($projectid) { + if ($projectid > 0) { $projectstat = new Project($db); if ($projectstat->fetch($projectid) > 0) { $projectstat->fetch_thirdparty(); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 93806bb86aa..57d0066323d 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1982,8 +1982,8 @@ class Ticket extends CommonObject * Link element with a project * Override core function because of key name 'fk_project' used for this module * - * @param int $projectid Project id to link element to - * @return int <0 if KO, >0 if OK + * @param int $projectid Project id to link element to + * @return int <0 if KO, >0 if OK */ public function setProject($projectid) { @@ -1994,16 +1994,15 @@ class Ticket extends CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; if ($projectid) { - $sql .= ' SET fk_project = '.$projectid; + $sql .= ' SET fk_project = '.((int) $projectid); } else { $sql .= ' SET fk_project = NULL'; } - - $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this)."::setProject sql=".$sql); if ($this->db->query($sql)) { - $this->fk_project = $projectid; + $this->fk_project = ((int) $projectid); return 1; } else { dol_print_error($this->db); From bd1f3d8b69f84617dcbb87f763edda79a6acbaec Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Mon, 29 Mar 2021 23:35:41 +0200 Subject: [PATCH 084/233] Update bom_note.php $help_url = 'EN:Module_BOM'; --- htdocs/bom/bom_note.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index 99f6a708c05..5a3a2ec62b4 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -79,8 +79,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); -//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; -$help_url = ''; +$help_url = 'EN:Module_BOM'; + llxHeader('', $langs->trans('BillOfMaterials'), $help_url); if ($id > 0 || !empty($ref)) { From 757a186b3ccb0cce907ccbac2a5afc7d1ed13ef5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 23:43:07 +0200 Subject: [PATCH 085/233] Fix phpunit --- test/phpunit/SecurityTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 616558f342a..01cd3343877 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -190,7 +190,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $this->assertGreaterThanOrEqual(0, $result, 'Error on testSqlAndScriptInject kkk'); */ - $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices'; + $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php'; $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should be ok'); @@ -201,7 +201,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase // Should detect XSS $expectedresult=1; - $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices;badaction'; + $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php/'; $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should detect XSS'); From 2d83686ddd78374e9a01088cb52b8df0ee0fd361 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Mar 2021 23:53:27 +0200 Subject: [PATCH 086/233] Keep copyright in same section than licence --- htdocs/install/mysql/data/llx_10_c_regions.sql | 4 ---- htdocs/install/mysql/data/llx_20_c_departements.sql | 2 -- htdocs/install/mysql/data/llx_c_forme_juridique.sql | 8 ++------ 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index ab5e78a6329..96ab85788ff 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -11,10 +11,6 @@ -- Copyright (C) 2015 Ferran Marcet -- Copyright (C) 2019~ Lao Tian <281388879@qq.com> -- Copyright (C) 2020-2021 Udo Tamm - - - --- LICENSE --------------------------------------------------------------------- -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 266f9d2524a..9e47a9ec050 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -10,8 +10,6 @@ -- Copyright (C) 2012 Ricardo Schluter -- Copyright (C) 2015 Ferran Marcet -- - --- LICENSE ------------------------------------------------------------------- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or diff --git a/htdocs/install/mysql/data/llx_c_forme_juridique.sql b/htdocs/install/mysql/data/llx_c_forme_juridique.sql index b3182846723..07a09724ed2 100644 --- a/htdocs/install/mysql/data/llx_c_forme_juridique.sql +++ b/htdocs/install/mysql/data/llx_c_forme_juridique.sql @@ -8,14 +8,10 @@ -- Copyright (C) 2010-2016 Juanjo Menent -- Copyright (C) 2012 Sebastian Neuwert -- Copyright (C) 2012 Tommaso Basilici --- Copyright (C) 2012 Ricardo Schluter --- Copyright (C) 2013 Cedric GROSS +-- Copyright (C) 2012 Ricardo Schluter +-- Copyright (C) 2013 Cedric GROSS -- Copyright (C) 2020-2021 Udo Tamm -- - - --- LICENSE --------------------------------------------------------------- --- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or From c36c4937ea29d579092a129d42b1779e76ee4210 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 30 Mar 2021 00:31:37 +0200 Subject: [PATCH 087/233] Update societe.class.php --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2653bafbcae..4af4b1e994b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3796,7 +3796,7 @@ class Societe extends CommonObject $this->code_client = ($customercode ? $customercode : -1); $this->code_fournisseur = -1; $this->typent_code = ($member->morphy == 'phy' ? 'TE_PRIVATE' : 0); - $this->typent_id = dol_getIdFromCode($this->db, $this->typent_code, 'c_typent', 'id', 'code'); + $this->typent_id = $this->typent_code ? dol_getIdFromCode($this->db, $this->typent_code, 'c_typent', 'id', 'code') : 0; $this->db->begin(); From c2d583e665f9887999b36df9fa3513847327a0e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 01:44:50 +0200 Subject: [PATCH 088/233] Fix picto --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 99fcea707e2..be02fb46408 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -322,7 +322,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'id' => $id, 'idsel' => 'bank', 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"', - 'prefix' => img_picto('', 'bank', 'class="fa-fw paddingright"'), + 'prefix' => img_picto('', 'bank_account', 'class="fa-fw paddingright"'), 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") ? 0 : 1), 'loadLangs' => array("compta", "banks"), 'submenus' => array(), @@ -347,7 +347,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'id' => $id, 'idsel' => 'accountancy', 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"', - 'prefix' => img_picto('', 'account', 'class="fa-fw paddingright"'), + 'prefix' => img_picto('', 'accountancy', 'class="fa-fw paddingright"'), 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1), 'loadLangs' => array("compta", "accountancy", "assets", "intracommreport"), 'submenus' => array(), From b863b2a3f36c5cbf6509751c86cfb84acd0e6e00 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 02:01:08 +0200 Subject: [PATCH 089/233] Look and feel v14 --- htdocs/core/modules/modCashDesk.class.php | 2 ++ htdocs/core/modules/modRecruitment.class.php | 2 +- htdocs/theme/eldy/global.inc.php | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index 8e9ca1131b9..ba6c7ddce6c 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -98,6 +98,8 @@ class modCashDesk extends DolibarrModules 'type'=>'top', // This is a Top menu entry 'titre'=>'PointOfSaleShort', 'mainmenu'=>'cashdesk', + 'leftmenu'=>'', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'url'=>'/cashdesk/index.php?user=__USER_LOGIN__', 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>900, diff --git a/htdocs/core/modules/modRecruitment.class.php b/htdocs/core/modules/modRecruitment.class.php index f7cd37c16be..3d4e88872ef 100644 --- a/htdocs/core/modules/modRecruitment.class.php +++ b/htdocs/core/modules/modRecruitment.class.php @@ -62,7 +62,7 @@ class modRecruitment extends DolibarrModules // Used only if file README.md and README-LL.md not found. $this->descriptionlong = "Manage and follow recruitment campaign for new job positions"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'experimental'; + $this->version = 'dolibarr'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index fc3addd6742..d08efdf39e4 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -719,6 +719,9 @@ textarea.centpercent { .paddingright2 { padding-: 2px; } +.paddingright2imp { + padding-: 2px !important; +} .paddingtop { padding-top: 4px; } From 9edb2fd857968b62d9ce247f6253091c02905ea5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 02:13:57 +0200 Subject: [PATCH 090/233] Fix sql error --- htdocs/core/class/canvas.class.php | 1 + htdocs/product/card.php | 31 +++++++++++++------------- htdocs/product/class/product.class.php | 12 +++++----- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 7541c58a889..4ae94d43136 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -107,6 +107,7 @@ class Canvas $this->card = $card; $this->dirmodule = $module; // Correct values if canvas is into an external module + $regs = array(); if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs)) { $this->canvas = $regs[1]; $this->dirmodule = $regs[2]; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 2c0531acaea..094ce8670a9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -940,20 +940,6 @@ if (empty($reshook)) { * View */ -$title = $langs->trans('ProductServiceCard'); -$helpurl = ''; -$shortlabel = dol_trunc($object->label, 16); -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); - $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte'; -} -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen'; -} - -llxHeader('', $title, $helpurl); - $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); @@ -962,6 +948,21 @@ if (!empty($conf->accounting->enabled)) { $formaccounting = new FormAccounting($db); } + +$title = $langs->trans('ProductServiceCard'); +$help_url = ''; +$shortlabel = dol_trunc($object->label, 16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); + $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); + $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen'; +} + +llxHeader('', $title, $help_url); + // Load object modBarCodeProduct $res = 0; if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { @@ -984,7 +985,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // When used with CANVAS // ----------------------------------------- if (empty($object->error) && $id) { - $object = new Product($db); $result = $object->fetch($id); if ($result <= 0) { dol_print_error('', $object->error); @@ -1465,6 +1465,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { /* * Product card */ + // Fiche en mode edition if ($action == 'edit' && $usercancreate) { //WYSIWYG Editor diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 77b73074b38..4ae3d682c07 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2172,20 +2172,20 @@ class Product extends CommonObject } $sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.fk_unit,"; $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } if ($id) { - $sql .= " WHERE rowid = ".(int) $id; + $sql .= " WHERE p.rowid = ".((int) $id); } else { - $sql .= " WHERE entity IN (".getEntity($this->element).")"; + $sql .= " WHERE p.entity IN (".getEntity($this->element).")"; if ($ref) { - $sql .= " AND ref = '".$this->db->escape($ref)."'"; + $sql .= " AND p.ref = '".$this->db->escape($ref)."'"; } elseif ($ref_ext) { - $sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; + $sql .= " AND p.ref_ext = '".$this->db->escape($ref_ext)."'"; } elseif ($barcode) { - $sql .= " AND barcode = '".$this->db->escape($barcode)."'"; + $sql .= " AND p.barcode = '".$this->db->escape($barcode)."'"; } } From bfbde43c95628c31f951b5d226dc88bea176bce5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 02:35:26 +0200 Subject: [PATCH 091/233] Debug dark mode --- htdocs/theme/eldy/global.inc.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d08efdf39e4..31841260d73 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -45,6 +45,8 @@ --amountremaintopaycolor:#880000; --amountpaymentcomplete:#008800; --amountremaintopaybackcolor:none; + --productlinestockod: #002200; + --productlinestocktoolow: #884400; } global->THEME_DARKMODEENABLED)) { --colorbackhmenu1: #1d1e20; --colorbackvmenu1: #2b2c2e; --colorbacktitle1: #2b2d2f; - --colorbacktabcard1: #38393d; + --colorbacktabcard1: #1d1e20; /* Must be same than colorbackbody */ --colorbacktabactive: rgb(220,220,220); --colorbacklineimpair1: #38393d; --colorbacklineimpair2: #2b2d2f; @@ -89,7 +91,11 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { --amountremaintopaycolor:rgb(252,84,91); --amountpaymentcomplete:rgb(101,184,77); --amountremaintopaybackcolor:rbg(245,130,46); - }\n"; + } + + body, button { + color: #bbb; + }\n"; if ($conf->global->THEME_DARKMODEENABLED != 2) { print "}\n"; } @@ -3492,9 +3498,11 @@ div.pagination li.pagination a, div.pagination li.pagination span { padding: 6px 12px; line-height: 1.42857143; - color: #000; text-decoration: none; background-repeat: repeat-x; + global->THEME_DARKMODEENABLED)) { ?> + color: #000; + } div.pagination li.pagination span.inactive { cursor: default; @@ -4274,8 +4282,8 @@ div.boximport { min-height: unset; } -.product_line_stock_ok { color: #002200; } -.product_line_stock_too_low { color: #884400; } +.product_line_stock_ok { color: var(--productlinestockok); } +.product_line_stock_too_low { color: var(--productlinestocktoolow); } .fieldrequired { font-weight: bold; color: var(--fieldrequiredcolor) !important; } From 4de6a3ee7db3b7f8e9b6d253134bb16bd19c5e9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 02:55:53 +0200 Subject: [PATCH 092/233] Debug dark mode --- htdocs/theme/eldy/btn.inc.php | 2 +- htdocs/theme/eldy/global.inc.php | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index d5d21a0d439..3e3ab1d3b01 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -72,7 +72,7 @@ span.butAction, span.butActionDelete { border-radius: 3px; } .butActionRefused:last-child, .butAction:last-child, .butActionDelete:last-child { - margin-right: 0px !important; + margin-: 0px !important; } .butActionRefused, .butAction, .butAction:link, .butAction:visited, .butAction:hover, .butAction:active, .butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active { text-decoration: none; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 31841260d73..5500de16650 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -21,6 +21,7 @@ --colorbacklinepairchecked: rgb(); --colorbacklinebreak: rgb(); --colorbackbody: rgb(); + --colorbackmobilemenu: #f8f8f8; --colortexttitlenotab: rgb(); --colortexttitlenotab2: rgb(); --colortexttitle: rgba(, 0.9); @@ -68,6 +69,7 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { --colorbacklinepairhover: #2b2d2f; --colorbacklinepairchecked: #0e5ccd; --colorbackbody: #1d1e20; + --colorbackmobilemenu: #080808; --tooltipbgcolor: #2b2d2f; --colortexttitlenotab: rgb(220,220,220); --colortexttitlenotab2: rgb(220,220,220); @@ -1836,7 +1838,7 @@ div.vmenu, td.vmenu { div.fiche { - margin-: dol_optimize_smallscreen) ? '32' : '6')); ?>px; + margin-: dol_optimize_smallscreen) ? '34' : '6')); ?>px; margin-: dol_optimize_smallscreen) ? '30' : '6')); ?>px; Date: Tue, 30 Mar 2021 03:27:46 +0200 Subject: [PATCH 093/233] FIX: Add a sub table to manage accountancy on product/company --- htdocs/accountancy/customer/index.php | 12 +++++----- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/customer/list.php | 16 ++++++------- htdocs/accountancy/supplier/list.php | 16 ++++++------- htdocs/core/modules/modFacture.class.php | 10 ++++---- htdocs/core/modules/modProduct.class.php | 30 ++++++++++++------------ htdocs/core/modules/modService.class.php | 30 ++++++++++++------------ htdocs/product/class/product.class.php | 8 +++---- htdocs/product/list.php | 22 ++++++++--------- 9 files changed, 73 insertions(+), 73 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 88a32340daa..cf3ab77e9a1 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -147,12 +147,12 @@ if ($action == 'validatehistory') { if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } - $alias_company_accounting = !empty($conf->global->ACCOUNTANCY_COMPANY_SHARED) ? "sa" : "s"; - $alias_product_accounting = !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_accounting . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_accounting . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_accounting . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_company_accounting . ".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; + $alias_societe_perentity = !empty($conf->global->ACCOUNTANCY_COMPANY_SHARED) ? "sa" : "s"; + $alias_product_perentity = !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 42e4c268b86..819de88520d 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -198,7 +198,7 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 07596350ef6..5ed6e5c2427 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -240,20 +240,20 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->ACCOUNTANCY_COMPANY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_accounting as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } -$alias_company_accounting = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "sa"; -$alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_accounting . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_accounting . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_accounting . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_company_accounting . ".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; +$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "sa"; +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 13ad707af96..087d3485a44 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -245,19 +245,19 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_accounting as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } -$alias_company_accounting = !empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "sa" : "s"; -$alias_product_accounting = !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_accounting . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_accounting . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_accounting . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_company_accounting . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; +$alias_societe_perentity = !empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "sa" : "s"; +$alias_product_perentity = !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; // Define begin binding date diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 25653fb216a..200ffe381bb 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -207,7 +207,7 @@ class modFacture extends DolibarrModules //-------- $r = 1; - $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r] = 'invoice'; @@ -228,7 +228,7 @@ class modFacture extends DolibarrModules 'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT", 'fd.total_ttc'=>"LineTotalTTC", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode', 'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', - $alias_product_accounting . '.accountancy_code_sell'=>'ProductAccountancySellCode' + $alias_product_perentity . '.accountancy_code_sell'=>'ProductAccountancySellCode' ); if (!empty($conf->multicurrency->enabled)) { $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; @@ -251,7 +251,7 @@ class modFacture extends DolibarrModules 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date", 'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', - $alias_product_accounting . '.accountancy_code_sell'=>'Text' + $alias_product_perentity . '.accountancy_code_sell'=>'Text' ); if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS)) { $this->export_TypeFields_array[$r]['f.module_source'] = 'Text'; @@ -263,7 +263,7 @@ class modFacture extends DolibarrModules 's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line", 'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line", 'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line', - 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', $alias_product_accounting . '.accountancy_code_sell'=>'product', + 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', $alias_product_perentity . '.accountancy_code_sell'=>'product', 'f.fk_user_author'=>'user', 'uc.login'=>'user', 'f.fk_user_valid'=>'user', 'uv.login'=>'user' ); $this->export_special_array[$r] = array('none.rest'=>'getRemainToPay'); @@ -296,7 +296,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 85cf49ebf73..2db081c8c27 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -176,7 +176,7 @@ class modProduct extends DolibarrModules //-------- $r = 0; - $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "Products"; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -186,9 +186,9 @@ class modProduct extends DolibarrModules 'p.fk_product_type'=>'Type', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.customcode'=>'CustomCode', 'p.fk_country'=>'IDCountry', - $alias_product_accounting . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_accounting . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - $alias_product_accounting . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_accounting . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", - $alias_product_accounting . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_accounting . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + $alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + $alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", + $alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.weight_units'=>"WeightUnits", 'p.length'=>"Length", 'p.length_units'=>"LengthUnits", 'p.width'=>"Width", 'p.width_units'=>"WidthUnits", 'p.height'=>"Height", 'p.height_units'=>"HeightUnits", 'p.surface'=>"Surface", 'p.surface_units'=>"SurfaceUnits", 'p.volume'=>"Volume", 'p.volume_units'=>"VolumeUnits", @@ -231,8 +231,8 @@ class modProduct extends DolibarrModules 'p.ref'=>"Text", 'p.label'=>"Text", 'p.fk_product_type'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.description'=>"Text", 'p.url'=>"Text", - $alias_product_accounting . '.accountancy_code_sell'=>"Text", $alias_product_accounting . '.accountancy_code_sell_intra'=>"Text", $alias_product_accounting . '.accountancy_code_sell_export'=>"Text", - $alias_product_accounting . '.accountancy_code_buy'=>"Text", $alias_product_accounting . '.accountancy_code_buy_intra'=>"Text", $alias_product_accounting . '.accountancy_code_buy_export'=>"Text", + $alias_product_perentity . '.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text", + $alias_product_perentity . '.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text", 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', @@ -295,7 +295,7 @@ class modProduct extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; @@ -390,9 +390,9 @@ class modProduct extends DolibarrModules $this->export_permission[$r] = array(array("produit", "export")); $this->export_fields_array[$r] = array( 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", - $alias_product_accounting . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_accounting . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - $alias_product_accounting . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_accounting . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", - $alias_product_accounting . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_accounting . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + $alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + $alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", + $alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", @@ -407,8 +407,8 @@ class modProduct extends DolibarrModules $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); $this->export_TypeFields_array[$r] = array( 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", - $alias_product_accounting . '.accountancy_code_sell'=>"Text", $alias_product_accounting . '.accountancy_code_sell_intra'=>"Text", $alias_product_accounting . '.accountancy_code_sell_export'=>"Text", - $alias_product_accounting . '.accountancy_code_buy'=>"Text", $alias_product_accounting . '.accountancy_code_buy_intra'=>"Text", $alias_product_accounting . '.accountancy_code_buy_export'=>"Text", + $alias_product_perentity . '.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text", + $alias_product_perentity . '.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text", 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", @@ -423,8 +423,8 @@ class modProduct extends DolibarrModules $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); $this->export_entities_array[$r] = array( 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", - $alias_product_accounting . '.accountancy_code_sell'=>'virtualproduct', $alias_product_accounting . '.accountancy_code_sell_intra'=>'virtualproduct', $alias_product_accounting . '.accountancy_code_sell_export'=>'virtualproduct', - $alias_product_accounting . '.accountancy_code_buy'=>'virtualproduct', $alias_product_accounting . '.accountancy_code_buy_intra'=>'virtualproduct', $alias_product_accounting . '.accountancy_code_buy_export'=>'virtualproduct', + $alias_product_perentity . '.accountancy_code_sell'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_export'=>'virtualproduct', + $alias_product_perentity . '.accountancy_code_buy'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_export'=>'virtualproduct', 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", @@ -446,7 +446,7 @@ class modProduct extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index dda0447371a..4454100ff80 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -143,7 +143,7 @@ class modService extends DolibarrModules //-------- $r = 0; - $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -153,9 +153,9 @@ class modService extends DolibarrModules 'p.fk_product_type'=>'Type', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.customcode'=>'CustomCode', 'p.fk_country'=>'IDCountry', - $alias_product_accounting . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_accounting . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - $alias_product_accounting . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_accounting . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", - $alias_product_accounting . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_accounting . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + $alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + $alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", + $alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.width'=>"Width", 'p.height'=>"Height", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.duration'=>"Duration", @@ -196,8 +196,8 @@ class modService extends DolibarrModules 'p.ref'=>"Text", 'p.label'=>"Text", 'p.fk_product_type'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.description'=>"Text", 'p.url'=>"Text", - $alias_product_accounting . '.accountancy_code_sell'=>"Text", $alias_product_accounting . '.accountancy_code_sell_intra'=>"Text", $alias_product_accounting . '.accountancy_code_sell_export'=>"Text", - $alias_product_accounting . '.accountancy_code_buy'=>"Text", $alias_product_accounting . '.accountancy_code_buy_intra'=>"Text", $alias_product_accounting . '.accountancy_code_buy_export'=>"Text", + $alias_product_perentity . '.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text", + $alias_product_perentity . '.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text", 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', @@ -258,7 +258,7 @@ class modService extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; @@ -351,9 +351,9 @@ class modService extends DolibarrModules $this->export_permission[$r] = array(array("service", "export")); $this->export_fields_array[$r] = array( 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", - $alias_product_accounting . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_accounting . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - $alias_product_accounting . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_accounting . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", - $alias_product_accounting . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_accounting . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + $alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + $alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", + $alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", @@ -368,8 +368,8 @@ class modService extends DolibarrModules $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); $this->export_TypeFields_array[$r] = array( 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", - $alias_product_accounting . 'p.accountancy_code_sell'=>"Text", $alias_product_accounting . '.accountancy_code_sell_intra'=>"Text", $alias_product_accounting . '.accountancy_code_sell_export'=>"Text", - $alias_product_accounting . 'p.accountancy_code_buy'=>"Text", $alias_product_accounting . '.accountancy_code_buy_intra'=>"Text", $alias_product_accounting . '.accountancy_code_buy_export'=>"Text", + $alias_product_perentity . 'p.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text", + $alias_product_perentity . 'p.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text", 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", @@ -384,8 +384,8 @@ class modService extends DolibarrModules $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); $this->export_entities_array[$r] = array( 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", - $alias_product_accounting . '.accountancy_code_sell'=>'virtualproduct', $alias_product_accounting . '.accountancy_code_sell_intra'=>'virtualproduct', $alias_product_accounting . '.accountancy_code_sell_export'=>'virtualproduct', - $alias_product_accounting . '.accountancy_code_buy'=>'virtualproduct', $alias_product_accounting . '.accountancy_code_buy_intra'=>'virtualproduct', $alias_product_accounting . '.accountancy_code_buy_export'=>'virtualproduct', + $alias_product_perentity . '.accountancy_code_sell'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_export'=>'virtualproduct', + $alias_product_perentity . '.accountancy_code_buy'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_export'=>'virtualproduct', 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", @@ -407,7 +407,7 @@ class modService extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->ACCOUNTANCY_COMPANY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_accounting as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4ae3d682c07..80dd87d76f7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -725,7 +725,7 @@ class Product extends CommonObject // update accountancy for this entity if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_accounting ("; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity ("; $sql .= " fk_product"; $sql .= ", entity"; $sql .= ", accountancy_code_buy"; @@ -1119,9 +1119,9 @@ class Product extends CommonObject // update accountancy for this entity if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_accounting WHERE fk_product = " . $this->id . " AND entity = " . $conf->entity); + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = " . $this->id . " AND entity = " . $conf->entity); - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_accounting ("; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity ("; $sql .= " fk_product"; $sql .= ", entity"; $sql .= ", accountancy_code_buy"; @@ -2174,7 +2174,7 @@ class Product extends CommonObject $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } if ($id) { $sql .= " WHERE p.rowid = ".((int) $id); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 7df96cbd97c..940c2ba04f9 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -191,7 +191,7 @@ if (empty($conf->global->PRODUIT_MULTIPRICES)) { $isInEEC = isInEEC($mysoc); -$alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; // Definition of fields for lists $arrayfields = array( @@ -228,12 +228,12 @@ $arrayfields = array( 'p.tobatch'=>array('label'=>"ManageLotSerial", 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>60), 'p.fk_country'=>array('label'=>"Country", 'checked'=>0, 'position'=>100), 'p.fk_state'=>array('label'=>"State", 'checked'=>0, 'position'=>101), - $alias_product_accounting . '.accountancy_code_sell'=>array('label'=>"ProductAccountancySellCode", 'checked'=>0, 'position'=>400), - $alias_product_accounting . '.accountancy_code_sell_intra'=>array('label'=>"ProductAccountancySellIntraCode", 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), - $alias_product_accounting . '.accountancy_code_sell_export'=>array('label'=>"ProductAccountancySellExportCode", 'checked'=>0, 'position'=>402), - $alias_product_accounting . '.accountancy_code_buy'=>array('label'=>"ProductAccountancyBuyCode", 'checked'=>0, 'position'=>403), - $alias_product_accounting . '.accountancy_code_buy_intra'=>array('label'=>"ProductAccountancyBuyIntraCode", 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>404), - $alias_product_accounting . '.accountancy_code_buy_export'=>array('label'=>"ProductAccountancyBuyExportCode", 'checked'=>0, 'position'=>405), + $alias_product_perentity . '.accountancy_code_sell'=>array('label'=>"ProductAccountancySellCode", 'checked'=>0, 'position'=>400), + $alias_product_perentity . '.accountancy_code_sell_intra'=>array('label'=>"ProductAccountancySellIntraCode", 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), + $alias_product_perentity . '.accountancy_code_sell_export'=>array('label'=>"ProductAccountancySellExportCode", 'checked'=>0, 'position'=>402), + $alias_product_perentity . '.accountancy_code_buy'=>array('label'=>"ProductAccountancyBuyCode", 'checked'=>0, 'position'=>403), + $alias_product_perentity . '.accountancy_code_buy_intra'=>array('label'=>"ProductAccountancyBuyIntraCode", 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>404), + $alias_product_perentity . '.accountancy_code_buy_export'=>array('label'=>"ProductAccountancyBuyExportCode", 'checked'=>0, 'position'=>405), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'p.tosell'=>array('label'=>$langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Sell").')', 'checked'=>1, 'position'=>1000), @@ -387,7 +387,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; @@ -493,13 +493,13 @@ if ($search_finished >= 0 && $search_finished !== '') { $sql .= " AND p.finished = ".((int) $search_finished); } if ($search_accountancy_code_sell) { - $sql .= natural_search($alias_product_accounting . '.accountancy_code_sell', $search_accountancy_code_sell); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell', $search_accountancy_code_sell); } if ($search_accountancy_code_sell_intra) { - $sql .= natural_search($alias_product_accounting . '.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); } if ($search_accountancy_code_sell_export) { - $sql .= natural_search($alias_product_accounting . '.accountancy_code_sell_export', $search_accountancy_code_sell_export); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_export', $search_accountancy_code_sell_export); } if ($search_accountancy_code_buy) { $sql .= natural_search($alias_product_accounting . '.accountancy_code_buy', $search_accountancy_code_buy); From fb8460858660e27dd8af11de4627824c8851f9a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 03:37:54 +0200 Subject: [PATCH 094/233] Clean sql --- htdocs/accountancy/admin/productaccount.php | 10 +++--- htdocs/accountancy/customer/card.php | 2 +- htdocs/accountancy/customer/index.php | 2 +- htdocs/accountancy/expensereport/card.php | 2 +- htdocs/accountancy/expensereport/list.php | 2 +- htdocs/accountancy/supplier/card.php | 2 +- htdocs/accountancy/supplier/index.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- htdocs/admin/menus/index.php | 8 ++--- htdocs/admin/perms.php | 4 +-- htdocs/categories/class/categorie.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 32 ++++++++++--------- htdocs/commande/class/commande.class.php | 12 ++++--- .../deplacement/class/deplacement.class.php | 6 ++-- htdocs/compta/facture/class/facture.class.php | 2 +- .../cheque/class/remisecheque.class.php | 4 +-- .../class/bonprelevement.class.php | 2 +- .../class/paymentsocialcontribution.class.php | 2 +- htdocs/compta/tva/class/paymentvat.class.php | 2 +- htdocs/contact/class/contact.class.php | 2 +- htdocs/core/actions_massactions.inc.php | 2 +- htdocs/core/class/commonobject.class.php | 10 +++--- htdocs/core/class/discount.class.php | 8 ++--- .../modules/mailings/modules_mailings.php | 4 +-- htdocs/don/class/don.class.php | 2 +- .../class/expensereport.class.php | 6 ++-- .../class/paymentexpensereport.class.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 6 ++-- .../class/fournisseur.commande.class.php | 4 +-- .../fourn/class/fournisseur.facture.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 26 +++++++-------- htdocs/install/repair.php | 6 ++-- htdocs/install/upgrade2.php | 2 +- htdocs/loan/class/paymentloan.class.php | 4 +-- htdocs/loan/payment/card.php | 4 +-- htdocs/product/admin/price_rules.php | 2 +- .../stock/class/mouvementstock.class.php | 4 +-- htdocs/projet/class/project.class.php | 4 +-- htdocs/projet/class/task.class.php | 12 +++---- .../class/recruitmentjobposition.class.php | 2 +- htdocs/salaries/class/paymentsalary.class.php | 2 +- htdocs/societe/card.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- .../class/supplier_proposal.class.php | 20 ++++++------ htdocs/user/class/user.class.php | 14 ++++---- 45 files changed, 130 insertions(+), 124 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index c1541bd2214..26de6e5ab16 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -189,13 +189,13 @@ if ($action == 'update') { $db->begin(); if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity (fk_product, entity, " . $accountancy_field_name . ")"; - $sql .= " VALUES (" . ((int) $productid) . ", " . ((int) $conf->entity) . ", " . $accounting->account_number . ")"; - $sql .= " ON DUPLICATE KEY UPDATE " . $accountancy_field_name . " = " . $accounting->account_number; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_perentity (fk_product, entity, '".$db->escape($accountancy_field_name)."')"; + $sql .= " VALUES (".((int) $productid).", ".((int) $conf->entity).", '".$db->escape($accounting->account_number)."')"; + $sql .= " ON DUPLICATE KEY UPDATE ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'"; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."product"; - $sql .= " SET " . $accountancy_field_name . " = " . $accounting->account_number; - $sql .= " WHERE rowid = " . ((int) $productid); + $sql .= " SET ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'"; + $sql .= " WHERE rowid = ".((int) $productid); } dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 099cecc4a71..88b199e76e3 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -61,7 +61,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) { } $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; - $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " SET fk_code_ventilation = ".((int) $codeventil); $sql .= " WHERE rowid = ".((int) $id); $resql = $db->query($sql); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 88a32340daa..354652c653c 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -207,7 +207,7 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; - $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $resqlupdate = $db->query($sqlupdate); diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index 200a493cfed..db270b9d2db 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -64,7 +64,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) { } $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; - $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " SET fk_code_ventilation = ".((int) $codeventil); $sql .= " WHERE rowid = ".((int) $id); $resql = $db->query($sql); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 84cd64bb44f..c7a1dec2d94 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -153,7 +153,7 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { $ko++; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; - $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " SET fk_code_ventilation = ".((int) $monCompte); $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index eee2059c660..cd17df33776 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -64,7 +64,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) { } $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; - $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " SET fk_code_ventilation = ".((int) $codeventil); $sql .= " WHERE rowid = ".((int) $id); $resql = $db->query($sql); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 7ef09acf91a..fc295fdafa4 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -193,7 +193,7 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; - $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $resqlupdate = $db->query($sqlupdate); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 13ad707af96..c322ebef9a2 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -177,7 +177,7 @@ if ($massaction == 'ventil') { $ko++; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; - $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " SET fk_code_ventilation = ".((int) $monCompte); $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 197db4c4721..1db1adf50cf 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -111,13 +111,13 @@ if ($action == 'up') { } $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; - $sql .= " SET m.position = ".$previous['order']; - $sql .= " WHERE m.rowid = ".$current['rowid']; // Up the selected entry + $sql .= " SET m.position = ".((int) $previous['order']); + $sql .= " WHERE m.rowid = ".((int) $current['rowid']); // Up the selected entry dol_syslog("admin/menus/index.php ".$sql); $db->query($sql); $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; - $sql .= " SET m.position = ".($current['order'] != $previous['order'] ? $current['order'] : $current['order'] + 1); - $sql .= " WHERE m.rowid = ".$previous['rowid']; // Descend celui du dessus + $sql .= " SET m.position = ".((int) ($current['order'] != $previous['order'] ? $current['order'] : $current['order'] + 1)); + $sql .= " WHERE m.rowid = ".((int) $previous['rowid']); // Descend celui du dessus dol_syslog("admin/menus/index.php ".$sql); $db->query($sql); } elseif ($action == 'down') { diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 31304c85819..f08a1497181 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -159,8 +159,8 @@ if ($result) { // TODO Define familyposition $family = (!empty($modules[$obj->module]->family_position) ? $modules[$obj->module]->family_position : ''); $familyposition = 0; - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; - $sqlupdate .= " family_position = ".$familyposition; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".((int) $modules[$obj->module]->module_position).","; + $sqlupdate .= " family_position = ".((int) $familyposition); $sqlupdate .= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; $db->query($sqlupdate); } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 94a1b89de8f..10cc15a2dc9 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -604,7 +604,7 @@ class Categorie extends CommonObject /* FIX #1317 : Check for child category and move up 1 level*/ if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; - $sql .= " SET fk_parent = ".$this->fk_parent; + $sql .= " SET fk_parent = ".((int) $this->fk_parent); $sql .= " WHERE fk_parent = ".$this->id; if (!$this->db->query($sql)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0460caf21f5..0388768fc1f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1232,7 +1232,7 @@ class Propal extends CommonObject /*if (! $error && $this->fk_delivery_address) { $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_delivery_address = ".$this->fk_delivery_address; + $sql.= " SET fk_delivery_address = ".((int) $this->fk_delivery_address); $sql.= " WHERE ref = '".$this->db->escape($this->ref)."'"; $sql.= " AND entity = ".setEntity($this); @@ -2203,7 +2203,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; - $sql .= " SET fk_input_reason = ".$id; + $sql .= " SET fk_input_reason = ".((int) $id); $sql .= " WHERE rowid = ".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); @@ -2322,13 +2322,13 @@ class Propal extends CommonObject $remise = trim($remise) ?trim($remise) : 0; if (!empty($user->rights->propal->creer)) { - $remise = price2num($remise); + $remise = price2num($remise, 2); $error = 0; $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise; + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".((float) $remise); $sql .= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); @@ -2380,17 +2380,18 @@ class Propal extends CommonObject public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable - $remise = trim($remise) ?trim($remise) : 0; + if (empty($remise)) { + $remise = 0; + } + $remise = price2num($remise); if (!empty($user->rights->propal->creer)) { - $remise = price2num($remise); - $error = 0; $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; - $sql .= " SET remise_absolue = ".$remise; + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql .= " SET remise_absolue = ".((float) $remise); $sql .= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); @@ -2435,19 +2436,17 @@ class Propal extends CommonObject * Reopen the commercial proposal * * @param User $user Object user that close - * @param int $statut Statut + * @param int $status Status * @param string $note Comment * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function reopen($user, $statut, $note = '', $notrigger = 0) + public function reopen($user, $status, $note = '', $notrigger = 0) { - - $this->statut = $statut; $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql .= " SET fk_statut = ".$this->statut.","; + $sql .= " SET fk_statut = ".$status.","; if (!empty($note)) { $sql .= " note_private = '".$this->db->escape($note)."',"; } @@ -2484,6 +2483,9 @@ class Propal extends CommonObject $this->db->rollback(); return -1 * $error; } else { + $this->statut = $status; + $this->status = $status; + $this->db->commit(); return 1; } @@ -2511,7 +2513,7 @@ class Propal extends CommonObject $newprivatenote = dol_concatdesc($this->note_private, $note); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql .= " SET fk_statut = ".$status.", note_private = '".$this->db->escape($newprivatenote)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; + $sql .= " SET fk_statut = ".((int) $status).", note_private = '".$this->db->escape($newprivatenote)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d6a63f83f27..2f2f0a4d81c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2468,18 +2468,20 @@ class Commande extends CommonOrder public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable - $remise = trim($remise) ?trim($remise) : 0; + if (empty($remise)) { + $remise = 0; + } + + $remise = price2num($remise); if ($user->rights->commande->creer) { $error = 0; $this->db->begin(); - $remise = price2num($remise); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql .= ' SET remise_absolue = '.$remise; - $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; + $sql .= ' SET remise_absolue = '.((float) $remise); + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index c34d89bfa2f..5562f797130 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -239,12 +239,12 @@ class Deplacement extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."deplacement "; - $sql .= " SET km = ".$this->km; // This is a distance or amount + $sql .= " SET km = ".((float) $this->km); // This is a distance or amount $sql .= " , dated = '".$this->db->idate($this->date)."'"; $sql .= " , type = '".$this->db->escape($this->type)."'"; $sql .= " , fk_statut = '".$this->db->escape($this->statut)."'"; - $sql .= " , fk_user = ".$this->fk_user; - $sql .= " , fk_user_modif = ".$user->id; + $sql .= " , fk_user = ".((int) $this->fk_user); + $sql .= " , fk_user_modif = ".((int) $user->id); $sql .= " , fk_soc = ".($this->socid > 0 ? $this->socid : 'null'); $sql .= " , note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= " , note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 960ff8f413f..111ace7c415 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3804,7 +3804,7 @@ class Facture extends CommonInvoice $remise = price2num($remise); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql .= ' SET remise_absolue = '.$remise; + $sql .= ' SET remise_absolue = '.((float) $remise); $sql .= ' WHERE rowid = '.$this->id; $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 8af9d5a6543..71e8ab10b38 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -236,8 +236,8 @@ class RemiseCheque extends CommonObject if ($checkremise) { $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql .= " SET fk_bordereau = ".$this->id; - $sql .= " WHERE rowid = ".$lineid; + $sql .= " SET fk_bordereau = ".((int) $this->id); + $sql .= " WHERE rowid = ".((int) $lineid); $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3d04cf1f6a5..3ea11463415 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -579,7 +579,7 @@ class BonPrelevement extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons "; $sql .= " SET fk_user_trans = ".$user->id; $sql .= " , date_trans = '".$this->db->idate($date)."'"; - $sql .= " , method_trans = ".$method; + $sql .= " , method_trans = ".((int) $method); $sql .= " , statut = ".self::STATUS_TRANSFERED; $sql .= " WHERE rowid = ".$this->id; $sql .= " AND entity = ".$conf->entity; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 8f7f13e6043..3207e533521 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -636,7 +636,7 @@ class PaymentSocialContribution extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 9ba1bd2ed1d..f8a397bdb9a 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -620,7 +620,7 @@ class PaymentVAT extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 5e0c65e1b70..6305a01c999 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1651,7 +1651,7 @@ class Contact extends CommonObject // Desactive utilisateur $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople"; - $sql .= " SET statut = ".$this->statut; + $sql .= " SET statut = ".((int) $this->statut); $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 057443d09b4..13cb7126769 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1321,7 +1321,7 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' } if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id); $res = $db->query($sql); if (!$res) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 622682060cb..9406c1e3ae5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2649,7 +2649,7 @@ abstract class CommonObject $fieldname = 'fk_address'; } - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".((int) $id); $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; if ($this->db->query($sql)) { @@ -2695,7 +2695,7 @@ abstract class CommonObject dol_syslog(get_class($this).'::setShippingMethod('.$shipping_method_id.')'); $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_shipping_method = ".$shipping_method_id; + $sql .= " SET fk_shipping_method = ".((int) $shipping_method_id); $sql .= " WHERE rowid=".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { @@ -2742,7 +2742,7 @@ abstract class CommonObject dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')'); $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_warehouse = ".$warehouse_id; + $sql .= " SET fk_warehouse = ".((int) $warehouse_id); $sql .= " WHERE rowid=".((int) $this->id); if ($this->db->query($sql)) { @@ -2819,7 +2819,7 @@ abstract class CommonObject dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')'); $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_account = ".$fk_account; + $sql .= " SET fk_account = ".((int) $fk_account); $sql .= " WHERE rowid=".((int) $this->id); $resql = $this->db->query($sql); @@ -8411,7 +8411,7 @@ abstract class CommonObject // If we have a field ref with a default value of (PROV) if (!$error) { if (key_exists('ref', $this->fields) && $this->fields['ref']['notnull'] > 0 && !is_null($this->fields['ref']['default']) && $this->fields['ref']['default'] == '(PROV)') { - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = ".((int) $this->id); $resqlupdate = $this->db->query($sql); if ($resqlupdate === false) { diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 4afcf295d40..a1c2b1fbf8c 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -421,17 +421,17 @@ class DiscountAbsolute $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; if (!empty($this->discount_type)) { if ($rowidline) { - $sql .= " SET fk_invoice_supplier_line = ".$rowidline; + $sql .= " SET fk_invoice_supplier_line = ".((int) $rowidline); } if ($rowidinvoice) { - $sql .= " SET fk_invoice_supplier = ".$rowidinvoice; + $sql .= " SET fk_invoice_supplier = ".((int) $rowidinvoice); } } else { if ($rowidline) { - $sql .= " SET fk_facture_line = ".$rowidline; + $sql .= " SET fk_facture_line = ".((int) $rowidline); } if ($rowidinvoice) { - $sql .= " SET fk_facture = ".$rowidinvoice; + $sql .= " SET fk_facture = ".((int) $rowidinvoice); } } $sql .= " WHERE rowid = ".$this->id; diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index cb7eb93b074..96dc6de934f 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -132,14 +132,14 @@ class MailingTargets // This can't be abstract as it is used for some method // phpcs:enable // Mise a jour nombre de destinataire dans table des mailings $sql = "SELECT COUNT(*) nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " WHERE fk_mailing = ".$mailing_id; + $sql .= " WHERE fk_mailing = ".((int) $mailing_id); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); $nb = $obj->nb; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing"; - $sql .= " SET nbemail = ".$nb." WHERE rowid = ".$mailing_id; + $sql .= " SET nbemail = ".$nb." WHERE rowid = ".((int) $mailing_id); if (!$this->db->query($sql)) { dol_syslog($this->db->error()); $this->error = $this->db->error(); diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index a5fb676e314..257eb309f25 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -702,7 +702,7 @@ class Don extends CommonObject $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = ".$userid." WHERE rowid = ".$id." AND fk_statut = 0"; + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = ".((int) $userid)." WHERE rowid = ".((int) $id)." AND fk_statut = 0"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 5ed3e777653..681675fd54c 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1384,7 +1384,7 @@ class ExpenseReport extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_APPROVED.", fk_user_approve = ".$fuser->id.","; + $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_APPROVED.", fk_user_approve = ".((int) $fuser->id).","; $sql .= " date_approve='".$this->db->idate($this->date_approve)."'"; $sql .= ' WHERE rowid = '.$this->id; if ($this->db->query($sql)) { @@ -1434,7 +1434,7 @@ class ExpenseReport extends CommonObject // date de refus if ($this->status != self::STATUS_REFUSED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".$fuser->id.","; + $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".((int) $fuser->id).","; $sql .= " date_refuse='".$this->db->idate($now)."',"; $sql .= " detail_refuse='".$this->db->escape($details)."',"; $sql .= " fk_user_approve = NULL"; @@ -1558,7 +1558,7 @@ class ExpenseReport extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_statut = ".self::STATUS_CANCELED.", fk_user_cancel = ".$fuser->id; + $sql .= " SET fk_statut = ".self::STATUS_CANCELED.", fk_user_cancel = ".((int) $fuser->id); $sql .= ", date_cancel='".$this->db->idate($this->date_cancel)."'"; $sql .= " ,detail_cancel='".$this->db->escape($detail)."'"; $sql .= ' WHERE rowid = '.$this->id; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index c9cf0cdaf41..c673316d491 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -607,7 +607,7 @@ class PaymentExpenseReport extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index d23b27278a1..1fef1ed7c03 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1622,7 +1622,7 @@ class FichinterLigne extends CommonObjectLine $sql = "SELECT SUM(duree) as total_duration, min(date) as dateo, max(date) as datee "; $sql .= " FROM ".MAIN_DB_PREFIX."fichinterdet"; - $sql .= " WHERE fk_fichinter=".$this->fk_fichinter; + $sql .= " WHERE fk_fichinter=".((int) $this->fk_fichinter); dol_syslog("FichinterLigne::update_total", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1634,10 +1634,10 @@ class FichinterLigne extends CommonObjectLine } $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; - $sql .= " SET duree = ".$total_duration; + $sql .= " SET duree = ".((int) $total_duration); $sql .= " , dateo = ".(!empty($obj->dateo) ? "'".$this->db->idate($obj->dateo)."'" : "null"); $sql .= " , datee = ".(!empty($obj->datee) ? "'".$this->db->idate($obj->datee)."'" : "null"); - $sql .= " WHERE rowid = ".$this->fk_fichinter; + $sql .= " WHERE rowid = ".((int) $this->fk_fichinter); dol_syslog("FichinterLigne::update_total", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index fad9f001100..0dfb4047b4f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1157,7 +1157,7 @@ class CommandeFournisseur extends CommonOrder $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".$statut; + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".((int) $statut); $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::cancel", LOG_DEBUG); if ($this->db->query($sql)) { @@ -2306,7 +2306,7 @@ class CommandeFournisseur extends CommonOrder $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql .= " SET fk_statut = ".$statut; + $sql .= " SET fk_statut = ".((int) $statut); $sql .= " WHERE rowid = ".$this->id; $sql .= " AND fk_statut IN (".self::STATUS_ORDERSENT.",".self::STATUS_RECEIVED_PARTIALLY.")"; // Process running or Partially received diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 55988f51169..73e8be88c37 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1465,7 +1465,7 @@ class FactureFournisseur extends CommonInvoice $this->newref = dol_sanitizeFileName($num); $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; - $sql .= " SET ref='".$num."', fk_statut = 1, fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; + $sql .= " SET ref='".$this->db->escape($num)."', fk_statut = 1, fk_user_valid = ".((int) $user->id).", date_valid = '".$this->db->idate($now)."'"; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate", LOG_DEBUG); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 708e3e621e4..0fa34c28d81 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -372,15 +372,15 @@ class ProductFournisseur extends Product } } $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; + $sql .= " SET fk_user = ".((int) $user->id)." ,"; $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; + $sql .= " price = ".((float) $buyprice).","; + $sql .= " quantity = ".((float) $qty).","; + $sql .= " remise_percent = ".((float) $remise_percent).","; + $sql .= " remise = ".((float) $remise).","; + $sql .= " unitprice = ".((float) $unitBuyPrice).","; + $sql .= " fk_availability = ".((int) $availability).","; $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; @@ -394,16 +394,16 @@ class ProductFournisseur extends Product //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; + $sql .= " info_bits = ".((int) $newnpr).","; + $sql .= " charges = ".((float) $charges).","; // deprecated + $sql .= " delivery_time_days = ".($delivery_time_days != '' ? ((int) $delivery_time_days) : 'null').","; $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); } - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; + $sql .= " WHERE rowid = ".((int) $this->product_fourn_price_id); // TODO Add price_base_type and price_ttc dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); @@ -885,8 +885,8 @@ class ProductFournisseur extends Product $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; + $sql .= " SET fk_supplier_price_expression = ".((int) $expression_id); + $sql .= " WHERE rowid = ".((int) $this->product_fourn_price_id); dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 1d695f40249..9357128d050 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -933,14 +933,14 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) { } if ($methodtofix == 'updatestock') { // Method 2 - print ' -> Update qty of product_stock with qty = '.($obj->reelbatch ? $obj->reelbatch : '0').' for ps.rowid = '.$obj->psrowid; + print ' -> Update qty of product_stock with qty = '.($obj->reelbatch ? ((float) $obj->reelbatch) : '0').' for ps.rowid = '.((int) $obj->psrowid); if (GETPOST('clean_product_stock_batch') == 'confirmed') { $error = 0; $db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_stock"; - $sql2 .= " SET reel = ".($obj->reelbatch ? $obj->reelbatch : '0')." WHERE rowid = ".$obj->psrowid; + $sql2 .= " SET reel = ".($obj->reelbatch ? ((float) $obj->reelbatch) : '0')." WHERE rowid = ".((int) $obj->psrowid); $resql2 = $db->query($sql2); if ($resql2) { // We update product_stock, so we must fill p.stock into product too. @@ -1027,7 +1027,7 @@ if ($ok && GETPOST('set_empty_time_spent_amount', 'alpha')) { if (GETPOST('set_empty_time_spent_amount') == 'confirmed') { $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql2 .= " SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".$obj->user_id; + $sql2 .= " SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".((int) $obj->user_id); $resql2 = $db->query($sql2); if (!$resql2) { $error++; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d613e4a18b0..ec322733c7d 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -678,7 +678,7 @@ function migrate_paiements($db, $langs, $conf) $res += $db->query($sql); - $sql = "UPDATE ".MAIN_DB_PREFIX."paiement SET fk_facture = 0 WHERE rowid = ".$row[$i][0]; + $sql = "UPDATE ".MAIN_DB_PREFIX."paiement SET fk_facture = 0 WHERE rowid = ".((int) $row[$i][0]); $res += $db->query($sql); diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index c7f1940943b..cf0a8e87f63 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -594,12 +594,12 @@ class PaymentLoan extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $this->fk_bank = $id_bank; + $this->fk_bank = ((int) $id_bank); return 1; } else { $this->error = $this->db->error(); diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index cf4466bb0da..675401e34f9 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -58,7 +58,7 @@ if ($id > 0) { if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) { $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."loan_schedule SET fk_bank = 0 WHERE fk_bank = ".$payment->fk_bank; + $sql = "UPDATE ".MAIN_DB_PREFIX."loan_schedule SET fk_bank = 0 WHERE fk_bank = ".((int) $payment->fk_bank); $db->query($sql); $fk_loan = $payment->fk_loan; @@ -66,7 +66,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del $result = $payment->delete($user); if ($result > 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT."/loan/card.php?id=".$fk_loan); + header("Location: ".DOL_URL_ROOT."/loan/card.php?id=".urlencode($fk_loan)); exit; } else { setEventMessages($payment->error, $payment->errors, 'errors'); diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php index fada766f065..2166ada6138 100644 --- a/htdocs/product/admin/price_rules.php +++ b/htdocs/product/admin/price_rules.php @@ -86,7 +86,7 @@ if ($action == 'update') { if (!$db->query($sql)) { //If we could not create, then we try updating $sql = "UPDATE ".MAIN_DB_PREFIX."product_pricerules"; - $sql .= " SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".$i; + $sql .= " SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".((int) $i); if (!$db->query($sql)) { setEventMessages($langs->trans('ErrorSavingChanges'), null, 'errors'); diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 8b2d729c29c..102e3ba1700 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -604,9 +604,9 @@ class MouvementStock extends CommonObject // $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty; // $sql.= " WHERE rowid = ".$fk_product; // Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql - $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$newpmp.","; + $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".((float) $newpmp).","; $sql .= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; - $sql .= " WHERE rowid = ".$fk_product; + $sql .= " WHERE rowid = ".((int) $fk_product); dol_syslog(get_class($this)."::_create update AWP", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8bf9c727f4e..792d2fd00de 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -771,7 +771,7 @@ class Project extends CommonObject 'actioncomm'=>'fk_project', 'mrp_mo'=>'fk_project' ); foreach ($listoftables as $key => $value) { - $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { $this->errors[] = $this->db->lasterror(); @@ -1033,7 +1033,7 @@ class Project extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; - $sql .= " SET fk_statut = ".self::STATUS_CLOSED.", fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'"; + $sql .= " SET fk_statut = ".self::STATUS_CLOSED.", fk_user_close = ".((int) $user->id).", date_close = '".$this->db->idate($now)."'"; $sql .= " WHERE rowid = ".$this->id; $sql .= " AND fk_statut = ".self::STATUS_VALIDATED; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 091409539a8..7916f79fdeb 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1197,11 +1197,11 @@ class Task extends CommonObject if ($ret > 0) { // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; + $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".((int) $this->id).")"; if (isset($this->progress)) { - $sql .= ", progress = ".$this->progress; // Do not overwrite value if not provided + $sql .= ", progress = ".((float) $this->progress); // Do not overwrite value if not provided } - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); if (!$this->db->query($sql)) { @@ -1210,8 +1210,8 @@ class Task extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql .= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->timespent_fk_user.")"; // set average hour rate of user - $sql .= " WHERE rowid = ".$tasktime_id; + $sql .= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".((int) $this->timespent_fk_user).")"; // set average hour rate of user + $sql .= " WHERE rowid = ".((int) $tasktime_id); dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); if (!$this->db->query($sql)) { @@ -1552,7 +1552,7 @@ class Task extends CommonObject $newDuration = $this->timespent_duration - $this->timespent_old_duration; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->db->escape($this->id).")"; + $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".((int) $this->id).")"; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index d82e2265e7e..68fb7a1fea6 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -670,7 +670,7 @@ class RecruitmentJobPosition extends CommonObject $newprivatenote = dol_concatdesc($this->note_private, $note); $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET status = ".$status.", note_private = '".$this->db->escape($newprivatenote)."'"; + $sql .= " SET status = ".((int) $status).", note_private = '".$this->db->escape($newprivatenote)."'"; //$sql .= ", date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; $sql .= " WHERE rowid = ".$this->id; diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index dc7e310d560..dcb50dac49a 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -570,7 +570,7 @@ class PaymentSalary extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index fd4fde95243..2a5f2b84a53 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -792,7 +792,7 @@ if (empty($reshook)) { // Update linked member if (!$error && $object->fk_soc > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql .= " SET fk_soc = NULL WHERE fk_soc = ".$id; + $sql .= " SET fk_soc = NULL WHERE fk_soc = ".((int) $socid); if (!$object->db->query($sql)) { $error++; $object->error .= $object->db->lasterror(); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 954ebe94673..7746001dea7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1985,7 +1985,7 @@ class Societe extends CommonObject $newclient = 3; //If prospect, we keep prospect tag } $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql .= " SET client = ".$newclient; + $sql .= " SET client = ".((int) $newclient); $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index ecd506e2cb4..bbb06f2a2da 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1541,13 +1541,13 @@ class SupplierProposal extends CommonObject $remise = trim($remise) ?trim($remise) : 0; if (!empty($user->rights->supplier_proposal->creer)) { - $remise = price2num($remise); + $remise = price2num($remise, 2); - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal SET remise_percent = ".$remise; + $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal SET remise_percent = ".((float) $remise); $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; if ($this->db->query($sql)) { - $this->remise_percent = $remise; + $this->remise_percent = ((float) $remise); $this->update_price(1); return 1; } else { @@ -1569,13 +1569,15 @@ class SupplierProposal extends CommonObject public function set_remise_absolue($user, $remise) { // phpcs:enable - $remise = trim($remise) ?trim($remise) : 0; + if (empty($remise)) { + $remise = 0; + } + + $remise = price2num($remise); if (!empty($user->rights->supplier_proposal->creer)) { - $remise = price2num($remise); - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal "; - $sql .= " SET remise_absolue = ".$remise; + $sql .= " SET remise_absolue = ".((float) $remise); $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; if ($this->db->query($sql)) { @@ -1608,7 +1610,7 @@ class SupplierProposal extends CommonObject $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; - $sql .= " SET fk_statut = ".$this->statut.","; + $sql .= " SET fk_statut = ".((int) $this->statut).","; if (!empty($note)) { $sql .= " note_private = '".$this->db->escape($note)."',"; } @@ -1669,7 +1671,7 @@ class SupplierProposal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; - $sql .= " SET fk_statut = ".$status.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; + $sql .= " SET fk_statut = ".((int) $status).", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index c1224285c7c..f01198f1ca8 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1110,16 +1110,14 @@ class User extends CommonObject // Check parameters if ($this->statut == $status) { return 0; - } else { - $this->statut = $status; } $this->db->begin(); // Save in database $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET statut = ".$this->statut; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " SET statut = ".((int) $status); + $sql .= " WHERE rowid = ".((int) $this->id); $result = $this->db->query($sql); dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); @@ -1136,6 +1134,8 @@ class User extends CommonObject $this->db->rollback(); return -$error; } else { + $this->status = $status; + $this->statut = $status; $this->db->commit(); return 1; } @@ -1199,7 +1199,7 @@ class User extends CommonObject // If contact, remove link if ($this->contact_id > 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user_creat = null WHERE rowid = ".$this->contact_id; + $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user_creat = null WHERE rowid = ".((int) $this->contact_id); if (!$error && !$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); @@ -1737,7 +1737,7 @@ class User extends CommonObject // If user is linked to a member, remove old link to this member if ($this->fk_member > 0) { dol_syslog(get_class($this)."::update remove link with member. We will recreate it later", LOG_DEBUG); - $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL where fk_member = ".$this->fk_member; + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL where fk_member = ".((int) $this->fk_member); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -5; @@ -1745,7 +1745,7 @@ class User extends CommonObject } // Set link to user dol_syslog(get_class($this)."::update set link with member", LOG_DEBUG); - $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member =".($this->fk_member > 0 ? $this->fk_member : 'null')." where rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member =".($this->fk_member > 0 ? ((int) $this->fk_member) : 'null')." where rowid = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -5; From d61f61ab45204ab43dac16302abd1fdac3f04c49 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 03:55:17 +0200 Subject: [PATCH 095/233] Clean $_GET --- htdocs/admin/dict.php | 4 ++-- htdocs/cashdesk/affContenu.php | 2 +- htdocs/comm/remise.php | 2 +- htdocs/compta/bank/card.php | 10 +++++----- htdocs/compta/payment_sc/card.php | 2 +- htdocs/compta/payment_vat/card.php | 4 ++-- htdocs/don/card.php | 2 +- htdocs/expensereport/card.php | 2 +- htdocs/opensurvey/results.php | 2 +- htdocs/product/fournisseurs.php | 6 +++--- htdocs/product/stock/class/entrepot.class.php | 2 +- htdocs/product/stock/fiche-valo.php | 12 ++++-------- htdocs/projet/activity/perday.php | 2 +- htdocs/projet/activity/permonth.php | 2 +- htdocs/projet/activity/perweek.php | 2 +- htdocs/projet/tasks/comment.php | 4 ++-- htdocs/projet/tasks/task.php | 4 ++-- htdocs/salaries/payment_salary/card.php | 2 +- htdocs/societe/ajaxcompanies.php | 8 ++++---- 19 files changed, 35 insertions(+), 39 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 9d05ad00377..0f2601f0349 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1915,10 +1915,10 @@ if ($id) { $showfield = 0; } elseif ($fieldlist[$field] == 'unicode') { $valuetoshow = $langs->getCurrencySymbol($obj->code, 1); - } elseif ($fieldlist[$field] == 'label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') { + } elseif ($fieldlist[$field] == 'label' && $tabname[GETPOST("id", 'int')] == MAIN_DB_PREFIX.'c_units') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); - } elseif ($fieldlist[$field] == 'short_label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') { + } elseif ($fieldlist[$field] == 'short_label' && $tabname[GETPOST("id", 'int')] == MAIN_DB_PREFIX.'c_units') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } elseif (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) { diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 7d9af18913e..d8e31f3b9c9 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -26,7 +26,7 @@ require_once 'class/Facturation.class.php'; // Si nouvelle vente, reinitialisation des donnees (destruction de l'objet et vidage de la table contenant la liste des articles) -if ($_GET['id'] == 'NOUV') { +if (GETPOST('id', 'int') == 'NOUV') { unset($_SESSION['serObjFacturation']); unset($_SESSION['poscart']); } diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 93876fdde96..f9cec9d11c1 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -66,7 +66,7 @@ if (GETPOST('action', 'aZ09') == 'setremise') { header("Location: ".$backtopage); exit; } else { - header("Location: remise.php?id=".$_GET["id"]); + header("Location: remise.php?id=".GETPOST("id", 'int')); exit; } } else { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 33d4bc37aed..48335d38964 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -570,13 +570,13 @@ if ($action == 'create') { /* */ /* ************************************************************************** */ - if (($_GET["id"] || $_GET["ref"]) && $action != 'edit') { + if ((GETPOST("id", 'int') || GETPOST("ref")) && $action != 'edit') { $object = new Account($db); - if ($_GET["id"]) { - $object->fetch($_GET["id"]); + if (GETPOST("id", 'int')) { + $object->fetch(GETPOST("id", 'int')); } - if ($_GET["ref"]) { - $object->fetch(0, $_GET["ref"]); + if (GETPOST("ref")) { + $object->fetch(0, GETPOST("ref")); $_GET["id"] = $object->id; } diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index c3640c1a760..c75974077c3 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -242,7 +242,7 @@ if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { if ($user->rights->facture->paiement) { - print ''.$langs->trans('Valid').''; + print ''.$langs->trans('Valid').''; } } } diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php index b671492c346..1b615bcbb8d 100644 --- a/htdocs/compta/payment_vat/card.php +++ b/htdocs/compta/payment_vat/card.php @@ -298,7 +298,7 @@ if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { if ($user->rights->facture->paiement) { - print ''.$langs->trans('Valid').''; + print ''.$langs->trans('Valid').''; } } } @@ -307,7 +307,7 @@ if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) if ($action == '') { if ($user->rights->tax->charges->supprimer) { if (!$disable_delete) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 64dcf07cf8c..1dfade00bec 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -275,7 +275,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Remove file in doc form /*if ($action == 'remove_file') { - $object = new Don($db, 0, $_GET['id']); + $object = new Don($db, 0, GETPOST('id', 'int')); if ($object->fetch($id)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index c356ed708b2..a4c565bc1be 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1191,7 +1191,7 @@ if (empty($reshook)) { } $object->update_totaux_del($object_ligne->total_ht, $object_ligne->total_tva); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id', 'int')); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 25bd65a77fe..0cf9cff7932 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -53,7 +53,7 @@ $nblines = $object->fetch_lines(); // Return to the results if (GETPOST('retoursondage')) { - header('Location: results.php?id='.$_GET['id']); + header('Location: results.php?id='.GETPOST('id', 'int')); exit; } diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 77659142744..ff18c361ff9 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -62,9 +62,9 @@ $extrafields = new ExtraFields($db); // If socid provided by ajax company selector if (!empty($_REQUEST['search_fourn_id'])) { - $_GET['id_fourn'] = $_GET['search_fourn_id']; - $_POST['id_fourn'] = $_POST['search_fourn_id']; - $_REQUEST['id_fourn'] = $_REQUEST['search_fourn_id']; + $_GET['id_fourn'] = GETPOST('search_fourn_id', 'int'); + $_POST['id_fourn'] = GETPOST('search_fourn_id', 'int'); + $_REQUEST['id_fourn'] = GETPOST('search_fourn_id', 'int'); } // Security check diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 30dba05e417..327c428e9c9 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -436,7 +436,7 @@ class Entrepot extends CommonObject $sql .= " model_pdf, import_key"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; if ($id) { - $sql .= " WHERE rowid = '".$id."'"; + $sql .= " WHERE rowid = ".((int) $id); } else { $sql .= " WHERE entity = ".$conf->entity; if ($ref) { diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php index 34380efbe7a..a2a15a34e53 100644 --- a/htdocs/product/stock/fiche-valo.php +++ b/htdocs/product/stock/fiche-valo.php @@ -28,7 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'companies')); -$mesg = ''; + +$id = GETPOST('id', 'int'); // Security check $result = restrictedArea($user, 'stock'); @@ -43,18 +44,13 @@ $form = new Form($db); $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("", $langs->trans("WarehouseCard"), $help_url); -if ($_GET["id"]) { - if ($mesg) { - print $mesg; - } - +if ($id > 0) { $entrepot = new Entrepot($db); - $result = $entrepot->fetch($_GET["id"]); + $result = $entrepot->fetch($id); if ($result < 0) { dol_print_error($db); } - $head = stock_prepare_head($entrepot); print dol_get_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock'); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 5b30d77ca21..fc5ea53e98a 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -50,7 +50,7 @@ if ($mode == 'mine') { $mine = 1; } -$projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); +$projectid = GETPOSTISSET("id") ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); $hookmanager->initHooks(array('timesheetperdaycard')); diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 7f40ab1c9a1..5fd76694c34 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -48,7 +48,7 @@ if ($mode == 'mine') { $mine = 1; } -$projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); +$projectid = GETPOSTISSET("id") ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); // Security check $socid = 0; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index b6cd2c04f10..4201fca41b6 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -50,7 +50,7 @@ if ($mode == 'mine') { $mine = 1; } -$projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); +$projectid = GETPOSTISSET("id") ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); $hookmanager->initHooks(array('timesheetperweekcard')); diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index c0ebc6850cc..aaa8bd0cd89 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -284,14 +284,14 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_head($head, 'task_comment', $langs->trans("Task"), -1, 'projecttask'); if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", "int").'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); } if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; } else { - $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id); } $morehtmlref = ''; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 0f6b67a0482..780d387512e 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -474,14 +474,14 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", 'int').'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); } if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; } else { - $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id); } $morehtmlref = ''; diff --git a/htdocs/salaries/payment_salary/card.php b/htdocs/salaries/payment_salary/card.php index c6d1fd7d07f..51f80b23efd 100644 --- a/htdocs/salaries/payment_salary/card.php +++ b/htdocs/salaries/payment_salary/card.php @@ -255,7 +255,7 @@ print '
    '; if ($action == '') { if ($user->rights->salaries->delete) { if (!$disable_delete) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; } diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php index 3221aafff55..28b105df9a0 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajaxcompanies.php @@ -66,12 +66,12 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { $return_arr = array(); // Define filter on text typed - $socid = $_GET['newcompany'] ? $_GET['newcompany'] : ''; + $socid = GETPOST('newcompany'); if (!$socid) { - $socid = $_GET['socid'] ? $_GET['socid'] : ''; + $socid = GETPOST('socid', 'int'); } if (!$socid) { - $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : ''; + $socid = GETPOST('id_fourn', 'int'); } $sql = "SELECT rowid, nom"; @@ -90,7 +90,7 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { $sql .= " OR code_fournisseur LIKE '%".$db->escape($socid)."%'"; } if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) { - $sql .= " OR rowid = '".$db->escape($socid)."'"; + $sql .= " OR rowid = ".((int) $socid); } $sql .= ")"; } From b4f638602a3d636f03bcc5a336cc4a1e9b05ccb0 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 30 Mar 2021 11:10:07 +0200 Subject: [PATCH 096/233] FIX: Show Ref.Supplier in LinkToObjectBlock --- htdocs/core/class/html.form.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 14251ce2912..247b81452df 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -16,7 +16,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2014 Alexandre Spangaro - * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2018-2021 Ferran Marcet * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Christophe Battarel @@ -6950,8 +6950,8 @@ class Form 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), - 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), - 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')'), + 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier as ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), + 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier as ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')'), 'ticket'=>array('enabled'=>$conf->ticket->enabled, 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('ticket').')') ); } From 6c98276ead973650d7f6db0cd51c5f275c33015f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 11:26:49 +0200 Subject: [PATCH 097/233] FIX #yogosha5782 --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/expedition/contact.php | 2 +- htdocs/projet/contact.php | 2 +- htdocs/reception/contact.php | 2 +- htdocs/resource/class/dolresource.class.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9406c1e3ae5..48e92d58172 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1175,7 +1175,7 @@ abstract class CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; - $sql .= " WHERE rowid =".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG); if ($this->db->query($sql)) { diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index d1bcab57412..9d5b7c4a8af 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -99,7 +99,7 @@ if ($action == 'addcontact' && $user->rights->expedition->creer) { $result = $objectsrc->swapContactStatus(GETPOST('ligne', 'int')); } elseif ($action == 'deletecontact' && $user->rights->expedition->creer) { // Efface un contact - $result = $objectsrc->delete_contact(GETPOST("lineid")); + $result = $objectsrc->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index fe434891fa9..92f4e4e3b15 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -223,7 +223,7 @@ if ($action == 'swapstatut' && $user->rights->projet->creer) { // Delete a contact if (($action == 'deleteline' || $action == 'deletecontact') && $user->rights->projet->creer) { $object->fetch($id); - $result = $object->delete_contact(GETPOST("lineid")); + $result = $object->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: contact.php?id=".$object->id); diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index 58e046ec0bb..3caa9a90fea 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -110,7 +110,7 @@ if ($action == 'addcontact' && $user->rights->reception->creer) { $result = $objectsrc->swapContactStatus(GETPOST('ligne', 'int')); } elseif ($action == 'deletecontact' && $user->rights->reception->creer) { // Efface un contact - $result = $objectsrc->delete_contact(GETPOST("lineid")); + $result = $objectsrc->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 5ab07cdd536..4979a883d9c 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -410,7 +410,7 @@ class Dolresource extends CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " WHERE rowid =".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this), LOG_DEBUG); if ($this->db->query($sql)) { From 08c7458dd93dee1ab6599cc7162c0f7c7c556090 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 11:36:50 +0200 Subject: [PATCH 098/233] FIX #yogosha5746 --- htdocs/comm/propal/class/propal.class.php | 4 ++-- htdocs/commande/class/commande.class.php | 4 ++-- .../compta/bank/class/paymentvarious.class.php | 2 +- htdocs/compta/bank/releve.php | 3 ++- .../cashcontrol/class/cashcontrol.class.php | 2 +- .../compta/facture/class/facture-rec.class.php | 6 +++--- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/compta/localtax/class/localtax.class.php | 2 +- htdocs/compta/paiement/class/paiement.class.php | 6 +++--- htdocs/core/class/commonobject.class.php | 16 ++++++++-------- .../expensereport/mod_expensereport_jade.php | 2 +- htdocs/fichinter/class/fichinterrec.class.php | 8 ++++---- htdocs/install/repair.php | 4 ++-- htdocs/projet/tasks/time.php | 6 +++--- htdocs/public/emailing/mailing-read.php | 6 +++--- htdocs/salaries/class/salary.class.php | 2 +- .../class/supplier_proposal.class.php | 2 +- htdocs/variants/class/ProductAttribute.class.php | 2 +- 18 files changed, 40 insertions(+), 39 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0388768fc1f..32206a0c251 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2997,7 +2997,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; - $sql .= ' SET fk_availability = '.$availability_id; + $sql .= ' SET fk_availability = '.((int) $availability_id); $sql .= ' WHERE rowid='.((int) $this->id); dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG); @@ -3061,7 +3061,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; - $sql .= ' SET fk_input_reason = '.$demand_reason_id; + $sql .= ' SET fk_input_reason = '.((int) $demand_reason_id); $sql .= ' WHERE rowid='.((int) $this->id); dol_syslog(__METHOD__.' demand_reason('.$demand_reason_id.')', LOG_DEBUG); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2f2f0a4d81c..c3e6babdbbe 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2743,7 +2743,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql .= ' SET fk_availability = '.$availability_id; + $sql .= ' SET fk_availability = '.((int) $availability_id); $sql .= ' WHERE rowid='.((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); @@ -2807,7 +2807,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql .= ' SET fk_input_reason = '.$demand_reason_id; + $sql .= ' SET fk_input_reason = '.((int) $demand_reason_id); $sql .= ' WHERE rowid='.((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index dccdcd5cd24..86a70a35311 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -572,7 +572,7 @@ class PaymentVarious extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.((int) $id_bank); $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index dc71a1d2d27..010b4a08fde 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -179,7 +179,8 @@ $sqlrequestforbankline = $sql; if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { // TODO Add a test to check newbankreceipt does not exists yet - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.$id; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank'; + $sqlupdate .= ' SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.((int) $id); $result = $db->query($sqlupdate); if ($result < 0) { dol_print_error($db); diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 1563309a3c4..cfd201e3ec4 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -213,7 +213,7 @@ class CashControl extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."pos_cash_fence"); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'pos_cash_fence SET ref = rowid where rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'pos_cash_fence SET ref = rowid where rowid = '.((int) $this->id); $this->db->query($sql); } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 674b5917b17..b93f48ff655 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1808,7 +1808,7 @@ class FactureRec extends CommonInvoice } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET nb_gen_max = '.$nb; + $sql .= ' SET nb_gen_max = '.((int) $nb); $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); @@ -1835,7 +1835,7 @@ class FactureRec extends CommonInvoice } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET auto_validate = '.$validate; + $sql .= ' SET auto_validate = '.((int) $validate); $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); @@ -1862,7 +1862,7 @@ class FactureRec extends CommonInvoice } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET generate_pdf = '.$validate; + $sql .= ' SET generate_pdf = '.((int) $validate); $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 111ace7c415..a43d4431c59 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4610,7 +4610,7 @@ class Facture extends CommonInvoice $this->db->begin(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$this->situation_final.' where rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$this->situation_final.' where rowid = '.((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 46b2b2b7805..324ccbf2923 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -559,7 +559,7 @@ class Localtax extends CommonObject public function update_fk_bank($id) { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.$id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.((int) $id); $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 9dcc57a47f2..5647295d171 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -736,7 +736,7 @@ class Paiement extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.((int) $id_bank); $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this).'::update_fk_bank', LOG_DEBUG); @@ -855,7 +855,7 @@ class Paiement extends CommonObject */ public function validate(User $user = null) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this).'::valide', LOG_DEBUG); $result = $this->db->query($sql); @@ -876,7 +876,7 @@ class Paiement extends CommonObject */ public function reject(User $user = null) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 2 WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 2 WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this).'::reject', LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 48e92d58172..ed1ce977221 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2332,7 +2332,7 @@ abstract class CommonObject $fieldname = 'multicurrency_tx'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$rate; + $sql .= ' SET '.$fieldname.' = '.((float) $rate); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2617,7 +2617,7 @@ abstract class CommonObject $fieldname = 'retained_warranty_fk_cond_reglement'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' SET '.$fieldname.' = '.((int) $id); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -3062,11 +3062,11 @@ abstract class CommonObject $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; $sql .= ' AND rang = '.($rang - 1); if ($this->db->query($sql)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang - 1); + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang - 1)); $sql .= ' WHERE rowid = '.((int) $rowid); if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -3093,11 +3093,11 @@ abstract class CommonObject $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; - $sql .= ' AND rang = '.($rang + 1); + $sql .= ' AND rang = '.((int) ($rang + 1)); if ($this->db->query($sql)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang + 1); + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang + 1)); $sql .= ' WHERE rowid = '.((int) $rowid); if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -7656,7 +7656,7 @@ abstract class CommonObject public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) { foreach ($tables as $table) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.$dest_id.' WHERE fk_soc = '.$origin_id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id); if (!$db->query($sql)) { if ($ignoreerrors) { diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index bbe2245a97d..b25ac15345b 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -163,7 +163,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport } $newref = str_replace(' ', '_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut, '%y%m%d'); - $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; + $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.((int) $ref_number_int).' WHERE rowid = '.((int) $object->id); $resqlbis = $db->query($sqlbis); if (!$resqlbis) { dol_print_error($resqlbis); diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 8ed842a70c9..960a2734706 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -784,8 +784,8 @@ class FichinterRec extends Fichinter } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET nb_gen_max = '.$nb; - $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' SET nb_gen_max = '.((int) $nb); + $sql .= ' WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); if ($this->db->query($sql)) { @@ -811,8 +811,8 @@ class FichinterRec extends Fichinter } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET auto_validate = '.$validate; - $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' SET auto_validate = '.((int) $validate); + $sql .= ' WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); if ($this->db->query($sql)) { diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 9357128d050..1eb980ae173 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1347,8 +1347,8 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { $qty_for_line = min($remaining_qty, $obj_line->qty); if ($first_iteration) { $sql_attach = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; - $sql_attach .= ' SET fk_commandefourndet = '.$obj_line->rowid.', qty = '.$qty_for_line; - $sql_attach .= ' WHERE rowid = '.$obj_dispatch->rowid; + $sql_attach .= ' SET fk_commandefourndet = '.((int) $obj_line->rowid).', qty = '.((float) $qty_for_line); + $sql_attach .= ' WHERE rowid = '.((int) $obj_dispatch->rowid); $first_iteration = false; } else { $sql_attach_values = array( diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 54f622b95a1..1c3cacb4cee 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -428,7 +428,7 @@ if ($action == 'confirm_generateinvoice') { $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $result = $db->query($sql); if (!$result) { @@ -467,7 +467,7 @@ if ($action == 'confirm_generateinvoice') { $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $result = $db->query($sql); if (!$result) { @@ -503,7 +503,7 @@ if ($action == 'confirm_generateinvoice') { $lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).')'; $result = $db->query($sql); if (!$result) { diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index 454201203cc..91418707d3a 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -122,19 +122,19 @@ if (!empty($tag)) { //Update status of target $statut = '2'; - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE rowid = ".((int) $obj->rowid); + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".((int) $statut)." WHERE rowid = ".((int) $obj->rowid); $resql = $db->query($sql); if (!$resql) dol_print_error($db); //Update status communication of thirdparty prospect if ($obj->source_id > 0 && $obj->source_type == 'thirdparty' && $obj->entity) { - $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid = '.$obj->source_id; + $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid = '.((int) $obj->source_id); $resql = $db->query($sql); } //Update status communication of contact prospect if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) { - $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.$obj->source_id.')'; + $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '((int) $obj->source_id).')'; $resql = $db->query($sql); } } diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index fdd1bfd7f73..85ccfc0a1db 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -463,7 +463,7 @@ class Salary extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.$id_bank; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.((int) $id_bank); $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index bbb06f2a2da..0320a663ea8 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1777,7 +1777,7 @@ class SupplierProposal extends CommonObject $price = price2num($product->subprice * $product->qty, 'MU'); $unitPrice = price2num($product->subprice, 'MU'); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$this->db->escape($product->ref_fourn).'", ' : '').' price ='.((float) $price).', unitprice ='.((float) $unitPrice).' WHERE rowid = '.((int) $idProductFournPrice); $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index a4e9f92eb10..1e7f44bb936 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -319,7 +319,7 @@ class ProductAttribute extends CommonObject $newrang = $this->rang + 1; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_attribute SET rang = '.$this->rang.' WHERE rang = '.$newrang; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_attribute SET rang = '.((int) $this->rang).' WHERE rang = '.((int) $newrang); if (!$this->db->query($sql)) { $this->db->rollback(); From 55560b7d38e3817f79e4448e5f265182958f861e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 30 Mar 2021 12:35:20 +0200 Subject: [PATCH 099/233] Inventory module working --- htdocs/core/modules/modStock.class.php | 6 +++ htdocs/langs/en_US/stocks.lang | 5 ++- htdocs/product/inventory/card.php | 6 +++ .../inventory/class/inventory.class.php | 27 ++++++++++++- htdocs/product/inventory/inventory.php | 38 +++++++++---------- 5 files changed, 61 insertions(+), 21 deletions(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 3d46d606265..c9379fb25d6 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -172,6 +172,12 @@ class modStock extends DolibarrModules $this->rights[9][3] = 0; // Permission by default for new user (0/1) $this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + + $this->rights[10][0] = 1016; + $this->rights[10][1] = 'inventoryDeletePermission'; // Permission label + $this->rights[10][3] = 0; // Permission by default for new user (0/1) + $this->rights[10][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[10][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) } // Main menu entries diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index a7205207cf9..639f025425a 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -184,6 +184,7 @@ inventoryCreatePermission=Create new inventory inventoryReadPermission=View inventories inventoryWritePermission=Update inventories inventoryValidatePermission=Validate inventory +inventoryDeletePermission=Delete inventory inventoryTitle=Inventory inventoryListTitle=Inventories inventoryListEmpty=No inventory in progress @@ -243,4 +244,6 @@ UpdateByScaning=Update by scaning UpdateByScaningProductBarcode=Update by scan (product barcode) UpdateByScaningLot=Update by scan (lot|serial barcode) DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. -LabelOfInventoryMovemement=Inventory %s \ No newline at end of file +LabelOfInventoryMovemement=Inventory %s +ReOpen=Reopen +ConfirmFinish=Confirm closing \ No newline at end of file diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 92ad4c2176b..dda16746398 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -407,6 +407,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans("SetToDraft").''; } } + // Back to validate + if ($object->status == $object::STATUS_RECORDED) { + if ($permissiontoadd) { + print ''.$langs->trans("ReOpen").''; + } + } // Modify if ($object->status == $object::STATUS_DRAFT) { diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index dc1b46331fc..bf34dd04efc 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -52,7 +52,7 @@ class Inventory extends CommonObject /** * @var int Does object support extrafields ? 0=No, 1=Yes */ - public $isextrafieldmanaged = 1; + public $isextrafieldmanaged = 0; /** * @var string String with name of icon for inventory @@ -254,6 +254,7 @@ class Inventory extends CommonObject */ public function validate(User $user, $notrigger = false) { + global $conf; $this->db->begin(); $result = 0; @@ -380,6 +381,27 @@ class Inventory extends CommonObject } } + /** + * Set to Canceled + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function setCanceled(User $user, $notrigger = false) + { + $this->db->begin(); + + $result = $this->setStatut($this::STATUS_CANCELED, null, '', 'INVENTORY_CANCELED'); + + if ($result > 0) { + $this->db->commit(); + } else { + $this->db->rollback(); + return -1; + } + } + /** * Clone and object into another one * @@ -587,9 +609,11 @@ class Inventory extends CommonObject $labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); $labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated').' ('.$langs->trans('Started').')'; $labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled'); + $labelStatus[self::STATUS_RECORDED] = $langs->trans('Closed'); $labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); $labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Started'); $labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Canceled'); + $labelStatusShort[self::STATUS_RECORDED] = $langs->trans('Closed'); return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', 'status'.$status, $mode); } @@ -649,6 +673,7 @@ class Inventory extends CommonObject public function initAsSpecimen() { $this->initAsSpecimenCommon(); + $this->title = ''; } } diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index d8e76489ffc..55f0ef51149 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -99,6 +99,10 @@ $now = dol_now(); * Actions */ +if ($action == 'cancel_record' && $permissiontoadd) { + $object->setCanceled($user); +} + if ($action == 'update' && $user->rights->stock->mouvement->creer) { $stockmovment = new MouvementStock($db); $stockmovment->origin = $object; @@ -285,6 +289,18 @@ if ($object->id > 0) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } + // Confirmation to close + if ($action == 'record') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $langs->trans('ConfirmFinish'), 'update', '', 0, 1); + $action = 'view'; + } + + // Confirmation to close + if ($action == 'confirm_cancel') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $langs->trans('ConfirmCancel'), 'cancel_record', '', 0, 1); + $action = 'view'; + } + // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -369,24 +385,7 @@ if ($object->id > 0) { // Buttons for actions - if ($action == 'record') { - print '
    '; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - - print '
    '; - print ''.$langs->trans("InventoryDesc").'
    '; - print ''; - print '   '; - print ''; - print '
    '; - print '
    '; - print '
    '; - } else { + if ($action != 'record') { print '
    '."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -422,7 +421,8 @@ if ($object->id > 0) { if ($object->status == Inventory::STATUS_VALIDATED) { if ($permissiontoadd) { - print ''.$langs->trans("Finish").''."\n"; + print ''.$langs->trans("Cancel").''."\n"; + print ''.$langs->trans("Close").''."\n"; } else { print ''.$langs->trans('Finish').''."\n"; } From bf42a2ad87eefdbc2cbdb4778763f0f24383debe Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 30 Mar 2021 14:38:53 +0200 Subject: [PATCH 100/233] Close #4951 : Add TestUnit --- .../inventory/class/inventory.class.php | 4 + test/phpunit/InventoryTest.php | 382 ++++++++++++++++++ 2 files changed, 386 insertions(+) create mode 100644 test/phpunit/InventoryTest.php diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index bf34dd04efc..e872d7e353a 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -329,6 +329,7 @@ class Inventory extends CommonObject } else { $this->db->rollback(); } + return $result; } /** @@ -358,6 +359,7 @@ class Inventory extends CommonObject } else { $this->db->rollback(); } + return $result; } /** @@ -379,6 +381,7 @@ class Inventory extends CommonObject $this->db->rollback(); return -1; } + return $result; } /** @@ -400,6 +403,7 @@ class Inventory extends CommonObject $this->db->rollback(); return -1; } + return $result; } /** diff --git a/test/phpunit/InventoryTest.php b/test/phpunit/InventoryTest.php new file mode 100644 index 00000000000..1d125a0311c --- /dev/null +++ b/test/phpunit/InventoryTest.php @@ -0,0 +1,382 @@ + + * Copyright (C) 2018 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file test/phpunit/InventoryTest.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +//require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/product/inventory/class/inventory.class.php'; + +if (empty($user->id)) { + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class InventoryTest extends PHPUnit\Framework\TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return InventoryTest + */ + public function __construct() + { + parent::__construct(); + + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + /** + * setUpBeforeClass + * + * @return void + */ + public static function setUpBeforeClass():void + { + global $conf,$user,$langs,$db; + + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; + } + + /** + * tearDownAfterClass + * + * @return void + */ + public static function tearDownAfterClass():void + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + * Init phpunit tests + * + * @return void + */ + protected function setUp():void + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + } + + /** + * End phpunit tests + * + * @return void + */ + protected function tearDown():void + { + print __METHOD__."\n"; + } + + /** + * testInventoryCreate + * + * @return int + */ + public function testInventoryCreate() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Inventory($db); + $localobject->initAsSpecimen(); + $result=$localobject->create($user); + $this->assertLessThan($result, 0); + print __METHOD__." result=".$result."\n"; + return $result; + } + + /** + * testInventoryFetch + * + * @param int $id Id invoice + * @return int + * + * @depends testInventoryCreate + * The depends says test is run only if previous is ok + */ + public function testInventoryFetch($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Inventory($this->savdb); + $result=$localobject->fetch($id); + + $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + return $localobject; + } + + /** + * testInventoryUpdate + * + * @param Inventory $localobject Invoice + * @return int + * + * @depends testInventoryFetch + * The depends says test is run only if previous is ok + */ + public function testInventoryUpdate($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject->status = 9; + $localobject->title = 'test'; + $result=$localobject->update($user, $user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $localobject; + } + + + /** + * testInventoryValidate + * + * @param Inventory $localobject Invoice + * @return void + * + * @depends testInventoryUpdate + * The depends says test is run only if previous is ok + */ + public function testInventoryValidate($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $result=$localobject->validate($user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + + $this->assertLessThan($result, 0); + $this->assertEquals($localobject->status, '1'); + return $localobject; + } + + /** + * testInventorySetDraft + * + * @param Inventory $localobject Invoice + * @return void + * + * @depends testInventoryValidate + * The depends says test is run only if previous is ok + */ + public function testInventorySetDraft($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $result=$localobject->setDraft($user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + + $this->assertLessThan($result, 0); + $this->assertEquals($localobject->status, '0'); + return $localobject; + } + + /** + * testInventorySetRecorded + * + * @param Inventory $localobject Invoice + * @return void + * + * @depends testInventorySetDraft + * The depends says test is run only if previous is ok + */ + public function testInventorySetRecorded($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $result=$localobject->setRecorded($user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + + $this->assertLessThan($result, 0); + $this->assertEquals($localobject->status, '2'); + return $localobject; + } + + /** + * testInventorySetCanceled + * + * @param Inventory $localobject Invoice + * @return void + * + * @depends testInventorySetRecorded + * The depends says test is run only if previous is ok + */ + public function testInventorySetCanceled($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $result=$localobject->setCanceled($user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + + $this->assertLessThan($result, 0); + $this->assertEquals($localobject->status, '9'); + return $localobject; + } + + /** + * testInventoryOther + * + * @param Inventory $localobject Invoice + * @return int + * @depends testInventorySetRecorded + * The depends says test is run only if previous is ok + */ + public function testInventoryOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + return $localobject->id; + } + + /** + * testInventoryDelete + * + * @param int $id Id of invoice + * @return int + * @depends testInventoryOther + * The depends says test is run only if previous is ok + */ + public function testInventoryDelete($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Inventory($this->savdb); + $result=$localobject->fetch($id); + $result=$localobject->delete($user); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + return $result; + } + + /** + * Compare all public properties values of 2 objects + * + * @param Object $oA Object operand 1 + * @param Object $oB Object operand 2 + * @param boolean $ignoretype False will not report diff if type of value differs + * @param array $fieldstoignorearray Array of fields to ignore in diff + * @return array Array with differences + */ + public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) + { + $retAr=array(); + + if (get_class($oA) !== get_class($oB)) { + $retAr[]="Supplied objects are not of same class."; + } else { + $oVarsA=get_object_vars($oA); + $oVarsB=get_object_vars($oB); + $aKeys=array_keys($oVarsA); + foreach ($aKeys as $sKey) { + if (in_array($sKey, $fieldstoignorearray)) { + continue; + } + if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { + $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); + } + if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) { + $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); + } + } + } + return $retAr; + } +} From 96b450a8495e753bd6562928c36cef6b6378bf85 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Tue, 30 Mar 2021 14:58:47 +0200 Subject: [PATCH 101/233] 20210330 --- htdocs/admin/stock.php | 11 +++++++++++ htdocs/langs/en_US/stocks.lang | 1 + htdocs/langs/fr_FR/stocks.lang | 1 + 3 files changed, 13 insertions(+) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index acab698f675..570ca0c2a5a 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -673,6 +673,17 @@ if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { print "\n"; print "\n"; } + +print ''; +print ''.$langs->trans("WarehouseAskWarehouseOnThirparty").''; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('SOCIETE_ASK_FOR_WAREHOUSE'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("SOCIETE_ASK_FOR_WAREHOUSE", $arrval, $conf->global->SOCIETE_ASK_FOR_WAREHOUSE); +} + print ''; print ''.$langs->trans("WarehouseAskWarehouseDuringPropal").''; print ''; diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 8e949661c49..0e9bd11ec4d 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -62,6 +62,7 @@ EnhancedValueOfWarehouses=Warehouses value UserWarehouseAutoCreate=Create a user warehouse automatically when creating a user AllowAddLimitStockByWarehouse=Manage also value for minimum and desired stock per pairing (product-warehouse) in addition to the value for minimum and desired stock per product RuleForWarehouse=Rule for warehouses +WarehouseAskWarehouseOnThirparty=Set a warehouse on thirparty WarehouseAskWarehouseDuringPropal=Set a warehouse on Commercial proposals WarehouseAskWarehouseDuringOrder=Set a warehouse on Sale orders UserDefaultWarehouse=Set a warehouse on Users diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang index c29c3b26d82..2d2be548f3b 100644 --- a/htdocs/langs/fr_FR/stocks.lang +++ b/htdocs/langs/fr_FR/stocks.lang @@ -62,6 +62,7 @@ EnhancedValueOfWarehouses=Valorisation des stocks UserWarehouseAutoCreate=Créer automatiquement un stock/entrepôt propre à l'utilisateur lors de sa création AllowAddLimitStockByWarehouse=Gérez également les valeurs des stocks minimums et souhaités par paire (produit-entrepôt) en plus des valeurs de minimums et souhaités par produit RuleForWarehouse=Règle pour les entrepôts +WarehouseAskWarehouseOnThirparty=Définir un entrepôt sur les tiers WarehouseAskWarehouseDuringPropal=Définir un entrepôt sur les propositions WarehouseAskWarehouseDuringOrder=Définir un entrepôt sur les commandes UserDefaultWarehouse=Définir un entrepôt sur les utilisateurs From d098ca7becde5745ab8a4b637ca02bf86b28af6b Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 16:01:35 +0200 Subject: [PATCH 102/233] Update llx_10_c_regions.sql LICENSE Australia Barbados Brazil Canada --- .../install/mysql/data/llx_10_c_regions.sql | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 96ab85788ff..37394db47e0 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -12,6 +12,9 @@ -- Copyright (C) 2019~ Lao Tian <281388879@qq.com> -- Copyright (C) 2020-2021 Udo Tamm -- +-- +-- LICENSE ---------------------------------------------------------------------- +-- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or @@ -64,16 +67,32 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2305, '', 0, 'Patagonia'); +-- Australia Regions (id country=28) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 28, 2801, '', 0, 'Australia'); + + -- Austria Regions (id country=41) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 41, 4101, '', 0, 'Österreich'); +-- Barbados Regions (id country=46) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 46, 4601, '', 0, 'Barbados'); + + -- Belgium Regions (id country=2) insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2, 201, '',1,'Flandre'); insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2, 202, '',2,'Wallonie'); insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2, 203, '',3,'Bruxelles-Capitale'); +-- Brazil Regions (id country=56) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 56, 5601, '', 0, 'Brasil'); + + +-- Canada Region (id country=14) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 14, 1401, '', 0, 'Canada'); + + -- Regions France (id country=1) insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 1,'97105',3,'Guadeloupe'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 2,'97209',3,'Martinique'); @@ -197,20 +216,10 @@ insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (10,102 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 11, 1101, '', 0, 'United-States', 1); - --- Region Canada (id country=14) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 14, 1401, '', 0, 'Canada', 1); - -- Regions The Netherlands (id country=17) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 17, 1701, '', 0,'Provincies van Nederland ', 1); --- Regions Australia (id country=28) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 28, 2801, '', 0, 'Australia', 1); - --- Regions Barbados (id country=46) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 46, 4601, '', 0, 'Barbados', 1); - -- Regions Bolivia (id country=52) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5201, '', 0, 'Chuquisaca', 1); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5202, '', 0, 'La Paz', 1); @@ -222,8 +231,6 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) v INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5208, '', 0, 'El Beni', 1); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5209, '', 0, 'Pando', 1); --- Regions Brazil (id country=56) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 56, 5601, '', 0, 'Brasil', 1); -- Regions Colombie (id country=70) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 70, 7001, '', 0, 'Colombie', 1); From a9bc37c63e31cbd97cb0cd879f027489ea8d0e63 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 16:19:07 +0200 Subject: [PATCH 103/233] Update llx_20_c_departements.sql --- .../mysql/data/llx_20_c_departements.sql | 125 ++++++++++-------- 1 file changed, 67 insertions(+), 58 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 9e47a9ec050..1a6e7970cde 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -7,8 +7,12 @@ -- Copyright (C) 2007 Patrick Raguin -- Copyright (C) 2010-2016 Juanjo Menent -- Copyright (C) 2012 Sebastian Neuwert --- Copyright (C) 2012 Ricardo Schluter --- Copyright (C) 2015 Ferran Marcet +-- Copyright (C) 2012 Ricardo Schluter +-- Copyright (C) 2015 Ferran Marcet +-- Copyright (C) 2020-2021 Udo Tamm +-- +-- +-- LICENSE ---------------------------------------------------------------------- -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -25,13 +29,13 @@ -- --- WARNING ------------------------------------------------------------------- +-- WARNING --------------------------------------------------------------------- -- Do not put comments at the end of the lines, this file is parsed during -- the install and all '-' prefixed texts are removed. -- Do not concatenate the values in a single query, for the same reason. --- NOTES ---------------------------------- +-- NOTES ----------------------------------------------------------------------- -- Departements/Cantons/Provinces/States -- -- Algeria @@ -39,9 +43,11 @@ -- Argentina -- Australia -- Austria +-- Barbados -- Belgium -- Canada --- +-- France +-- Germany -- TEMPLATE ------------------------------------------------------------------------------------------------------------- @@ -139,26 +145,40 @@ INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc -- Australia States & Territories (id country=28) -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'NSW','',1,'','New South Wales'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'VIC','',1,'','Victoria'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'QLD','',1,'','Queensland'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'SA' ,'',1,'','South Australia'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'ACT','',1,'','Australia Capital Territory'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'TAS','',1,'','Tasmania'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'WA' ,'',1,'','Western Australia'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'NT' ,'',1,'','Northern Territory'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'NSW','',1,'','New South Wales'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'VIC','',1,'','Victoria'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'QLD','',1,'','Queensland'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'SA' ,'',1,'','South Australia'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'ACT','',1,'','Australia Capital Territory'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'TAS','',1,'','Tasmania'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'WA' ,'',1,'','Western Australia'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'NT' ,'',1,'','Northern Territory'); -- Austria States / Österreich Bundesländer (id country=41) -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'B','BURGENLAND','Burgenland',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'K','KAERNTEN','Kärnten',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'N','NIEDEROESTERREICH','Niederösterreich',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'O','OBEROESTERREICH','Oberösterreich',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'S','SALZBURG','Salzburg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'ST','STEIERMARK','Steiermark',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'T','TIROL','Tirol',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'V','VORARLBERG','Vorarlberg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'W','WIEN','Wien',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'B','BURGENLAND','Burgenland',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'K','KAERNTEN','Kärnten',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'N','NIEDEROESTERREICH','Niederösterreich',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'O','OBEROESTERREICH','Oberösterreich',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'S','SALZBURG','Salzburg',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'ST','STEIERMARK','Steiermark',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'T','TIROL','Tirol',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'V','VORARLBERG','Vorarlberg',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'W','WIEN','Wien',1); + + +-- Barbados Parish (id country=46) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'CC', 'Oistins', 0, 'CC', 'Christ Church'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SA', 'Greenland', 0, 'SA', 'Saint Andrew'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SG', 'Bulkeley', 0, 'SG', 'Saint George'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'JA', 'Holetown', 0, 'JA', 'Saint James'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SJ', 'Four Roads', 0, 'SJ', 'Saint John'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SB', 'Bathsheba', 0, 'SB', 'Saint Joseph'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SL', 'Crab Hill', 0, 'SL', 'Saint Lucy'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SM', 'Bridgetown', 0, 'SM', 'Saint Michael'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SP', 'Speightstown', 0, 'SP', 'Saint Peter'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SC', 'Crane', 0, 'SC', 'Saint Philip'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'ST', 'Hillaby', 0, 'ST', 'Saint Thomas'); -- Belgium Provinces (id country=2) @@ -188,12 +208,12 @@ insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401,'NL','',1,'','Newfoundland and Labrador'); --- Departements France (id country=1) -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 1,'971','97105',3,'GUADELOUPE','Guadeloupe'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 2,'972','97209',3,'MARTINIQUE','Martinique'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 3,'973','97302',3,'GUYANE','Guyane'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 4,'974','97411',3,'REUNION','Réunion'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 6,'976','97601',3,'MAYOTTE','Mayotte'); +-- France Departements (id country=1) +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 1,'971','97105',3,'GUADELOUPE','Guadeloupe'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 2,'972','97209',3,'MARTINIQUE','Martinique'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 3,'973','97302',3,'GUYANE','Guyane'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 4,'974','97411',3,'REUNION','Réunion'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 6,'976','97601',3,'MAYOTTE','Mayotte'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'01','01053',5,'AIN','Ain'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (32,'02','02408',5,'AISNE','Aisne'); @@ -293,6 +313,25 @@ insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,no insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (11,'95','95500',2,'VAL-D OISE','Val-d Oise'); +-- Germany States / Bundesländer (id country=5) +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'BW', 'BADEN-WÜRTTEMBERG', 'Baden-Württemberg'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'BY', 'BAYERN', 'Bayern'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'BE', 'BERLIN', 'Berlin'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'BB', 'BRANDENBURG', 'Brandenburg'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'HB', 'BREMEN', 'Bremen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'HH', 'HAMBURG', 'Hamburg'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'HE', 'HESSEN', 'Hessen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'MV', 'MECKLENBURG-VORPOMMERN', 'Mecklenburg-Vorpommern'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'NI', 'NIEDERSACHSEN', 'Niedersachsen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'NW', 'NORDRHEIN-WESTFALEN', 'Nordrhein-Westfalen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'RP', 'RHEINLAND-PFALZ', 'Rheinland-Pfalz'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'SL', 'SAARLAND', 'Saarland'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'SN', 'SACHSEN', 'Sachsen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'ST', 'SACHSEN-ANHALT', 'Sachsen-Anhalt'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'SH', 'SCHLESWIG-HOLSTEIN', 'Schleswig-Holstein'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'TH', 'THÜRINGEN', 'Thüringen'); + + -- Provinces Italy (id=3) insert into llx_c_departements (code_departement,fk_region,cheflieu,tncc,ncc,nom) values ('AG',315,NULL,NULL,NULL,'AGRIGENTO'); insert into llx_c_departements (code_departement,fk_region,cheflieu,tncc,ncc,nom) values ('AL',312,NULL,NULL,NULL,'ALESSANDRIA'); @@ -685,23 +724,6 @@ INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom) VALUES ('ZA', '403', '49', 3, 'ZAMORA', 'Zamora'); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom) VALUES ('Z', '402', '50', 1, 'ZARAGOZA', 'Zaragoza'); --- Provinces Germany (id country=5) -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'BW','BADEN-WÜRTTEMBERG','Baden-Württemberg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'BY','BAYERN','Bayern',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'BE','BERLIN','Berlin',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'BB','BRANDENBURG','Brandenburg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'HB','BREMEN','Bremen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'HH','HAMBURG','Hamburg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'HE','HESSEN','Hessen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'MV','MECKLENBURG-VORPOMMERN','Mecklenburg-Vorpommern',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'NI','NIEDERSACHSEN','Niedersachsen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'NW','NORDRHEIN-WESTFALEN','Nordrhein-Westfalen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'RP','RHEINLAND-PFALZ','Rheinland-Pfalz',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'SL','SAARLAND','Saarland',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'SN','SACHSEN','Sachsen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'ST','SACHSEN-ANHALT','Sachsen-Anhalt',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'SH','SCHLESWIG-HOLSTEIN','Schleswig-Holstein',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'TH','THÜRINGEN','Thüringen',1); -- Provinces Greece (id country=102) INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('66', 10201, '', 0, '', 'Αθήνα', 1); @@ -1005,19 +1027,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CU', 8601, '', 0, '', 'Cuscatlan', 1); --- Parish Barbados (id country=46) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CC', 4601, 'Oistins', 0, 'CC', 'Christ Church', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SA', 4601, 'Greenland', 0, 'SA', 'Saint Andrew', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SG', 4601, 'Bulkeley', 0, 'SG', 'Saint George', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('JA', 4601, 'Holetown', 0, 'JA', 'Saint James', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SJ', 4601, 'Four Roads', 0, 'SJ', 'Saint John', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SB', 4601, 'Bathsheba', 0, 'SB', 'Saint Joseph', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SL', 4601, 'Crab Hill', 0, 'SL', 'Saint Lucy', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SM', 4601, 'Bridgetown', 0, 'SM', 'Saint Michael', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SP', 4601, 'Speightstown', 0, 'SP', 'Saint Peter', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SC', 4601, 'Crane', 0, 'SC', 'Saint Philip', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ST', 4601, 'Hillaby', 0, 'ST', 'Saint Thomas', 1); - -- Provinces Brazil (id country=56) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AC', 5601, 'ACRE', 0, 'AC', 'Acre', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AL', 5601, 'ALAGOAS', 0, 'AL', 'Alagoas', 1); From 6e422d26f33f31e59ef0e067988a00e3bf71db2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 11:36:50 +0200 Subject: [PATCH 104/233] FIX #yogosha5746 - next step (wip) --- htdocs/accountancy/admin/categories_list.php | 2 +- .../class/accountancycategory.class.php | 2 +- .../class/accountancyexport.class.php | 4 +- htdocs/accountancy/journal/bankjournal.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 4 +- .../comm/propal/class/propalestats.class.php | 6 +- htdocs/commande/class/commande.class.php | 6 +- htdocs/commande/class/commandestats.class.php | 4 +- .../bank/class/paymentvarious.class.php | 2 +- htdocs/compta/bank/releve.php | 3 +- .../cashcontrol/class/cashcontrol.class.php | 2 +- htdocs/compta/facture/card.php | 2 +- .../facture/class/facture-rec.class.php | 6 +- htdocs/compta/facture/class/facture.class.php | 11 +- .../facture/class/facturestats.class.php | 4 +- .../compta/localtax/class/localtax.class.php | 4 +- .../compta/paiement/class/cpaiement.class.php | 2 +- .../compta/paiement/class/paiement.class.php | 6 +- .../sociales/class/cchargesociales.class.php | 2 +- htdocs/core/class/commoninvoice.class.php | 2 +- htdocs/core/class/commonobject.class.php | 18 +-- htdocs/core/class/dolreceiptprinter.class.php | 2 +- .../expensereport/mod_expensereport_jade.php | 2 +- .../modules/import/import_csv.modules.php | 4 +- .../modules/import/import_xlsx.modules.php | 4 +- htdocs/don/class/donstats.class.php | 2 +- .../class/conferenceorbooth.class.php | 2 +- .../class/expeditionstats.class.php | 4 +- .../class/expensereport.class.php | 4 +- .../class/expensereport_rule.class.php | 2 +- htdocs/fichinter/class/fichinterrec.class.php | 8 +- .../fichinter/class/fichinterstats.class.php | 4 +- .../fournisseur.commande.dispatch.class.php | 4 +- .../fourn/class/fournisseur.facture.class.php | 4 +- htdocs/install/lib/repair.lib.php | 2 +- htdocs/install/repair.php | 4 +- htdocs/install/upgrade2.php | 2 +- .../class/multicurrency.class.php | 2 +- htdocs/product/class/product.class.php | 4 +- .../class/productfournisseurprice.class.php | 113 ++++++------------ htdocs/product/fournisseurs.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 4 +- .../stock/class/mouvementstock.class.php | 2 +- .../class/productstockentrepot.class.php | 2 +- .../product/stock/lib/replenishment.lib.php | 4 +- htdocs/product/stock/replenish.php | 2 +- htdocs/product/stock/stockatdate.php | 2 +- htdocs/projet/tasks/time.php | 6 +- htdocs/public/emailing/mailing-read.php | 6 +- htdocs/salaries/class/salary.class.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- .../class/supplier_proposal.class.php | 2 +- .../variants/class/ProductAttribute.class.php | 2 +- htdocs/website/class/websitepage.class.php | 4 +- htdocs/zapier/class/hook.class.php | 4 +- 56 files changed, 140 insertions(+), 175 deletions(-) diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index deae39aef54..c61674921f1 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -149,7 +149,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { // Check that all fields are filled $ok = 1; foreach ($listfield as $f => $value) { - if ($value == 'formula' && empty($_POST['formula'])) { + if ($value == 'formula' && !GETPOST('formula')) { continue; } if ($value == 'range_account' && empty($_POST['range_account'])) { diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 1bdc0f438bf..9301c809125 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -863,7 +863,7 @@ class AccountancyCategory // extends CommonObject if (!empty($cat_id)) { $sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = ".$cat_id; + $sql .= " WHERE t.fk_accounting_category = ".((int) $cat_id); $sql .= " AND t.entity = ".$conf->entity; $sql .= " ORDER BY t.account_number"; } else { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index ac8c3db644b..ad3e863cc8c 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1644,7 +1644,7 @@ class AccountancyExport // Get new customer invoice ref and company name $sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; - $sql .= ' WHERE f.rowid = ' . $line->fk_doc; + $sql .= ' WHERE f.rowid = '.((int) $line->fk_doc); $resql = $this->db->query($sql); if ($resql) { if ($obj = $this->db->fetch_object($resql)) { @@ -1658,7 +1658,7 @@ class AccountancyExport // Get new supplier invoice ref and company name $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid'; - $sql .= ' WHERE ff.rowid = ' . $line->fk_doc; + $sql .= ' WHERE ff.rowid = '.((int) $line->fk_doc); $resql = $this->db->query($sql); if ($resql) { if ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 9093721bff6..9878f67890c 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -421,7 +421,7 @@ if ($result) { //$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount; $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; - $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.$obj->rowid; + $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 4bef5ddcd16..715da90f3a7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1367,7 +1367,7 @@ class ActionComm extends CommonObject $sql .= ' fk_user_author,'; $sql .= ' fk_user_mod'; $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql .= ' WHERE a.id = '.$id; + $sql .= ' WHERE a.id = '.((int) $id); dol_syslog(get_class($this)."::info", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0388768fc1f..32206a0c251 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2997,7 +2997,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; - $sql .= ' SET fk_availability = '.$availability_id; + $sql .= ' SET fk_availability = '.((int) $availability_id); $sql .= ' WHERE rowid='.((int) $this->id); dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG); @@ -3061,7 +3061,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; - $sql .= ' SET fk_input_reason = '.$demand_reason_id; + $sql .= ' SET fk_input_reason = '.((int) $demand_reason_id); $sql .= ' WHERE rowid='.((int) $this->id); dol_syslog(__METHOD__.' demand_reason('.$demand_reason_id.')', LOG_DEBUG); diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index f64bc31c6ac..a06945a09a6 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -100,18 +100,18 @@ class PropaleStats extends Stats $this->where .= " AND p.fk_soc = ".$this->socid; } if ($this->userid > 0) { - $this->where .= ' AND fk_user_author = '.$this->userid; + $this->where .= ' AND fk_user_author = '.((int) $this->userid); } if ($typentid) { $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; - $this->where .= ' AND s.fk_typent = '.$typentid; + $this->where .= ' AND s.fk_typent = '.((int) $typentid); } if ($categid) { $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = p.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; - $this->where .= ' AND c.rowid = '.$categid; + $this->where .= ' AND c.rowid = '.((int) $categid); } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2f2f0a4d81c..607753d90fa 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2417,7 +2417,7 @@ class Commande extends CommonOrder $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql .= ' SET remise_percent = '.((float) $remise); - $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -2743,7 +2743,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql .= ' SET fk_availability = '.$availability_id; + $sql .= ' SET fk_availability = '.((int) $availability_id); $sql .= ' WHERE rowid='.((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); @@ -2807,7 +2807,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql .= ' SET fk_input_reason = '.$demand_reason_id; + $sql .= ' SET fk_input_reason = '.((int) $demand_reason_id); $sql .= ' WHERE rowid='.((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index a266dc0c4cf..85036543e18 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -100,13 +100,13 @@ class CommandeStats extends Stats if ($typentid) { $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = c.fk_soc'; - $this->where .= ' AND s.fk_typent = '.$typentid; + $this->where .= ' AND s.fk_typent = '.((int) $typentid); } if ($categid) { $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie'; - $this->where .= ' AND cat.rowid = '.$categid; + $this->where .= ' AND cat.rowid = '.((int) $categid); } } diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index dccdcd5cd24..86a70a35311 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -572,7 +572,7 @@ class PaymentVarious extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.((int) $id_bank); $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index dc71a1d2d27..010b4a08fde 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -179,7 +179,8 @@ $sqlrequestforbankline = $sql; if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { // TODO Add a test to check newbankreceipt does not exists yet - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.$id; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank'; + $sqlupdate .= ' SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.((int) $id); $result = $db->query($sqlupdate); if ($result < 0) { dol_print_error($db); diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 1563309a3c4..cfd201e3ec4 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -213,7 +213,7 @@ class CashControl extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."pos_cash_fence"); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'pos_cash_fence SET ref = rowid where rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'pos_cash_fence SET ref = rowid where rowid = '.((int) $this->id); $this->db->query($sql); } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b891ae6eec7..bf30e2b011f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3091,7 +3091,7 @@ if ($action == 'create') { $sql = 'SELECT r.rowid, r.titre as title, r.total_ttc'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as r'; - $sql .= ' WHERE r.fk_soc = '.$invoice_predefined->socid; + $sql .= ' WHERE r.fk_soc = '.((int) $invoice_predefined->socid); $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 674b5917b17..b93f48ff655 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1808,7 +1808,7 @@ class FactureRec extends CommonInvoice } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET nb_gen_max = '.$nb; + $sql .= ' SET nb_gen_max = '.((int) $nb); $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); @@ -1835,7 +1835,7 @@ class FactureRec extends CommonInvoice } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET auto_validate = '.$validate; + $sql .= ' SET auto_validate = '.((int) $validate); $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); @@ -1862,7 +1862,7 @@ class FactureRec extends CommonInvoice } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET generate_pdf = '.$validate; + $sql .= ' SET generate_pdf = '.((int) $validate); $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 111ace7c415..7e9300be61c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2282,9 +2282,9 @@ class Facture extends CommonInvoice // Invoice line extrafileds $main = MAIN_DB_PREFIX.'facturedet'; $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture = ".((int) $rowid); // Delete invoice line - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.((int) $rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); @@ -3585,8 +3585,7 @@ class Facture extends CommonInvoice { $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd INNER JOIN '.MAIN_DB_PREFIX.'facture f ON (fd.fk_facture = f.rowid) - WHERE fd.fk_prev_id = '.$idline.' - AND f.fk_statut <> 0'; + WHERE fd.fk_prev_id = '.((int) $idline).' AND f.fk_statut <> 0'; $result = $this->db->query($sql); if (!$result) { @@ -3663,7 +3662,7 @@ class Facture extends CommonInvoice // Libere remise liee a ligne de facture $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql .= ' SET fk_facture_line = NULL'; - $sql .= ' WHERE fk_facture_line = '.$rowid; + $sql .= ' WHERE fk_facture_line = '.((int) $rowid); dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $result = $this->db->query($sql); @@ -4610,7 +4609,7 @@ class Facture extends CommonInvoice $this->db->begin(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$this->situation_final.' where rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$this->situation_final.' where rowid = '.((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 47644e4b13e..31c4704bb77 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -105,13 +105,13 @@ class FactureStats extends Stats if ($typentid) { $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = f.fk_soc'; - $this->where .= ' AND s.fk_typent = '.$typentid; + $this->where .= ' AND s.fk_typent = '.((int) $typentid); } if ($categid) { $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = f.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; - $this->where .= ' AND c.rowid = '.$categid; + $this->where .= ' AND c.rowid = '.((int) $categid); } } diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 46b2b2b7805..2adfe41330b 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -559,8 +559,8 @@ class Localtax extends CommonObject public function update_fk_bank($id) { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.$id; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.((int) $id); + $sql .= ' WHERE rowid = '.((int) $this->id); $result = $this->db->query($sql); if ($result) { return 1; diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index d1cd1f0015b..e9623f55c11 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -187,7 +187,7 @@ class Cpaiement $sql .= ' WHERE t.entity IN ('.getEntity('c_paiement').')'; $sql .= " AND t.code = '".$this->db->escape($ref)."'"; } else { - $sql .= ' WHERE t.id = '.$id; + $sql .= ' WHERE t.id = '.((int) $id); } $resql = $this->db->query($sql); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 9dcc57a47f2..5647295d171 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -736,7 +736,7 @@ class Paiement extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.((int) $id_bank); $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this).'::update_fk_bank', LOG_DEBUG); @@ -855,7 +855,7 @@ class Paiement extends CommonObject */ public function validate(User $user = null) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this).'::valide', LOG_DEBUG); $result = $this->db->query($sql); @@ -876,7 +876,7 @@ class Paiement extends CommonObject */ public function reject(User $user = null) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 2 WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 2 WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this).'::reject', LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 4ae06f378b8..8cfadd84f4f 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -190,7 +190,7 @@ class Cchargesociales if (null !== $ref) { $sql .= " WHERE t.code = '".$this->db->escape($ref)."'"; } else { - $sql .= ' WHERE t.id = '.$id; + $sql .= ' WHERE t.id = '.((int) $id); } $resql = $this->db->query($sql); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 6366cf52756..50d94da8531 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -801,7 +801,7 @@ abstract class CommonInvoice extends CommonObject { // phpcs:enable $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - $sql .= ' WHERE rowid = '.$did; + $sql .= ' WHERE rowid = '.((int) $did); $sql .= ' AND traite = 0'; if ($this->db->query($sql)) { return 0; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 48e92d58172..410c896d329 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2332,7 +2332,7 @@ abstract class CommonObject $fieldname = 'multicurrency_tx'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$rate; + $sql .= ' SET '.$fieldname.' = '.((float) $rate); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2617,7 +2617,7 @@ abstract class CommonObject $fieldname = 'retained_warranty_fk_cond_reglement'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' SET '.$fieldname.' = '.((int) $id); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -3062,11 +3062,11 @@ abstract class CommonObject $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; $sql .= ' AND rang = '.($rang - 1); if ($this->db->query($sql)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang - 1); + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang - 1)); $sql .= ' WHERE rowid = '.((int) $rowid); if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -3093,11 +3093,11 @@ abstract class CommonObject $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; - $sql .= ' AND rang = '.($rang + 1); + $sql .= ' AND rang = '.((int) ($rang + 1)); if ($this->db->query($sql)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang + 1); + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang + 1)); $sql .= ' WHERE rowid = '.((int) $rowid); if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -4221,7 +4221,7 @@ abstract class CommonObject public function getSpecialCode($lineid) { $sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE rowid = '.$lineid; + $sql .= ' WHERE rowid = '.((int) $lineid); $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); @@ -7656,7 +7656,7 @@ abstract class CommonObject public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) { foreach ($tables as $table) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.$dest_id.' WHERE fk_soc = '.$origin_id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id); if (!$db->query($sql)) { if ($ignoreerrors) { diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 49eda053b8d..be13eb94849 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -879,7 +879,7 @@ class dolReceiptPrinter extends Printer $error = 0; $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE rowid = '.$printerid; + $sql .= ' WHERE rowid = '.((int) $printerid); $sql .= ' AND entity = '.$conf->entity; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index bbe2245a97d..b25ac15345b 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -163,7 +163,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport } $newref = str_replace(' ', '_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut, '%y%m%d'); - $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; + $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.((int) $ref_number_int).' WHERE rowid = '.((int) $object->id); $resqlbis = $db->query($sqlbis); if (!$resqlbis) { dol_print_error($resqlbis); diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 63a28fbe3d2..1768029b97e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -790,7 +790,7 @@ class ImportCsv extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; + $sqlSelect .= ' WHERE '.$keyfield.' = '.((int) $lastinsertid); $resql = $this->db->query($sqlSelect); if ($resql) { @@ -824,7 +824,7 @@ class ImportCsv extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; + $sqlend = ' WHERE '.$keyfield.' = '.((int) $lastinsertid); $sql = $sqlstart.$sqlend; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 257e8f5253e..bc146c5ece7 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -830,7 +830,7 @@ class ImportXlsx extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlSelect .= ' WHERE ' . $keyfield . ' = ' . $lastinsertid; + $sqlSelect .= ' WHERE ' . $keyfield . ' = ' .((int) $lastinsertid); $resql = $this->db->query($sqlSelect); if ($resql) { @@ -864,7 +864,7 @@ class ImportXlsx extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlend = ' WHERE ' . $keyfield . ' = ' . $lastinsertid; + $sqlend = ' WHERE ' . $keyfield . ' = '.((int) $lastinsertid); $sql = $sqlstart . $sqlend; diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index e3deff2dc2d..07eb6d6588e 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -85,7 +85,7 @@ class DonationStats extends Stats //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; $this->where .= " AND d.entity = ".$conf->entity; if ($this->userid > 0) { - $this->where .= ' WHERE c.fk_user_author = '.$this->userid; + $this->where .= ' WHERE c.fk_user_author = '.((int) $this->userid); } } diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index d91181d0c51..f4914148f44 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -694,7 +694,7 @@ class ConferenceOrBooth extends ActionComm $sql = 'SELECT rowid, datec as datec, tms as datem,'; $sql .= ' fk_user_author, fk_user_mod'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.id = '.$id; + $sql .= ' WHERE t.id = '.((int) $id); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { diff --git a/htdocs/expedition/class/expeditionstats.class.php b/htdocs/expedition/class/expeditionstats.class.php index 50382cef164..d25c7b52098 100644 --- a/htdocs/expedition/class/expeditionstats.class.php +++ b/htdocs/expedition/class/expeditionstats.class.php @@ -77,10 +77,10 @@ class ExpeditionStats extends Stats $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($this->socid) { - $this->where .= " AND c.fk_soc = ".$this->socid; + $this->where .= " AND c.fk_soc = ".((int) $this->socid); } if ($this->userid > 0) { - $this->where .= ' AND c.fk_user_author = '.$this->userid; + $this->where .= ' AND c.fk_user_author = '.((int) $this->userid); } } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 681675fd54c..d9b58667574 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -973,7 +973,7 @@ class ExpenseReport extends CommonObject { $sql = 'SELECT tt.total_ht, tt.total_ttc, tt.total_tva'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as tt'; - $sql .= ' WHERE tt.'.$this->fk_element.' = '.$id; + $sql .= ' WHERE tt.'.$this->fk_element.' = '.((int) $id); $total_ht = 0; $total_tva = 0; $total_ttc = 0; @@ -2757,7 +2757,7 @@ class ExpenseReportLine $sql = 'SELECT SUM(d.total_ttc) as total_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det d'; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'expensereport e ON (d.fk_expensereport = e.rowid)'; - $sql .= ' WHERE e.fk_user_author = '.$fk_user; + $sql .= ' WHERE e.fk_user_author = '.((int) $fk_user); if (!empty($this->id)) { $sql .= ' AND d.rowid <> '.$this->id; } diff --git a/htdocs/expensereport/class/expensereport_rule.class.php b/htdocs/expensereport/class/expensereport_rule.class.php index 4e4d1009750..653f030b6d2 100644 --- a/htdocs/expensereport/class/expensereport_rule.class.php +++ b/htdocs/expensereport/class/expensereport_rule.class.php @@ -167,7 +167,7 @@ class ExpenseReportRule extends CoreObject if ($fk_user > 0) { $sql .= ' AND (er.is_for_all = 1'; $sql .= ' OR er.fk_user = '.$fk_user; - $sql .= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.$fk_user.') )'; + $sql .= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.((int) $fk_user).') )'; } $sql .= ' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user'; diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 8ed842a70c9..960a2734706 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -784,8 +784,8 @@ class FichinterRec extends Fichinter } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET nb_gen_max = '.$nb; - $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' SET nb_gen_max = '.((int) $nb); + $sql .= ' WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); if ($this->db->query($sql)) { @@ -811,8 +811,8 @@ class FichinterRec extends Fichinter } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET auto_validate = '.$validate; - $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' SET auto_validate = '.((int) $validate); + $sql .= ' WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); if ($this->db->query($sql)) { diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index a0d22cf1e2a..2daede1457a 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -78,10 +78,10 @@ class FichinterStats extends Stats $this->where .= ($this->where ? ' AND ' : '')."c.entity IN (".getEntity('fichinter').')'; if ($this->socid) { - $this->where .= " AND c.fk_soc = ".$this->socid; + $this->where .= " AND c.fk_soc = ".((int) $this->socid); } if ($this->userid > 0) { - $this->where .= ' AND c.fk_user_author = '.$this->userid; + $this->where .= ' AND c.fk_user_author = '.((int) $this->userid); } } diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 21c36ced633..0f8b8341a3d 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -674,8 +674,10 @@ class CommandeFournisseurDispatch extends CommonObject $sqlwhere [] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } elseif ($key == 't.datec' || $key == 't.tms' || $key == 't.eatby' || $key == 't.sellby' || $key == 't.batch') { $sqlwhere [] = $key.' = \''.$this->db->escape($value).'\''; + } elseif ($key == 'qty') { + $sqlwhere [] = $key.' = '.((float) $value); } else { - $sqlwhere [] = $key.' = '.$this->db->escape($value); + $sqlwhere [] = $key.' = '.((int) $value); } } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 73e8be88c37..ab7e6ea3fc4 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1181,7 +1181,7 @@ class FactureFournisseur extends CommonInvoice if (!$error) { // If invoice was converted into a discount not yet consumed, we remove discount $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql .= ' WHERE fk_invoice_supplier_source = '.$rowid; + $sql .= ' WHERE fk_invoice_supplier_source = '.((int) $rowid); $sql .= ' AND fk_invoice_supplier_line IS NULL'; $resql = $this->db->query($sql); @@ -2092,7 +2092,7 @@ class FactureFournisseur extends CommonInvoice // Libere remise liee a ligne de facture $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql .= ' SET fk_invoice_supplier_line = NULL'; - $sql .= ' WHERE fk_invoice_supplier_line = '.$rowid; + $sql .= ' WHERE fk_invoice_supplier_line = '.((int) $rowid); dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/install/lib/repair.lib.php b/htdocs/install/lib/repair.lib.php index 6133f3eccc8..242fbff25d4 100644 --- a/htdocs/install/lib/repair.lib.php +++ b/htdocs/install/lib/repair.lib.php @@ -106,7 +106,7 @@ function checkLinkedElements($sourcetype, $targettype) foreach ($elements as $key => $element) { if (!checkElementExist($element[$sourcetype], $sourcetable) || !checkElementExist($element[$targettype], $targettable)) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'element_element'; - $sql .= ' WHERE rowid = '.$key; + $sql .= ' WHERE rowid = '.((int) $key); $resql = $db->query($sql); $deleted++; } diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 9357128d050..1eb980ae173 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1347,8 +1347,8 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { $qty_for_line = min($remaining_qty, $obj_line->qty); if ($first_iteration) { $sql_attach = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; - $sql_attach .= ' SET fk_commandefourndet = '.$obj_line->rowid.', qty = '.$qty_for_line; - $sql_attach .= ' WHERE rowid = '.$obj_dispatch->rowid; + $sql_attach .= ' SET fk_commandefourndet = '.((int) $obj_line->rowid).', qty = '.((float) $qty_for_line); + $sql_attach .= ' WHERE rowid = '.((int) $obj_dispatch->rowid); $first_iteration = false; } else { $sql_attach_values = array( diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index ec322733c7d..de4ff58d018 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1342,7 +1342,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons. $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn'; $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; - $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; + $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.((int) $select_obj->fk_facture_fourn); $check_resql = $db->query($check_sql); if ($check_resql) { $check_num = $db->num_rows($check_resql); diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 7886bd35774..5067a6e91d5 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -591,7 +591,7 @@ class MultiCurrency extends CommonObject { global $db; - $sql = 'SELECT multicurrency_tx FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.$fk_facture; + $sql = 'SELECT multicurrency_tx FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.((int) $fk_facture); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4ae3d682c07..ad3b694f137 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3862,7 +3862,7 @@ class Product extends CommonObject // Check not already father of id_pere (to avoid father -> child -> father links) $sql = 'SELECT fk_product_pere from '.MAIN_DB_PREFIX.'product_association'; - $sql .= ' WHERE fk_product_pere = '.$id_fils.' AND fk_product_fils = '.$id_pere; + $sql .= ' WHERE fk_product_pere = '.((int) $id_fils).' AND fk_product_fils = '.((int) $id_pere); if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; @@ -3875,7 +3875,7 @@ class Product extends CommonObject return -1; } else { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec)'; - $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.')'; + $sql .= ' VALUES ('.((int) $id_pere).', '.((int) $id_fils).', '.((float) $qty).', '.((int) $incdec).')'; if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; diff --git a/htdocs/product/class/productfournisseurprice.class.php b/htdocs/product/class/productfournisseurprice.class.php index 71e25b0c4e1..13fa8433d07 100644 --- a/htdocs/product/class/productfournisseurprice.class.php +++ b/htdocs/product/class/productfournisseurprice.class.php @@ -181,10 +181,8 @@ class ProductFournisseurPrice extends CommonObject if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } @@ -241,14 +239,11 @@ class ProductFournisseurPrice extends CommonObject if (property_exists($object, 'date_modification')) { $object->date_modification = null; } // ... // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { + if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach ($object->array_options as $key => $option) - { + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) - { + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } @@ -264,20 +259,16 @@ class ProductFournisseurPrice extends CommonObject $this->errors = $object->errors; } - if (!$error) - { + if (!$error) { // copy internal contacts - if ($this->copy_linked_contact($object, 'internal') < 0) - { + if ($this->copy_linked_contact($object, 'internal') < 0) { $error++; } } - if (!$error) - { + if (!$error) { // copy external contacts if same company - if (property_exists($this, 'socid') && $this->socid == $object->socid) - { + if (property_exists($this, 'socid') && $this->socid == $object->socid) { if ($this->copy_linked_contact($object, 'external') < 0) $error++; } @@ -362,8 +353,7 @@ class ProductFournisseurPrice extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) - { + while ($i < ($limit ? min($limit, $num) : $num)) { $obj = $this->db->fetch_object($resql); $record = new self($this->db); @@ -424,8 +414,7 @@ class ProductFournisseurPrice extends CommonObject $error = 0; // Protection - if ($this->status == self::STATUS_VALIDATED) - { + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); return 0; } @@ -435,8 +424,7 @@ class ProductFournisseurPrice extends CommonObject $this->db->begin(); // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef(); } else { $num = $this->ref; @@ -454,15 +442,13 @@ class ProductFournisseurPrice extends CommonObject dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $this->error = $this->db->lasterror(); $error++; } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('PRODUCTFOURNISSEURPRICE_VALIDATE', $user); if ($result < 0) $error++; @@ -470,13 +456,11 @@ class ProductFournisseurPrice extends CommonObject } } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'productfournisseurprice/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'productfournisseurprice/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; @@ -488,17 +472,14 @@ class ProductFournisseurPrice extends CommonObject $newref = dol_sanitizeFileName($num); $dirsource = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$oldref; $dirdest = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -511,14 +492,12 @@ class ProductFournisseurPrice extends CommonObject } // Set new ref and current status - if (!$error) - { + if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -538,8 +517,7 @@ class ProductFournisseurPrice extends CommonObject public function setDraft($user, $notrigger = 0) { // Protection - if ($this->status <= self::STATUS_DRAFT) - { + if ($this->status <= self::STATUS_DRAFT) { return 0; } @@ -556,8 +534,7 @@ class ProductFournisseurPrice extends CommonObject public function cancel($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_VALIDATED) - { + if ($this->status != self::STATUS_VALIDATED) { return 0; } @@ -574,8 +551,7 @@ class ProductFournisseurPrice extends CommonObject public function reopen($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_CANCELED) - { + if ($this->status != self::STATUS_CANCELED) { return 0; } @@ -609,8 +585,7 @@ class ProductFournisseurPrice extends CommonObject $url = dol_buildpath('/buypricehistory/productfournisseurprice_card.php', 1).'?id='.$this->id; - if ($option != 'nolink') - { + if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; @@ -618,10 +593,8 @@ class ProductFournisseurPrice extends CommonObject } $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowProductFournisseurPrice"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -699,8 +672,7 @@ class ProductFournisseurPrice extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("buypricehistory@buypricehistory"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); @@ -729,30 +701,25 @@ class ProductFournisseurPrice extends CommonObject $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql .= ' fk_user_creat, fk_user_modif'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.rowid = '.$id; + $sql .= ' WHERE t.rowid = '.((int) $id); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) - { + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; @@ -794,8 +761,7 @@ class ProductFournisseurPrice extends CommonObject $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON = 'mod_productfournisseurprice_standard'; } - if (!empty($conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON)) - { + if (!empty($conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON)) { $mybool = false; $file = $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON.".php"; @@ -803,16 +769,14 @@ class ProductFournisseurPrice extends CommonObject // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/buypricehistory/"); // Load file with numbering class (if found) $mybool |= @include_once $dir.$file; } - if ($mybool === false) - { + if ($mybool === false) { dol_print_error('', "Failed to include file ".$file); return ''; } @@ -821,8 +785,7 @@ class ProductFournisseurPrice extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($this); - if ($numref != '' && $numref != '-1') - { + if ($numref != '' && $numref != '-1') { return $numref; } else { $this->error = $obj->error; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index ff18c361ff9..cde318cda81 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -290,7 +290,7 @@ if (empty($reshook)) { foreach ($extrafield_values as $key => $value) { $sql .= str_replace('options_', '', $key).' = "'.$value.'", '; } - $sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.$object->product_fourn_price_id; + $sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.((int) $object->product_fourn_price_id); } // Execute the sql command from above diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 327c428e9c9..214a12ead14 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -782,7 +782,7 @@ class Entrepot extends CommonObject $parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents $i = 0; while ($parentid > 0 && $i < $protection) { - $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.$parentid; + $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.((int) $parentid); $resql = $this->db->query($sql); if ($resql) { $objarbo = $this->db->fetch_object($resql); @@ -817,7 +817,7 @@ class Entrepot extends CommonObject $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'entrepot - WHERE fk_parent = '.$id; + WHERE fk_parent = '.((int) $id); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 102e3ba1700..74803f63909 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -896,7 +896,7 @@ class MouvementStock extends CommonObject $nb = 0; $sql = 'SELECT SUM(value) as nb from '.MAIN_DB_PREFIX.'stock_mouvement'; - $sql .= ' WHERE fk_product = '.$productidselected; + $sql .= ' WHERE fk_product = '.((int) $productidselected); $sql .= " AND datem < '".$this->db->idate($datebefore)."'"; dol_syslog(get_class($this).__METHOD__.'', LOG_DEBUG); diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 88fc636e07e..aea8c3e1f14 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -196,7 +196,7 @@ class ProductStockEntrepot extends CommonObject if (!empty($id)) { $sql .= ' WHERE t.rowid = '.((int) $id); } else { - $sql .= ' WHERE t.fk_product = '.$fk_product.' AND t.fk_entrepot = '.$fk_entrepot; + $sql .= ' WHERE t.fk_product = '.((int) $fk_product).' AND t.fk_entrepot = '.((int) $fk_entrepot); } $resql = $this->db->query($sql); diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php index d0415ccad78..1faa67ad860 100644 --- a/htdocs/product/stock/lib/replenishment.lib.php +++ b/htdocs/product/stock/lib/replenishment.lib.php @@ -39,7 +39,7 @@ function dolDispatchToDo($order_id) // Count nb of quantity dispatched per product $sql = 'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; - $sql .= ' WHERE fk_commande = '.$order_id; + $sql .= ' WHERE fk_commande = '.((int) $order_id); $sql .= ' GROUP BY fk_product'; $sql .= ' ORDER by fk_product'; $resql = $db->query($sql); @@ -51,7 +51,7 @@ function dolDispatchToDo($order_id) // Count nb of quantity to dispatch per product $sql = 'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet'; - $sql .= ' WHERE fk_commande = '.$order_id; + $sql .= ' WHERE fk_commande = '.((int) $order_id); $sql .= ' AND fk_product > 0'; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $sql .= ' AND product_type = 0'; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 904fa9b7e94..b282984cef5 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -756,7 +756,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if (!empty($conf->global->MAIN_MULTILANGS)) { $sql = 'SELECT label,description'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; - $sql .= ' WHERE fk_product = '.$objp->rowid; + $sql .= ' WHERE fk_product = '.((int) $objp->rowid); $sql .= ' AND lang = "'.$langs->getDefaultLang().'"'; $sql .= ' LIMIT 1'; diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index bdac3a70f54..d9a9be0cd70 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -487,7 +487,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { { $sql = 'SELECT label,description'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; - $sql .= ' WHERE fk_product = '.$objp->rowid; + $sql .= ' WHERE fk_product = '.((int) $objp->rowid); $sql .= ' AND lang = "'.$langs->getDefaultLang().'"'; $sql .= ' LIMIT 1'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 54f622b95a1..1c3cacb4cee 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -428,7 +428,7 @@ if ($action == 'confirm_generateinvoice') { $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $result = $db->query($sql); if (!$result) { @@ -467,7 +467,7 @@ if ($action == 'confirm_generateinvoice') { $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $result = $db->query($sql); if (!$result) { @@ -503,7 +503,7 @@ if ($action == 'confirm_generateinvoice') { $lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).')'; $result = $db->query($sql); if (!$result) { diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index 454201203cc..91418707d3a 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -122,19 +122,19 @@ if (!empty($tag)) { //Update status of target $statut = '2'; - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE rowid = ".((int) $obj->rowid); + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".((int) $statut)." WHERE rowid = ".((int) $obj->rowid); $resql = $db->query($sql); if (!$resql) dol_print_error($db); //Update status communication of thirdparty prospect if ($obj->source_id > 0 && $obj->source_type == 'thirdparty' && $obj->entity) { - $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid = '.$obj->source_id; + $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid = '.((int) $obj->source_id); $resql = $db->query($sql); } //Update status communication of contact prospect if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) { - $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.$obj->source_id.')'; + $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '((int) $obj->source_id).')'; $resql = $db->query($sql); } } diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index fdd1bfd7f73..85ccfc0a1db 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -463,7 +463,7 @@ class Salary extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.$id_bank; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.((int) $id_bank); $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7746001dea7..99453db7ac4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4620,7 +4620,7 @@ class Societe extends CommonObject $resql = $db->query($sql); while ($obj = $db->fetch_object($resql)) { - $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.$obj->rowid); + $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.((int) $obj->rowid)); } /** diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index bbb06f2a2da..0320a663ea8 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1777,7 +1777,7 @@ class SupplierProposal extends CommonObject $price = price2num($product->subprice * $product->qty, 'MU'); $unitPrice = price2num($product->subprice, 'MU'); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$this->db->escape($product->ref_fourn).'", ' : '').' price ='.((float) $price).', unitprice ='.((float) $unitPrice).' WHERE rowid = '.((int) $idProductFournPrice); $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index a4e9f92eb10..1e7f44bb936 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -319,7 +319,7 @@ class ProductAttribute extends CommonObject $newrang = $this->rang + 1; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_attribute SET rang = '.$this->rang.' WHERE rang = '.$newrang; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_attribute SET rang = '.((int) $this->rang).' WHERE rang = '.((int) $newrang); if (!$this->db->query($sql)) { $this->db->rollback(); diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 3dbdb353a3e..32c8c0b8688 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -407,7 +407,7 @@ class WebsitePage extends CommonObject $sql .= " t.object_type,"; $sql .= " t.fk_object"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.fk_website = '.$websiteid; + $sql .= ' WHERE t.fk_website = '.((int) $websiteid); // Manage filter (same than into countAll) $sqlwhere = array(); if (count($filter) > 0) { @@ -509,7 +509,7 @@ class WebsitePage extends CommonObject $sql = 'SELECT COUNT(t.rowid) as nb'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.fk_website = '.$websiteid; + $sql .= ' WHERE t.fk_website = '.((int) $websiteid); // Manage filter (same than into fetchAll) $sqlwhere = array(); if (count($filter) > 0) { diff --git a/htdocs/zapier/class/hook.class.php b/htdocs/zapier/class/hook.class.php index 92066e496e2..5197296f659 100644 --- a/htdocs/zapier/class/hook.class.php +++ b/htdocs/zapier/class/hook.class.php @@ -416,13 +416,13 @@ class Hook extends CommonObject $sql .= ' t.rowid'; // TODO Get all fields $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.entity = '.$conf->entity; + $sql .= ' WHERE t.entity = '.((int) $conf->entity); // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.rowid') { - $sqlwhere[] = $key.'='.$value; + $sqlwhere[] = $key.' = '.((int) $value); } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; } elseif ($key == 'customsql') { From 804fbd421d9c97f36e795b96b9b00c7c6fd64275 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 16:44:41 +0200 Subject: [PATCH 105/233] Update card.php --- htdocs/product/composition/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 6dd6a0ac89d..442232686d3 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -171,11 +171,11 @@ $help_url = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('AssociatedProducts'); - $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('AssociatedProducts'); - $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen'; } llxHeader('', $title, $help_url); From 7a4303183525dc3746105dc5a02bd055d1be073c Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 17:14:11 +0200 Subject: [PATCH 106/233] Update CODE_OF_CONDUCT.md https --- .github/CODE_OF_CONDUCT.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 9a84fdbbda0..1c46e8e2d50 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -77,8 +77,8 @@ contact@dolibarr.org ## 10. License and attribution -This Code of Conduct is distributed under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). +This Code of Conduct is distributed under a [Creative Commons Attribution-ShareAlike license](https://creativecommons.org/licenses/by-sa/3.0/). -Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). +Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](https://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). -Retrieved on November 22, 2016 from [http://citizencodeofconduct.org/](http://citizencodeofconduct.org/) +Retrieved on November 22, 2016 from [https://citizencodeofconduct.org/](http://citizencodeofconduct.org/) From 17d0da276491f68d25d7bfde360ed168d356d55f Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 17:16:16 +0200 Subject: [PATCH 107/233] Update COPYING --- COPYING | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COPYING b/COPYING index 2a000655e93..e60008693e0 100644 --- a/COPYING +++ b/COPYING @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. From 0585712014f995d34b6a6fc1700542177da67959 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 17:18:49 +0200 Subject: [PATCH 108/233] Update type_translation.php LICENSE https:// --- htdocs/adherents/type_translation.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index a99f1f990ad..7111f9c905c 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -4,6 +4,9 @@ * Copyright (C) 2010-2012 Destailleur Laurent * Copyright (C) 2014 Henry Florian * + * + * LICENSE + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -15,8 +18,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ + * along with this program. If not, see . + * or see https://www.gnu.org/ */ /** From 87c9b4b9fd8f1f08d849318eeb0c30f52d2f55c8 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 17:21:10 +0200 Subject: [PATCH 109/233] Update PSWebServiceLibrary.class.php https:// --- htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index bf63f4c42ab..adaf82d6964 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -7,7 +7,7 @@ * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: -* http://opensource.org/licenses/osl-3.0.php +* https://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. @@ -16,11 +16,11 @@ * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your -* needs please refer to http://www.prestashop.com for more information. +* needs please refer to https://www.prestashop.com for more information. * * @author PrestaShop SA * @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA * PrestaShop Webservice Library * @package PrestaShopWebservice From 3259d70e72cd2a56e65e849c12c40515e416d8cc Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 30 Mar 2021 17:23:05 +0200 Subject: [PATCH 110/233] FIX : several fix after lists uniformization --- htdocs/compta/sociales/list.php | 2 +- htdocs/compta/sociales/payments.php | 9 +++++---- htdocs/compta/tva/list.php | 5 ----- htdocs/compta/tva/payments.php | 4 ++-- htdocs/salaries/payments.php | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 0614532605f..0ef916c3ef7 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -233,7 +233,7 @@ if ($year > 0) { if ($search_typeid) { $sql .= " AND cs.fk_type=".$db->escape($search_typeid); } -$sql .= " GROUP BY cs.rowid, cs.fk_type, cs.fk_user, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle, cs.fk_account, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos"; +$sql .= " GROUP BY cs.rowid, cs.fk_type, cs.fk_user, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle, cs.fk_account, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, pay.code, u.lastname"; if (!empty($conf->projet->enabled)) { $sql .= ", p.rowid, p.ref, p.title"; } diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index c11f13c14fa..e8e4102b5cc 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -169,7 +169,8 @@ if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield) - || preg_match('/^u\./', $sortfield)) { + || preg_match('/^u\./', $sortfield) + || preg_match('/^ba\./', $sortfield)) { $sql .= $db->order($sortfield, $sortorder); } @@ -233,8 +234,8 @@ print "\n"; print ''; print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("SocialContribution", $_SERVER["PHP_SELF"], "c.libelle", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "cs.fk_type", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'width="140px"', $sortfield, $sortorder); +print_liste_field_titre("TypeContrib", $_SERVER["PHP_SELF"], "cs.fk_type", "", $param, '', $sortfield, $sortorder); +print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.periode", "", $param, 'width="140px"', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); @@ -316,7 +317,7 @@ while ($i < min($num, $limit)) { print ''; print ''; - if ($obj->fk_bank > 0) { + if ($obj->bid > 0) { $accountstatic->id = $obj->bid; $accountstatic->ref = $obj->bref; $accountstatic->number = $obj->bnumber; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 16e780e4b0d..ac9e7b55ecd 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -57,7 +57,6 @@ $search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', $search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int')); $search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int')); $search_type = GETPOST('search_type', 'int'); -$search_cheque = GETPOST('search_cheque', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', 'alpha'); $search_status = GETPOST('search_status', 'int'); @@ -123,7 +122,6 @@ if (empty($reshook)) { $search_datepayment_start = ''; $search_datepayment_end = ''; $search_type = ''; - $search_cheque = ''; $search_account = ''; $search_amount = ''; $search_status = ''; @@ -268,9 +266,6 @@ if (!empty($search_datepayment_end)) { if (!empty($search_type) && $search_type > 0) { $param .= '&search_type='.$search_type; } -if (!empty($search_cheque)) { - $param .= '&search_cheque="'.$search_cheque.'"'; -} if (!empty($search_account) && $search_account > 0) { $param .= '&search_account='.$search_account; } diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 83399d5a5c8..3ebb9a335fc 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -120,11 +120,11 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print ''; print ''; print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "ptva.rowid", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("VATDeclaration", $_SERVER["PHP_SELF"], "tva.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("VATDeclaration", $_SERVER["PHP_SELF"], "tva.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "tva.datev", "", $param, 'width="140px"', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "pc.num_paiement", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); + print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "ptva.num_paiement", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); if (!empty($conf->banque->enabled)) { print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "ptva.fk_bank", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "bank.ref", "", $param, '', $sortfield, $sortorder); diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index c91613f2327..18c29f9d5aa 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -485,7 +485,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); + if($accountstatic->id > 0) print $accountstatic->getNomUrl(1); } else print ' '; print ''; if (!$i) $totalarray['nbfield']++; From 4903f92172b7d96d5d71ebc1645514fd083bae39 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 30 Mar 2021 15:26:15 +0000 Subject: [PATCH 111/233] Fixing style errors. --- htdocs/salaries/payments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 18c29f9d5aa..b3a398c8c45 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -485,7 +485,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } $accountstatic->label = $obj->blabel; - if($accountstatic->id > 0) print $accountstatic->getNomUrl(1); + if ($accountstatic->id > 0) print $accountstatic->getNomUrl(1); } else print ' '; print ''; if (!$i) $totalarray['nbfield']++; From 9ad3ba15724c350c0eb60bd19902b32e9bc58dfb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 17:28:58 +0200 Subject: [PATCH 112/233] Fix regression in export --- htdocs/core/modules/modFacture.class.php | 4 +- htdocs/core/modules/modProduct.class.php | 17 ++++-- htdocs/core/modules/modService.class.php | 77 +++++++++++++++++------- 3 files changed, 70 insertions(+), 28 deletions(-) diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 25653fb216a..a1c582f87aa 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -207,7 +207,7 @@ class modFacture extends DolibarrModules //-------- $r = 1; - $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pac"; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r] = 'invoice'; @@ -296,7 +296,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 85cf49ebf73..68d336c3a39 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -176,7 +176,7 @@ class modProduct extends DolibarrModules //-------- $r = 0; - $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pac"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "Products"; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -446,7 +446,7 @@ class modProduct extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; @@ -641,7 +641,16 @@ class modProduct extends DolibarrModules } // End add extra fields $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - + $this->import_regex_array[$r] = array( + 'p.ref'=>'[^ ]', + 'p.price_base_type' => 'HT|TTC', + 'p.tosell'=>'^[0|1]$', + 'p.tobuy'=>'^[0|1]$', + 'p.fk_product_type'=>'^[0|1]$', + 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'p.recuperableonly' => '^[0|1]$', + 'p.finished' => '^[0|1]$' + ); // field order as per structure of table llx_product $import_sample = array( 'p.ref' => "ref:PREF123456", @@ -893,7 +902,7 @@ class modProduct extends DolibarrModules $this->import_convertvalue_array[$r] = array( 'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r] = array('l.fk_product'=>'PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); + $this->import_examplevalues_array[$r] = array('l.fk_product'=>'ref:PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); $this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language'); } } diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index dda0447371a..ae4c7e223fe 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -143,7 +143,7 @@ class modService extends DolibarrModules //-------- $r = 0; - $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_product_accounting = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pac"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -368,8 +368,8 @@ class modService extends DolibarrModules $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); $this->export_TypeFields_array[$r] = array( 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", - $alias_product_accounting . 'p.accountancy_code_sell'=>"Text", $alias_product_accounting . '.accountancy_code_sell_intra'=>"Text", $alias_product_accounting . '.accountancy_code_sell_export'=>"Text", - $alias_product_accounting . 'p.accountancy_code_buy'=>"Text", $alias_product_accounting . '.accountancy_code_buy_intra'=>"Text", $alias_product_accounting . '.accountancy_code_buy_export'=>"Text", + $alias_product_accounting . '.accountancy_code_sell'=>"Text", $alias_product_accounting . '.accountancy_code_sell_intra'=>"Text", $alias_product_accounting . '.accountancy_code_sell_export'=>"Text", + $alias_product_accounting . '.accountancy_code_buy'=>"Text", $alias_product_accounting . '.accountancy_code_buy_intra'=>"Text", $alias_product_accounting . '.accountancy_code_buy_export'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text", 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", @@ -406,8 +406,8 @@ class modService extends DolibarrModules $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; - if (!empty($conf->global->ACCOUNTANCY_COMPANY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_accounting as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; @@ -450,13 +450,13 @@ class modService extends DolibarrModules 'p.weight' => "Weight", 'p.weight_units' => "WeightUnits", 'p.length' => "Length", - 'p.length_units' => "LengthUnit", + 'p.length_units' => "LengthUnits", 'p.width' => "Width", 'p.width_units' => "WidthUnits", 'p.height' => "Height", - 'p.height_units' => "HeightUnit", + 'p.height_units' => "HeightUnits", 'p.surface' => "Surface", - 'p.surface_units' => "SurfaceUnit", + 'p.surface_units' => "SurfaceUnits", 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits", 'p.duration' => "Duration", //duration of service @@ -470,13 +470,6 @@ class modService extends DolibarrModules 'p.datec' => 'DateCreation', 'p.cost_price' => "CostPrice", ); - if (!empty($conf->stock->enabled)) {//if Stock module enabled - $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning - 'p.pmp' => 'PMPValue', //weighted average price - 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature - )); - } $this->import_convertvalue_array[$r] = array( 'p.weight_units' => array( @@ -535,6 +528,41 @@ class modService extends DolibarrModules 'dict' => 'DictionaryCountry' ) ); + + $this->import_regex_array[$r] = array( + 'p.ref' => '[^ ]', + 'p.price_base_type' => '\AHT\z|\ATTC\z', + 'p.tosell' => '^[0|1]$', + 'p.tobuy' => '^[0|1]$', + 'p.fk_product_type' => '^[0|1]$', + 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'p.recuperableonly' => '^[0|1]$', + ); + + if (!empty($conf->stock->enabled)) {//if Stock module enabled + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'p.fk_default_warehouse'=>'DefaultWarehouse', + 'p.tobatch'=>'ManageLotSerial', + 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning + 'p.pmp' => 'PMPValue', //weighted average price + 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature + )); + + $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array( + 'p.tobatch' => '^[0|1|2]$' + )); + + $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( + 'p.fk_default_warehouse' => array( + 'rule' => 'fetchidfromref', + 'classfile' => '/product/stock/class/entrepot.class.php', + 'class' => 'Entrepot', + 'method' => 'fetch', + 'element'=> 'Warehouse' + ) + )); + } + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) { $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); } @@ -569,7 +597,7 @@ class modService extends DolibarrModules $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r] = array( 'p.ref'=>'[^ ]', - 'p.price_base_type' => '\AHT\z|\ATTC\z', + 'p.price_base_type' => 'HT|TTC', 'p.tosell'=>'^[0|1]$', 'p.tobuy'=>'^[0|1]$', 'p.fk_product_type'=>'^[0|1]$', @@ -579,7 +607,7 @@ class modService extends DolibarrModules ); // field order as per structure of table llx_product $import_sample = array( - 'p.ref' => "PREF123456", + 'p.ref' => "ref:PREF123456", 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'), 'p.label' => "Product name in default language", 'p.description' => "Product description in default language", @@ -616,7 +644,7 @@ class modService extends DolibarrModules 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume' => "", 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', - 'p.finished' => '0 (raw material) / 1 (finished goods)' + 'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.'c_product_nature"' ); //clauses copied from import_fields_array if (!empty($conf->stock->enabled)) { @@ -718,7 +746,7 @@ class modService extends DolibarrModules 'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); $this->import_examplevalues_array[$r] = array( - 'sp.fk_product' => "PRODUCT_REF or id:123456", + 'sp.fk_product' => "ref:PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", 'sp.ref_fourn' => "XYZ-F123456", 'sp.quantity' => "5", @@ -755,8 +783,13 @@ class modService extends DolibarrModules 'sp.multicurrency_price'=>'' )); } + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( + 'sp.packagning'=>'1', + )); + } - $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); + $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); } if (!empty($conf->global->PRODUIT_MULTIPRICES)) { @@ -783,7 +816,7 @@ class modService extends DolibarrModules $this->import_convertvalue_array[$r] = array( 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"SERVICE_REF or id:123456", + $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"ref:SERVICE_REF or id:123456", 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1", 'pr.price'=>"100", 'pr.price_ttc'=>"110", 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", @@ -806,7 +839,7 @@ class modService extends DolibarrModules $this->import_convertvalue_array[$r] = array( 'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r] = array('l.fk_product'=>'SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); + $this->import_examplevalues_array[$r] = array('l.fk_product'=>'ref:SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); $this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language'); } } From c80a8517d4feb8b84869c42b8f8867553af84be7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 17:39:48 +0200 Subject: [PATCH 113/233] Fix position of line for ticket group --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_c_ticket_category.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index f908d57a5af..e96b20d90f4 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -310,5 +310,5 @@ ALTER TABLE llx_societe_perentity ADD INDEX idx_societe_perentity_fk_soc (fk_soc ALTER TABLE llx_societe_perentity ADD UNIQUE INDEX uk_societe_perentity (fk_soc, entity); ALTER TABLE llx_c_ticket_category ADD COLUMN public integer DEFAULT 0; - +ALTER TABLE llc_c_ticket_category MODIFY COLUMN pos integer DEFAULT 0 NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.sql index c42c3f029d4..317be25e142 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_category.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_category.sql @@ -21,7 +21,7 @@ create table llx_c_ticket_category entity integer DEFAULT 1, code varchar(32) NOT NULL, label varchar(128) NOT NULL, - pos varchar(32) NOT NULL, + pos integer DEFAULT 0 NOT NULL, public integer DEFAULT 0, use_default integer DEFAULT 1, active integer DEFAULT 1, From 5935d7d0826f097efe5fc970dad869ee9d056c1f Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 17:42:44 +0200 Subject: [PATCH 114/233] Update sms.php href="https://www.dolistore.com/ --- htdocs/admin/sms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 9ddbc3361c8..f84425eda4d 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -156,7 +156,7 @@ asort($listofmethods); if (!count($listofmethods)) { $descnosms = $langs->trans("NoSmsEngine", '{Dolistore}'); - $descnosms = str_replace('{Dolistore}', 'DoliStore', $descnosms); + $descnosms = str_replace('{Dolistore}', 'DoliStore', $descnosms); print '
    '.$descnosms.'
    '; } From fae3cca4947d9c160a0a7da1d6a7f84e8eb07411 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 17:45:15 +0200 Subject: [PATCH 115/233] FIX #yogosha5746 - next step (work in progress) --- htdocs/compta/facture/class/facture.class.php | 6 +++--- htdocs/compta/paiement/cheque/class/remisecheque.class.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/install/repair.php | 4 ++-- htdocs/install/upgrade2.php | 2 +- htdocs/intracommreport/class/intracommreport.class.php | 2 +- htdocs/opensurvey/class/opensurveysondage.class.php | 2 +- htdocs/opensurvey/results.php | 2 +- htdocs/product/inventory/inventory.php | 2 +- htdocs/website/class/website.class.php | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7e9300be61c..3c0722684ca 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2233,7 +2233,7 @@ class Facture extends CommonInvoice if (!$error) { // If invoice was converted into a discount not yet consumed, we remove discount $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql .= ' WHERE fk_facture_source = '.$rowid; + $sql .= ' WHERE fk_facture_source = '.((int) $rowid); $sql .= ' AND fk_facture_line IS NULL'; $resql = $this->db->query($sql); @@ -4575,7 +4575,7 @@ class Facture extends CommonInvoice global $conf; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture'; - $sql .= ' WHERE situation_cycle_ref = '.$this->situation_cycle_ref; + $sql .= ' WHERE situation_cycle_ref = '.((int) $this->situation_cycle_ref); $sql .= ' AND situation_counter < '.$this->situation_counter; $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); @@ -4654,7 +4654,7 @@ class Facture extends CommonInvoice if (!empty($this->situation_cycle_ref)) { // No point in testing anything if we're not inside a cycle $sql = 'SELECT max(situation_counter) FROM '.MAIN_DB_PREFIX.'facture'; - $sql .= ' WHERE situation_cycle_ref = '.$this->situation_cycle_ref; + $sql .= ' WHERE situation_cycle_ref = '.((int) $this->situation_cycle_ref); $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 71e8ab10b38..489d4c7cec0 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -746,7 +746,7 @@ class RemiseCheque extends CommonObject // Get invoices list to reopen them $sql = 'SELECT pf.fk_facture, pf.amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; - $sql .= ' WHERE pf.fk_paiement = '.$payment->id; + $sql .= ' WHERE pf.fk_paiement = '.((int) $payment->id); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 410c896d329..967691c34be 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4047,7 +4047,7 @@ abstract class CommonObject global $db; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.$fk_object_where; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.((int) $fk_object_where); $resql = $db->query($sql); if (empty($resql)) { diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 1eb980ae173..1f80d37efd8 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1318,8 +1318,8 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { } while ($obj_dispatch = $db->fetch_object($resql_dispatch)) { $sql_line = 'SELECT line.rowid, line.qty FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet AS line'; - $sql_line .= ' WHERE line.fk_commande = '.$obj_dispatch->fk_commande; - $sql_line .= ' AND line.fk_product = '.$obj_dispatch->fk_product; + $sql_line .= ' WHERE line.fk_commande = '.((int) $obj_dispatch->fk_commande); + $sql_line .= ' AND line.fk_product = '.((int) $obj_dispatch->fk_product); $resql_line = $db->query($sql_line); // s’il y a plusieurs lignes avec le même produit sur cette commande fournisseur, diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index de4ff58d018..fb63847c3e6 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1342,7 +1342,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons. $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn'; $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; - $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.((int) $select_obj->fk_facture_fourn); + $check_sql .= ' WHERE fk_paiementfourn = '.((int) $select_obj->rowid).' AND fk_facturefourn = '.((int) $select_obj->fk_facture_fourn); $check_resql = $db->query($check_sql); if ($check_resql) { $check_num = $db->num_rows($check_resql); diff --git a/htdocs/intracommreport/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php index cd4765161e9..a36a489ea70 100644 --- a/htdocs/intracommreport/class/intracommreport.class.php +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -417,7 +417,7 @@ class IntracommReport extends CommonObject ( SELECT fk_product FROM '.MAIN_DB_PREFIX.'categorie_product - WHERE fk_categorie = '.$categ_fraisdeport->id.' + WHERE fk_categorie = '.((int) $categ_fraisdeport->id).' ) )'; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index badb3f60149..e11fb65184a 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -594,7 +594,7 @@ class Opensurveysondage extends CommonObject */ public function deleteComment($id_comment) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.((int) $id_comment).' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 0cf9cff7932..6d12259a39f 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -283,7 +283,7 @@ for ($i = 0; $i < $nblines; $i++) { if ($compteur == $i) { $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users); + $sql2 .= " WHERE id_users = ".((int) $obj->id_users); $resql2 = $db->query($sql2); } diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index dea3b46c946..85be4ec7325 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -453,7 +453,7 @@ if ($object->id > 0) { $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; - $sql .= ' WHERE id.fk_inventory = '.$object->id; + $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); $cacheOfProducts = array(); $cacheOfWarehouses = array(); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 27ede3cd0ef..171918238b8 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1281,7 +1281,7 @@ class Website extends CommonObject $objectpagestatic = new WebsitePage($this->db); - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page WHERE fk_website = '.$this->id; + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page WHERE fk_website = '.((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { From d2290a8e13d3744a7fbc3198e5b82d2cae01731d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 17:53:25 +0200 Subject: [PATCH 116/233] FIX #yogosha5746 - next step (work in progress) --- htdocs/accountancy/admin/account.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/accountancy/class/accountancycategory.class.php | 2 +- htdocs/accountancy/closure/index.php | 6 +++--- htdocs/accountancy/customer/index.php | 2 +- htdocs/accountancy/expensereport/list.php | 2 +- htdocs/accountancy/supplier/index.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- .../canvas/actions_adherentcard_common.class.php | 2 +- htdocs/adherents/class/adherent.class.php | 10 +++++----- htdocs/adherents/class/adherent_type.class.php | 2 +- htdocs/adherents/class/adherentstats.class.php | 2 +- htdocs/public/emailing/mailing-read.php | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index cf2bd2065a2..39bf2b07b29 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -218,7 +218,7 @@ if ($db->type == 'pgsql') { } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; } -$sql .= " WHERE asy.rowid = ".$pcgver; +$sql .= " WHERE asy.rowid = ".((int) $pcgver); //print $sql; if (strlen(trim($search_account))) { $lengthpaddingaccount = 0; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 8daefea76d2..b3f946e9245 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -520,7 +520,7 @@ if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->ex $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql .= " SET date_export = '".$db->idate($now)."'"; $sql .= " , date_validated = '".$db->idate($now)."'"; - $sql .= " WHERE rowid = ".$movement->id; + $sql .= " WHERE rowid = ".((int) $movement->id); dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 9301c809125..3e171110c8b 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -428,7 +428,7 @@ class AccountancyCategory // extends CommonObject global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = ".$id; + $sql .= " WHERE t.fk_accounting_category = ".((int) $id); $sql .= " AND t.entity = ".$conf->entity; $this->lines_display = array(); diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 3ba552cdfa4..390c288b606 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -91,9 +91,9 @@ if ($action == 'validate_movements_confirm' && !empty($user->rights->accounting- $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql .= " SET date_validated = '".$db->idate($now)."'"; - $sql .= " WHERE rowid = ".$movement->id; - $sql .= " AND doc_date >= '" . dol_print_date($date_start, 'dayrfc') . "'"; - $sql .= " AND doc_date <= '" . dol_print_date($date_end, 'dayrfc') . "'"; + $sql .= " WHERE rowid = ".((int) $movement->id); + $sql .= " AND doc_date >= '" . $db->idate($date_start) . "'"; + $sql .= " AND doc_date <= '" . $db->idate($date_end) . "'"; dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 354652c653c..6a8289f9d39 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -208,7 +208,7 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); - $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $objp->rowid); $resqlupdate = $db->query($sqlupdate); if (!$resqlupdate) { diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index c7a1dec2d94..98decf4d27a 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -154,7 +154,7 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { } else { $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; $sql .= " SET fk_code_ventilation = ".((int) $monCompte); - $sql .= " WHERE rowid = ".$monId; + $sql .= " WHERE rowid = ".((int) $monId); $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, '', 1); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index fc295fdafa4..392551708de 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -194,7 +194,7 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); - $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $objp->rowid); $resqlupdate = $db->query($sqlupdate); if (!$resqlupdate) { diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index c322ebef9a2..847e330e8e4 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -178,7 +178,7 @@ if ($massaction == 'ventil') { } else { $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sql .= " SET fk_code_ventilation = ".((int) $monCompte); - $sql .= " WHERE rowid = ".$monId; + $sql .= " WHERE rowid = ".((int) $monId); $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, '', 1); diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index 3c6e72cc783..2c0e1d992cc 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -273,7 +273,7 @@ abstract class ActionsAdherentCardCommon // We set country_id, and country_code label of the chosen country if ($this->object->country_id) { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".((int) $this->object->country_id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index eca8668e308..79fef823883 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -692,7 +692,7 @@ class Adherent extends CommonObject $sql .= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member } $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); // If we change the type of membership, we set also label of new type if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { @@ -964,7 +964,7 @@ class Adherent extends CommonObject } // Remove category - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".((int) $rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { @@ -975,7 +975,7 @@ class Adherent extends CommonObject // Remove subscription if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".((int) $rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { @@ -1007,7 +1007,7 @@ class Adherent extends CommonObject // Remove adherent if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { @@ -1154,7 +1154,7 @@ class Adherent extends CommonObject // Set link to user if ($userid > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".((int) $this->id); - $sql .= " WHERE rowid = ".$userid; + $sql .= " WHERE rowid = ".((int) $userid); dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 460cefdeed3..b2f181e59be 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -425,7 +425,7 @@ class AdherentType extends CommonObject $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 62d0e03e27e..1f3dbd32cb6 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -72,7 +72,7 @@ class AdherentStats extends Stats $this->where .= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")"; //if (!$user->rights->societe->client->voir && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($this->memberid) { - $this->where .= " AND m.rowid = ".$this->memberid; + $this->where .= " AND m.rowid = ".((int) $this->memberid); } //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; } diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index 91418707d3a..ea9eeb377e7 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -134,7 +134,7 @@ if (!empty($tag)) { //Update status communication of contact prospect if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) { - $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '((int) $obj->source_id).')'; + $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.((int) $obj->source_id).')'; $resql = $db->query($sql); } } From 3744bc6a7a819513a0f30152ed2fc27d4e21c3e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 17:53:25 +0200 Subject: [PATCH 117/233] FIX #yogosha5746 - next step (work in progress) --- htdocs/accountancy/admin/account.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 2 +- .../class/accountancycategory.class.php | 2 +- htdocs/accountancy/closure/index.php | 6 ++--- htdocs/accountancy/customer/index.php | 2 +- htdocs/accountancy/expensereport/list.php | 2 +- htdocs/accountancy/supplier/index.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- .../actions_adherentcard_common.class.php | 2 +- htdocs/adherents/class/adherent.class.php | 10 ++++----- .../adherents/class/adherent_type.class.php | 2 +- .../adherents/class/adherentstats.class.php | 2 +- htdocs/admin/boxes.php | 2 +- htdocs/admin/external_rss.php | 2 +- htdocs/admin/menus/index.php | 8 +++---- htdocs/admin/translation.php | 2 +- htdocs/api/class/api_setup.class.php | 22 +++++++++---------- htdocs/asset/class/asset_type.class.php | 2 +- htdocs/categories/class/categorie.class.php | 2 +- htdocs/comm/mailing/card.php | 2 +- .../mailing/class/advtargetemailing.class.php | 8 +++---- htdocs/comm/mailing/class/mailing.class.php | 4 ++-- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 4 ++-- htdocs/compta/bank/class/account.class.php | 6 ++--- .../bank/class/api_bankaccounts.class.php | 2 +- .../bank/class/paymentvarious.class.php | 2 +- htdocs/compta/bank/line.php | 12 +++++----- htdocs/compta/bank/releve.php | 2 +- .../compta/cashcontrol/cashcontrol_card.php | 2 +- htdocs/compta/charges/index.php | 2 +- .../deplacement/class/deplacement.class.php | 2 +- .../class/deplacementstats.class.php | 2 +- htdocs/compta/facture/card.php | 2 +- .../facture/class/api_invoices.class.php | 2 +- .../facture/class/facture-rec.class.php | 8 +++---- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/compta/localtax/list.php | 2 +- htdocs/compta/paiement_charge.php | 2 +- htdocs/compta/paiement_vat.php | 2 +- .../class/bonprelevement.class.php | 6 ++--- htdocs/compta/prelevement/fiche-stat.php | 2 +- htdocs/compta/recap-compta.php | 2 +- htdocs/compta/sociales/card.php | 2 +- .../class/paymentsocialcontribution.class.php | 2 +- htdocs/compta/tva/card.php | 2 +- .../actions_contactcard_common.class.php | 2 +- htdocs/contact/class/contact.class.php | 4 ++-- htdocs/contact/consumption.php | 2 +- htdocs/contrat/class/contrat.class.php | 4 ++-- .../box_accountancy_suspense_account.php | 2 +- htdocs/core/boxes/box_bookmarks.php | 2 +- htdocs/core/class/comment.class.php | 2 +- htdocs/core/class/commonobject.class.php | 14 ++++++------ htdocs/core/class/ctypent.class.php | 3 +-- htdocs/core/class/ctyperesource.class.php | 5 +---- htdocs/core/class/discount.class.php | 6 ++--- htdocs/core/class/dolreceiptprinter.class.php | 2 +- htdocs/core/class/fiscalyear.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- .../class/html.formexpensereport.class.php | 2 +- htdocs/core/class/link.class.php | 6 ++--- htdocs/core/lib/bank.lib.php | 4 ++-- htdocs/core/lib/invoice2.lib.php | 2 +- htdocs/core/lib/price.lib.php | 4 ++-- htdocs/core/lib/website.lib.php | 4 ++-- htdocs/core/modules/DolibarrModules.class.php | 2 +- .../modules/mailings/modules_mailings.php | 2 +- htdocs/core/modules/modApi.class.php | 4 ++-- .../societe/doc/doc_generic_odt.modules.php | 2 +- .../doc/pdf_canelle.modules.php | 2 +- .../interface_80_modStripe_Stripe.class.php | 2 +- htdocs/core/website.inc.php | 2 +- htdocs/delivery/class/delivery.class.php | 4 ++-- htdocs/don/class/don.class.php | 6 ++--- htdocs/don/payment/payment.php | 2 +- .../class/expensereport.class.php | 2 +- htdocs/public/emailing/mailing-read.php | 2 +- 80 files changed, 136 insertions(+), 140 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index cf2bd2065a2..39bf2b07b29 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -218,7 +218,7 @@ if ($db->type == 'pgsql') { } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; } -$sql .= " WHERE asy.rowid = ".$pcgver; +$sql .= " WHERE asy.rowid = ".((int) $pcgver); //print $sql; if (strlen(trim($search_account))) { $lengthpaddingaccount = 0; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 8daefea76d2..b3f946e9245 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -520,7 +520,7 @@ if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->ex $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql .= " SET date_export = '".$db->idate($now)."'"; $sql .= " , date_validated = '".$db->idate($now)."'"; - $sql .= " WHERE rowid = ".$movement->id; + $sql .= " WHERE rowid = ".((int) $movement->id); dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 9301c809125..3e171110c8b 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -428,7 +428,7 @@ class AccountancyCategory // extends CommonObject global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = ".$id; + $sql .= " WHERE t.fk_accounting_category = ".((int) $id); $sql .= " AND t.entity = ".$conf->entity; $this->lines_display = array(); diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 3ba552cdfa4..390c288b606 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -91,9 +91,9 @@ if ($action == 'validate_movements_confirm' && !empty($user->rights->accounting- $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql .= " SET date_validated = '".$db->idate($now)."'"; - $sql .= " WHERE rowid = ".$movement->id; - $sql .= " AND doc_date >= '" . dol_print_date($date_start, 'dayrfc') . "'"; - $sql .= " AND doc_date <= '" . dol_print_date($date_end, 'dayrfc') . "'"; + $sql .= " WHERE rowid = ".((int) $movement->id); + $sql .= " AND doc_date >= '" . $db->idate($date_start) . "'"; + $sql .= " AND doc_date <= '" . $db->idate($date_end) . "'"; dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 354652c653c..6a8289f9d39 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -208,7 +208,7 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); - $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $objp->rowid); $resqlupdate = $db->query($sqlupdate); if (!$resqlupdate) { diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index c7a1dec2d94..98decf4d27a 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -154,7 +154,7 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { } else { $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; $sql .= " SET fk_code_ventilation = ".((int) $monCompte); - $sql .= " WHERE rowid = ".$monId; + $sql .= " WHERE rowid = ".((int) $monId); $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, '', 1); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index fc295fdafa4..392551708de 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -194,7 +194,7 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); - $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $objp->rowid); $resqlupdate = $db->query($sqlupdate); if (!$resqlupdate) { diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index c322ebef9a2..847e330e8e4 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -178,7 +178,7 @@ if ($massaction == 'ventil') { } else { $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sql .= " SET fk_code_ventilation = ".((int) $monCompte); - $sql .= " WHERE rowid = ".$monId; + $sql .= " WHERE rowid = ".((int) $monId); $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, '', 1); diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index 3c6e72cc783..2c0e1d992cc 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -273,7 +273,7 @@ abstract class ActionsAdherentCardCommon // We set country_id, and country_code label of the chosen country if ($this->object->country_id) { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".((int) $this->object->country_id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index eca8668e308..79fef823883 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -692,7 +692,7 @@ class Adherent extends CommonObject $sql .= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member } $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); // If we change the type of membership, we set also label of new type if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { @@ -964,7 +964,7 @@ class Adherent extends CommonObject } // Remove category - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".((int) $rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { @@ -975,7 +975,7 @@ class Adherent extends CommonObject // Remove subscription if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".((int) $rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { @@ -1007,7 +1007,7 @@ class Adherent extends CommonObject // Remove adherent if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { @@ -1154,7 +1154,7 @@ class Adherent extends CommonObject // Set link to user if ($userid > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".((int) $this->id); - $sql .= " WHERE rowid = ".$userid; + $sql .= " WHERE rowid = ".((int) $userid); dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 460cefdeed3..b2f181e59be 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -425,7 +425,7 @@ class AdherentType extends CommonObject $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 62d0e03e27e..1f3dbd32cb6 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -72,7 +72,7 @@ class AdherentStats extends Stats $this->where .= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")"; //if (!$user->rights->societe->client->voir && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($this->memberid) { - $this->where .= " AND m.rowid = ".$this->memberid; + $this->where .= " AND m.rowid = ".((int) $this->memberid); } //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; } diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 5b89eefc4f7..741a6157dcd 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -93,7 +93,7 @@ if ($action == 'add') { $arrayofexistingboxid = array(); $nbboxonleft = $nbboxonright = 0; $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity; + $sql .= " WHERE position = ".((int) $pos)." AND fk_user = ".((int) $fk_user)." AND entity = ".((int) $conf->entity); dol_syslog("boxes.php activate box", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 0ef302765e8..b8b412ad6f8 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -140,7 +140,7 @@ if (GETPOST("delete")) { $resql = $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql .= " WHERE rowid = ".$obj->rowid; + $sql .= " WHERE rowid = ".((int) $obj->rowid); $resql = $db->query($sql); if (!$resql) { diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 1db1adf50cf..4d9c85a69f9 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -162,13 +162,13 @@ if ($action == 'up') { } $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; - $sql .= " SET m.position = ".($current['order'] != $next['order'] ? $next['order'] : $current['order'] + 1); // Down the selected entry - $sql .= " WHERE m.rowid = ".$current['rowid']; + $sql .= " SET m.position = ".((int) ($current['order'] != $next['order'] ? $next['order'] : $current['order'] + 1)); // Down the selected entry + $sql .= " WHERE m.rowid = ".((int) $current['rowid']); dol_syslog("admin/menus/index.php ".$sql); $db->query($sql); $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m"; // Up the next entry - $sql .= " SET m.position = ".$current['order']; - $sql .= " WHERE m.rowid = ".$next['rowid']; + $sql .= " SET m.position = ".((int) $current['order']); + $sql .= " WHERE m.rowid = ".((int) $next['rowid']); dol_syslog("admin/menus/index.php ".$sql); $db->query($sql); } elseif ($action == 'confirm_delete' && $confirm == 'yes') { diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index d6b8b2f9f66..315673f1582 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -168,7 +168,7 @@ if ($action == 'add') { // Delete line from delete picto if ($action == 'delete') { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."overwrite_trans WHERE rowid = ".$db->escape($id); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."overwrite_trans WHERE rowid = ".((int) $id); $result = $db->query($sql); if ($result >= 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 674cc53b69f..064fb6ad359 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -73,7 +73,7 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, libelle as label, module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_input_method as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); // Add sql filters if ($sqlfilters) { if (!DolibarrApi::_checkFilters($sqlfilters)) { @@ -136,7 +136,7 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, label, module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); // Add sql filters if ($sqlfilters) { if (!DolibarrApi::_checkFilters($sqlfilters)) { @@ -539,7 +539,7 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); // Add sql filters if ($sqlfilters) { if (!DolibarrApi::_checkFilters($sqlfilters)) { @@ -648,7 +648,7 @@ class Setup extends DolibarrApi $sql = "SELECT id, code, type, libelle as label, module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); if ($type) { $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; } @@ -714,7 +714,7 @@ class Setup extends DolibarrApi $sql = "SELECT id, code, label, accountancy_code, active, module, position"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); if ($module) { $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; } @@ -778,7 +778,7 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, element as type, libelle as label, source, module, position"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); if ($type) { $sql .= " AND type LIKE '%".$this->db->escape($type)."%'"; } @@ -843,7 +843,7 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, label, module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); if ($module) { $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; } @@ -911,7 +911,7 @@ class Setup extends DolibarrApi $sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso"; $sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency_rate as cr ON (m.rowid = cr.fk_multicurrency)"; } - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); if (!empty($multicurrency)) { $sql .= " AND m.entity IN (".getEntity('multicurrency').")"; if (!empty($multicurrency) && $multicurrency != 2) { @@ -1242,7 +1242,7 @@ class Setup extends DolibarrApi //TODO link with multicurrency module $sql = "SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); // Add sql filters if ($sqlfilters) { if (!DolibarrApi::_checkFilters($sqlfilters)) { @@ -1365,7 +1365,7 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, pos, label, use_default, description"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); // Add sql filters if ($sqlfilters) { if (!DolibarrApi::_checkFilters($sqlfilters)) { @@ -1423,7 +1423,7 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, pos, label, use_default, color, description"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; - $sql .= " WHERE t.active = ".$active; + $sql .= " WHERE t.active = ".((int) $active); // Add sql filters if ($sqlfilters) { if (!DolibarrApi::_checkFilters($sqlfilters)) { diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 17943f4dfd4..99205d2b3f3 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -238,7 +238,7 @@ class AssetType extends CommonObject $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_type"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 10cc15a2dc9..1f467b507d1 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -869,7 +869,7 @@ class Categorie extends CommonObject public function containsObject($type, $object_id) { $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); - $sql .= " WHERE fk_categorie = ".$this->id." AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".$object_id; + $sql .= " WHERE fk_categorie = ".$this->id." AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".((int) $object_id); dol_syslog(get_class($this)."::containsObject", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index f907bd98f58..00c5c946326 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -149,7 +149,7 @@ if (empty($reshook)) { // or sent in error (statut=-1) $sql = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; + $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".((int) $object->id); $sql .= " ORDER BY mc.statut DESC"; // first status 0, then status -1 dol_syslog("card.php: select targets", LOG_DEBUG); diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 063fb6c7f00..90132557f38 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -284,9 +284,9 @@ class AdvanceTargetingMailing extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; if (!empty($id)) { - $sql .= " WHERE t.fk_element = ".$id." AND type_element='mailing'"; + $sql .= " WHERE t.fk_element = ".((int) $id)." AND type_element = 'mailing'"; } else { - $sql .= " WHERE t.fk_element = ".$this->fk_element." AND type_element='mailing'"; + $sql .= " WHERE t.fk_element = ".((int) $this->fk_element)." AND type_element = 'mailing'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); @@ -347,9 +347,9 @@ class AdvanceTargetingMailing extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; if (!empty($id)) { - $sql .= " WHERE t.fk_element = ".$id." AND type_element='$type_element'"; + $sql .= " WHERE t.fk_element = ".((int) $id)." AND type_element = '".$this->db->escape($type_element)."'"; } else { - $sql .= " WHERE t.fk_element = ".$this->fk_element." AND type_element='$type_element'"; + $sql .= " WHERE t.fk_element = ".((int) $this->fk_element)." AND type_element = '".$this->db->escape($type_element)."'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 251550bdded..aed8bd1431f 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -427,7 +427,7 @@ class Mailing extends CommonObject $sql .= " source_id ,"; $sql .= " source_type"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " WHERE fk_mailing = ".$fromid; + $sql .= " WHERE fk_mailing = ".((int) $fromid); $result = $this->db->query($sql); if ($result) { @@ -499,7 +499,7 @@ class Mailing extends CommonObject public function delete($rowid) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing"; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog("Mailing::delete", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 32206a0c251..f67cb2c60d4 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2886,7 +2886,7 @@ 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 ".$this->fk_element." = ".$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." = ".((int) $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++; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 4585c2dffb2..a1cebf0db4b 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -423,7 +423,7 @@ if (empty($reshook)) { $originidforcontact=$srcobject->origin_id; } $sqlcontact = "SELECT code, fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$db->escape($originforcontact)."'"; + $sqlcontact.= " WHERE element_id = ".((int) $originidforcontact)." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$db->escape($originforcontact)."'"; $resqlcontact = $db->query($sqlcontact); if ($resqlcontact) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 607753d90fa..635e561eaef 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1113,7 +1113,7 @@ class Commande extends CommonOrder } $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; + $sqlcontact .= " WHERE element_id = ".((int) $originidforcontact)." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { @@ -2331,7 +2331,7 @@ class Commande extends CommonOrder $sql = "SELECT fk_product, qty"; $sql .= " FROM ".MAIN_DB_PREFIX."commandedet"; - $sql .= " WHERE rowid = ".$lineid; + $sql .= " WHERE rowid = ".((int) $lineid); $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 451f855a5fe..943fef0c32a 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -451,9 +451,9 @@ class Account extends CommonObject $sql = "SELECT fk_bank, url_id, url, label, type"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_url"; if ($fk_bank > 0) { - $sql .= " WHERE fk_bank = ".$fk_bank; + $sql .= " WHERE fk_bank = ".((int) $fk_bank); } else { - $sql .= " WHERE url_id = ".$url_id." AND type = '".$this->db->escape($type)."'"; + $sql .= " WHERE url_id = ".((int) $url_id)." AND type = '".$this->db->escape($type)."'"; } $sql .= " ORDER BY type, label"; @@ -2435,7 +2435,7 @@ class AccountLine extends CommonObject $type = 'bank'; - $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".$this->id; + $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index be37ec23403..23c739064f8 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -425,7 +425,7 @@ class BankAccounts extends DolibarrApi } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank "; - $sql .= " WHERE fk_account = ".$id; + $sql .= " WHERE fk_account = ".((int) $id); // Add sql filters if ($sqlfilters) { diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 86a70a35311..d9d50d74421 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -783,7 +783,7 @@ class PaymentVarious extends CommonObject $type = 'bank'; - $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".$banklineid; + $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $banklineid); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 292a61e8bc6..bfea7c74b60 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -107,7 +107,7 @@ if ($user->rights->banque->consolidate && $action == 'donext') { if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier) { $cat1 = GETPOST("cat1", 'int'); if (!empty($rowid) && !empty($cat1)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".$cat1; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".((int) $rowid)." AND fk_categ = ".((int) $cat1); if (!$db->query($sql)) { dol_print_error($db); } @@ -174,7 +174,7 @@ if ($user->rights->banque->modifier && $action == "update") { } } $sql .= " fk_account = ".$actarget->id; - $sql .= " WHERE rowid = ".$acline->id; + $sql .= " WHERE rowid = ".((int) $acline->id); $result = $db->query($sql); if (!$result) { @@ -183,14 +183,14 @@ if ($user->rights->banque->modifier && $action == "update") { if (!$error) { $arrayofcategs = GETPOST('custcats', 'array'); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".((int) $rowid); if (!$db->query($sql)) { $error++; dol_print_error($db); } if (count($arrayofcategs)) { foreach ($arrayofcategs as $val) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$val.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".((int) $rowid).", ".((int) $val).")"; if (!$db->query($sql)) { $error++; dol_print_error($db); @@ -229,9 +229,9 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == if (empty($num_rel)) { $sql .= ", rappro = 0"; } else { - $sql .= ", rappro = ".$rappro; + $sql .= ", rappro = ".((int) $rappro); } - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog("line.php", LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 010b4a08fde..c607f0f922c 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -232,7 +232,7 @@ if (empty($numref)) { // List of all standing receipts $sql = "SELECT DISTINCT(b.num_releve) as numr"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql .= " WHERE b.fk_account = ".$object->id; + $sql .= " WHERE b.fk_account = ".((int) $object->id); $sql .= $db->order($sortfield, $sortorder); // Count total nb of records diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index ccaa0158af2..26949590334 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -304,7 +304,7 @@ if ($action == "create" || $action == "start" || $action == 'close') { if ($bankid > 0) { $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; - $sql .= " WHERE fk_account = ".$bankid; + $sql .= " WHERE fk_account = ".((int) $bankid); if ($syear && !$smonth) { $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; } elseif ($syear && $smonth && !$sday) { diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index d3604b0d7cc..f171546f6c1 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -405,7 +405,7 @@ while ($j < $numlt) { $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; - $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j; + $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".((int) $j); if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 5562f797130..1972e3f686e 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -441,7 +441,7 @@ class Deplacement extends CommonObject $sql = "SELECT id, code, label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees"; - $sql .= " WHERE active = ".$active; + $sql .= " WHERE active = ".((int) $active); dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index 64cee98c33b..cf712f49333 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -102,7 +102,7 @@ class DeplacementStats extends Stats { $sql = "SELECT MONTH(dated) as dm, count(*)"; $sql .= " FROM ".$this->from; - $sql .= " WHERE YEAR(dated) = ".$year; + $sql .= " WHERE YEAR(dated) = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index bf30e2b011f..69f5baa8600 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1743,7 +1743,7 @@ if (empty($reshook)) { $originidforcontact=$srcobject->origin_id; } $sqlcontact = "SELECT code, fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$db->escape($originforcontact)."'"; + $sqlcontact.= " WHERE element_id = ".((int) $originidforcontact)." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$db->escape($originforcontact)."'"; $resqlcontact = $db->query($sqlcontact); if ($resqlcontact) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 9c224b057ab..87bcbe12b3e 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1142,7 +1142,7 @@ class Invoices extends DolibarrApi $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql .= " re.description, re.fk_facture_source"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; - $sql .= " WHERE fk_facture = ".$this->invoice->id; + $sql .= " WHERE fk_facture = ".((int) $this->invoice->id); $resql = $this->db->query($sql); if (!empty($resql)) { while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index b93f48ff655..eea700527ec 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -762,12 +762,12 @@ class FactureRec extends CommonInvoice $main = MAIN_DB_PREFIX.'facturedet_rec'; $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture = ".((int) $rowid); dol_syslog($sqlef); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".((int) $rowid); dol_syslog($sql); if ($this->db->query($sqlef) && $this->db->query($sql)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".((int) $rowid); dol_syslog($sql); if ($this->db->query($sql)) { // Delete linked object @@ -1151,7 +1151,7 @@ class FactureRec extends CommonInvoice $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht; $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva; $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::updateline", LOG_DEBUG); if ($this->db->query($sql)) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3c0722684ca..ca4e445c880 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -751,7 +751,7 @@ class Facture extends CommonInvoice } $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; + $sqlcontact .= " WHERE element_id = ".((int) $originidforcontact)." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a3c5fb08133..0f595fdc984 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -382,7 +382,7 @@ if ($massaction == 'makepayment') { $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login"; $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $rsql .= " , ".MAIN_DB_PREFIX."user as u"; - $rsql .= " WHERE fk_facture = ".$objecttmp->id; + $rsql .= " WHERE fk_facture = ".((int) $objecttmp->id); $rsql .= " AND pfd.fk_user_demande = u.rowid"; $rsql .= " AND pfd.traite = 0"; $rsql .= " ORDER BY pfd.date_demande DESC"; diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index dd77938366a..6590e250832 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -54,7 +54,7 @@ print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Paym $sql = "SELECT rowid, amount, label, f.datev, f.datep"; $sql .= " FROM ".MAIN_DB_PREFIX."localtax as f "; -$sql .= " WHERE f.entity = ".$conf->entity." AND localtaxtype = ".$db->escape($ltt); +$sql .= " WHERE f.entity = ".$conf->entity." AND localtaxtype = ".((int) $ltt); $sql .= " ORDER BY datev DESC"; $result = $db->query($sql); diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 6b47dacdd9d..9ac22d30e1f 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -193,7 +193,7 @@ if ($action == 'create') { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql .= " WHERE p.fk_charge = ".$chid; + $sql .= " WHERE p.fk_charge = ".((int) $chid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index 64952def30d..323221f6f2b 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -189,7 +189,7 @@ if ($action == 'create') { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as p"; - $sql .= " WHERE p.fk_tva = ".$chid; + $sql .= " WHERE p.fk_tva = ".((int) $chid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3ea11463415..92f9c320acd 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1076,7 +1076,7 @@ class BonPrelevement extends CommonObject $sql .= " SET traite = 1"; $sql .= ", date_traite = '".$this->db->idate($now)."'"; $sql .= ", fk_prelevement_bons = ".$this->id; - $sql .= " WHERE rowid = ".$fac[1]; + $sql .= " WHERE rowid = ".((int) $fac[1]); $resql = $this->db->query($sql); if (!$resql) { @@ -1139,7 +1139,7 @@ class BonPrelevement extends CommonObject if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql .= " SET amount = ".price2num($this->total); - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); @@ -2107,7 +2107,7 @@ class BonPrelevement extends CommonObject $sql = "SELECT rowid, ref"; $sql .= " FROM"; $sql .= " ".MAIN_DB_PREFIX."prelevement_bons as pb"; - $sql .= " WHERE pb.rowid = ".$this->id; + $sql .= " WHERE pb.rowid = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 91ecccef242..3f51b5b554d 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -162,7 +162,7 @@ if ($prev_id > 0 || $ref) { $sql = "SELECT sum(pl.amount), pl.statut"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql .= " WHERE pl.fk_prelevement_bons = ".$object->id; + $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $object->id); $sql .= " GROUP BY pl.statut"; $resql = $db->query($sql); diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 9f9ee72cc6d..3abdf04ae1b 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -139,7 +139,7 @@ if ($id > 0) { $sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; $sql .= " u.login, u.rowid as userid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; + $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id); $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= " AND f.fk_user_valid = u.rowid"; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index b8562829066..2fba1288b75 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -613,7 +613,7 @@ if ($id > 0) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id"; $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql .= " WHERE p.fk_charge = ".$id; + $sql .= " WHERE p.fk_charge = ".((int) $id); $sql .= " AND p.fk_charge = cs.rowid"; $sql .= " AND cs.entity IN (".getEntity('tax').")"; $sql .= " ORDER BY dp DESC"; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 3207e533521..434078959b9 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -636,7 +636,7 @@ class PaymentSocialContribution extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 2a116c6376b..a5169675f69 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -618,7 +618,7 @@ if ($id) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id"; $sql .= ", ".MAIN_DB_PREFIX."tva as tva"; - $sql .= " WHERE p.fk_tva = ".$id; + $sql .= " WHERE p.fk_tva = ".((int) $id); $sql .= " AND p.fk_tva = tva.rowid"; $sql .= " AND tva.entity IN (".getEntity('tax').")"; $sql .= " ORDER BY dp DESC"; diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 332b7dd36c6..0e80df07676 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -308,7 +308,7 @@ abstract class ActionsContactCardCommon // We set country_id, and country_code label of the chosen country if ($this->object->country_id) { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".((int) $this->object->country_id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 6305a01c999..5befcba4537 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1652,7 +1652,7 @@ class Contact extends CommonObject // Desactive utilisateur $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople"; $sql .= " SET statut = ".((int) $this->statut); - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); $result = $this->db->query($sql); dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); @@ -1882,7 +1882,7 @@ class Contact extends CommonObject $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcommcontact"; if ($active >= 0) { - $sql .= " WHERE active = ".$active; + $sql .= " WHERE active = ".((int) $active); } $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 1e0f5b06094..b87a73e8cc2 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -258,7 +258,7 @@ if ($type_element == 'fichinter') { // Customer : show products from invoices // $documentstatic=new SupplierProposal($db); // $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; // $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d"; - // $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + // $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); // $where.= " AND d.fk_supplier_proposal = c.rowid"; // $where.= " AND c.entity = ".$conf->entity; // $dateprint = 'c.date_valid'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 64d2b5e2c0a..33dd0e8e2f7 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1057,7 +1057,7 @@ class Contrat extends CommonObject } $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; + $sqlcontact .= " WHERE element_id = ".((int) $originidforcontact)." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { @@ -1759,7 +1759,7 @@ class Contrat extends CommonObject $sql .= ",date_cloture=null"; } $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 31eaa65bf72..70edf818dc0 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -83,7 +83,7 @@ class box_accountancy_suspense_account extends ModeleBoxes if (!empty($suspenseAccount) && $suspenseAccount > 0) { $sql = "SELECT COUNT(*) as nb_suspense_account"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " WHERE b.numero_compte = ".$suspenseAccount; + $sql .= " WHERE b.numero_compte = '".$this->db->escape($suspenseAccount)."'"; $sql .= " AND b.entity = ".$conf->entity; $result = $this->db->query($sql); diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 9d6df6c7535..1a3a1183032 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -87,7 +87,7 @@ class box_bookmarks extends ModeleBoxes if ($user->rights->bookmark->lire) { $sql = "SELECT b.title, b.url, b.target, b.favicon"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; - $sql .= " WHERE fk_user = ".$user->id; + $sql .= " WHERE fk_user = ".((int) $user->id); $sql .= " AND b.entity = ".$conf->entity; $sql .= $this->db->order("position", "ASC"); $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 78f168fd8f7..7184d7846b0 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -365,7 +365,7 @@ class Comment extends CommonObject $sql = "SELECT"; $sql .= " c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c"; - $sql .= " WHERE c.fk_element = ".$fk_element; + $sql .= " WHERE c.fk_element = ".((int) $fk_element); $sql .= " AND c.element_type = '".$this->db->escape($element_type)."'"; $sql .= " AND c.entity = ".$conf->entity; $sql .= " ORDER BY c.tms DESC"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 967691c34be..e113cf2654a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1148,7 +1148,7 @@ abstract class CommonObject if ($fk_socpeople) { $sql .= ", fk_socpeople = ".((int) $fk_socpeople); } - $sql .= " where rowid = ".$rowid; + $sql .= " where rowid = ".((int) $rowid); $resql = $this->db->query($sql); if ($resql) { return 0; @@ -1548,7 +1548,7 @@ abstract class CommonObject $sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; } $sql .= " ".MAIN_DB_PREFIX."c_type_contact as tc"; - $sql .= " WHERE ec.element_id = ".$id; + $sql .= " WHERE ec.element_id = ".((int) $id); $sql .= " AND ec.fk_socpeople = c.rowid"; if ($source == 'internal') { $sql .= " AND c.entity IN (".getEntity('user').")"; @@ -1564,7 +1564,7 @@ abstract class CommonObject } $sql .= " AND tc.active = 1"; if ($status) { - $sql .= " AND ec.statut = ".$status; + $sql .= " AND ec.statut = ".((int) $status); } dol_syslog(get_class($this)."::getIdContact", LOG_DEBUG); @@ -1706,7 +1706,7 @@ abstract class CommonObject if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) { // If data not already loaded $sql = "SELECT rowid, code, libelle as label, coder"; $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; - $sql .= " WHERE rowid = ".$idtype; + $sql .= " WHERE rowid = ".((int) $idtype); dol_syslog(get_class($this).'::fetch_barcode', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1939,7 +1939,7 @@ abstract class CommonObject } } - $sql .= " WHERE ".$id_field." = ".$id; + $sql .= " WHERE ".$id_field." = ".((int) $id); dol_syslog(__METHOD__."", LOG_DEBUG); $resql = $this->db->query($sql); @@ -4263,7 +4263,7 @@ abstract class CommonObject //print $id.'-'.$table.'-'.$elementname.'
    '; // Check if third party can be deleted $sql = "SELECT COUNT(*) as nb from ".MAIN_DB_PREFIX.$table; - $sql .= " WHERE ".$this->fk_element." = ".$id; + $sql .= " WHERE ".$this->fk_element." = ".((int) $id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -9267,7 +9267,7 @@ 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; + $sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 01a6eb5e697..c8421c54b1f 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -163,7 +163,6 @@ class Ctypent // extends CommonObject */ public function fetch($id, $code = '', $label = '') { - global $langs; $sql = "SELECT"; $sql .= " t.id,"; $sql .= " t.code,"; @@ -173,7 +172,7 @@ class Ctypent // extends CommonObject $sql .= " t.module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t"; if ($id) { - $sql .= " WHERE t.id = ".$id; + $sql .= " WHERE t.id = ".((int) $id); } elseif ($code) { $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; } elseif ($label) { diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 6ba04c044e9..b0a604e9e28 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -165,15 +165,12 @@ class Ctyperesource $sql = 'SELECT'; $sql .= ' t.rowid,'; - $sql .= " t.code,"; $sql .= " t.label,"; $sql .= " t.active"; - - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($id) { - $sql .= " WHERE t.id = ".$id; + $sql .= " WHERE t.id = ".((int) $id); } elseif ($code) { $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; } elseif ($label) { diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index a1c2b1fbf8c..63ef3dc1153 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -337,11 +337,11 @@ class DiscountAbsolute // Delete but only if not used $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; if ($this->fk_facture_source) { - $sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie + $sql .= " WHERE fk_facture_source = ".((int) $this->fk_facture_source); // Delete all lines of same serie } elseif ($this->fk_invoice_supplier_source) { - $sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie + $sql .= " WHERE fk_invoice_supplier_source = ".((int) $this->fk_invoice_supplier_source); // Delete all lines of same serie } else { - $sql .= " WHERE rowid = ".$this->id; // Delete only line + $sql .= " WHERE rowid = ".((int) $this->id); // Delete only line } $sql .= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount $sql .= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index be13eb94849..6ac331167d3 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -784,7 +784,7 @@ class dolReceiptPrinter extends Printer $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; + $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id); $sql .= " ORDER BY p.datep"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 566407cffc4..7356e53dc0a 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -196,8 +196,8 @@ class Fiscalyear extends CommonObject $sql .= ", date_start = '".$this->db->idate($this->date_start)."'"; $sql .= ", date_end = ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null"); $sql .= ", statut = '".$this->db->escape($this->statut ? $this->statut : 0)."'"; - $sql .= ", fk_user_modif = ".$user->id; - $sql .= " WHERE rowid = ".$this->id; + $sql .= ", fk_user_modif = ".((int) $user->id); + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 628c6a2ff04..ec92a99ff2a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3530,7 +3530,7 @@ class Form // looking for users $sql = "SELECT a.rowid, a.label"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_address as a"; - $sql .= " WHERE a.fk_soc = ".$socid; + $sql .= " WHERE a.fk_soc = ".((int) $socid); $sql .= " ORDER BY a.label ASC"; dol_syslog(get_class($this)."::select_address", LOG_DEBUG); diff --git a/htdocs/core/class/html.formexpensereport.class.php b/htdocs/core/class/html.formexpensereport.class.php index b25d4397f81..5ecc4e4669d 100644 --- a/htdocs/core/class/html.formexpensereport.class.php +++ b/htdocs/core/class/html.formexpensereport.class.php @@ -114,7 +114,7 @@ class FormExpenseReport $sql = "SELECT c.id, c.code, c.label as type FROM ".MAIN_DB_PREFIX."c_type_fees as c"; if ($active >= 0) { - $sql .= " WHERE c.active = ".$active; + $sql .= " WHERE c.active = ".((int) $active); } $sql .= " ORDER BY c.label ASC"; $resql = $this->db->query($sql); diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index 0f59859bd64..be81c1e2737 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -234,7 +234,7 @@ class Link extends CommonObject global $conf; $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; - $sql .= " WHERE objecttype = '".$this->db->escape($objecttype)."' AND objectid = ".$objectid; + $sql .= " WHERE objecttype = '".$this->db->escape($objecttype)."' AND objectid = ".((int) $objectid); if ($conf->entity != 0) { $sql .= " AND entity = ".$conf->entity; } @@ -284,7 +284,7 @@ class Link extends CommonObject global $conf; $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."links"; - $sql .= " WHERE objecttype = '".$db->escape($objecttype)."' AND objectid = ".$objectid; + $sql .= " WHERE objecttype = '".$db->escape($objecttype)."' AND objectid = ".((int) $objectid); if ($conf->entity != 0) { $sql .= " AND entity = ".$conf->entity; } @@ -314,7 +314,7 @@ class Link extends CommonObject } $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); if ($conf->entity != 0) { $sql .= " AND entity = ".$conf->entity; } diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 6eac92e69bc..30a3d21de90 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -72,7 +72,7 @@ function bank_prepare_head(Account $object) // List of all standing receipts $sql = "SELECT COUNT(DISTINCT(b.num_releve)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql .= " WHERE b.fk_account = ".$object->id; + $sql .= " WHERE b.fk_account = ".((int) $object->id); $resql = $db->query($sql); if ($resql) { @@ -83,7 +83,7 @@ function bank_prepare_head(Account $object) $db->free($resql); } - $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".((int) $object->id); $head[$h][1] = $langs->trans("AccountStatements"); if (($nbReceipts) > 0) { $head[$h][1] .= ''.($nbReceipts).''; diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index e6680293b64..c5e2aeb0a16 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -96,7 +96,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte } if (in_array('bank', $filter)) { $sqlwhere .= " AND p.fk_bank = b.rowid"; - $sqlwhere .= " AND b.fk_account = ".$paymentbankid; + $sqlwhere .= " AND b.fk_account = ".((int) $paymentbankid); } $sqlorder = " ORDER BY p.datep ASC"; } diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 3a73f47a6a0..9be293a81ab 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -151,8 +151,8 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; - $sql .= " WHERE cv.taux = ".$txtva; - $sql .= " AND cv.fk_pays = ".$countryid; + $sql .= " WHERE cv.taux = ".((float) $txtva); + $sql .= " AND cv.fk_pays = ".((int) $countryid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 170202717c8..bf3b9f3dd07 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -846,9 +846,9 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so if (is_array($otherfilters) && !empty($otherfilters['category'])) { $sql .= ', '.MAIN_DB_PREFIX.'categorie_website_page as cwp'; } - $sql .= " WHERE wp.fk_website = ".$website->id; + $sql .= " WHERE wp.fk_website = ".((int) $website->id); if ($status >= 0) { - $sql .= " AND wp.status = ".$status; + $sql .= " AND wp.status = ".((int) $status); } if ($langcode) { $sql .= " AND wp.lang ='".$db->escape($langcode)."'"; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 3d3009fd667..b92937cdada 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1696,7 +1696,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // Search if perm already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def"; - $sql .= " WHERE id = ".$r_id." AND entity = ".$entity; + $sql .= " WHERE id = ".((int) $r_id)." AND entity = ".((int) $entity); $resqlselect = $this->db->query($sql); if ($resqlselect) { diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 96dc6de934f..7c0aa2b19b5 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -250,7 +250,7 @@ class MailingTargets // This can't be abstract as it is used for some method { // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " WHERE fk_mailing = ".$mailing_id; + $sql .= " WHERE fk_mailing = ".((int) $mailing_id); if (!$this->db->query($sql)) { dol_syslog($this->db->error()); diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 0c6ebeb6f37..0f77a67c33b 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -245,8 +245,8 @@ class modApi extends DolibarrModules { // Remove old constants with entity fields different of 0 $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_API', 1), - "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('API_PRODUCTION_MODE', 1) + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->db->escape($this->db->encrypt('MAIN_MODULE_API'))."'", + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->db->escape($this->db->encrypt('API_PRODUCTION_MODE'))."'" ); return $this->_remove($sql, $options); diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index c6579700c9d..1822a5b8c95 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -291,7 +291,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; - $sql .= " WHERE p.fk_soc = ".$object->id; + $sql .= " WHERE p.fk_soc = ".((int) $object->id); $result = $this->db->query($sql); $num = $this->db->num_rows($result); 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 e5fa94135ad..e37caab3ed1 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -1023,7 +1023,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql .= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id; + $sql .= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".((int) $object->id); $sql .= " ORDER BY p.datep"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 64d30eeeb93..0e571f26c98 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -198,7 +198,7 @@ class InterfaceStripe extends DolibarrTriggers } $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account"; - $sql .= " WHERE site='stripe' AND fk_soc = ".$object->id; + $sql .= " WHERE site='stripe' AND fk_soc = ".((int) $object->id); $this->db->query($sql); } diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 67ba6e64edc..30ffee00248 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -93,7 +93,7 @@ if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') { // If we browsi if (GETPOST('l', 'aZ09')) { $sql = "SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; - $sql .= " WHERE wp.fk_website = ".$website->id; + $sql .= " WHERE wp.fk_website = ".((int) $website->id); $sql .= " AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; if (is_object($websitepage) && $websitepage->fk_page > 0) { $sql .= " OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 5b14b509de4..18887a99e28 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -614,7 +614,7 @@ class Delivery extends CommonObject { if ($this->statut == 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet"; - $sql .= " WHERE rowid = ".$lineid; + $sql .= " WHERE rowid = ".((int) $lineid); if ($this->db->query($sql)) { $this->update_price(); @@ -940,7 +940,7 @@ class Delivery extends CommonObject $sqlSourceLine .= ", p.ref, p.label"; $sqlSourceLine .= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0]['type']."det as st"; $sqlSourceLine .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid"; - $sqlSourceLine .= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid']; + $sqlSourceLine .= " WHERE fk_".$this->linked_object[0]['type']." = ".((int) $this->linked_object[0]['linkid']); $resultSourceLine = $this->db->query($sqlSourceLine); if ($resultSourceLine) { diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 257eb309f25..1ec3ebe1cc5 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -759,9 +759,9 @@ class Don extends CommonObject { $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; if ($modepayment) { - $sql .= ", fk_payment=".$modepayment; + $sql .= ", fk_payment = ".((int) $modepayment); } - $sql .= " WHERE rowid = ".$id." AND fk_statut = 1"; + $sql .= " WHERE rowid = ".((int) $id)." AND fk_statut = 1"; $resql = $this->db->query($sql); if ($resql) { @@ -843,7 +843,7 @@ class Don extends CommonObject $sql = "SELECT sum(amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."don"; - $sql .= " WHERE fk_statut = ".$param; + $sql .= " WHERE fk_statut = ".((int) $param); $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php index d571940cc9b..cf6328d15c4 100644 --- a/htdocs/don/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -144,7 +144,7 @@ llxHeader(); $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p"; -$sql .= " WHERE p.fk_donation = ".$chid; +$sql .= " WHERE p.fk_donation = ".((int) $chid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index d9b58667574..993ea72e7f3 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -663,7 +663,7 @@ class ExpenseReport extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."expensereport"; $sql .= " SET fk_statut = ".self::STATUS_CLOSED.", paid=1"; - $sql .= " WHERE rowid = ".$id." AND fk_statut = ".self::STATUS_APPROVED; + $sql .= " WHERE rowid = ".((int) $id)." AND fk_statut = ".self::STATUS_APPROVED; dol_syslog(get_class($this)."::set_paid sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index 91418707d3a..ea9eeb377e7 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -134,7 +134,7 @@ if (!empty($tag)) { //Update status communication of contact prospect if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) { - $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '((int) $obj->source_id).')'; + $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.((int) $obj->source_id).')'; $resql = $db->query($sql); } } From 0203eab0b0b51760933fda42a9f5c0dcd1cce23b Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 18:28:07 +0200 Subject: [PATCH 118/233] Update box_accountancy_suspense_account.php https:// --- htdocs/core/boxes/box_accountancy_suspense_account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 70edf818dc0..aa648270b97 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ /** From 479421d923d0710934847d1708aadb44c0213f77 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 18:30:07 +0200 Subject: [PATCH 119/233] Update box_supplier_orders_awaiting_reception.php https:// --- htdocs/core/boxes/box_supplier_orders_awaiting_reception.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 7325b9bed5f..1a8cec07155 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ /** From 34077d5b8a600a7585a089202ed93cf485a91db5 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 18:31:36 +0200 Subject: [PATCH 120/233] Update canvas.class.php --- htdocs/core/class/canvas.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 4ae94d43136..a4414fa6edb 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -195,7 +195,7 @@ class Canvas // This functions should not be used anymore because canvas should contains only templates. - // http://wiki.dolibarr.org/index.php/Canvas_development + // https://wiki.dolibarr.org/index.php/Canvas_development /** * Return if a canvas contains an action controller @@ -216,7 +216,7 @@ class Canvas * @param string $action Action string * @param int $id Object id * @return mixed Return return code of doActions of canvas - * @see http://wiki.dolibarr.org/index.php/Canvas_development + * @see https://wiki.dolibarr.org/index.php/Canvas_development */ public function doActions(&$action = 'view', $id = 0) { From a9e720eec39699ad8247b3411644690b89bbfa70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 30 Mar 2021 18:33:52 +0200 Subject: [PATCH 121/233] Update mod_facture_mars.php --- htdocs/core/modules/facture/mod_facture_mars.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index cd36b4d322a..c7a69a82caa 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -55,6 +55,7 @@ class mod_facture_mars extends ModeleNumRefFactures */ public function __construct() { + global $conf; if (!empty($conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX)) { $this->prefixinvoice = $conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX; } From 4c874ddf15a8e6dd7e22e2b41a7d4d898e356325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 30 Mar 2021 18:35:46 +0200 Subject: [PATCH 122/233] Update mod_facture_terre.php --- htdocs/core/modules/facture/mod_facture_terre.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 2f142a1adc7..f3e38cf7db7 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -65,6 +65,7 @@ class mod_facture_terre extends ModeleNumRefFactures */ public function __construct() { + global $conf; if (!empty($conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX)) { $this->prefixinvoice = $conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX; } From 680850f168e2e58988975c801e8453380dae5f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 30 Mar 2021 18:55:37 +0200 Subject: [PATCH 123/233] fix sql delete invoice --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ca4e445c880..74e2f380d91 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2282,7 +2282,7 @@ class Facture extends CommonInvoice // Invoice line extrafileds $main = MAIN_DB_PREFIX.'facturedet'; $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture = ".((int) $rowid); + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture = ".((int) $rowid).")"; // Delete invoice line $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.((int) $rowid); From be6bb3a7564fdc8feeca600b9e527bb5371097da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 19:12:07 +0200 Subject: [PATCH 124/233] FIX #yogosha5746 - next step (work in progress) --- .../class/expensereport.class.php | 16 ++++----- .../class/expensereportstats.class.php | 2 +- htdocs/expensereport/payment/payment.php | 2 +- htdocs/fichinter/class/fichinterrec.class.php | 4 +-- .../fichinter/class/fichinterstats.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 6 ++-- htdocs/fourn/recap-fourn.php | 2 +- htdocs/holiday/class/holiday.class.php | 2 +- htdocs/install/upgrade2.php | 30 ++++++++-------- htdocs/loan/card.php | 2 +- htdocs/loan/class/loanschedule.class.php | 6 ++-- htdocs/loan/payment/payment.php | 2 +- htdocs/margin/agentMargins.php | 2 +- .../template/class/myobject.class.php | 4 +-- htdocs/product/class/product.class.php | 34 +++++++++---------- .../class/productcustomerprice.class.php | 2 +- .../class/productfournisseurprice.class.php | 2 +- .../class/propalmergepdfproduct.class.php | 2 +- .../class/price_expression.class.php | 2 +- .../class/price_global_variable.class.php | 2 +- .../price_global_variable_updater.class.php | 2 +- htdocs/product/fournisseurs.php | 4 +-- htdocs/product/list.php | 4 +-- htdocs/product/price.php | 22 ++++++------ .../stock/class/mouvementstock.class.php | 16 ++++----- .../product/stock/class/productlot.class.php | 2 +- htdocs/product/stock/replenish.php | 2 +- htdocs/projet/class/project.class.php | 16 ++++----- htdocs/projet/class/task.class.php | 6 ++-- htdocs/public/members/public_list.php | 2 +- htdocs/public/stripe/ipn.php | 2 +- htdocs/reception/class/reception.class.php | 2 +- htdocs/resource/element_resource.php | 6 ++-- htdocs/salaries/card.php | 2 +- htdocs/salaries/class/salariesstats.class.php | 4 +-- htdocs/salaries/paiement_salary.php | 4 +-- .../societe/class/api_thirdparties.class.php | 12 +++---- htdocs/societe/class/client.class.php | 2 +- .../class/companybankaccount.class.php | 10 +++--- .../class/companypaymentmode.class.php | 6 ++-- htdocs/societe/class/societe.class.php | 8 ++--- htdocs/societe/class/societeaccount.class.php | 2 +- htdocs/societe/consumption.php | 20 +++++------ htdocs/societe/paymentmodes.php | 10 +++--- htdocs/societe/societecontact.php | 2 +- htdocs/takepos/receipt.php | 2 +- htdocs/ticket/class/ticket.class.php | 2 +- htdocs/ticket/class/ticketstats.class.php | 2 +- htdocs/user/class/user.class.php | 2 +- htdocs/webservices/server_contact.php | 2 +- .../webservices/server_productorservice.php | 2 +- htdocs/website/class/website.class.php | 4 +-- 52 files changed, 155 insertions(+), 155 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 993ea72e7f3..8ec99aa1007 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -880,7 +880,7 @@ class ExpenseReport extends CommonObject if ($user->rights->expensereport->lire) { $sql = "SELECT de.fk_expensereport, de.date, de.comments, de.total_ht, de.total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as de"; - $sql .= " WHERE de.fk_projet = ".$projectid; + $sql .= " WHERE de.fk_projet = ".((int) $projectid); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); @@ -1117,8 +1117,8 @@ class ExpenseReport 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 ".$this->fk_element." = ".$this->id.")"; - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$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." = ".((int) $this->id).")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".((int) $this->id); if (!$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); @@ -1154,7 +1154,7 @@ class ExpenseReport extends CommonObject // Delete main record if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".((int) $this->id); $res = $this->db->query($sql); if (!$res) { $error++; @@ -2124,7 +2124,7 @@ class ExpenseReport extends CommonObject // Select des infos sur le type fees $sql = "SELECT c.code as code_type_fees, c.label as libelle_type_fees"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as c"; - $sql .= " WHERE c.id = ".$type_fees_id; + $sql .= " WHERE c.id = ".((int) $type_fees_id); $resql = $this->db->query($sql); if ($resql) { $objp_fees = $this->db->fetch_object($resql); @@ -2136,7 +2136,7 @@ class ExpenseReport extends CommonObject // Select des informations du projet $sql = "SELECT p.ref as ref_projet, p.title as title_projet"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " WHERE p.rowid = ".$projet_id; + $sql .= " WHERE p.rowid = ".((int) $projet_id); $resql = $this->db->query($sql); if ($resql) { $objp_projet = $this->db->fetch_object($resql); @@ -2331,7 +2331,7 @@ class ExpenseReport extends CommonObject $ret = array(); $sql = "SELECT id, code, label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees"; - $sql .= " WHERE active = ".$active; + $sql .= " WHERE active = ".((int) $active); dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -2495,7 +2495,7 @@ class ExpenseReport extends CommonObject $type = 'expense_report'; - $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".$this->id; + $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index ec71f530f51..8f3574f2952 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -114,7 +114,7 @@ class ExpenseReportStats extends Stats { $sql = "SELECT MONTH(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)"; $sql .= " FROM ".$this->from; - $sql .= " WHERE YEAR(e.".$this->datetouse.") = ".$year; + $sql .= " WHERE YEAR(e.".$this->datetouse.") = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index d50f6336669..b7057af86fc 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -206,7 +206,7 @@ if ($action == 'create' || empty($action)) { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e"; - $sql .= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$id; + $sql .= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".((int) $id); $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 960a2734706..4fe35c32a2c 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -434,10 +434,10 @@ class FichinterRec extends Fichinter $error = 0; $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet_rec WHERE fk_fichinter = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet_rec WHERE fk_fichinter = ".((int) $rowid); dol_syslog($sql); if ($this->db->query($sql)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter_rec WHERE rowid = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter_rec WHERE rowid = ".((int) $rowid); dol_syslog($sql); if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index 2daede1457a..297aeca7760 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -73,7 +73,7 @@ class FichinterStats extends Stats //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled } if (!$user->rights->societe->client->voir && !$this->socid) { - $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $this->where .= ($this->where ? ' AND ' : '')."c.entity IN (".getEntity('fichinter').')'; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 0fa34c28d81..c910cffe8d4 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -164,7 +164,7 @@ class ProductFournisseur extends Product $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; + $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".((int) $id_fourn); dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); $resql2 = $this->db->query($sql); @@ -208,7 +208,7 @@ class ProductFournisseur extends Product if (empty($error)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); @@ -438,7 +438,7 @@ class ProductFournisseur extends Product // Delete price for this quantity $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; + $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".((float) $qty)." AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { // Add price for this quantity to supplier diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index 06ad90ec858..97a6b53f2e2 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -73,7 +73,7 @@ if ($socid > 0) { $sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; $sql .= " u.login, u.rowid as userid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; + $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $societe->id); $sql .= " AND f.entity IN (".getEntity("facture_fourn").")"; // Recognition of the entity attributed to this invoice for Multicompany $sql .= " AND f.fk_user_valid = u.rowid"; $sql .= " ORDER BY f.datef DESC"; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 4b5c742b3f1..ffd394a35b3 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2069,7 +2069,7 @@ class Holiday extends CommonObject $sql = "SELECT rowid, code, label, affect, delay, newByMonth"; $sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types"; - $sql .= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; + $sql .= " WHERE (fk_country IS NULL OR fk_country = ".((int) $mysoc->country_id).')'; if ($active >= 0) { $sql .= " AND active = ".((int) $active); } diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index fb63847c3e6..26c791c2290 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -2161,7 +2161,7 @@ function migrate_detail_livraison($db, $langs, $conf) if ($resql2) { $sql = "SELECT total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql .= " WHERE rowid = ".$obj->fk_livraison; + $sql .= " WHERE rowid = ".((int) $obj->fk_livraison); $resql3 = $db->query($sql); if ($resql3) { @@ -2864,7 +2864,7 @@ function migrate_project_task_time($db, $langs, $conf) foreach ($totaltime as $taskid => $total_duration) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; $sql .= " duration_effective = ".$total_duration; - $sql .= " WHERE rowid = ".$taskid; + $sql .= " WHERE rowid = ".((int) $taskid); $resql = $db->query($sql); if (!$resql) { @@ -3235,7 +3235,7 @@ function migrate_mode_reglement($db, $langs, $conf) $sqlSelect = "SELECT id"; $sqlSelect .= " FROM ".MAIN_DB_PREFIX."c_paiement"; - $sqlSelect .= " WHERE id = ".$old_id; + $sqlSelect .= " WHERE id = ".((int) $old_id); $sqlSelect .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sqlSelect); @@ -3246,23 +3246,23 @@ function migrate_mode_reglement($db, $langs, $conf) $db->begin(); - $sqla = "UPDATE ".MAIN_DB_PREFIX."paiement SET "; - $sqla .= "fk_paiement = ".$elements['new_id'][$key]; - $sqla .= " WHERE fk_paiement = ".$old_id; - $sqla .= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".$old_id." AND code = '".$db->escape($elements['code'][$key])."')"; + $sqla = "UPDATE ".MAIN_DB_PREFIX."paiement SET"; + $sqla .= " fk_paiement = ".$elements['new_id'][$key]; + $sqla .= " WHERE fk_paiement = ".((int) $old_id); + $sqla .= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".((int) $old_id)." AND code = '".$db->escape($elements['code'][$key])."')"; $resqla = $db->query($sqla); - $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement SET "; - $sql .= "id = ".$elements['new_id'][$key]; - $sql .= " WHERE id = ".$old_id; + $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement SET"; + $sql .= " id = ".((int) $elements['new_id'][$key]); + $sql .= " WHERE id = ".((int) $old_id); $sql .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sql); if ($resqla && $resql) { foreach ($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; - $sql .= "fk_mode_reglement = ".$elements['new_id'][$key]; - $sql .= " WHERE fk_mode_reglement = ".$old_id; + $sql .= "fk_mode_reglement = "((int) $elements['new_id'][$key]); + $sql .= " WHERE fk_mode_reglement = ".((int) $old_id); $resql = $db->query($sql); if (!$resql) { @@ -3786,16 +3786,16 @@ function migrate_remise_except_entity($db, $langs, $conf) $sqlSelect2 = "SELECT f.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sqlSelect2 .= " WHERE f.rowid = ".$fk_facture; + $sqlSelect2 .= " WHERE f.rowid = ".((int) $fk_facture); } elseif (!empty($obj->fk_facture_line)) { $sqlSelect2 = "SELECT f.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; - $sqlSelect2 .= " WHERE fd.rowid = ".$obj->fk_facture_line; + $sqlSelect2 .= " WHERE fd.rowid = ".((int) $obj->fk_facture_line); $sqlSelect2 .= " AND fd.fk_facture = f.rowid"; } else { $sqlSelect2 = "SELECT s.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sqlSelect2 .= " WHERE s.rowid = ".$obj->fk_soc; + $sqlSelect2 .= " WHERE s.rowid = ".((int) $obj->fk_soc); } $resql2 = $db->query($sqlSelect2); diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 9e9e1a0a992..c3c08b6cf2f 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -636,7 +636,7 @@ if ($id > 0) { $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; $sql .= ", ".MAIN_DB_PREFIX."loan as l"; - $sql .= " WHERE p.fk_loan = ".$id; + $sql .= " WHERE p.fk_loan = ".((int) $id); $sql .= " AND p.fk_loan = l.rowid"; $sql .= " AND l.entity IN ( ".getEntity('loan').")"; $sql .= " ORDER BY dp DESC"; diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index bc819f747ca..54d4607ab70 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -447,7 +447,7 @@ class LoanSchedule extends CommonObject $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql .= " WHERE t.fk_loan = ".$loanid; + $sql .= " WHERE t.fk_loan = ".((int) $loanid); dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); $resql = $this->db->query($sql); @@ -535,7 +535,7 @@ class LoanSchedule extends CommonObject { $sql = "SELECT p.datep"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p "; - $sql .= " WHERE p.fk_loan = ".$loanid; + $sql .= " WHERE p.fk_loan = ".((int) $loanid); $sql .= " ORDER BY p.datep DESC "; $sql .= " LIMIT 1 "; @@ -563,7 +563,7 @@ class LoanSchedule extends CommonObject $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p "; - $sql .= " WHERE p.fk_loan = ".$loanid; + $sql .= " WHERE p.fk_loan = ".((int) $loanid); if (!empty($datemax)) { $sql .= " AND p.datep > '".$this->db->idate($datemax)."'"; } diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index eec24d9b3e2..58783be181e 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -239,7 +239,7 @@ if ($action == 'create') { $sql = "SELECT SUM(amount_capital) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan"; - $sql .= " WHERE fk_loan = ".$chid; + $sql .= " WHERE fk_loan = ".((int) $chid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index a27393c8bb2..1ac670c4a7f 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -290,7 +290,7 @@ if ($result) { // sql nb sellers $sql_seller = "SELECT COUNT(sc.rowid) as nb"; $sql_seller .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql_seller .= " WHERE sc.fk_soc = ".$objp->socid; + $sql_seller .= " WHERE sc.fk_soc = ".((int) $objp->socid); $sql_seller .= " LIMIT 1"; $resql_seller = $db->query($sql_seller); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 6a17e500a69..df687f84e56 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -579,9 +579,9 @@ class MyObject extends CommonObject $sql .= ", date_validation = '".$this->db->idate($now)."'"; } if (!empty($this->fields['fk_user_valid'])) { - $sql .= ", fk_user_valid = ".$user->id; + $sql .= ", fk_user_valid = ".((int) $user->id); } - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ad3b694f137..d9cadd304b2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1820,9 +1820,9 @@ class Product extends CommonObject $sql .= ", pfp.packaging"; } $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE pfp.rowid = ".$prodfournprice; + $sql .= " WHERE pfp.rowid = ".((int) $prodfournprice); if ($qty > 0) { - $sql .= " AND pfp.quantity <= ".$qty; + $sql .= " AND pfp.quantity <= ".((float) $qty); } $sql .= " ORDER BY pfp.quantity DESC"; @@ -1874,15 +1874,15 @@ class Product extends CommonObject $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; $sql .= " pfp.packaging"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE pfp.fk_product = ".$product_id; + $sql .= " WHERE pfp.fk_product = ".((int) $product_id); if ($fourn_ref != 'none') { $sql .= " AND pfp.ref_fourn = '".$this->db->escape($fourn_ref)."'"; } if ($fk_soc > 0) { - $sql .= " AND pfp.fk_soc = ".$fk_soc; + $sql .= " AND pfp.fk_soc = ".((int) $fk_soc); } if ($qty > 0) { - $sql .= " AND pfp.quantity <= ".$qty; + $sql .= " AND pfp.quantity <= ".((float) $qty); } $sql .= " ORDER BY pfp.quantity DESC"; $sql .= " LIMIT 1"; @@ -2360,7 +2360,7 @@ class Product extends CommonObject $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; - $sql .= " WHERE fk_product = ".$this->id; + $sql .= " WHERE fk_product = ".((int) $this->id); $sql .= " ORDER BY date_price DESC, rowid DESC"; $sql .= " LIMIT 1"; $resql = $this->db->query($sql); @@ -2374,7 +2374,7 @@ class Product extends CommonObject if ($this->prices_by_qty[0] == 1) { $sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise, remise, price_base_type"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql .= " WHERE fk_product_price = ".$this->prices_by_qty_id[0]; + $sql .= " WHERE fk_product_price = ".((int) $this->prices_by_qty_id[0]); $sql .= " ORDER BY quantity ASC"; $resultat = array(); $resql = $this->db->query($sql); @@ -3946,8 +3946,8 @@ class Product extends CommonObject } $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; - $sql .= " WHERE fk_product_pere = ".$fk_parent; - $sql .= " AND fk_product_fils = ".$fk_child; + $sql .= " WHERE fk_product_pere = ".((int) $fk_parent); + $sql .= " AND fk_product_fils = ".((int) $fk_child); dol_syslog(get_class($this).'::del_sousproduit', LOG_DEBUG); if (!$this->db->query($sql)) { @@ -4040,14 +4040,14 @@ class Product extends CommonObject $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$id_fourn; + $sql .= " WHERE fk_soc = ".((int) $id_fourn); if ($ref_fourn) { $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; } else { $sql .= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; } - $sql .= " AND quantity = ".$quantity; - $sql .= " AND fk_product = ".$this->id; + $sql .= " AND quantity = ".((float) $quantity); + $sql .= " AND fk_product = ".((int) $this->id); $sql .= " AND entity IN (".getEntity('productsupplierprice').")"; $resql = $this->db->query($sql); @@ -4198,7 +4198,7 @@ class Product extends CommonObject $sql .= ", multicurrency_price"; $sql .= ", multicurrency_price_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; - $sql .= " WHERE fk_product = ".$fromId; + $sql .= " WHERE fk_product = ".((int) $fromId); $sql .= " ORDER BY date_price DESC"; if ($conf->global->PRODUIT_MULTIPRICES_LIMIT > 0) { $sql .= " LIMIT ".$conf->global->PRODUIT_MULTIPRICES_LIMIT; @@ -4230,7 +4230,7 @@ class Product extends CommonObject $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association (fk_product_pere, fk_product_fils, qty)'; $sql .= " SELECT ".$toId.", fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association"; - $sql .= " WHERE fk_product_pere = ".$fromId; + $sql .= " WHERE fk_product_pere = ".((int) $fromId); dol_syslog(get_class($this).'::clone_association', LOG_DEBUG); if (!$this->db->query($sql)) { @@ -4262,7 +4262,7 @@ class Product extends CommonObject . " datec, fk_product, fk_soc, ref_fourn, fk_user_author )" . " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, ref_fourn, fk_user_author" . " FROM ".MAIN_DB_PREFIX."product_fournisseur" - . " WHERE fk_product = ".$fromId; + . " WHERE fk_product = ".((int) $fromId); if ( ! $this->db->query($sql ) ) { @@ -4273,9 +4273,9 @@ class Product extends CommonObject // les prix de fournisseurs. $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("; $sql .= " datec, fk_product, fk_soc, price, quantity, fk_user)"; - $sql .= " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, price, quantity, fk_user"; + $sql .= " SELECT '".$this->db->idate($now)."', ".((int) $toId).", fk_soc, price, quantity, fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$fromId; + $sql .= " WHERE fk_product = ".((int) $fromId); dol_syslog(get_class($this).'::clone_fournisseurs', LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 046aed05a10..9b0d29b4cdd 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -814,7 +814,7 @@ class Productcustomerprice extends CommonObject // Find all susidiaries $sql = "SELECT s.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE s.parent = ".$this->fk_soc; + $sql .= " WHERE s.parent = ".((int) $this->fk_soc); $sql .= " AND s.entity IN (".getEntity('societe').")"; dol_syslog(get_class($this)."::setPriceOnAffiliateThirdparty", LOG_DEBUG); diff --git a/htdocs/product/class/productfournisseurprice.class.php b/htdocs/product/class/productfournisseurprice.class.php index 13fa8433d07..709afcb6d20 100644 --- a/htdocs/product/class/productfournisseurprice.class.php +++ b/htdocs/product/class/productfournisseurprice.class.php @@ -438,7 +438,7 @@ class ProductFournisseurPrice extends CommonObject $sql .= " status = ".self::STATUS_VALIDATED; if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."'"; if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index f7cf48df5e0..a1d92cc492a 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -239,7 +239,7 @@ class Propalmergepdfproduct extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t"; - $sql .= " WHERE t.fk_product = ".$product_id; + $sql .= " WHERE t.fk_product = ".((int) $product_id); if ($conf->global->MAIN_MULTILANGS && !empty($lang)) { $sql .= " AND t.lang = '".$this->db->escape($lang)."'"; } diff --git a/htdocs/product/dynamic_price/class/price_expression.class.php b/htdocs/product/dynamic_price/class/price_expression.class.php index 546c2050990..db0c427c334 100644 --- a/htdocs/product/dynamic_price/class/price_expression.class.php +++ b/htdocs/product/dynamic_price/class/price_expression.class.php @@ -327,7 +327,7 @@ class PriceExpression if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(__METHOD__); $resql = $this->db->query($sql); diff --git a/htdocs/product/dynamic_price/class/price_global_variable.class.php b/htdocs/product/dynamic_price/class/price_global_variable.class.php index 29505ff8573..5286b932ca7 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable.class.php @@ -250,7 +250,7 @@ class PriceGlobalVariable if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(__METHOD__); $resql = $this->db->query($sql); diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index f43d6bc731d..96e77d661ab 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -275,7 +275,7 @@ class PriceGlobalVariableUpdater if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(__METHOD__); $resql = $this->db->query($sql); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index cde318cda81..6e3b487a429 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -793,7 +793,7 @@ END; $sql .= ", ".$key; } $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields"; - $sql .= " WHERE fk_object = ".$rowid; + $sql .= " WHERE fk_object = ".((int) $rowid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1145,7 +1145,7 @@ END; $sql .= ", ".$key; } $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields"; - $sql .= " WHERE fk_object = ".$productfourn->product_fourn_price_id; + $sql .= " WHERE fk_object = ".((int) $productfourn->product_fourn_price_id); $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) != 1) { diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 7df96cbd97c..b6f5956bfd3 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -473,7 +473,7 @@ if ($searchCategoryProductOperator == 1) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL"; } elseif (intval($searchCategoryProduct) > 0) { - $searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_categorie = ".$searchCategoryProduct.")"; + $searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")"; } } if (!empty($searchCategoryProductSqlList)) { @@ -1530,7 +1530,7 @@ if ($resql) { // then reuse the cache array if we need prices for other price levels $sqlp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price, p.price_base_type"; $sqlp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; - $sqlp .= " WHERE fk_product = ".$obj->rowid; + $sqlp .= " WHERE fk_product = ".((int) $obj->rowid); $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; $resultp = $db->query($sqlp); if ($resultp) { diff --git a/htdocs/product/price.php b/htdocs/product/price.php index ee86d43c09f..6647201b719 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -429,12 +429,12 @@ if (empty($reshook)) { // Ajout / mise à jour if ($rowid > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."product_price_by_qty SET"; - $sql .= " price='".$db->escape($price)."',"; - $sql .= " unitprice=".$unitPrice.","; - $sql .= " quantity=".$quantity.","; - $sql .= " remise_percent=".$remise_percent.","; - $sql .= " remise=".$remise; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " price=".((float) $price)."',"; + $sql .= " unitprice=".((float) $unitPrice).","; + $sql .= " quantity=".((float) $quantity).","; + $sql .= " remise_percent=".((float) $remise_percent).","; + $sql .= " remise=".((float) $remise); + $sql .= " WHERE rowid = ".((int) $rowid); $result = $db->query($sql); if (!$result) { @@ -442,7 +442,7 @@ if (empty($reshook)) { } } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values ("; - $sql .= $priceid.','.$price.','.$unitPrice.','.$quantity.','.$remise_percent.','.$remise.')'; + $sql .= ((int) $priceid).','.((float) $price).','.((float) $unitPrice).','.((float) $quantity).','.((float) $remise_percent).','.((float) $remise).')'; $result = $db->query($sql); if (!$result) { @@ -460,7 +460,7 @@ if (empty($reshook)) { $rowid = GETPOST('rowid', 'int'); if (!empty($rowid)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); $result = $db->query($sql); } else { @@ -472,7 +472,7 @@ if (empty($reshook)) { $priceid = GETPOST('priceid', 'int'); if (!empty($rowid)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql .= " WHERE fk_product_price = ".$priceid; + $sql .= " WHERE fk_product_price = ".((int) $priceid); $result = $db->query($sql); } else { @@ -1413,11 +1413,11 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul $sql .= " p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p,"; $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE fk_product = ".$object->id; + $sql .= " WHERE fk_product = ".((int) $object->id); $sql .= " AND p.entity IN (".getEntity('productprice').")"; $sql .= " AND p.fk_user_author = u.rowid"; if (!empty($socid) && !empty($conf->global->PRODUIT_MULTIPRICES)) { - $sql .= " AND p.price_level = ".$soc->price_level; + $sql .= " AND p.price_level = ".((int) $soc->price_level); } $sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; // $sql .= $db->plimit(); diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 74803f63909..d8dad67bee2 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -488,7 +488,7 @@ class MouvementStock extends CommonObject if (!$error) { $sql = "SELECT rowid, reel FROM ".MAIN_DB_PREFIX."product_stock"; - $sql .= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product; // This is a unique key + $sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product); // This is a unique key dol_syslog(get_class($this)."::_create check if a record already exists in product_stock", LOG_DEBUG); $resql = $this->db->query($sql); @@ -544,12 +544,12 @@ class MouvementStock extends CommonObject { if ($alreadyarecord > 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + ".$qty; - $sql .= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product; + $sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + ".((float) $qty); + $sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product); } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock"; $sql .= " (reel, fk_entrepot, fk_product) VALUES "; - $sql .= " (".$qty.", ".$entrepot_id.", ".$fk_product.")"; + $sql .= " (".((float) $qty).", ".((int) $entrepot_id).", ".((int) $fk_product).")"; } dol_syslog(get_class($this)."::_create update stock value", LOG_DEBUG); @@ -602,7 +602,7 @@ class MouvementStock extends CommonObject $newpmp = price2num($newpmp, 'MU'); // $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty; - // $sql.= " WHERE rowid = ".$fk_product; + // $sql.= " WHERE rowid = ".((int) $fk_product); // Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".((float) $newpmp).","; $sql .= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; @@ -763,7 +763,7 @@ class MouvementStock extends CommonObject $sql = "SELECT fk_product_pere, fk_product_fils, qty"; $sql .= " FROM ".MAIN_DB_PREFIX."product_association"; - $sql .= " WHERE fk_product_pere = ".$idProduct; + $sql .= " WHERE fk_product_pere = ".((int) $idProduct); $sql .= " AND incdec = 1"; dol_syslog(get_class($this)."::_createSubProduct for parent product ".$idProduct, LOG_DEBUG); @@ -875,7 +875,7 @@ class MouvementStock extends CommonObject $nbSP=0; $resql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."product_association"; - $resql.= " WHERE fk_product_pere = ".$id; + $resql.= " WHERE fk_product_pere = ".((int) $id); if ($this->db->query($resql)) { $obj=$this->db->fetch_object($resql); @@ -1284,7 +1284,7 @@ class MouvementStock extends CommonObject $sql = "SELECT sum(pb.qty) as cpt"; $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."product_stock as ps ON ps.rowid = pb.fk_product_stock"; - $sql .= " WHERE ps.fk_product = " . $fk_product; + $sql .= " WHERE ps.fk_product = " . ((int) $fk_product); $sql .= " AND pb.batch = '" . $this->db->escape($batch) . "'"; $result = $this->db->query($sql); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 9b6c0a38a1c..f05d6ebc168 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -275,7 +275,7 @@ class Productlot extends CommonObject $sql .= " t.import_key"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($product_id > 0 && $batch != '') { - $sql .= " WHERE t.batch = '".$this->db->escape($batch)."' AND t.fk_product = ".$product_id; + $sql .= " WHERE t.batch = '".$this->db->escape($batch)."' AND t.fk_product = ".((int) $product_id); } else { $sql .= ' WHERE t.rowid = '.((int) $id); } diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index b282984cef5..393fbc73ae2 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -205,7 +205,7 @@ if ($action == 'order' && GETPOST('valid')) { $order = new CommandeFournisseur($db); // Check if an order for the supplier exists $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql .= " WHERE fk_soc = ".$suppliersid[$i]; + $sql .= " WHERE fk_soc = ".((int) $suppliersid[$i]); $sql .= " AND source = 42 AND fk_statut = 0"; $sql .= " AND entity IN (".getEntity('commande_fournisseur').")"; $sql .= " ORDER BY date_creation DESC"; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 792d2fd00de..8253980c034 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -463,7 +463,7 @@ class Project extends CommonObject $sql .= ", accept_booth_suggestions = ".($this->accept_booth_suggestions ? 1 : 0); $sql .= ", price_registration = ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : "null"); $sql .= ", price_booth = ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : "null"); - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -783,7 +783,7 @@ class Project extends CommonObject // Remove linked categories. if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_project"; - $sql .= " WHERE fk_project = ".$this->id; + $sql .= " WHERE fk_project = ".((int) $this->id); $result = $this->db->query($sql); if (!$result) { @@ -808,7 +808,7 @@ class Project extends CommonObject foreach ($elements as $table) { if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; - $sql .= " WHERE fk_project = ".$this->id; + $sql .= " WHERE fk_project = ".((int) $this->id); $result = $this->db->query($sql); if (!$result) { @@ -900,17 +900,17 @@ class Project extends CommonObject if ($type == 'agenda') { $sql = "SELECT COUNT(id) as nb FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project = ".$this->id." AND entity IN (".getEntity('agenda').")"; } elseif ($type == 'expensereport') { - $sql = "SELECT COUNT(ed.rowid) as nb FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet = ".$this->id; + $sql = "SELECT COUNT(ed.rowid) as nb FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet = ".((int) $this->id); } elseif ($type == 'project_task') { $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet = ".$this->id; } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user - $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet = ".$this->id; + $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet = ".((int) $this->id); } elseif ($type == 'stock_mouvement') { - $sql = 'SELECT COUNT(ms.rowid) as nb FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin = ".$this->id." AND ms.type_mouvement = 1"; + $sql = 'SELECT COUNT(ms.rowid) as nb FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin = ".((int) $this->id)." AND ms.type_mouvement = 1"; } elseif ($type == 'loan') { - $sql = 'SELECT COUNT(l.rowid) as nb FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet = ".$this->id; + $sql = 'SELECT COUNT(l.rowid) as nb FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet = ".((int) $this->id); } else { - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." = ".$this->id." AND entity IN (".getEntity($type).")"; + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." = ".((int) $this->id)." AND entity IN (".getEntity($type).")"; } $result = $this->db->query($sql); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 7916f79fdeb..fe8b2eeb8e3 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1317,9 +1317,9 @@ class Task extends CommonObject $sql .= " SUM(t.task_duration) as nbseconds,"; $sql .= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql .= " WHERE t.fk_task = ".$id; + $sql .= " WHERE t.fk_task = ".((int) $id); if (is_object($fuser) && $fuser->id > 0) { - $sql .= " AND fk_user = ".$fuser->id; + $sql .= " AND fk_user = ".((int) $fuser->id); } if ($dates > 0) { $datefieldname = "task_datehour"; @@ -1553,7 +1553,7 @@ class Task extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".((int) $this->id).")"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); if (!$this->db->query($sql)) { diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index a19c1212761..80e092f2951 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -131,7 +131,7 @@ llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead); $sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent"; -$sql .= " WHERE entity = ".$entity; +$sql .= " WHERE entity = ".((int) $entity); $sql .= " AND statut = 1"; $sql .= " AND public = 1"; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index d39f48f2dfe..f44bc0b1c99 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -373,7 +373,7 @@ if ($event->type == 'payout.created') { } } elseif ($event->type == 'payment_method.detached') { $db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib WHERE number = '".$db->escape($event->data->object->id)."' and status = ".$servicestatus; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib WHERE number = '".$db->escape($event->data->object->id)."' and status = ".((int) $servicestatus); $db->query($sql); $db->commit(); } elseif ($event->type == 'charge.succeeded') { diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index a8a55c7faf2..b2f31505c44 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1410,7 +1410,7 @@ class Reception extends CommonObject if (!empty($this->shipping_method_id)) { $sql = "SELECT em.code, em.tracking"; $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql .= " WHERE em.rowid = ".$this->shipping_method_id; + $sql .= " WHERE em.rowid = ".((int) $this->shipping_method_id); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index c16018a30c1..24be7dfbb5a 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -118,7 +118,7 @@ if (empty($reshook)) { $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = '".$db->escape($resource_type)."'"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($objstat->element)."'"; - $sql .= " WHERE er.resource_id = ".$resource_id; + $sql .= " WHERE er.resource_id = ".((int) $resource_id); $sql .= " AND er.busy = 1"; $sql .= " AND ("; @@ -193,8 +193,8 @@ if (empty($reshook)) { $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = '".$db->escape($object->resource_type)."'"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element_type)."'"; - $sql .= " WHERE er.resource_id = ".$object->resource_id; - $sql .= " AND ac.id != ".$object->element_id; + $sql .= " WHERE er.resource_id = ".((int) $object->resource_id); + $sql .= " AND ac.id <> ".((int) $object->element_id); $sql .= " AND er.busy = 1"; $sql .= " AND ("; diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index e1225f15258..afd152fb785 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -780,7 +780,7 @@ if ($id) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; $sql .= ", ".MAIN_DB_PREFIX."salary as salaire"; - $sql .= " WHERE p.fk_salary = ".$id; + $sql .= " WHERE p.fk_salary = ".((int) $id); $sql .= " AND p.fk_salary = salaire.rowid"; $sql .= " AND salaire.entity IN (".getEntity('tax').")"; $sql .= " ORDER BY dp DESC"; diff --git a/htdocs/salaries/class/salariesstats.class.php b/htdocs/salaries/class/salariesstats.class.php index f8a7d618fb0..b3e6c20a0ca 100644 --- a/htdocs/salaries/class/salariesstats.class.php +++ b/htdocs/salaries/class/salariesstats.class.php @@ -64,7 +64,7 @@ class SalariesStats extends Stats $this->where = " entity = ".$conf->entity; if ($this->socid > 0) { - $this->where .= " AND fk_soc = ".$this->socid; + $this->where .= " AND fk_soc = ".((int) $this->socid); } if (is_array($this->userid) && count($this->userid) > 0) { $this->where .= ' AND fk_user IN ('.$this->db->sanitize(join(',', $this->userid)).')'; @@ -101,7 +101,7 @@ class SalariesStats extends Stats { $sql = "SELECT MONTH(datep) as dm, count(*)"; $sql .= " FROM ".$this->from; - $sql .= " WHERE YEAR(datep) = ".$year; + $sql .= " WHERE YEAR(datep) = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); diff --git a/htdocs/salaries/paiement_salary.php b/htdocs/salaries/paiement_salary.php index eb9fe8bfd17..6c282eac94d 100644 --- a/htdocs/salaries/paiement_salary.php +++ b/htdocs/salaries/paiement_salary.php @@ -188,12 +188,12 @@ if ($action == 'create') { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " WHERE p.fk_salary = ".$chid; + $sql .= " WHERE p.fk_salary = ".((int) $chid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } /*print '
    '; print '';*/ diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index ddc9fa41fdb..6fd5160d8a6 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1017,7 +1017,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT f.ref, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture, re.fk_facture_line"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f"; - $sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".$id; + $sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".((int) $id); if ($filter == "available") { $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL"; } @@ -1155,7 +1155,7 @@ class Thirdparties extends DolibarrApi $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; if ($id) { - $sql .= " WHERE fk_soc = ".$id." "; + $sql .= " WHERE fk_soc = ".((int) $id); } @@ -1505,7 +1505,7 @@ class Thirdparties extends DolibarrApi throw new RestException(422, 'Unprocessable Entity: You must pass the site attribute in your request data !'); } - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."'"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".((int) $id)." AND site = '".$this->db->escape($request_data['site'])."'"; $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) == 0) { @@ -1585,7 +1585,7 @@ class Thirdparties extends DolibarrApi // We found an existing SocieteAccount entity, we are replacing it } else { if (isset($request_data['site']) && $request_data['site'] !== $site) { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' "; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".((int) $id)." AND site = '".$this->db->escape($request_data['site'])."' "; $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) !== 0) { @@ -1649,7 +1649,7 @@ class Thirdparties extends DolibarrApi } else { // If the user tries to edit the site member, we check first if if (isset($request_data['site']) && $request_data['site'] !== $site) { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' "; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".((int) $id)." AND site = '".$this->db->escape($request_data['site'])."' "; $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) !== 0) { @@ -1733,7 +1733,7 @@ class Thirdparties extends DolibarrApi */ $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".((int) $id); $result = $this->db->query($sql); diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php index 6b09d88ac71..eefb71b6772 100644 --- a/htdocs/societe/class/client.class.php +++ b/htdocs/societe/class/client.class.php @@ -104,7 +104,7 @@ class Client extends Societe $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm"; if ($active >= 0) { - $sql .= " WHERE active = ".$active; + $sql .= " WHERE active = ".((int) $active); } $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index c611ccab462..3e410019b22 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -217,12 +217,12 @@ class CompanyBankAccount extends Account $sql .= " WHERE rowid = ".((int) $id); } if ($socid) { - $sql .= " WHERE fk_soc = ".$socid; + $sql .= " WHERE fk_soc = ".((int) $socid); if ($default > -1) { - $sql .= " AND default_rib = ".$this->db->escape($default); + $sql .= " AND default_rib = ".((int) $default); } if ($type) { - $sql .= " AND type ='".$this->db->escape($type)."'"; + $sql .= " AND type = '".$this->db->escape($type)."'"; } } @@ -351,12 +351,12 @@ class CompanyBankAccount extends Account $this->db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0"; - $sql2 .= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc; + $sql2 .= " WHERE type = 'ban' AND fk_soc = ".((int) $obj->fk_soc); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result2 = $this->db->query($sql2); $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1"; - $sql3 .= " WHERE rowid = ".$obj->id; + $sql3 .= " WHERE rowid = ".((int) $obj->id); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result3 = $this->db->query($sql3); diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index db19840fd8e..1f11e6a29c3 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -318,7 +318,7 @@ class CompanyPaymentMode extends CommonObject public function fetch($id, $ref = null, $socid = 0, $type = '', $morewhere = '') { if ($socid) { - $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1"; + $morewhere .= " AND fk_soc = ".((int) $socid)." AND default_rib = 1"; } if ($type) { $morewhere .= " AND type = '".$this->db->escape($type)."'"; @@ -464,7 +464,7 @@ class CompanyPaymentMode extends CommonObject $this->db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms"; - $sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc; + $sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".((int) $obj->fk_soc); if ($type) { $sql2 .= " AND type = '".$this->db->escape($type)."'"; } @@ -472,7 +472,7 @@ class CompanyPaymentMode extends CommonObject $result2 = $this->db->query($sql2); $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1"; - $sql3 .= " WHERE rowid = ".$obj->id; + $sql3 .= " WHERE rowid = ".((int) $obj->id); if ($type) { $sql3 .= " AND type = '".$this->db->escape($type)."'"; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 99453db7ac4..6874c4b3b2d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1907,7 +1907,7 @@ class Societe extends CommonObject } } else { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete; - $sql .= " WHERE fk_soc = ".$id; + $sql .= " WHERE fk_soc = ".((int) $id); if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); @@ -1930,7 +1930,7 @@ class Societe extends CommonObject if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; $sql .= " SET parent = NULL"; - $sql .= " WHERE parent = ".$id; + $sql .= " WHERE parent = ".((int) $id); if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); @@ -2326,7 +2326,7 @@ class Societe extends CommonObject if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; + $sql .= " WHERE fk_soc = ".$this->id." AND fk_user = ".((int) $commid); $resql = $this->db->query($sql); if (!$resql) { @@ -2389,7 +2389,7 @@ class Societe extends CommonObject if ($this->id > 0 && $commid > 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; - $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; + $sql .= " WHERE fk_soc = ".$this->id." AND fk_user = ".((int) $commid); if (!$this->db->query($sql)) { dol_syslog(get_class($this)."::del_commercial Erreur"); diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 5be05d99a56..8fbbbbcee6e 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -284,7 +284,7 @@ class SocieteAccount extends CommonObject { $sql = "SELECT sa.key_account as key_account, sa.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as sa"; - $sql .= " WHERE sa.fk_soc = ".$id; + $sql .= " WHERE sa.fk_soc = ".((int) $id); $sql .= " AND sa.entity IN (".getEntity('societe').")"; $sql .= " AND sa.site = '".$this->db->escape($site)."' AND sa.status = ".((int) $status); $sql .= " AND sa.key_account IS NOT NULL AND sa.key_account <> ''"; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index a7ef895041e..3190ad5e64e 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -146,7 +146,7 @@ if ($object->client) { print ' ('.$langs->trans("WrongCustomerCode").')'; } print ''; - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -183,7 +183,7 @@ if ($object->fournisseur) { print ' ('.$langs->trans("WrongSupplierCode").')'; } print ''; - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".((int) $socid); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -229,7 +229,7 @@ if ($type_element == 'fichinter') { // Customer : show products from invoices $documentstatic = new Fichinter($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."fichinter as f LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as d ON d.fk_fichinter = f.rowid"; // Must use left join to work also with option that disable usage of lines. - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND f.entity = ".$conf->entity; $dateprint = 'f.datec'; $doc_number = 'f.ref'; @@ -239,7 +239,7 @@ if ($type_element == 'invoice') { // Customer : show products from invoices $documentstatic = new Facture($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; $tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d"; - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_facture = f.rowid"; $where .= " AND f.entity IN (".getEntity('invoice').")"; $dateprint = 'f.datef'; @@ -251,7 +251,7 @@ if ($type_element == 'propal') { $documentstatic = new Propal($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."propal as c,".MAIN_DB_PREFIX."propaldet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_propal = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $datePrint = 'c.datep'; @@ -263,7 +263,7 @@ if ($type_element == 'order') { $documentstatic = new Commande($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."commande as c,".MAIN_DB_PREFIX."commandedet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_commande = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_commande'; @@ -275,7 +275,7 @@ if ($type_element == 'supplier_invoice') { // Supplier : Show products from inv $documentstatic = new FactureFournisseur($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; $tables_from = MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."facture_fourn_det as d"; - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_facture_fourn = f.rowid"; $where .= " AND f.entity = ".$conf->entity; $dateprint = 'f.datef'; @@ -287,7 +287,7 @@ if ($type_element == 'supplier_proposal') { $documentstatic = new SupplierProposal($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_supplier_proposal = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; @@ -299,7 +299,7 @@ if ($type_element == 'supplier_order') { // Supplier : Show products from order $documentstatic = new CommandeFournisseur($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_commande = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; @@ -312,7 +312,7 @@ if ($type_element == 'contract') { // Order $documentstaticline = new ContratLigne($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, '; $tables_from = MAIN_DB_PREFIX."contrat as c,".MAIN_DB_PREFIX."contratdet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_contrat = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 8c321b1386d..dc8d95ef42f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -517,10 +517,10 @@ if (empty($reshook)) { $db->begin(); if (empty($newcu)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; } else { $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_account"; - $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! } $resql = $db->query($sql); @@ -542,7 +542,7 @@ if (empty($reshook)) { } else { $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; $sql .= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."', site_account = '".$db->escape($site_account)."'"; - $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! $resql = $db->query($sql); } } @@ -761,7 +761,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ' ('.$langs->trans("WrongCustomerCode").')'; } print ''; - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -823,7 +823,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ' ('.$langs->trans("WrongSupplierCode").')'; } print ''; - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index c37f61e4fe2..2a6dd2176df 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -227,7 +227,7 @@ if ($id > 0 || !empty($ref)) { $sql .= " t.libelle as type, t.subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t"; - $sql .= " WHERE d.fk_soc = ".$id; + $sql .= " WHERE d.fk_soc = ".((int) $id); $sql .= " AND d.fk_adherent_type = t.rowid"; dol_syslog("get list sql=".$sql); diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index dd895eb4265..e9d721a44e3 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -260,7 +260,7 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) { $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$facid; + $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $facid); $sql .= " ORDER BY p.datep"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 57d0066323d..1d77e323c10 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -568,7 +568,7 @@ class Ticket extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; if ($id) { - $sql .= " WHERE t.rowid = ".$this->db->escape($id); + $sql .= " WHERE t.rowid = ".((int) $id); } else { $sql .= " WHERE t.entity IN (".getEntity($this->element, 1).")"; if (!empty($ref)) { diff --git a/htdocs/ticket/class/ticketstats.class.php b/htdocs/ticket/class/ticketstats.class.php index 51449c6b233..2bcd0fe89fc 100644 --- a/htdocs/ticket/class/ticketstats.class.php +++ b/htdocs/ticket/class/ticketstats.class.php @@ -98,7 +98,7 @@ class TicketStats extends Stats { $sql = "SELECT MONTH(datec) as dm, count(*)"; $sql .= " FROM ".$this->from; - $sql .= " WHERE YEAR(datec) = ".$year; + $sql .= " WHERE YEAR(datec) = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f01198f1ca8..b3303492417 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -871,7 +871,7 @@ class User extends CommonObject $nid = $obj->id; $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights"; - $sql .= " WHERE fk_user = ".$this->id." AND fk_id=".$nid; + $sql .= " WHERE fk_user = ".$this->id." AND fk_id = ".((int) $nid); $sql .= " AND entity = ".$entity; if (!$this->db->query($sql)) { $error++; diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index 9f57a445cc3..a28371443d5 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -503,7 +503,7 @@ function getContactsForThirdParty($authentication, $idthirdparty) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - $sql .= " WHERE c.fk_soc = ".$idthirdparty; + $sql .= " WHERE c.fk_soc = ".((int) $idthirdparty); $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 259f3ec67fe..95b7246d021 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -1006,7 +1006,7 @@ function getProductsForCategory($authentication, $id, $lang = '') $table = "product"; $field = "product"; $sql = "SELECT fk_".$field." FROM ".MAIN_DB_PREFIX."categorie_".$table; - $sql .= " WHERE fk_categorie = ".$id; + $sql .= " WHERE fk_categorie = ".((int) $id); $sql .= " ORDER BY fk_".$field." ASC"; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 171918238b8..80d31f0024d 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1414,10 +1414,10 @@ class Website extends CommonObject $sql = "SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; - $sql .= " WHERE wp.fk_website = ".$website->id; + $sql .= " WHERE wp.fk_website = ".((int) $website->id); $sql .= " AND (wp.fk_page = ".((int) $pageid)." OR wp.rowid = ".((int) $pageid); if ($tmppage->fk_page > 0) { - $sql .= " OR wp.fk_page = ".$tmppage->fk_page." OR wp.rowid = ".$tmppage->fk_page; + $sql .= " OR wp.fk_page = ".((int) $tmppage->fk_page)." OR wp.rowid = ".((int) $tmppage->fk_page); } $sql .= ")"; From fb7cfe6c508a26a2b9023f6251758a18fff09fa3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 19:15:20 +0200 Subject: [PATCH 125/233] Fix sql error --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ca4e445c880..74e2f380d91 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2282,7 +2282,7 @@ class Facture extends CommonInvoice // Invoice line extrafileds $main = MAIN_DB_PREFIX.'facturedet'; $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture = ".((int) $rowid); + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture = ".((int) $rowid).")"; // Delete invoice line $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.((int) $rowid); From ab58ba80c9137610588bb2bb04f74e1ac986f6bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 19:17:12 +0200 Subject: [PATCH 126/233] Update llx_10_c_regions.sql --- htdocs/install/mysql/data/llx_10_c_regions.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 37394db47e0..b054ca383ef 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -12,9 +12,6 @@ -- Copyright (C) 2019~ Lao Tian <281388879@qq.com> -- Copyright (C) 2020-2021 Udo Tamm -- --- --- LICENSE ---------------------------------------------------------------------- --- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or From d6b5e24d9635532eb9aaf13d5d005b12fc7c6836 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 19:20:02 +0200 Subject: [PATCH 127/233] Update payments.php --- htdocs/salaries/payments.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index b3a398c8c45..0ec83a55595 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -485,7 +485,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } $accountstatic->label = $obj->blabel; - if ($accountstatic->id > 0) print $accountstatic->getNomUrl(1); + if ($accountstatic->id > 0) { + print $accountstatic->getNomUrl(1); + } } else print ' '; print ''; if (!$i) $totalarray['nbfield']++; From fd410adcf3819b908b5517f852dda0eac4c6d654 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 19:22:02 +0200 Subject: [PATCH 128/233] Update llx_20_c_departements.sql --- htdocs/install/mysql/data/llx_20_c_departements.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 1a6e7970cde..2ac7a30a99b 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -11,9 +11,6 @@ -- Copyright (C) 2015 Ferran Marcet -- Copyright (C) 2020-2021 Udo Tamm -- --- --- LICENSE ---------------------------------------------------------------------- --- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or From e763bb548332b5e4ff4e1b66c7ccb562d9d1cafc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 19:22:51 +0200 Subject: [PATCH 129/233] Update type_translation.php --- htdocs/adherents/type_translation.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 7111f9c905c..84fe883e41f 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -4,9 +4,6 @@ * Copyright (C) 2010-2012 Destailleur Laurent * Copyright (C) 2014 Henry Florian * - * - * LICENSE - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or From 6ba725eb5e0df190d62b4f4d9b6a7434bd8a3246 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 21:04:12 +0200 Subject: [PATCH 130/233] Fix sql error --- htdocs/install/upgrade2.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 26c791c2290..32959af80cc 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3247,7 +3247,7 @@ function migrate_mode_reglement($db, $langs, $conf) $db->begin(); $sqla = "UPDATE ".MAIN_DB_PREFIX."paiement SET"; - $sqla .= " fk_paiement = ".$elements['new_id'][$key]; + $sqla .= " fk_paiement = ".((int) $elements['new_id'][$key]); $sqla .= " WHERE fk_paiement = ".((int) $old_id); $sqla .= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".((int) $old_id)." AND code = '".$db->escape($elements['code'][$key])."')"; $resqla = $db->query($sqla); @@ -3261,7 +3261,7 @@ function migrate_mode_reglement($db, $langs, $conf) if ($resqla && $resql) { foreach ($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; - $sql .= "fk_mode_reglement = "((int) $elements['new_id'][$key]); + $sql .= "fk_mode_reglement = ".((int) $elements['new_id'][$key]); $sql .= " WHERE fk_mode_reglement = ".((int) $old_id); $resql = $db->query($sql); From 06e92bb262a651b38bf37b328b633d9f65c2762f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Mar 2021 22:03:14 +0200 Subject: [PATCH 131/233] Fix compatibility php5.6+ --- test/phpunit/InventoryTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/phpunit/InventoryTest.php b/test/phpunit/InventoryTest.php index 1d125a0311c..ad2b19aebd3 100644 --- a/test/phpunit/InventoryTest.php +++ b/test/phpunit/InventoryTest.php @@ -79,7 +79,7 @@ class InventoryTest extends PHPUnit\Framework\TestCase * * @return void */ - public static function setUpBeforeClass():void + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; @@ -93,7 +93,7 @@ class InventoryTest extends PHPUnit\Framework\TestCase * * @return void */ - public static function tearDownAfterClass():void + public static function tearDownAfterClass() { global $conf,$user,$langs,$db; $db->rollback(); @@ -106,7 +106,7 @@ class InventoryTest extends PHPUnit\Framework\TestCase * * @return void */ - protected function setUp():void + protected function setUp() { global $conf,$user,$langs,$db; $conf=$this->savconf; @@ -122,7 +122,7 @@ class InventoryTest extends PHPUnit\Framework\TestCase * * @return void */ - protected function tearDown():void + protected function tearDown() { print __METHOD__."\n"; } From ba84a3628294e3c1792eca67401929ff09f62a0b Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 22:12:13 +0200 Subject: [PATCH 132/233] Update card.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas|DE:Modul_Banken_und_Barbestände'; --- htdocs/compta/bank/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 48335d38964..72be65b0a4f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -306,7 +306,7 @@ $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans(" $title = $langs->trans("FinancialAccount")." - ".$langs->trans("Card"); -$help_url = "EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses"; +$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas|DE:Modul_Banken_und_Barbestände'; llxHeader("", $title, $help_url); From 38d47c184ead60a255625148529ed92983dcaff0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 30 Mar 2021 22:12:57 +0200 Subject: [PATCH 133/233] FIX: Add a sub table to manage accountancy on product/company --- htdocs/accountancy/admin/productaccount.php | 2 +- htdocs/accountancy/customer/card.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 2 +- htdocs/compta/journal/sellsjournal.php | 2 +- htdocs/core/modules/modService.class.php | 2 +- htdocs/product/list.php | 54 ++++++++++----------- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 26de6e5ab16..d2d71dfb77c 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -280,7 +280,7 @@ $sql .= " p.tms, p.fk_product_type as product_type,"; $sql .= " aa.rowid as aaid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = pa." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } else { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = p." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 88b199e76e3..f0bcd9f7a49 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -110,7 +110,7 @@ if (!empty($id)) { $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = l.fk_facture"; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 8944fa958d9..d1361d1296e 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -116,7 +116,7 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { } $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index e8b5a7e44b2..9fa4168ea0a 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -121,7 +121,7 @@ $sql .= " ct.accountancy_code_sell as account_tva, ct.recuperableonly"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 22e7059a82e..09fc738d78c 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -408,7 +408,7 @@ class modService extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_accounting as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index f97acd96504..dc035187f30 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -502,13 +502,13 @@ if ($search_accountancy_code_sell_export) { $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_export', $search_accountancy_code_sell_export); } if ($search_accountancy_code_buy) { - $sql .= natural_search($alias_product_accounting . '.accountancy_code_buy', $search_accountancy_code_buy); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy', $search_accountancy_code_buy); } if ($search_accountancy_code_buy_intra) { - $sql .= natural_search($alias_product_accounting . '.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); } if ($search_accountancy_code_buy_export) { - $sql .= natural_search($alias_product_accounting . '.accountancy_code_buy_export', $search_accountancy_code_buy_export); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', $search_accountancy_code_buy_export); } // Add where from extra fields @@ -1004,23 +1004,23 @@ if ($resql) { print ''; } // Accountancy code sell - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_sell']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { print ''; } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_sell_intra']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { print ''; } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_sell_export']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { print ''; } // Accountancy code buy - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_buy']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { print ''; } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_buy_intra']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { print ''; } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_buy_export']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { print ''; } // Extra fields @@ -1167,23 +1167,23 @@ if ($resql) { if (!empty($arrayfields['p.fk_state']['checked'])) { print_liste_field_titre($arrayfields['p.fk_state']['label'], $_SERVER["PHP_SELF"], "p.fk_state", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_sell']['checked'])) { - print_liste_field_titre($arrayfields[$alias_product_accounting . '.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], $alias_product_accounting . ".accountancy_code_sell", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_sell", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_sell_intra']['checked'])) { - print_liste_field_titre($arrayfields[$alias_product_accounting . '.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], $alias_product_accounting . ".accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_sell_export']['checked'])) { - print_liste_field_titre($arrayfields[$alias_product_accounting . '.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], $alias_product_accounting . ".accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_buy']['checked'])) { - print_liste_field_titre($arrayfields[$alias_product_accounting . '.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], $alias_product_accounting . ".accountancy_code_buy", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_buy", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_buy_intra']['checked'])) { - print_liste_field_titre($arrayfields[$alias_product_accounting . '.accountancy_code_buy_intra']['label'], $_SERVER["PHP_SELF"], $alias_product_accounting . ".accountancy_code_buy_intra", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_buy_intra", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_buy_export']['checked'])) { - print_liste_field_titre($arrayfields[$alias_product_accounting . '.accountancy_code_buy_export']['label'], $_SERVER["PHP_SELF"], $alias_product_accounting . ".accountancy_code_buy_export", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_buy_export", "", $param, '', $sortfield, $sortorder); } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1708,38 +1708,38 @@ if ($resql) { } } // Accountancy code sell - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_sell']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; } } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_sell_intra']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; } } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_sell_export']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; } } // Accountancy code buy - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_buy']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; } } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_buy_intra']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; } } - if (!empty($arrayfields[$alias_product_accounting . '.accountancy_code_buy_export']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; From dd4c941f47cc69344400f82396657bcb72aa90bf Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 22:27:33 +0200 Subject: [PATCH 134/233] Update ekiga.sh --- scripts/clicktodial/ekiga.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/clicktodial/ekiga.sh b/scripts/clicktodial/ekiga.sh index 09331c24350..4fce22f63cb 100755 --- a/scripts/clicktodial/ekiga.sh +++ b/scripts/clicktodial/ekiga.sh @@ -2,8 +2,8 @@ #--------------------------------------------------------- # Script to launch Ekiga softphone. # This script can be used to setup a ClickToDial system -# when using Ekiga soft phone. -# More information on http://wiki.dolibarr.org/index.php/Module_ClickToDial_En +# when using Ekiga soft phone with Dolibarr. +# More information on https://wiki.dolibarr.org/index.php/Module_ClickToDial_En #--------------------------------------------------------- ekiga -c $1 & From 0c2230cb03aa14f35037319cbc58addf1b336c76 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 22:28:31 +0200 Subject: [PATCH 135/233] Update linphone.sh --- scripts/clicktodial/linphone.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/clicktodial/linphone.sh b/scripts/clicktodial/linphone.sh index 97c3bcb18d7..ee013526c69 100755 --- a/scripts/clicktodial/linphone.sh +++ b/scripts/clicktodial/linphone.sh @@ -1,9 +1,11 @@ #!/bin/bash #--------------------------------------------------------- # Script to launch LinPhone softphone. +# # This script can be used to setup a ClickToDial system -# when using LinPhone soft phone. -# More information on http://wiki.dolibarr.org/index.php/Module_ClickToDial_En +# when using LinPhone soft phone with Dolibarr. +# +# More information on https://wiki.dolibarr.org/index.php/Module_ClickToDial_En #--------------------------------------------------------- # Note: Adding handler into gconf-tools seems to do nothing From 3ffc7a466ff5d58f3d95a96eeee14c4db541c1fe Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 22:33:06 +0200 Subject: [PATCH 136/233] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad4971f50db..0a3aeecb9f4 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Main application/modules (all optional) - Customers, Prospects (Leads) and/or Suppliers directory + Contacts -- Members management +- Members/Membership management - Products and/or Services catalog - Commercial proposals management - Customer & Supplier Orders management @@ -112,6 +112,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Shared calendar/agenda (with ical and vcal export for third party tools integration) - Opportunities or Leads management - Projects & Tasks management +- Ticket System - Contracts management - Interventions management - Employee's leave requests management @@ -160,7 +161,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Canadian double taxes (federal/province) and other countries using cumulative VAT - Tunisian tax stamp - Argentina invoice numbering using A,B,C... - - Compatible with [European directives](http://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) + - Compatible with [European directives] (https://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) - Compatible with European GDPR rules - ... - Flexible PDF & ODT generation for invoices, proposals, orders... From 6845967f56e8061dcf402dd6ee7ea6ab3a1120d4 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 30 Mar 2021 22:45:03 +0200 Subject: [PATCH 137/233] Update ChangeLog --- ChangeLog | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 646c1314b1f..c784c2f4bf3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,21 +48,21 @@ FIX: #16533 FIX: #16629 FIX: #16671 Can not generate zip file of documents in backup tool FIX: Add "Now" link on social charges creation card -FIX: avoid undefined url and missing token +FIX: avoid undefined URL and missing token FIX: Bad project filter in ticket list FIX: Buttons to disable bindings not working FIX: class not found when creating recuring invoice from invoice+discount -FIX: File attachment on lots +FIX: File attachment on lots/batches FIX: handling $heightforinfotot when he's superior to a page height on Supplier Invoice FIX: hourglass and hide button to pay -FIX: massaction validate invoice do not regenerate pdf +FIX: massaction validate invoice do not regenerate PDF FIX: missing mp4 video mime FIX: picto on shipment to reset qty to 0. Some quantities were not reset. FIX: Protection to avoid #16504 FIX: rounding amount on card updating -FIX: Rounding amount on social charges card updating +FIX: rounding amount on social charges card updating FIX: select list dependencies now work for ModuleBuilder sellist field -FIX: Status in popup of member in widget +FIX: status in popup of member in widget FIX: status on tooltip on widgets FIX: Timezone management for datetime on list of events FIX: Timezone management for datetime with modulebuilder and extrafields @@ -93,9 +93,9 @@ FIX: #16135 FIX: #16143 FIX: #16156 FIX: #16160 -FIX: #16165 Create customer discount without vat +FIX: #16165 Create customer discount without VAT FIX: #16185 -FIX: #16189, fix download/see check deposit PDF +FIX: #16189 fix download/see check deposit PDF FIX: #16215 FIX: Accountancy - label_operation is used instead of label_compte FIX: Add critical price patch @@ -105,7 +105,7 @@ FIX: cash fence for takepos with multientity FIX: CSRF errors on margin forms FIX: encoding status in graph of vendor proposals FIX: Fix detect dispached product and set to received completely when the supplier order have services (support STOCK_SUPPORTS_SERVICES) -FIX: Hide/Unhide external ICSS calendars +FIX: hide/unhide external ICS calendars FIX: link to create event when task is in a project with a thirdparty FIX: Localtax must be converted with price2num FIX: manage price min for PRODUIT_CUSTOMER_PRICES @@ -126,7 +126,7 @@ FIX: warning when adding a line if $remise_percent is an empty string FIX: status late on purchase orders FIX: ODT generation very slow FIX: amount in summary of report -FIX: vat value when code contains number +FIX: VAT value when code contains number FIX: payment term label on PDF FIX: date selector when using reduced year (like on smartphone) @@ -145,7 +145,7 @@ NEW: Accountancy - add options to disable binding on sales, purchases & expense NEW: Accountancy balance - add a menu entry to show subtotal by group NEW: Accountancy - change menu disposition NEW: Accountancy - on transfers, select the periodicity by default -NEW: Accountancy - Add export for Gestinum (v3 & v5) #15180 +NEW: Accountancy - add export for Gestinum (v3 & v5) #15180 NEW: new currency rate editor NEW: Solve blocking feature. Can increase stock of a Kit without changing subproduct stock. NEW: add a widget to show the customers with outstanding limits reached From 0f6dae313df955d8aa1ca3e11468338a0b271a7e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 30 Mar 2021 23:02:53 +0200 Subject: [PATCH 138/233] fix : test on reception must be done on lineToTest if checked --- htdocs/reception/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 3bac7265606..7bfbff09ecb 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -318,9 +318,15 @@ if (empty($reshook)) $entrepot_id = is_numeric(GETPOST($ent, 'int')) ? GETPOST($ent, 'int') : GETPOST('entrepot_id', 'int'); + if (!empty($lineToTest)) { + $fk_product = $lineToTest->fk_product; + } else { + $fk_product = $linesrc->fk_product; + } + if ($entrepot_id < 0) $entrepot_id = ''; - if (!($linesrc->fk_product > 0) && empty($conf->global->STOCK_SUPPORTS_SERVICES)) + if (!($fk_product > 0) && empty($conf->global->STOCK_SUPPORTS_SERVICES)) $entrepot_id = 0; $eatby = GETPOST($eatby, 'alpha'); $sellby = GETPOST($sellby, 'alpha'); From cd37d3440a38ea7211365a33503e8a9b6d7d2ec3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 30 Mar 2021 23:04:29 +0200 Subject: [PATCH 139/233] fix : test on reception must be done on lineToTest if checked --- htdocs/reception/card.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 7bfbff09ecb..66aa1b300b8 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -237,8 +237,6 @@ if (empty($reshook)) $objectsrc = new $classname($db); $objectsrc->fetch($object->origin_id); - - $object->socid = $objectsrc->socid; $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); $object->model_pdf = GETPOST('model'); @@ -280,10 +278,8 @@ if (empty($reshook)) $stockLocation = "ent1".$i."_0"; $qty = "qtyl".$i; - - - //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit; - //reception line for product with no batch management and no multiple stock location + //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit; + //reception line for product with no batch management and no multiple stock location if (GETPOST($qty, 'int') > 0) $totalqty += GETPOST($qty, 'int'); From d13435cc84e80f2fbd4a268e107f3461ab5f4fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 31 Mar 2021 00:46:47 +0200 Subject: [PATCH 140/233] use same code from actioncom card --- htdocs/resource/element_resource.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 24be7dfbb5a..83a8d58d410 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013-2018 Jean-François Ferry * Copyright (C) 2016 Gilles Poirier * Copyright (C) 2019 Josep Lluís Amador + * Copyright (C) 2021 Frédéric France * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -355,7 +356,10 @@ if (!$ret) { // Type if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''; + print ''; } // Full day event From 5723dbb836213940ca7c9e419c3977eb27e874bd Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 31 Mar 2021 04:52:24 +0200 Subject: [PATCH 141/233] FIX: Add a sub table to manage accountancy on product/company --- htdocs/accountancy/admin/productaccount.php | 4 ++-- htdocs/accountancy/customer/index.php | 4 ++-- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/supplier/list.php | 4 ++-- htdocs/core/modules/modFacture.class.php | 2 +- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modService.class.php | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index d2d71dfb77c..2013b0c7295 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -287,7 +287,7 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if (strlen(trim($search_current_account))) { - $sql .= natural_search((!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa." : "p.") . $accountancy_field_name, $search_current_account); + $sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, $search_current_account); } if ($search_current_account_valid == 'withoutvalidaccount') { $sql .= " AND aa.account_number IS NULL"; @@ -466,7 +466,7 @@ if ($result) { } else { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); } - print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa." : "p.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); $clickpitco = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center '); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 57ce6d5d98a..0b32e2802c4 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -147,8 +147,8 @@ if ($action == 'validatehistory') { if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } - $alias_societe_perentity = !empty($conf->global->ACCOUNTANCY_COMPANY_SHARED) ? "sa" : "s"; - $alias_product_perentity = !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_societe_perentity = empty($conf->global->ACCOUNTANCY_COMPANY_SHARED) ? "s" : "sa"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 819de88520d..6f522750398 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -183,7 +183,7 @@ $sql = "SELECT f.rowid as facid, f.ref as ref, f.type, f.datef, f.ref_client,"; $sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,"; $sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,"; $sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label,"; -if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell,"; } else { $sql .= " p.accountancy_code_sell,"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 5ed6e5c2427..a5506fc6ebb 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -218,7 +218,7 @@ if (empty($chartaccountcode)) { $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; -if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; $sql .= " pa.accountancy_code_buy as code_buy, pa.accountancy_code_buy_intra as code_buy_intra, pa.accountancy_code_buy_export as code_buy_export,"; } else { diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 22004ce1545..24ee3afe218 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -252,8 +252,8 @@ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } -$alias_societe_perentity = !empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "sa" : "s"; -$alias_product_perentity = !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; +$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "sa"; +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 200ffe381bb..a88a18df131 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -207,7 +207,7 @@ class modFacture extends DolibarrModules //-------- $r = 1; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r] = 'invoice'; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 10ef1aa5991..fd1c7cceca0 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -176,7 +176,7 @@ class modProduct extends DolibarrModules //-------- $r = 0; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 09fc738d78c..3b21cf046c8 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -143,7 +143,7 @@ class modService extends DolibarrModules //-------- $r = 0; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "pa" : "p"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; From 9b65529fc716447c67efe30889010999012573f6 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 31 Mar 2021 04:59:12 +0200 Subject: [PATCH 142/233] NEW: Accountancy - Add FEC import --- .../class/accountancyimport.class.php | 99 +++++++++++++++++++ htdocs/core/modules/modAccounting.class.php | 82 +++++++++++++-- htdocs/langs/en_US/accountancy.lang | 20 ++++ 3 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 htdocs/accountancy/class/accountancyimport.class.php diff --git a/htdocs/accountancy/class/accountancyimport.class.php b/htdocs/accountancy/class/accountancyimport.class.php new file mode 100644 index 00000000000..c27ff6911ed --- /dev/null +++ b/htdocs/accountancy/class/accountancyimport.class.php @@ -0,0 +1,99 @@ + + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Pierre-Henry Favre + * Copyright (C) 2016-2020 Alexandre Spangaro + * Copyright (C) 2013-2017 Olivier Geffroy + * Copyright (C) 2017 Elarifr. Ari Elbaz + * Copyright (C) 2017-2019 Frédéric France + * Copyright (C) 2017 André Schild + * Copyright (C) 2020 Guillaume Alexandre + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/accountancy/class/accountancyimport.class.php + * \ingroup Accountancy (Double entries) + * \brief Class accountancy import + */ + + + +/** + * Manage the different format accountancy import + */ +class AccountancyImport +{ + /** + * Compute amount + * + * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... + * @param string $fieldname Field name with alias + * @param array $listfields Fields list to add + * @param array $listvalues Values list to add + * @return int <0 if KO, >0 if OK + */ + public function computeMontant(&$arrayrecord, $fieldname, &$listfields, &$listvalues) { + $fieldArr = explode('.', $fieldname); + if (count($fieldArr) > 0) { + $fieldname = $fieldArr[1]; + } + + $debit = trim($arrayrecord[11]['val']); + $credit = trim($arrayrecord[12]['val']); + if (!empty($debit)) { + $amount = $debit; + } else { + $amount = $credit; + } + + $listfields[] = $fieldname; + $listvalues[] = "'" . abs($amount) . "'"; + + return 1; + } + + + /** + * Compute sens + * + * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... + * @param string $fieldname Field name with alias + * @param array $listfields Fields list to add + * @param array $listvalues Values list to add + * @return int <0 if KO, >0 if OK + */ + public function computeSens(&$arrayrecord, $fieldname, &$listfields, &$listvalues) { + $fieldArr = explode('.', $fieldname); + if (count($fieldArr) > 0) { + $fieldname = $fieldArr[1]; + } + + $debit = trim($arrayrecord[11]['val']); + if (!empty($debit)) { + $sens = 'D'; + } else { + $sens = 'C'; + } + + $listfields[] = $fieldname; + $listvalues[] = "'" . $sens . "'"; + + return 1; + } +} diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 15710d71dfa..8034f98d9a7 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2013-2019 Alexandre Spangaro - * Copyright (C) 2014 Ari Elbaz (elarifr) - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2016-2017 Laurent Destailleur - * Copyright (C) 2017 Open-DSI +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2014 Ari Elbaz (elarifr) + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2016-2017 Laurent Destailleur + * Copyright (C) 2017-2021 Open-DSI * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -314,6 +314,76 @@ class modAccounting extends DolibarrModules 'b.sens'=>'C' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit ); + // General ledger - Fichier FEC + $r++; + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = 'ImportAccountingEntriesFECFormat'; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('b'=>MAIN_DB_PREFIX.'accounting_bookkeeping'); // List of tables to insert into (insert done in same order) + $this->import_fields_array[$r] = array( + 'b.code_journal'=>'FECFormatJournalCode*', + 'b.journal_label'=>'FECFormatJournalLabel', + 'b.piece_num'=>'FECFormatEntryNum*', + 'b.doc_date'=>'FECFormatEntryDate*', + 'b.numero_compte'=>'FECFormatGeneralAccountNumber*', + 'b.label_compte'=>'FECFormatGeneralAccountLabel*', + 'b.subledger_account'=>'FECFormatSubledgerAccountNumber', + 'b.subledger_label'=>'FECFormatSubledgerAccountLabel', + 'b.doc_ref'=>'FECFormatPieceRef*', + 'b.date_creation'=>'FECFormatPieceDate', + 'b.label_operation'=>'FECFormatLabelOperation', + 'b.debit'=>'FECFormatDebit*', + 'b.credit'=>'FECFormatCredit*', + 'b.lettering_code'=>'FECFormatReconcilableCode', + 'b.date_lettering'=>'FECFormatReconcilableDate', + 'b.date_validated'=>'FECFormatValidateDate', + 'b.multicurrency_amount'=>'FECFormatMulticurrencyAmount', + 'b.multicurrency_code'=>'FECFormatMulticurrencyCode' + ); + $this->import_fieldshidden_array[$r] = array( + 'b.doc_type'=>'const-import_from_external', + 'b.fk_doc'=>'const-0', + 'b.fk_docdet'=>'const-0', + 'b.fk_user_author'=>'user->id', + 'b.montant'=>'rule-computeMontant', + 'b.sens'=>'rule-computeSens' + ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_convertvalue_array[$r]=array( + 'b.montant' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeMontant', 'element' => 'Accountancy'), + 'b.sens' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeSens', 'element' => 'Accountancy'), + ); + $this->import_regex_array[$r] = array( + //'b.doc_date'=>'^\d{4}\d{2}\d{2}$', + 'b.doc_ref'=>'^.{1,300}$', + 'b.numero_compte'=>'^.{1,32}$', + 'b.label_compte'=>'^.{1,255}$', + 'b.subledger_compte'=>'^.{1,32}$', + 'b.subledger_label'=>'^.{1,255}$', + 'b.label_operation'=>'^.{1,255}$', + //'b.sens'=>'^[D|C]$', + ); + $this->import_examplevalues_array[$r] = array( + 'b.code_journal'=>"VT", + 'b.journal_label'=>"Sale journal", + 'b.piece_num'=>'123 (!!! use next value not already used)', + 'b.doc_date'=>dol_print_date(dol_now(), "%Y%m%d"), + 'b.numero_compte'=>"707", + 'b.label_compte'=>'Sale', + 'b.subledger_account'=>'', + 'b.subledger_label'=>'', + 'b.doc_ref'=>'My document ABC', + 'b.date_creation'=>dol_print_date(dol_now(), "%Y%m%d"), + 'b.label_operation'=>"Sale of ABC", + 'b.debit'=>"0", + 'b.credit'=>"100", + 'b.lettering_code'=>'ABC', + 'b.date_lettering'=>dol_print_date(dol_now(), "%Y%m%d"), + 'b.date_validated'=>dol_print_date(dol_now(), "%Y%m%d"), + 'b.multicurrency_amount'=>"90 (Necessary if devise is different than EUR)", + 'b.multicurrency_code'=>"US (Necessary if devise is different than EUR)", + ); + // Chart of accounts $r++; $this->import_code[$r] = $this->rights_class.'_'.$r; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index c635809404e..380a747a53a 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -402,6 +402,26 @@ UseMenuToSetBindindManualy=Lines not yet bound, use menu %s to ## Import ImportAccountingEntries=Accounting entries +ImportAccountingEntriesFECFormat=Accounting entries - FEC format +FECFormatJournalCode=Code journal (JournalCode) +FECFormatJournalLabel=Label journal (JournalLib) +FECFormatEntryNum=Piece number (EcritureNum) +FECFormatEntryDate=Piece date (EcritureDate) +FECFormatGeneralAccountNumber=General account number (CompteNum) +FECFormatGeneralAccountLabel=General account label (CompteLib) +FECFormatSubledgerAccountNumber=Subledger account number (CompAuxNum) +FECFormatSubledgerAccountLabel=Subledger account number (CompAuxLib) +FECFormatPieceRef=Piece ref (PieceRef) +FECFormatPieceDate=Piece date creation (PieceDate) +FECFormatLabelOperation=Label operation (EcritureLib) +FECFormatDebit=Debit (Debit) +FECFormatCredit=Credit (Credit) +FECFormatReconcilableCode=Reconcilable code (EcritureLet) +FECFormatReconcilableDate=Reconcilable date (DateLet) +FECFormatValidateDate=Piece date validated (ValidDate) +FECFormatMulticurrencyAmount=Multicurrency amount (Montantdevise) +FECFormatMulticurrencyCode=Multicurrency code (Idevise) + DateExport=Date export WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manually in the Ledger. If your journalization is up to date, the bookkeeping view is more accurate. ExpenseReportJournal=Expense Report Journal From 14a62442c48db4a465072caa24bfccb97c829f1a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 31 Mar 2021 05:07:05 +0200 Subject: [PATCH 143/233] FIX: Accountancy - Import in general ledger --- htdocs/core/modules/modAccounting.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 747cae06573..e01a4009abe 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -285,9 +285,9 @@ class modAccounting extends DolibarrModules //'b.doc_type'=>'Doctype', 'b.doc_ref'=>'Piece', 'b.code_journal'=>'Codejournal', - //'b.journal_label'=>'JournalLabel', + 'b.journal_label'=>'JournalLabel', 'b.numero_compte'=>'AccountAccounting', - //'b.label_compte'=>'LabelAccount', + 'b.label_compte'=>'LabelAccount', 'b.subledger_account'=>'SubledgerAccount', 'b.subledger_label'=>'SubledgerAccountLabel', 'b.label_operation'=>'LabelOperation', @@ -302,9 +302,9 @@ class modAccounting extends DolibarrModules //'b.doc_type'=>'import', 'b.doc_ref'=>'My document ABC', 'b.code_journal'=>"VTE", - //'b.journal_label'=>"Sale journal", + 'b.journal_label'=>"Sale journal", 'b.numero_compte'=>"707", - //'b.label_compte'=>'Product account 707', + 'b.label_compte'=>'Product account 707', 'b.subledger_account'=>'', 'b.subledger_label'=>'', 'b.label_operation'=>"Sale of ABC", From 4e1b84af45acbb1d77116cb2414914debee4086d Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 31 Mar 2021 08:27:27 +0200 Subject: [PATCH 144/233] NEW translate in "en_US" to complete PR 16980 --- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/other.lang | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b13e15b4a9f..dc2a83f2015 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -278,6 +278,7 @@ DateModificationShort=Modif. date IPModification=Modification IP DateLastModification=Latest modification date DateValidation=Validation date +DateSigning=Signing date DateClosing=Closing date DateDue=Due date DateValue=Value date diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 7a895bb1ca5..5ae6c7727b3 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -114,6 +114,7 @@ DemoCompanyAll=Company with multiple activities (all main modules) CreatedBy=Created by %s ModifiedBy=Modified by %s ValidatedBy=Validated by %s +SignedBy=Signed by %s ClosedBy=Closed by %s CreatedById=User id who created ModifiedById=User id who made latest change From b6faa6b6059ca4c4815ed5650414be086753fd65 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 31 Mar 2021 09:40:12 +0200 Subject: [PATCH 145/233] FIX: Show Ref.Supplier in LinkToObjectBlock --- htdocs/core/class/html.form.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 247b81452df..63964142f8b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6950,8 +6950,8 @@ class Form 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), - 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier as ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), - 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier as ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')'), + 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), + 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')'), 'ticket'=>array('enabled'=>$conf->ticket->enabled, 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('ticket').')') ); } @@ -7020,7 +7020,7 @@ class Form print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; From 19265179caa24ce4ce647085fc0c9e9812de7852 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 31 Mar 2021 10:11:51 +0200 Subject: [PATCH 146/233] FIX : last uniformizations --- htdocs/compta/tva/payments.php | 8 ++++++-- htdocs/salaries/payments.php | 34 ++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 3ebb9a335fc..134f840d196 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -121,6 +121,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print ''; print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "ptva.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATDeclaration", $_SERVER["PHP_SELF"], "tva.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "tva.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "tva.datev", "", $param, 'width="140px"', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); @@ -184,7 +185,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // Ref payment print '\n"; - // Label + // VAT print ''; + // Label + print ''; + // Date $date = $obj->datev; print ''; @@ -243,7 +247,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { } print ''; print ''; // A total here has no sense - //print ''; + print ''; print ''; if (!empty($conf->banque->enabled)) { print ''; diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 0ec83a55595..a6442614d1b 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -75,6 +75,8 @@ $search_user = GETPOST('search_user', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); $search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_dateep_start = dol_mktime(0, 0, 0, GETPOST('search_dateep_startmonth', 'int'), GETPOST('search_dateep_startday', 'int'), GETPOST('search_dateep_startyear', 'int')); +$search_dateep_end = dol_mktime(23, 59, 59, GETPOST('search_dateep_endmonth', 'int'), GETPOST('search_dateep_endday', 'int'), GETPOST('search_dateep_endyear', 'int')); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_fk_bank = GETPOST('search_fk_bank', 'int'); @@ -141,6 +143,8 @@ if (empty($reshook)) { $search_label = ""; $search_date_start = ''; $search_date_end = ''; + $search_dateep_start = ''; + $search_dateep_end = ''; $search_amount = ""; $search_account = ''; $search_fk_bank = ''; @@ -184,7 +188,7 @@ $help_url = ''; $title = $langs->trans('SalariesPayments'); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,"; -$sql .= " s.rowid, s.fk_user, s.amount, s.salary, sal.rowid as id_salary, sal.label, s.datep as datep, b.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,"; +$sql .= " s.rowid, s.fk_user, s.amount, s.salary, sal.rowid as id_salary, sal.label, s.datep as datep, sal.dateep, b.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,"; $sql .= " pst.code as payment_code"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; @@ -204,6 +208,8 @@ if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.fir if ($search_label) $sql .= natural_search(array('sal.label'), $search_label); if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'"; if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; +if ($search_dateep_start) $sql .= " AND sal.dateep >= '".$db->idate($search_dateep_start)."'"; +if ($search_dateep_end) $sql .= " AND sal.dateep <= '".$db->idate($search_dateep_end)."'"; if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1); if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account); if ($search_fk_bank) $sql .= " AND s.fk_bank=".((int) $search_fk_bank); @@ -259,7 +265,9 @@ if ($search_fk_bank) $param .= '&search_fk_bank='.urlencode($search_fk_bank); if ($search_chq_number) $param .= '&search_chq_number='.urlencode($search_chq_number); if ($search_account) $param .= '&search_account='.urlencode($search_account); if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int')); +if ($search_dateep_start) $param .= '&search_dateep_startday='.urlencode(GETPOST('search_dateep_startday', 'int')).'&search_dateep_startmonth='.urlencode(GETPOST('search_dateep_startmonth', 'int')).'&search_dateep_startyear='.urlencode(GETPOST('search_dateep_startyear', 'int')); if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int')); +if ($search_dateep_end) $param .= '&search_dateep_endday='.urlencode(GETPOST('search_dateep_endday', 'int')).'&search_dateep_endmonth='.urlencode(GETPOST('search_dateep_endmonth', 'int')).'&search_dateep_endyear='.urlencode(GETPOST('search_dateep_endyear', 'int')); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -308,6 +316,15 @@ print ''; +// Date end period +print ''; // Date payment print ''; // Date value -print ''; +/*print '';*/ // Employee print ''; print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Salary", $_SERVER["PHP_SELF"], "sal.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); +print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "sal.dateep", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); -print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "b.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); +//print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "b.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pst.code", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "s.num_payment", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); @@ -436,13 +454,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print "\n"; if (!$i) $totalarray['nbfield']++; + // Date end period + print '\n"; + if (!$i) $totalarray['nbfield']++; + // Date payment print '\n"; if (!$i) $totalarray['nbfield']++; // Date value - print '\n"; - if (!$i) $totalarray['nbfield']++; + /*print '\n"; + if (!$i) $totalarray['nbfield']++;*/ // Employee print "\n"; From 508dc337495dd807f19880ca675428948f28730f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 31 Mar 2021 08:16:02 +0000 Subject: [PATCH 147/233] Fixing style errors. --- htdocs/salaries/payments.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index a6442614d1b..09c90854f22 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -144,7 +144,7 @@ if (empty($reshook)) { $search_date_start = ''; $search_date_end = ''; $search_dateep_start = ''; - $search_dateep_end = ''; + $search_dateep_end = ''; $search_amount = ""; $search_account = ''; $search_fk_bank = ''; @@ -456,7 +456,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Date end period print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Date payment print '\n"; From c27c52331ab74e678e371b1ae1ffaf86337ac5a8 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 31 Mar 2021 10:34:21 +0200 Subject: [PATCH 148/233] FIX : default value --- htdocs/compta/tva/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index a5169675f69..bbf4bc9ac2b 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -136,7 +136,7 @@ if ($action == 'reopen' && $user->rights->tax->charges->creer) { } } -if ($action == 'add' && $cancel) { +if ($action == 'add' && !$cancel) { $error = 0; $object->fk_account = GETPOST("accountid", 'int'); @@ -454,7 +454,7 @@ if ($action == 'create') { // Comments print ''; print ''; - print ''; + print ''; print ''; // Other attributes From bd092cc84d58e5d6eb63129c7492e158ed1f7456 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 31 Mar 2021 12:04:37 +0200 Subject: [PATCH 149/233] Close #16761 : new mass stock transfer --- htdocs/langs/en_US/stocks.lang | 4 +- htdocs/product/stock/massstockmove.php | 237 ++++++++++++++++++++++++- 2 files changed, 239 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 8e949661c49..586595baa94 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -242,4 +242,6 @@ InventoryRealQtyHelp=Set value to 0 to reset qty
    Keep field empty, or remove UpdateByScaning=Update by scaning UpdateByScaningProductBarcode=Update by scan (product barcode) UpdateByScaningLot=Update by scan (lot|serial barcode) -DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. \ No newline at end of file +DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. +ImportFromCSV=Import CSV list of movement +ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... \ No newline at end of file diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 5a5808b04f3..39962e1bd49 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -30,6 +30,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/import/import_csv.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/import.lib.php'; + +$confirm = GETPOST('confirm', 'alpha'); +$filetoimport = GETPOST('filetoimport'); // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'orders', 'productbatch')); @@ -80,6 +86,20 @@ if (!empty($_SESSION['massstockmove'])) { * Actions */ + +if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) { + dol_mkdir($conf->stock->dir_temp); + $nowyearmonth = dol_print_date(dol_now(), '%Y%m%d%H%M%S'); + + $fullpath = $conf->stock->dir_temp."/".$nowyearmonth.'-'.$_FILES['userfile']['name']; + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1) > 0) { + dol_syslog("File ".$fullpath." was added for import"); + } else { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); + } +} + if ($action == 'addline') { if (!($id_product > 0)) { $error++; @@ -288,8 +308,99 @@ if ($action == 'createmovements') { } } +if ($action == 'importCSV') { + $importcsv = new ImportCsv($db, 'massstocklist'); + $dir = $conf->stock->dir_temp; + $fullpath = $dir.'/'.$filetoimport; + $nblinesrecord = $importcsv->import_get_nb_of_lines($fullpath)-1; + $importcsv->import_open_file($fullpath); + $labelsrecord = $importcsv->import_read_record(); + $i=0; + $data = array(); + while ($i < $nblinesrecord) { + $data[] = $importcsv->import_read_record(); + $id_product = $data[$i][0]['val']; + $qty = $data[$i][1]['val']; + $id_sw = $data[$i][2]['val']; + $id_tw = $data[$i][3]['val']; + $batch = $data[$i][4]['val']; + if (!($id_product > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); + } + if (!($id_sw > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); + } + if (!($id_tw > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); + } + if ($id_sw > 0 && $id_tw == $id_sw) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors'); + } + if (!$qty) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); + } + // Check a batch number is provided if product need it + if (!$error) { + $producttmp = new Product($db); + $producttmp->fetch($id_product); + if ($producttmp->hasbatch()) { + if (empty($batch)) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $producttmp->ref), null, 'errors'); + } + } + } + + $i++; + } + if (!$error) { + foreach ($data as $key => $value) { + if (count(array_keys($listofdata)) > 0) { + $id = max(array_keys($listofdata)) + 1; + } else { + $id = 1; + } + $id_product = $data[$key][0]['val']; + $qty = $data[$key][1]['val']; + $id_sw = $data[$key][2]['val']; + $id_tw = $data[$key][3]['val']; + $batch = $data[$key][4]['val']; + $listofdata[$key] = array('id'=>$key, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); + } + } + $_SESSION['massstockmove'] = json_encode($listofdata); +} + +if ($action == 'confirm_deletefile' && $confirm == 'yes') { + $langs->load("other"); + + $param = '&datatoimport='.urlencode($datatoimport).'&format='.urlencode($format); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + + $file = $conf->stock->dir_temp.'/'.GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $ret = dol_delete_file($file); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + Header('Location: '.$_SERVER["PHP_SELF"]); + exit; +} /* * View */ @@ -411,6 +522,128 @@ print ''; print ''; +print '
    '; + +print '
    '; +print ''; +print ''; +print ''; +$s = $langs->trans("ChooseFileToImport", '{s1}'); +$s = str_replace('{s1}', img_picto('', 'next'), $s); +print $s; +print '

    '; + +print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
    '.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
    '.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
    '.$formcompany->select_state($search_state, $search_country).''.$obj->accountancy_code_sell.''.$obj->accountancy_code_sell_intra.''.$obj->accountancy_code_sell_export.''.$obj->accountancy_code_buy.''.$obj->accountancy_code_buy_intra.''.$obj->accountancy_code_buy_export.'
    '.$langs->trans("Type").''.$act->type.'
    '.$langs->trans("Type").''; + print $act->getTypePicto(); + print $langs->trans("Action".$act->type_code); + print '
    '.$objp->ref.''.$objp->ref_client.''.(!empty($objp->ref_client)?$objp->ref_client:$objp->ref_supplier).''.price($objp->total_ht).''.$objp->name.'
    '.$payment_vat_static->getNomUrl(1)."'; $tva->id = $obj->rowid; $tva->ref = $obj->rowid; @@ -192,6 +193,9 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print $tva->getNomUrl(1, '20'); print ''.$obj->label.''.dol_print_date($date, 'day').'
    '.$langs->trans("Total").'    '; +print '
    '; +print $form->selectDate($search_dateep_start ? $search_dateep_start : -1, 'search_dateep_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); +print '
    '; +print '
    '; +print $form->selectDate($search_dateep_end ? $search_dateep_end : -1, 'search_dateep_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); +print '
    '; +print '
    '; print '
    '; @@ -318,8 +335,8 @@ print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_e print '
    '; print '
    '; -print ''; +print ''; print ''; @@ -366,8 +383,9 @@ print '
    ".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->dateep), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."'.dol_print_date($db->jdate($obj->datev), 'day')."'.dol_print_date($db->jdate($obj->datev), 'day')."".$userstatic->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dateep), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."
    '.$langs->trans("Comments").'
    '; + +print ''; +print "\n"; + +// Search available imports +$filearray = dol_dir_list($conf->stock->dir_temp, 'files', 0, '', '', 'name', SORT_DESC); +if (count($filearray) > 0) { + $dir = $conf->stock->dir_temp; + + // Search available files to import + $i = 0; + foreach ($filearray as $key => $val) { + $file = $val['name']; + + // readdir return value in ISO and we want UTF8 in memory + if (!utf8_check($file)) { + $file = utf8_encode($file); + } + + if (preg_match('/^\./', $file)) { + continue; + } + + $modulepart = 'import'; + $urlsource = $_SERVER["PHP_SELF"].'&filetoimport='.urlencode($filetoimport); + $relativepath = $file; + + print ''; + print ''; + print ''; + // Affiche taille fichier + print ''; + // Affiche date fichier + print ''; + // Del button + print ''; + // Action button + print ''; + print ''; + } +} + +print '
    '; +print '     '; +$out = (empty($conf->global->MAIN_UPLOAD_DOC) ? ' disabled' : ''); +print ''; +$out = ''; +if (!empty($conf->global->MAIN_UPLOAD_DOC)) { + $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb + $maxphp = @ini_get('upload_max_filesize'); // In unknown + if (preg_match('/k$/i', $maxphp)) { + $maxphp = $maxphp * 1; + } + if (preg_match('/m$/i', $maxphp)) { + $maxphp = $maxphp * 1024; + } + if (preg_match('/g$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024 * 1024; + } + $maxphp2 = @ini_get('post_max_size'); // In unknown + if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1; + } + if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024; + } + if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + } + // Now $max and $maxphp and $maxphp2 are in Kb + $maxmin = $max; + $maxphptoshow = $maxphptoshowparam = ''; + if ($maxphp > 0) { + $maxmin = min($max, $maxphp); + $maxphptoshow = $maxphp; + $maxphptoshowparam = 'upload_max_filesize'; + } + if ($maxphp2 > 0) { + $maxmin = min($max, $maxphp2); + if ($maxphp2 < $maxphp) { + $maxphptoshow = $maxphp2; + $maxphptoshowparam = 'post_max_size'; + } + } + + $langs->load('other'); + $out .= ' '; + $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphptoshow), 1); +} else { + $out .= ' ('.$langs->trans("UploadDisabled").')'; +} +print $out; +print '
    '.img_mime($file).''; + print ''; + print $file; + print ''; + print ''.dol_print_size(dol_filesize($dir.'/'.$file)).''.dol_print_date(dol_filemtime($dir.'/'.$file), 'dayhour').''.img_delete().''; + print ''.img_picto($langs->trans("NewImport"), 'next', 'class="fa-15x"').''; + print '
    '; +print '
    '; + +print ''; print '
    '; @@ -437,7 +670,9 @@ print '
    '; print '
    '; print ''; - +if ($action == 'delete') { + print $form->formconfirm($_SERVER["PHP_SELF"].'?urlfile='.urlencode(GETPOST('urlfile')).'&step=3'.$param, $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); +} // End of page llxFooter(); $db->close(); From 633b8f1431c574e4b06e543ba51fa13dd13ac944 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 31 Mar 2021 12:18:31 +0200 Subject: [PATCH 150/233] Close #16761 : Info template import --- htdocs/langs/en_US/stocks.lang | 3 ++- htdocs/product/stock/massstockmove.php | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 586595baa94..e3d3ae4e0ae 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -244,4 +244,5 @@ UpdateByScaningProductBarcode=Update by scan (product barcode) UpdateByScaningLot=Update by scan (lot|serial barcode) DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. ImportFromCSV=Import CSV list of movement -ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... \ No newline at end of file +ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... +InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields) : Product_id* | Source_Warehouse_id* | Target_Warehouse_id* | Quantity* | Batch_id \ No newline at end of file diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 39962e1bd49..a89e234acfb 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -320,9 +320,9 @@ if ($action == 'importCSV') { while ($i < $nblinesrecord) { $data[] = $importcsv->import_read_record(); $id_product = $data[$i][0]['val']; - $qty = $data[$i][1]['val']; - $id_sw = $data[$i][2]['val']; - $id_tw = $data[$i][3]['val']; + $id_sw = $data[$i][1]['val']; + $id_tw = $data[$i][2]['val']; + $qty = $data[$i][3]['val']; $batch = $data[$i][4]['val']; if (!($id_product > 0)) { @@ -370,9 +370,9 @@ if ($action == 'importCSV') { $id = 1; } $id_product = $data[$key][0]['val']; - $qty = $data[$key][1]['val']; - $id_sw = $data[$key][2]['val']; - $id_tw = $data[$key][3]['val']; + $id_sw = $data[$key][1]['val']; + $id_tw = $data[$key][2]['val']; + $qty = $data[$key][3]['val']; $batch = $data[$key][4]['val']; $listofdata[$key] = array('id'=>$key, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); } @@ -531,6 +531,8 @@ print ''; $s = $langs->trans("ChooseFileToImport", '{s1}'); $s = str_replace('{s1}', img_picto('', 'next'), $s); print $s; +print '

    '; +print $langs->trans('InfoTemplateImport'); print '


    '; print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table From 625ade1a534eb97cc1d4eb4122dcff160273f778 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 12:41:44 +0200 Subject: [PATCH 151/233] Clean log --- htdocs/admin/company.php | 4 ++-- htdocs/cashdesk/facturation_verif.php | 28 +++++++++++++-------------- htdocs/cashdesk/validation_verif.php | 2 +- htdocs/core/ajax/selectobject.php | 5 ----- htdocs/core/ajax/ziptown.php | 9 ++++----- htdocs/imports/import.php | 4 ++-- htdocs/product/ajax/products.php | 2 -- htdocs/projet/ajax/projects.php | 1 - htdocs/societe/ajax/company.php | 2 -- htdocs/societe/ajaxcompanies.php | 2 -- htdocs/societe/ajaxcountries.php | 2 -- 11 files changed, 23 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index f0bb3ea9067..d8af6ac1b4f 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -288,8 +288,8 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thu } else { $error++; $langs->load("errors"); - setEventMessages($langs->trans("ErrorFileDoesNotExists", $_GET["file"]), null, 'errors'); - dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", $_GET["file"]), LOG_WARNING); + setEventMessages($langs->trans("ErrorFileDoesNotExists", GETPOST("file")), null, 'errors'); + dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", GETPOST("file")), LOG_WARNING); } } diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index eed48555e20..f51cda3e77b 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -1,7 +1,7 @@ * Copyright (C) 2008-2010 Laurent Destailleur - * Copyright (C) 2018 Juanjo Menent + * Copyright (C) 2018 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,14 +45,14 @@ if (empty($user->rights->cashdesk->run)) { switch ($action) { default: - if ($_POST['hdnSource'] != 'NULL') { + if (GETPOST('hdnSource') != 'NULL') { $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.default_vat_code, p.recuperableonly"; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { $sql .= ", ps.reel"; } $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".((int) $conf_fkentrepot); } $sql .= " WHERE p.entity IN (".getEntity('product').")"; @@ -164,18 +164,18 @@ switch ($action) { $obj_facturation->vatrate = $vatrate; // Save vat rate (full text vat with code) // Definition du filtre pour n'afficher que le produit concerne - if ($_POST['hdnSource'] == 'LISTE') { + if (GETPOST('hdnSource') == 'LISTE') { $filtre = $ret['ref']; - } elseif ($_POST['hdnSource'] == 'REF') { - $filtre = $_POST['txtRef']; + } elseif (GETPOST('hdnSource') == 'REF') { + $filtre = GETPOST('txtRef'); } - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$filtre; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.urlencode($filtre); } else { $obj_facturation->raz(); - if ($_POST['hdnSource'] == 'REF') { - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$_POST['txtRef']; + if (GETPOST('hdnSource') == 'REF') { + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.urlencode(GETPOST('txtRef')); } else { $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; } @@ -200,10 +200,10 @@ switch ($action) { case 'ajout_article': if (!empty($obj_facturation->id)) { // A product was previously selected and stored in session, so we can add it - dol_syslog("facturation_verif save vat ".$_POST['selTva']); - $obj_facturation->qte($_POST['txtQte']); - $obj_facturation->tva($_POST['selTva']); // id of vat. Saved so we can use it for next product - $obj_facturation->remisePercent($_POST['txtRemise']); + dol_syslog("facturation_verif save vat ".GETPOST('selTva')); + $obj_facturation->qte(GETPOST('txtQte')); + $obj_facturation->tva(GETPOST('selTva')); // id of vat. Saved so we can use it for next product + $obj_facturation->remisePercent(GETPOST('txtRemise')); $obj_facturation->ajoutArticle(); // This add an entry into $_SESSION['poscart'] // We update prixTotalTtc } @@ -212,7 +212,7 @@ switch ($action) { break; case 'suppr_article': - $obj_facturation->supprArticle($_GET['suppr_id']); + $obj_facturation->supprArticle(GETPOST('suppr_id')); $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; break; diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 76cba5d3d95..0c9758d9a29 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -165,7 +165,7 @@ switch ($action) { if (empty($cond_reglement_id)) { $cond_reglement_id = 0; // If cond_reglement_id not found } - $note .= $_POST['txtaNotes']; + $note .= GETPOST('txtaNotes', 'alphanohtml'); dol_syslog("obj_facturation->getSetPaymentMode()=".$obj_facturation->getSetPaymentMode()." mode_reglement_id=".$mode_reglement_id." cond_reglement_id=".$cond_reglement_id); $error = 0; diff --git a/htdocs/core/ajax/selectobject.php b/htdocs/core/ajax/selectobject.php index c491ad63749..c8c3e13ea3d 100644 --- a/htdocs/core/ajax/selectobject.php +++ b/htdocs/core/ajax/selectobject.php @@ -43,9 +43,7 @@ require '../../main.inc.php'; $objectdesc = GETPOST('objectdesc', 'alpha'); $htmlname = GETPOST('htmlname', 'aZ09'); -$sqlfilter = GETPOST('sqlfilter', 'alpha'); $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); -$action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); @@ -54,11 +52,8 @@ $id = GETPOST('id', 'int'); */ //print ''."\n"; - -dol_syslog(join(',', $_GET)); //print_r($_GET); - require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $form = new Form($db); diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index 44c7bc0760b..aa9474ce142 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -59,17 +59,17 @@ top_httphead(); //print ''."\n"; -dol_syslog("GET is ".join(',', $_GET).', MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY) ? '' : $conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); +dol_syslog('ziptown call with MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY) ? '' : $conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); //var_dump($_GET); // Generation of list of zip-town -if (!empty($_GET['zipcode']) || !empty($_GET['town'])) { +if (GETPOST('zipcode') || GETPOST('town')) { $return_arr = array(); $formcompany = new FormCompany($db); // Define filter on text typed - $zipcode = $_GET['zipcode'] ? $_GET['zipcode'] : ''; - $town = $_GET['town'] ? $_GET['town'] : ''; + $zipcode = GETPOST('zipcode'); + $town = GETPOST('town'); if (!empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) { // Use zip-town table $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; @@ -141,7 +141,6 @@ if (!empty($_GET['zipcode']) || !empty($_GET['town'])) { } echo json_encode($return_arr); -} else { } $db->close(); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 50ab14dfce5..f484e3b0901 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -307,8 +307,8 @@ if ($step == 4 && $action == 'select_model') { if ($action == 'saveorder') { // Enregistrement de la position des champs - dol_syslog("boxorder=".$_GET['boxorder']." datatoimport=".$_GET["datatoimport"], LOG_DEBUG); - $part = explode(':', $_GET['boxorder']); + dol_syslog("boxorder=".GETPOST('boxorder')." datatoimport=".GETPOST("datatoimport"), LOG_DEBUG); + $part = explode(':', GETPOST('boxorder')); $colonne = $part[0]; $list = $part[1]; dol_syslog('column='.$colonne.' list='.$list); diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 9dacb4e547d..b09c29f75da 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -68,8 +68,6 @@ $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); */ // print ''."\n"; - -dol_syslog(join(',', $_GET)); // print_r($_GET); if (!empty($action) && $action == 'fetch' && !empty($id)) { diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 22f58f62c90..5264fa02596 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -61,7 +61,6 @@ restrictedArea($user, 'projet', 0, 'projet&project'); */ dol_syslog("Call ajax projet/ajax/projects.php"); -//dol_syslog(join(',', $_GET)); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 57edbcebc1d..86e6f68c16c 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -57,8 +57,6 @@ $showtype = GETPOST('showtype', 'int'); */ //print ''."\n"; - -dol_syslog(join(',', $_GET)); //print_r($_GET); if (!empty($action) && $action == 'fetch' && !empty($id)) { diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php index 28b105df9a0..cc327b155fa 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajaxcompanies.php @@ -58,8 +58,6 @@ top_httphead(); //print ''."\n"; -dol_syslog(join(',', $_GET)); - // Generation liste des societes if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { diff --git a/htdocs/societe/ajaxcountries.php b/htdocs/societe/ajaxcountries.php index a4efc4ecc94..aa6cbf70de8 100644 --- a/htdocs/societe/ajaxcountries.php +++ b/htdocs/societe/ajaxcountries.php @@ -59,8 +59,6 @@ top_httphead(); print ''."\n"; -dol_syslog(join(',', $_POST)); - // Generate list of countries if (!empty($country)) { global $langs; From 6aa1229c19a236e21657beb2709eefc429b3ec0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 12:44:13 +0200 Subject: [PATCH 152/233] FIX #yogosha5791 --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e7a47edf5d2..90e025fb56a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1398,7 +1398,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = // If html log tag enabled and url parameter log defined, we show output log on HTML comments if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET["log"])) { print "\n\n\n"; } From e4b01b7ffc540bf74cc94a157fe7ef43df8a3f9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 13:01:49 +0200 Subject: [PATCH 153/233] FIX #yogosha5791 --- htdocs/public/payment/newpayment.php | 6 +- htdocs/public/stripe/confirm_payment.php | 169 ----------------------- 2 files changed, 3 insertions(+), 172 deletions(-) delete mode 100644 htdocs/public/stripe/confirm_payment.php diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index dc5d99a43eb..486223b0293 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -405,8 +405,8 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { } dol_syslog("--- newpayment.php Execute action = ".$action, LOG_DEBUG, 0, '_stripe'); - dol_syslog("POST keys : ".join(',', array_keys($_POST)), LOG_DEBUG, 0, '_stripe'); - dol_syslog("POST values: ".join(',', $_POST), LOG_DEBUG, 0, '_stripe'); + dol_syslog("GET=".var_export($_GET, true), LOG_DEBUG, 0, '_stripe'); + dol_syslog("POST=".var_export($_POST, true), LOG_DEBUG, 0, '_stripe'); $stripeToken = GETPOST("stripeToken", 'alpha'); $email = GETPOST("email", 'alpha'); @@ -414,7 +414,7 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { $dol_type = (GETPOST('s', 'alpha') ? GETPOST('s', 'alpha') : GETPOST('source', 'alpha')); $dol_id = GETPOST('dol_id', 'int'); $vatnumber = GETPOST('vatnumber', 'alpha'); - $savesource = GETPOSTISSET('savesource') ?GETPOST('savesource', 'int') : 1; + $savesource = GETPOSTISSET('savesource') ? GETPOST('savesource', 'int') : 1; dol_syslog("POST stripeToken = ".$stripeToken, LOG_DEBUG, 0, '_stripe'); dol_syslog("POST email = ".$email, LOG_DEBUG, 0, '_stripe'); diff --git a/htdocs/public/stripe/confirm_payment.php b/htdocs/public/stripe/confirm_payment.php deleted file mode 100644 index b0f8f8213a0..00000000000 --- a/htdocs/public/stripe/confirm_payment.php +++ /dev/null @@ -1,169 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// TODO Do we really need this page. We alread have a ipn.php page ! - -if (!defined('NOLOGIN')) { - define("NOLOGIN", 1); // This means this output page does not require to be logged. -} -if (!defined('NOCSRFCHECK')) { - define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. -} -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} -if (!defined('NOBROWSERNOTIF')) { - define('NOBROWSERNOTIF', '1'); -} - -$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) { - define("DOLENTITY", $entity); -} - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; -require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php'; -require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - -if (empty($conf->stripe->enabled)) { - accessforbidden('', 0, 0, 1); -} - - -// You can find your endpoint's secret in your webhook settings -if (isset($_GET['connect'])) { - if (isset($_GET['test'])) { - $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY; - $service = 'StripeTest'; - $servicestatus = 0; - } else { - $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY; - $service = 'StripeLive'; - $servicestatus = 1; - } -} else { - if (isset($_GET['test'])) { - $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY; - $service = 'StripeTest'; - $servicestatus = 0; - } else { - $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY; - $service = 'StripeLive'; - $servicestatus = 1; - } -} - - - -/* - * Actions - */ - -$langs->load("main"); - -// TODO Do we really need a user in setup just to have an name to fill an email topic when it is a technical system notification email -$user = new User($db); -$user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS); -$user->getrights(); - -// list of action -$stripe = new Stripe($db); - -// Subject -$societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $societeName = $conf->global->MAIN_APPLICATION_TITLE; -} - - -dol_syslog("Stripe confirm_payment was called"); -dol_syslog("GET=".var_export($_GET, true)); -dol_syslog("POST=".var_export($_POST, true)); - - -header('Content-Type: application/json'); - -// retrieve json from POST body -$json_str = file_get_contents('php://input'); -$json_obj = json_decode($json_str); - -$intent = null; -try { - if (isset($json_obj->payment_method_id)) { - // Create the PaymentIntent - $intent = \Stripe\PaymentIntent::create(array( - 'payment_method' => $json_obj->payment_method_id, - 'amount' => 1099, - 'currency' => 'eur', - 'confirmation_method' => 'manual', - 'confirm' => true, - )); - } - if (isset($json_obj->payment_intent_id)) { - $intent = \Stripe\PaymentIntent::retrieve( - $json_obj->payment_intent_id - ); - $intent->confirm(); - } - generatePaymentResponse($intent); -} catch (\Stripe\Error\Base $e) { - // Display error on client - echo json_encode(array( - 'error' => $e->getMessage() - )); -} - -/** - * Generate payment response - * - * @param \Stripe\PaymentIntent $intent PaymentIntent - * @return void - */ -function generatePaymentResponse($intent) -{ - if ($intent->status == 'requires_source_action' && - $intent->next_action->type == 'use_stripe_sdk') { - // Tell the client to handle the action - echo json_encode(array( - 'requires_action' => true, - 'payment_intent_client_secret' => $intent->client_secret - )); - } elseif ($intent->status == 'succeeded') { - // The payment didn’t need any additional actions and completed! - // Handle post-payment fulfillment - - // TODO - - echo json_encode(array( - "success" => true - )); - } else { - // Invalid status - http_response_code(500); - echo json_encode(array('error' => 'Invalid PaymentIntent status')); - } -} From fafff6d9a474864c9579a049dd2318af4e648a58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 15:07:18 +0200 Subject: [PATCH 154/233] Debug feature to import stock movements from a file. --- htdocs/langs/en_US/stocks.lang | 3 +- htdocs/product/stock/massstockmove.php | 441 ++++++++++++------------- 2 files changed, 205 insertions(+), 239 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index bb18c960aae..449c1598ec8 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -247,7 +247,8 @@ UpdateByScaningLot=Update by scan (lot|serial barcode) DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. ImportFromCSV=Import CSV list of movement ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... -InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields) : Product_id* | Source_Warehouse_id* | Target_Warehouse_id* | Quantity* | Batch_id +OrSelectAStockMovementFileToImport=Or select a stock movement file to import +InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields):
    Source_Warehouse_id* | Target_Warehouse_id* | Product_id* | Quantity* | Lot/serial number
    CSV character separator must be %s LabelOfInventoryMovemement=Inventory %s ReOpen=Reopen ConfirmFinish=Confirm closing diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index a89e234acfb..bf1291ac428 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -86,21 +86,7 @@ if (!empty($_SESSION['massstockmove'])) { * Actions */ - -if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) { - dol_mkdir($conf->stock->dir_temp); - $nowyearmonth = dol_print_date(dol_now(), '%Y%m%d%H%M%S'); - - $fullpath = $conf->stock->dir_temp."/".$nowyearmonth.'-'.$_FILES['userfile']['name']; - if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1) > 0) { - dol_syslog("File ".$fullpath." was added for import"); - } else { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); - } -} - -if ($action == 'addline') { +if ($action == 'addline' && !empty($user->rights->stock->mouvement->creer)) { if (!($id_product > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); @@ -162,7 +148,7 @@ if ($action == 'addline') { } } -if ($action == 'delline' && $idline != '') { +if ($action == 'delline' && $idline != '' && !empty($user->rights->stock->mouvement->creer)) { if (!empty($listofdata[$idline])) { unset($listofdata[$idline]); } @@ -173,7 +159,7 @@ if ($action == 'delline' && $idline != '') { } } -if ($action == 'createmovements') { +if ($action == 'createmovements' && !empty($user->rights->stock->mouvement->creer)) { $error = 0; if (!GETPOST("label")) { @@ -308,75 +294,107 @@ if ($action == 'createmovements') { } } -if ($action == 'importCSV') { - $importcsv = new ImportCsv($db, 'massstocklist'); - $dir = $conf->stock->dir_temp; - $fullpath = $dir.'/'.$filetoimport; - $nblinesrecord = $importcsv->import_get_nb_of_lines($fullpath)-1; - $importcsv->import_open_file($fullpath); - $labelsrecord = $importcsv->import_read_record(); - $i=0; - $data = array(); - while ($i < $nblinesrecord) { - $data[] = $importcsv->import_read_record(); - $id_product = $data[$i][0]['val']; - $id_sw = $data[$i][1]['val']; - $id_tw = $data[$i][2]['val']; - $qty = $data[$i][3]['val']; - $batch = $data[$i][4]['val']; +if ($action == 'importCSV' && !empty($user->rights->stock->mouvement->creer)) { + dol_mkdir($conf->stock->dir_temp); + $nowyearmonth = dol_print_date(dol_now(), '%Y%m%d%H%M%S'); - if (!($id_product > 0)) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - } - if (!($id_sw > 0)) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); - } - if (!($id_tw > 0)) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); - } - if ($id_sw > 0 && $id_tw == $id_sw) { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors'); - } - if (!$qty) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); - } + $fullpath = $conf->stock->dir_temp."/".$user->id.'-csvfiletotimport.csv'; + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1) > 0) { + dol_syslog("File ".$fullpath." was added for import"); + } else { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); + } - // Check a batch number is provided if product need it - if (!$error) { - $producttmp = new Product($db); - $producttmp->fetch($id_product); - if ($producttmp->hasbatch()) { - if (empty($batch)) { + if (!$error) { + $importcsv = new ImportCsv($db, 'massstocklist'); + //print $importcsv->separator; + + $nblinesrecord = $importcsv->import_get_nb_of_lines($fullpath)-1; + $importcsv->import_open_file($fullpath); + $labelsrecord = $importcsv->import_read_record(); + + if ($nblinesrecord <= 1) { + setEventMessages($langs->trans("BadNumberOfLinesMustHaveAtLeastOneLinePlusTitle"), null, 'errors'); + } else { + $i=0; + $data = array(); + while (($i < $nblinesrecord) && !$error) { + $data[] = $importcsv->import_read_record(); + if (count($data[$i]) == 1) { + // Only 1 empty line + unset($data); + $i++; + continue; + } + //var_dump($data); + + $id_sw = $data[$i][0]['val']; + $id_tw = $data[$i][1]['val']; + $id_product = $data[$i][2]['val']; + $qty = $data[$i][3]['val']; + $batch = $data[$i][4]['val']; + + // TODO If product is a ref (not numeric or starts with "ref:..."), retreive the id of product from the ref + if (!($id_product > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); + } + // TODO If warehouse is a ref (not numeric or starts with "ref:..."), retreive the id of product from the ref + if (!($id_sw > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); + } + // TODO If warehouse is a ref (not numeric or starts with "ref:..."), retreive the id of product from the ref + if (!($id_tw > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); + } + if ($id_sw > 0 && $id_tw == $id_sw) { $error++; $langs->load("errors"); - setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $producttmp->ref), null, 'errors'); + setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors'); + } + if (!$qty) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); + } + + // Check a batch number is provided if product need it + if (!$error) { + $producttmp = new Product($db); + $producttmp->fetch($id_product); + if ($producttmp->hasbatch()) { + if (empty($batch)) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $producttmp->ref), null, 'errors'); + } + } + } + + $i++; + } + + if (!$error) { + foreach ($data as $key => $value) { + if (count(array_keys($listofdata)) > 0) { + $id = max(array_keys($listofdata)) + 1; + } else { + $id = 1; + } + $id_product = $data[$key][0]['val']; + $id_sw = $data[$key][1]['val']; + $id_tw = $data[$key][2]['val']; + $qty = $data[$key][3]['val']; + $batch = $data[$key][4]['val']; + $listofdata[$key] = array('id'=>$key, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); } } } + } - $i++; - } - if (!$error) { - foreach ($data as $key => $value) { - if (count(array_keys($listofdata)) > 0) { - $id = max(array_keys($listofdata)) + 1; - } else { - $id = 1; - } - $id_product = $data[$key][0]['val']; - $id_sw = $data[$key][1]['val']; - $id_tw = $data[$key][2]['val']; - $qty = $data[$key][3]['val']; - $batch = $data[$key][4]['val']; - $listofdata[$key] = array('id'=>$key, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); - } - } $_SESSION['massstockmove'] = json_encode($listofdata); } @@ -401,6 +419,8 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { Header('Location: '.$_SERVER["PHP_SELF"]); exit; } + + /* * View */ @@ -426,119 +446,18 @@ $buttonrecord = $langs->trans("RecordMovement"); $titletoaddnoent = $langs->transnoentitiesnoconv("Select"); $buttonrecordnoent = $langs->transnoentitiesnoconv("RecordMovement"); print ''.$langs->trans("SelectProductInAndOutWareHouse", $titletoaddnoent, $buttonrecordnoent).'
    '; -print '
    '."\n"; - -// Form to add a line -print '
    '; -print ''; -print ''; - - -print '
    '; -print ''; -//print '
    '; - -$param = ''; - -print '
    '; -print getTitleFieldOfList($langs->trans('WarehouseSource'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); -print getTitleFieldOfList($langs->trans('WarehouseTarget'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); -print getTitleFieldOfList($langs->trans('ProductRef'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); -if ($conf->productbatch->enabled) { - print getTitleFieldOfList($langs->trans('Batch'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); -} -print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone '); -print getTitleFieldOfList('', 0); -print ''; - - -print ''; -// From warehouse -print ''; -// To warehouse -print ''; -// Product -print ''; -// Batch number -if ($conf->productbatch->enabled) { - print ''; -} -// Qty -print ''; -// Button to add line -print ''; - -print ''; - - -foreach ($listofdata as $key => $val) { - $productstatic->fetch($val['id_product']); - $warehousestatics->fetch($val['id_sw']); - $warehousestatict->fetch($val['id_tw']); - - print ''; - print ''; - print ''; - print ''; - if ($conf->productbatch->enabled) { - print ''; - } - print ''; - print ''; - - print ''; -} - -print '
    '; -print img_picto($langs->trans("WarehouseSource"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); -print ''; -print img_picto($langs->trans("WarehouseTarget"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); -print ''; -$filtertype = 0; -if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $filtertype = ''; -} -if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) { - $limit = ''; -} else { - $limit = $conf->global->PRODUIT_LIMIT_SIZE; -} - -print img_picto($langs->trans("Product"), 'product', 'class="paddingright"'); -print $form->select_produits($id_product, 'productid', $filtertype, $limit, 0, -1, 2, '', 1, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1, '', null, 1); -print ''; - print img_picto($langs->trans("LotSerial"), 'lot', 'class="paddingright"'); - print ''; - print '
    '; - print $warehousestatics->getNomUrl(1); - print ''; - print $warehousestatict->getNomUrl(1); - print ''; - print $productstatic->getNomUrl(1).' - '.$productstatic->label; - print ''; - print $val['batch']; - print ''.$val['qty'].''.img_delete($langs->trans("Remove")).'
    '; -print '
    '; - -print '
    '; print '
    '; +// Form to upload a file print '
    '; print ''; +print ''; print ''; print ''; -$s = $langs->trans("ChooseFileToImport", '{s1}'); -$s = str_replace('{s1}', img_picto('', 'next'), $s); -print $s; -print '

    '; -print $langs->trans('InfoTemplateImport'); -print '


    '; +print $form->textwithpicto($langs->trans('OrSelectAStockMovementFileToImport'), $langs->transnoentitiesnoconv("InfoTemplateImport", $importcsv->separator)); +print ''; -print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''; - -print ''; } @@ -368,8 +368,8 @@ if (!empty($arrayfields['cs.rowid']['checked'])) { // Filter: Type if (!empty($arrayfields['cs.fk_type']['checked'])) { - print ''; } @@ -399,27 +399,27 @@ if (!empty($arrayfields['p.ref']['checked'])) { if (!empty($arrayfields['cs.fk_user']['checked'])) { // Employee - print ''; } // Filter: Bank Account if (!empty($arrayfields['cs.fk_account']['checked'])) { - print ''; } // Filter: Amount if (!empty($arrayfields['cs.amount']['checked'])) { - print ''; } @@ -452,16 +452,16 @@ if (!empty($arrayfields['cs.rowid']['checked'])) { print_liste_field_titre($arrayfields['cs.rowid']['label'], $_SERVER["PHP_SELF"], "cs.rowid", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.libelle']['checked'])) { - print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle", '', $param, 'class="left"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.fk_type']['checked'])) { - print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type", '', $param, 'class="left"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.date_ech']['checked'])) { - print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech", '', $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech", '', $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['cs.periode']['checked'])) { - print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); @@ -470,10 +470,10 @@ if (!empty($arrayfields['cs.fk_user']['checked'])) { print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, 'class="left"', $sortfield, $sortorder); } if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) { - print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement", '', $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.fk_account']['checked'])) { - print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account", '', $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account", '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['cs.amount']['checked'])) { print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount", '', $param, 'class="right"', $sortfield, $sortorder); @@ -533,7 +533,7 @@ while ($i < min($num, $limit)) { // Type if (!empty($arrayfields['cs.fk_type']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -551,7 +551,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['cs.periode']['checked'])) { print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } From f2f0e4a6fdc0ada2a8eb6045f9e6da5af10afa18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 16:47:36 +0200 Subject: [PATCH 160/233] css --- htdocs/compta/sociales/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 8a43924f41a..d1ec270fd8b 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -525,7 +525,7 @@ while ($i < min($num, $limit)) { // Label if (!empty($arrayfields['cs.libelle']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } From cf57826a5edfec0107e64b63bb02b712fc30cae9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 16:57:58 +0200 Subject: [PATCH 161/233] Trans --- htdocs/compta/sociales/card.php | 10 +++++----- htdocs/compta/sociales/list.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 2fba1288b75..e4ac225a624 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -366,13 +366,13 @@ if ($action == 'create') { } // Payment Mode - print ''; // Bank Account if (!empty($conf->banque->enabled)) { - print ''; } @@ -557,7 +557,7 @@ if ($id > 0) { // Mode of payment print ''; // Show project -print ''; +if (!empty($conf->projet->enabled)) { + print ''; +} //Invert sender and recipient From d4f14183b7deb04536f59d5f2a4213d01fc34b4a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 13:15:23 +0200 Subject: [PATCH 186/233] Code comment --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 96a67f4051e..91de150c889 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7232,7 +7232,7 @@ class Form } /** - * Show a multiselect form from an array. + * Show a multiselect form from an array. WARNING: Use this only for short lists. * * @param string $htmlname Name of select * @param array $array Array with key+value From 75d395c848898e725f8d8624309946b0754d5952 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 1 Apr 2021 14:13:59 +0200 Subject: [PATCH 187/233] FIX: Filter on supplier payment list --- htdocs/fourn/paiement/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 1bf8984a6ee..5a9fa544984 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -11,6 +11,7 @@ * Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2021 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -171,7 +172,7 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_payment_type != '') $sql .= " AND c.code='".$db->escape($search_payment_type)."'"; if ($search_cheque_num != '') $sql .= natural_search('p.num_paiement', $search_cheque_num); if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); -if ($search_bank_account > 0) $sql .= ' AND b.fk_account='.$search_bank_account."'"; +if ($search_bank_account > 0) $sql .= ' AND b.fk_account='.$search_bank_account; if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); From 03ee7ec433166b432b5048fcff1d17e64828ed8a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 1 Apr 2021 17:08:26 +0200 Subject: [PATCH 188/233] fix: Right ID defenition in module builder --- .../template/core/modules/modMyModule.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 0959a650d6e..0bc85dee027 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -264,17 +264,17 @@ class modMyModule extends DolibarrModules $r = 0; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) From b1562cffb16cb71b4620f89682a8471caf76f289 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 1 Apr 2021 17:20:14 +0200 Subject: [PATCH 189/233] better doc comment --- .../template/core/modules/modMyModule.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 0bc85dee027..e98d66b4277 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -266,18 +266,18 @@ class modMyModule extends DolibarrModules /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label - $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject) + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->read) $r++; $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label - $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject) + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->write) $r++; $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label - $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject) + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->delete) $r++; /* END MODULEBUILDER PERMISSIONS */ From 39fc2e6e6025ec100511f0e5b912047a6f6b9638 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 19:48:15 +0200 Subject: [PATCH 190/233] NEW Save old page with .old in edition of a website page --- htdocs/core/lib/website2.lib.php | 16 +++++++++++++--- htdocs/website/index.php | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index e9a5aa6309f..e66ef50b161 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -66,7 +66,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) { global $conf; - // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) + // Now create the .tpl file dol_syslog("dolSavePageAlias We regenerate the alias page filealias=".$filealias); $aliascontent = 'lang) { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 021edc52920..3e4c56cd240 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1996,7 +1996,7 @@ if ($usercanedit && (($action == 'updatesource' || $action == 'updatecontent' || } // Save page content - $result = dolSavePageContent($filetpl, $object, $objectpage); + $result = dolSavePageContent($filetpl, $object, $objectpage, 1); if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); From 83ed2ffefddb0a7392f7f08640e095e98aca8d2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 01:12:45 +0200 Subject: [PATCH 191/233] Fix syntax errors --- .../mysql/data/llx_accounting_account_de.sql | 371 +++++++++--------- 1 file changed, 185 insertions(+), 186 deletions(-) diff --git a/htdocs/install/mysql/data/llx_accounting_account_de.sql b/htdocs/install/mysql/data/llx_accounting_account_de.sql index f6f6ab702fb..1ff393421ba 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_de.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_de.sql @@ -884,7 +884,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) VALUES (__ENTITY__, 1966, 'SKR03', '2', '2010', '0', 'Betriebsfremde Aufwendungen (soweit nicht außerordentlich)'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1967, 'SKR03', '2', '2020', '0', 'Periodenfremde Aufwendungen (soweit nicht außerordentlich)'); -); + INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1970, 'SKR03', '2', '2100', '0', 'Zinsen und ähnliche Aufwendungen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1971, 'SKR03', '2', '2103', '0', 'Steuerlich abzugsfähige andere Nebenleistungen zu steuern'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1972, 'SKR03', '2', '2104', '0', 'Steuerlich nicht abzugsfähige andere Nebenleistungen zu Steuern'); @@ -1051,7 +1051,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) VALUES (__ENTITY__, 2138, 'SKR03', '2', '2680', '0', 'Zinsähnliche Erträge'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2139, 'SKR03', '2', '2689', '0', 'Zinsähnliche Erträge aus verbundenen Unternehmen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2142, 'SKR03', '2', '2700', '0',, 'Sonstige Erträge'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2142, 'SKR03', '2', '2700', '0', 'Sonstige Erträge'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2143, 'SKR03', '2', '2705', '0', 'Sonstige Erträge betrieblich und regelmäßig'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2144, 'SKR03', '2', '2707', '0', 'Sonstige Erträge betriebsfremd und regelmäßig'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2145, 'SKR03', '2', '2709', '0', 'Sonstige Erträge unregelmäßig'); @@ -1145,133 +1145,133 @@ 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) VALUES (__ENTITY__, 2240, 'SKR03', '3', '3200', '0', 'Wareneingang'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2241, 'SKR03', '3', '3300', '2240', 'Wareneingang 7% Vorsteuer'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2242, 'SKR03', '3', '3301', '2240', 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2243, 'SKR03', '3', '3302', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2244, 'SKR03', '3', '3303', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2245, 'SKR03', '3', '3304', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2246, 'SKR03', '3', '3305', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2247, 'SKR03', '3', '3306', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2248, 'SKR03', '3', '3307', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2249, 'SKR03', '3', '3308', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2250, 'SKR03', '3', '3309', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2251, 'SKR03', '3', '3340', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2252, 'SKR03', '3', '3341', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2253, 'SKR03', '3', '3342', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2254, 'SKR03', '3', '3343', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2255, 'SKR03', '3', '3344', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2256, 'SKR03', '3', '3345', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2257, 'SKR03', '3', '3346', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2258, 'SKR03', '3', '3347', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2259, 'SKR03', '3', '3348', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2260, 'SKR03', '3', '3349', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2261, 'SKR03', '3', '3400', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2262, 'SKR03', '3', '3401', '2240' 'Produkt Ausgaben'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2263, 'SKR03', '3', '3402', '2240' 'Produkt Vertriebsausgaben'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2264, 'SKR03', '3', '3403', '2240' 'Konto Kasse Aufwand'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2265, 'SKR03', '3', '3404', '2240' 'Einstandskosten Verrechnungskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2266, 'SKR03', '3', '3405', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2267, 'SKR03', '3', '3406', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2268, 'SKR03', '3', '3407', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2269, 'SKR03', '3', '3408', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2270, 'SKR03', '3', '3409', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2271, 'SKR03', '3', '3420', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2272, 'SKR03', '3', '3421', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2273, 'SKR03', '3', '3422', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2274, 'SKR03', '3', '3423', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2275, 'SKR03', '3', '3424', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2276, 'SKR03', '3', '3425', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2277, 'SKR03', '3', '3426', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2278, 'SKR03', '3', '3427', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2279, 'SKR03', '3', '3428', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2280, 'SKR03', '3', '3429', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2281, 'SKR03', '3', '3430', '2240' 'Innergemeinschaftlicher Erwerb ohne Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2282, 'SKR03', '3', '3433', '2240' 'Innergemeinschaftlicher Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2283, 'SKR03', '3', '3434', '2240' 'Innergemeinschaftlicher Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2284, 'SKR03', '3', '3435', '2240' 'Innergemeinschaftlicher Erwerb ohne Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2285, 'SKR03', '3', '3440', '2240' 'Innergemeinschaftlicher Erwerb von Neufahrzeugen von Lieferanten ohne Umsatzsteuer-Identifikationsnummer 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2286, 'SKR03', '3', '3441', '2240' 'Innergemeinschaftlicher Erwerb von Neufahrzeugen von Lieferanten ohne Umsatzsteuer-Identifikationsnummer 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2287, 'SKR03', '3', '3500', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2288, 'SKR03', '3', '3501', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2289, 'SKR03', '3', '3502', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2290, 'SKR03', '3', '3503', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2291, 'SKR03', '3', '3504', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2292, 'SKR03', '3', '3505', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2293, 'SKR03', '3', '3506', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2294, 'SKR03', '3', '3507', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2295, 'SKR03', '3', '3508', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2296, 'SKR03', '3', '3509', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2297, 'SKR03', '3', '3530', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2298, 'SKR03', '3', '3531', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2299, 'SKR03', '3', '3532', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2300, 'SKR03', '3', '3533', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2301, 'SKR03', '3', '3534', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2302, 'SKR03', '3', '3540', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2303, 'SKR03', '3', '3541', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2304, 'SKR03', '3', '3542', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2305, 'SKR03', '3', '3543', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2306, 'SKR03', '3', '3544', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2307, 'SKR03', '3', '3545', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2308, 'SKR03', '3', '3546', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2309, 'SKR03', '3', '3547', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2310, 'SKR03', '3', '3548', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2311, 'SKR03', '3', '3549', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2312, 'SKR03', '3', '3550', '2240' 'steuerfreier innergemeinschaftlicher Erwerb'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2313, 'SKR03', '3', '3551', '2240' 'Wareneingang im Drittland steuerbar'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2314, 'SKR03', '3', '3559', '2240' 'Steuerfreier Einfuhren'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2315, 'SKR03', '3', '3558', '2240' 'Wareneingang I.a. EG-Land steuerbar'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2316, 'SKR03', '3', '3560', '2240' 'waren aus einem Umsatzsteuerlager § 13a UStG 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2317, 'SKR03', '3', '3565', '2240' 'waren aus einem Umsatzsteuerlager § 13a UStG 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2318, 'SKR03', '3', '3566', '2240' 'waren aus einem Umsatzsteuerlager § 13a UStG 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2319, 'SKR03', '3', '3600', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2320, 'SKR03', '3', '3601', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2321, 'SKR03', '3', '3602', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2322, 'SKR03', '3', '3603', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2323, 'SKR03', '3', '3604', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2324, 'SKR03', '3', '3605', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2325, 'SKR03', '3', '3606', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2326, 'SKR03', '3', '3607', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2327, 'SKR03', '3', '3608', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2328, 'SKR03', '3', '3609', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2329, 'SKR03', '3', '3610', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2330, 'SKR03', '3', '3611', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2331, 'SKR03', '3', '3612', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2332, 'SKR03', '3', '3613', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2333, 'SKR03', '3', '3614', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2334, 'SKR03', '3', '3615', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2335, 'SKR03', '3', '3616', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2336, 'SKR03', '3', '3617', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2337, 'SKR03', '3', '3618', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2338, 'SKR03', '3', '3619', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2339, 'SKR03', '3', '3650', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2340, 'SKR03', '3', '3651', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2341, 'SKR03', '3', '3652', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2342, 'SKR03', '3', '3653', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2343, 'SKR03', '3', '3654', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2344, 'SKR03', '3', '3655', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2345, 'SKR03', '3', '3656', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2346, 'SKR03', '3', '3657', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2347, 'SKR03', '3', '3658', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2348, 'SKR03', '3', '3659', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2349, 'SKR03', '3', '3660', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2350, 'SKR03', '3', '3661', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2351, 'SKR03', '3', '3662', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2352, 'SKR03', '3', '3663', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2353, 'SKR03', '3', '3664', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2354, 'SKR03', '3', '3665', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2355, 'SKR03', '3', '3666', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2356, 'SKR03', '3', '3667', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2357, 'SKR03', '3', '3668', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2358, 'SKR03', '3', '3669', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2359, 'SKR03', '3', '3700', '2240' 'Nachlässe'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2360, 'SKR03', '3', '3710', '2240' 'Nachlässe 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2361, 'SKR03', '3', '3711', '2240' 'Nachlässe 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2362, 'SKR03', '3', '3720', '2240' 'Nachlässe 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2363, 'SKR03', '3', '3721', '2240' 'Nachlässe 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2364, 'SKR03', '3', '3722', '2240' 'Nachlässe 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2365, 'SKR03', '3', '3723', '2240' 'Nachlässe 15% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2366, 'SKR03', '3', '3724', '2240' 'Nachlässe aus innergemeinschaftlichem Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2367, 'SKR03', '3', '3725', '2240' 'Nachlässe aus innergemeinschaftlichem Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2368, 'SKR03', '3', '3726', '2240' 'Nachlässe aus innergemeinschaftlichem Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2369, 'SKR03', '3', '3727', '2240' 'Nachlässe aus innergemeinschaftlichem Erwerb 15% Vorsteuer und 15% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2243, 'SKR03', '3', '3302', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2244, 'SKR03', '3', '3303', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2245, 'SKR03', '3', '3304', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2246, 'SKR03', '3', '3305', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2247, 'SKR03', '3', '3306', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2248, 'SKR03', '3', '3307', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2249, 'SKR03', '3', '3308', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2250, 'SKR03', '3', '3309', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2251, 'SKR03', '3', '3340', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2252, 'SKR03', '3', '3341', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2253, 'SKR03', '3', '3342', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2254, 'SKR03', '3', '3343', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2255, 'SKR03', '3', '3344', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2256, 'SKR03', '3', '3345', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2257, 'SKR03', '3', '3346', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2258, 'SKR03', '3', '3347', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2259, 'SKR03', '3', '3348', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2260, 'SKR03', '3', '3349', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2261, 'SKR03', '3', '3400', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2262, 'SKR03', '3', '3401', '2240', 'Produkt Ausgaben'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2263, 'SKR03', '3', '3402', '2240', 'Produkt Vertriebsausgaben'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2264, 'SKR03', '3', '3403', '2240', 'Konto Kasse Aufwand'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2265, 'SKR03', '3', '3404', '2240', 'Einstandskosten Verrechnungskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2266, 'SKR03', '3', '3405', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2267, 'SKR03', '3', '3406', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2268, 'SKR03', '3', '3407', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2269, 'SKR03', '3', '3408', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2270, 'SKR03', '3', '3409', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2271, 'SKR03', '3', '3420', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2272, 'SKR03', '3', '3421', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2273, 'SKR03', '3', '3422', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2274, 'SKR03', '3', '3423', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2275, 'SKR03', '3', '3424', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2276, 'SKR03', '3', '3425', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2277, 'SKR03', '3', '3426', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2278, 'SKR03', '3', '3427', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2279, 'SKR03', '3', '3428', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2280, 'SKR03', '3', '3429', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2281, 'SKR03', '3', '3430', '2240', 'Innergemeinschaftlicher Erwerb ohne Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2282, 'SKR03', '3', '3433', '2240', 'Innergemeinschaftlicher Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2283, 'SKR03', '3', '3434', '2240', 'Innergemeinschaftlicher Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2284, 'SKR03', '3', '3435', '2240', 'Innergemeinschaftlicher Erwerb ohne Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2285, 'SKR03', '3', '3440', '2240', 'Innergemeinschaftlicher Erwerb von Neufahrzeugen von Lieferanten ohne Umsatzsteuer-Identifikationsnummer 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2286, 'SKR03', '3', '3441', '2240', 'Innergemeinschaftlicher Erwerb von Neufahrzeugen von Lieferanten ohne Umsatzsteuer-Identifikationsnummer 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2287, 'SKR03', '3', '3500', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2288, 'SKR03', '3', '3501', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2289, 'SKR03', '3', '3502', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2290, 'SKR03', '3', '3503', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2291, 'SKR03', '3', '3504', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2292, 'SKR03', '3', '3505', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2293, 'SKR03', '3', '3506', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2294, 'SKR03', '3', '3507', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2295, 'SKR03', '3', '3508', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2296, 'SKR03', '3', '3509', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2297, 'SKR03', '3', '3530', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2298, 'SKR03', '3', '3531', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2299, 'SKR03', '3', '3532', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2300, 'SKR03', '3', '3533', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2301, 'SKR03', '3', '3534', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2302, 'SKR03', '3', '3540', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2303, 'SKR03', '3', '3541', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2304, 'SKR03', '3', '3542', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2305, 'SKR03', '3', '3543', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2306, 'SKR03', '3', '3544', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2307, 'SKR03', '3', '3545', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2308, 'SKR03', '3', '3546', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2309, 'SKR03', '3', '3547', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2310, 'SKR03', '3', '3548', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2311, 'SKR03', '3', '3549', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2312, 'SKR03', '3', '3550', '2240', 'steuerfreier innergemeinschaftlicher Erwerb'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2313, 'SKR03', '3', '3551', '2240', 'Wareneingang im Drittland steuerbar'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2314, 'SKR03', '3', '3559', '2240', 'Steuerfreier Einfuhren'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2315, 'SKR03', '3', '3558', '2240', 'Wareneingang I.a. EG-Land steuerbar'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2316, 'SKR03', '3', '3560', '2240', 'waren aus einem Umsatzsteuerlager § 13a UStG 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2317, 'SKR03', '3', '3565', '2240', 'waren aus einem Umsatzsteuerlager § 13a UStG 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2318, 'SKR03', '3', '3566', '2240', 'waren aus einem Umsatzsteuerlager § 13a UStG 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2319, 'SKR03', '3', '3600', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2320, 'SKR03', '3', '3601', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2321, 'SKR03', '3', '3602', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2322, 'SKR03', '3', '3603', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2323, 'SKR03', '3', '3604', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2324, 'SKR03', '3', '3605', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2325, 'SKR03', '3', '3606', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2326, 'SKR03', '3', '3607', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2327, 'SKR03', '3', '3608', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2328, 'SKR03', '3', '3609', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2329, 'SKR03', '3', '3610', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2330, 'SKR03', '3', '3611', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2331, 'SKR03', '3', '3612', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2332, 'SKR03', '3', '3613', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2333, 'SKR03', '3', '3614', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2334, 'SKR03', '3', '3615', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2335, 'SKR03', '3', '3616', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2336, 'SKR03', '3', '3617', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2337, 'SKR03', '3', '3618', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2338, 'SKR03', '3', '3619', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2339, 'SKR03', '3', '3650', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2340, 'SKR03', '3', '3651', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2341, 'SKR03', '3', '3652', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2342, 'SKR03', '3', '3653', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2343, 'SKR03', '3', '3654', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2344, 'SKR03', '3', '3655', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2345, 'SKR03', '3', '3656', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2346, 'SKR03', '3', '3657', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2347, 'SKR03', '3', '3658', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2348, 'SKR03', '3', '3659', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2349, 'SKR03', '3', '3660', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2350, 'SKR03', '3', '3661', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2351, 'SKR03', '3', '3662', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2352, 'SKR03', '3', '3663', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2353, 'SKR03', '3', '3664', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2354, 'SKR03', '3', '3665', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2355, 'SKR03', '3', '3666', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2356, 'SKR03', '3', '3667', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2357, 'SKR03', '3', '3668', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2358, 'SKR03', '3', '3669', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2359, 'SKR03', '3', '3700', '2240', 'Nachlässe'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2360, 'SKR03', '3', '3710', '2240', 'Nachlässe 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2361, 'SKR03', '3', '3711', '2240', 'Nachlässe 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2362, 'SKR03', '3', '3720', '2240', 'Nachlässe 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2363, 'SKR03', '3', '3721', '2240', 'Nachlässe 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2364, 'SKR03', '3', '3722', '2240', 'Nachlässe 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2365, 'SKR03', '3', '3723', '2240', 'Nachlässe 15% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2366, 'SKR03', '3', '3724', '2240', 'Nachlässe aus innergemeinschaftlichem Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2367, 'SKR03', '3', '3725', '2240', 'Nachlässe aus innergemeinschaftlichem Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2368, 'SKR03', '3', '3726', '2240', 'Nachlässe aus innergemeinschaftlichem Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2369, 'SKR03', '3', '3727', '2240', 'Nachlässe aus innergemeinschaftlichem Erwerb 15% Vorsteuer und 15% Umsatzsteuer'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2372, 'SKR03', '3', '3730', '0', 'Erhaltene Skonti'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2373, 'SKR03', '3', '3731', '0', 'Erhaltene Skonti 7% Vorsteuer'); @@ -1295,9 +1295,9 @@ 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) VALUES (__ENTITY__, 2391, 'SKR03', '3', '3791', '0', 'Erhaltene Rabatte 19% Vorsteuer'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2392, 'SKR03', '3', '3794', '0', 'Erhaltene Rabatte 16% Vorsteuer'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2393, 'SKR03', '3', '3795', '0', 'Erhaltene Rabatte 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2394, 'SKR03', '3', '3800', '0' 'Bezugsnebenkosten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2395, 'SKR03', '3', '3830', '0' 'Leergut'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2396, 'SKR03', '3', '3850', '0' 'Zölle und Einfuhrabgaben'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2394, 'SKR03', '3', '3800', '0', 'Bezugsnebenkosten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2395, 'SKR03', '3', '3830', '0', 'Leergut'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2396, 'SKR03', '3', '3850', '0', 'Zölle und Einfuhrabgaben'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2399, 'SKR03', '3', '3960', '0', 'Bestandsveränderungen Roh- Hilfs- und Betriebsstoffe sowie bezogene Waren'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2400, 'SKR03', '3', '3961', '0', 'Bestandsveränderungen Roh- Hilfs- und Betriebsstoffe sowie bezogene Waren'); @@ -2707,7 +2707,6 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc -- SKR04 -- Some lines of SKR04 has been disabled because the fiel account_parent is wrong, it must be the rowid of parent line and not the account_number of parent line -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3837, 'SKR04', 'Anlagevermögen', 0, 0, 'Anlagevermögen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3838, 'SKR04', 'Anlagevermögen', 100, 0, 'Entgeltlich erworbene Konzessionen, gewerbliche Schutzrechte und ähnliche Rechte und Werte sowie Lizenzen an solchen Rechten und Werten'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3839, 'SKR04', 'Anlagevermögen', 110, 3838, 'Konzessionen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3840, 'SKR04', 'Anlagevermögen', 120, 3838, 'Gewerbliche Schutzrechte'); @@ -2715,66 +2714,66 @@ 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) VALUES (__ENTITY__, 3842, 'SKR04', 'Anlagevermögen', 135, 3838, 'EDV-Software'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3843, 'SKR04', 'Anlagevermögen', 140, 3838, 'Lizenzen an gewerblichen Schutzrechten und ähnlichen Rechten und Werte'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3844, 'SKR04', 'Anlagevermögen', 143, 0, 'Selbst geschaffene immaterielle Vermögensgegenstände'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3845, 'SKR04', 'Anlagevermögen', 144, 143, 'EDV-Software'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3846, 'SKR04', 'Anlagevermögen', 145, 143, 'Lizenzen und Franchiseverträge'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3847, 'SKR04', 'Anlagevermögen', 146, 143, 'Konzessionen und gewerbliche Schutzrechte'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3848, 'SKR04', 'Anlagevermögen', 147, 143, 'Rezepte, Verfahren, Prototypen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3849, 'SKR04', 'Anlagevermögen', 148, 143, 'Immaterielle Vermögensgegenstände in Entwicklung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3845, 'SKR04', 'Anlagevermögen', 144, 3844, 'EDV-Software'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3846, 'SKR04', 'Anlagevermögen', 145, 3844, 'Lizenzen und Franchiseverträge'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3847, 'SKR04', 'Anlagevermögen', 146, 3844, 'Konzessionen und gewerbliche Schutzrechte'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3848, 'SKR04', 'Anlagevermögen', 147, 3844, 'Rezepte, Verfahren, Prototypen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3849, 'SKR04', 'Anlagevermögen', 148, 3844, 'Immaterielle Vermögensgegenstände in Entwicklung'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3850, 'SKR04', 'Anlagevermögen', 150, 0, 'Geschäfts- oder Firmenwert'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3851, 'SKR04', 'Anlagevermögen', 160, 0, 'Verschmelzungsmehrwert'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3852, 'SKR04', 'Anlagevermögen', 170, 0, 'Geleistete Anzahlungen auf immaterielle Vermögensgegenstände'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3853, 'SKR04', 'Anlagevermögen', 179, 0, 'Anzahlungen auf Geschäfts- oder Firmenwert'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3854, 'SKR04', 'Anlagevermögen', 200, 0, 'Grundstücke, grundstücksgleiche Rechte und Bauten einschließlich der Bauten auf fremden Grundstück'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3855, 'SKR04', 'Anlagevermögen', 210, 200, 'Grundstücksgleiche Rechte ohne Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3856, 'SKR04', 'Anlagevermögen', 215, 200, 'Unbebaute Grundstücke'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3857, 'SKR04', 'Anlagevermögen', 220, 200, 'Grundstücksgleiche Rechte (Erbbaurecht, Dauerwohnrecht, unbebaute Grundstücke)'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3858, 'SKR04', 'Anlagevermögen', 225, 200, 'Grundstücke mit Substanzverkehr'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3859, 'SKR04', 'Anlagevermögen', 229, 200, 'Grundstücksanteil des häuslichen Arbeitszimmers'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3860, 'SKR04', 'Anlagevermögen', 230, 200, 'Bauten auf eigenen Grundstücken und grundstücksgleichen Rechten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3861, 'SKR04', 'Anlagevermögen', 235, 200, 'Grundstückswerte eigener bebauter Grundstücke'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3862, 'SKR04', 'Anlagevermögen', 240, 200, 'Geschäftsbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3863, 'SKR04', 'Anlagevermögen', 250, 200, 'Fabrikbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3864, 'SKR04', 'Anlagevermögen', 260, 200, 'Andere Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3865, 'SKR04', 'Anlagevermögen', 270, 200, 'Garagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3866, 'SKR04', 'Anlagevermögen', 280, 200, 'Außenanlagen für Geschäfts-, Fabrik- und andere Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3867, 'SKR04', 'Anlagevermögen', 285, 200, 'Hof- und Wegbefestigungen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3868, 'SKR04', 'Anlagevermögen', 290, 200, 'Einrichtungen für Geschäfts-. Fabrik- und andere Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3869, 'SKR04', 'Anlagevermögen', 300, 200, 'Wohnbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3870, 'SKR04', 'Anlagevermögen', 305, 200, 'Garagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3871, 'SKR04', 'Anlagevermögen', 310, 200, 'Außenanlagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3872, 'SKR04', 'Anlagevermögen', 315, 200, 'Hof- und Wegbefestigungen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3873, 'SKR04', 'Anlagevermögen', 320, 200, 'Einrichtungen für Wohnbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3874, 'SKR04', 'Anlagevermögen', 329, 200, 'Gebäudeteil des häuslichen Arbeitszimmers'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3875, 'SKR04', 'Anlagevermögen', 330, 200, 'Bauten auf fremden Grundstücken'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3876, 'SKR04', 'Anlagevermögen', 340, 200, 'Geschäftsbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3877, 'SKR04', 'Anlagevermögen', 350, 200, 'Fabrikbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3878, 'SKR04', 'Anlagevermögen', 360, 200, 'Wohnbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3879, 'SKR04', 'Anlagevermögen', 370, 200, 'Andere Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3880, 'SKR04', 'Anlagevermögen', 380, 200, 'Garagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3881, 'SKR04', 'Anlagevermögen', 390, 200, 'Außenanlagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3882, 'SKR04', 'Anlagevermögen', 395, 200, 'Hof- und Wegbefestigungen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3883, 'SKR04', 'Anlagevermögen', 398, 200, 'Einrichtungen für Geschäfts-. Fabrik-, Wohn- und andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3855, 'SKR04', 'Anlagevermögen', 210, 3854, Grundstücksgleiche Rechte ohne Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3856, 'SKR04', 'Anlagevermögen', 215, 3854, Unbebaute Grundstücke'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3857, 'SKR04', 'Anlagevermögen', 220, 3854, Grundstücksgleiche Rechte (Erbbaurecht, Dauerwohnrecht, unbebaute Grundstücke)'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3858, 'SKR04', 'Anlagevermögen', 225, 3854, Grundstücke mit Substanzverkehr'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3859, 'SKR04', 'Anlagevermögen', 229, 3854, Grundstücksanteil des häuslichen Arbeitszimmers'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3860, 'SKR04', 'Anlagevermögen', 230, 3854, Bauten auf eigenen Grundstücken und grundstücksgleichen Rechten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3861, 'SKR04', 'Anlagevermögen', 235, 3854, Grundstückswerte eigener bebauter Grundstücke'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3862, 'SKR04', 'Anlagevermögen', 240, 3854, Geschäftsbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3863, 'SKR04', 'Anlagevermögen', 250, 3854, Fabrikbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3864, 'SKR04', 'Anlagevermögen', 260, 3854, Andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3865, 'SKR04', 'Anlagevermögen', 270, 3854, Garagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3866, 'SKR04', 'Anlagevermögen', 280, 3854, Außenanlagen für Geschäfts-, Fabrik- und andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3867, 'SKR04', 'Anlagevermögen', 285, 3854, Hof- und Wegbefestigungen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3868, 'SKR04', 'Anlagevermögen', 290, 3854, Einrichtungen für Geschäfts-. Fabrik- und andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3869, 'SKR04', 'Anlagevermögen', 300, 3854, Wohnbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3870, 'SKR04', 'Anlagevermögen', 305, 3854, Garagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3871, 'SKR04', 'Anlagevermögen', 310, 3854, Außenanlagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3872, 'SKR04', 'Anlagevermögen', 315, 3854, Hof- und Wegbefestigungen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3873, 'SKR04', 'Anlagevermögen', 320, 3854, Einrichtungen für Wohnbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3874, 'SKR04', 'Anlagevermögen', 329, 3854, Gebäudeteil des häuslichen Arbeitszimmers'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3875, 'SKR04', 'Anlagevermögen', 330, 3854, Bauten auf fremden Grundstücken'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3876, 'SKR04', 'Anlagevermögen', 340, 3854, Geschäftsbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3877, 'SKR04', 'Anlagevermögen', 350, 3854, Fabrikbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3878, 'SKR04', 'Anlagevermögen', 360, 3854, Wohnbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3879, 'SKR04', 'Anlagevermögen', 370, 3854, Andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3880, 'SKR04', 'Anlagevermögen', 380, 3854, Garagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3881, 'SKR04', 'Anlagevermögen', 390, 3854, Außenanlagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3882, 'SKR04', 'Anlagevermögen', 395, 3854, Hof- und Wegbefestigungen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3883, 'SKR04', 'Anlagevermögen', 398, 3854, Einrichtungen für Geschäfts-. Fabrik-, Wohn- und andere Bauten'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3884, 'SKR04', 'Anlagevermögen', 400, 0, 'Technische Anlagen und Maschinen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3885, 'SKR04', 'Anlagevermögen', 420, 400, 'Technische Anlagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3886, 'SKR04', 'Anlagevermögen', 440, 400, 'Maschinen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3887, 'SKR04', 'Anlagevermögen', 450, 400, 'Transportanlagen und Ähnlichen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3888, 'SKR04', 'Anlagevermögen', 460, 400, 'Maschinengebundene Werkzeuge'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3889, 'SKR04', 'Anlagevermögen', 470, 400, 'Betriebsvorrichtungen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3885, 'SKR04', 'Anlagevermögen', 420, 3884, 'Technische Anlagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3886, 'SKR04', 'Anlagevermögen', 440, 3884, 'Maschinen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3887, 'SKR04', 'Anlagevermögen', 450, 3884, 'Transportanlagen und Ähnlichen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3888, 'SKR04', 'Anlagevermögen', 460, 3884, 'Maschinengebundene Werkzeuge'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3889, 'SKR04', 'Anlagevermögen', 470, 3884, 'Betriebsvorrichtungen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3890, 'SKR04', 'Anlagevermögen', 500, 0, 'Andere Anlagen, Betriebs- und Geschäftsausstattungen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3891, 'SKR04', 'Anlagevermögen', 510, 500, 'Andere Anlagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3892, 'SKR04', 'Anlagevermögen', 520, 500, 'PKW'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3893, 'SKR04', 'Anlagevermögen', 540, 500, 'LKW'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3894, 'SKR04', 'Anlagevermögen', 560, 500, 'Sonstige Transportmittel'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3895, 'SKR04', 'Anlagevermögen', 620, 500, 'Werkzeuge'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3896, 'SKR04', 'Anlagevermögen', 630, 500, 'Betriebsausstattung'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3897, 'SKR04', 'Anlagevermögen', 635, 500, 'Geschäftsausstattung'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3898, 'SKR04', 'Anlagevermögen', 640, 500, 'Ladeneinrichtung'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3899, 'SKR04', 'Anlagevermögen', 650, 500, 'Büroeinrichtung'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3900, 'SKR04', 'Anlagevermögen', 660, 500, 'Gerüst- und Schalungsmaterial'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3901, 'SKR04', 'Anlagevermögen', 670, 500, 'Geringwertige Wirtschaftsgüter'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3902, 'SKR04', 'Anlagevermögen', 675, 500, 'Wirtschaftsgüter (Sammelposten)'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3903, 'SKR04', 'Anlagevermögen', 680, 500, 'Einbauten in fremde Grundstücke'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3904, 'SKR04', 'Anlagevermögen', 690, 500, 'Sonstige Betriebs- und Geschäftsausstattung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3891, 'SKR04', 'Anlagevermögen', 510, 3890, 'Andere Anlagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3892, 'SKR04', 'Anlagevermögen', 520, 3890, 'PKW'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3893, 'SKR04', 'Anlagevermögen', 540, 3890, 'LKW'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3894, 'SKR04', 'Anlagevermögen', 560, 3890, 'Sonstige Transportmittel'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3895, 'SKR04', 'Anlagevermögen', 620, 3890, 'Werkzeuge'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3896, 'SKR04', 'Anlagevermögen', 630, 3890, 'Betriebsausstattung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3897, 'SKR04', 'Anlagevermögen', 635, 3890, 'Geschäftsausstattung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3898, 'SKR04', 'Anlagevermögen', 640, 3890, 'Ladeneinrichtung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3899, 'SKR04', 'Anlagevermögen', 650, 3890, 'Büroeinrichtung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3900, 'SKR04', 'Anlagevermögen', 660, 3890, 'Gerüst- und Schalungsmaterial'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3901, 'SKR04', 'Anlagevermögen', 670, 3890, 'Geringwertige Wirtschaftsgüter'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3902, 'SKR04', 'Anlagevermögen', 675, 3890, 'Wirtschaftsgüter (Sammelposten)'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3903, 'SKR04', 'Anlagevermögen', 680, 3890, 'Einbauten in fremde Grundstücke'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3904, 'SKR04', 'Anlagevermögen', 690, 3890, 'Sonstige Betriebs- und Geschäftsausstattung'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3905, 'SKR04', 'Anlagevermögen', 700, 0, 'Geleistete Anzahlungen und Anlagen im Bau'); --INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3906, 'SKR04', 'Anlagevermögen', 705, 700, 'Anzahlungen auf Grundstücke und grundstücksgleiche Rechte ohne Bauten'); --INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3907, 'SKR04', 'Anlagevermögen', 710, 700, 'Geschäfts-, Fabrik- und andere Bauten im Bau auf eigenen Grundstücken'); From 8ff15d7567e2f333230dc5bc131f1c83b2ade7ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 01:28:18 +0200 Subject: [PATCH 192/233] Try to fix some id parent, at least for SKR03 --- .../mysql/data/llx_accounting_account_de.sql | 226 +++++++++--------- 1 file changed, 113 insertions(+), 113 deletions(-) diff --git a/htdocs/install/mysql/data/llx_accounting_account_de.sql b/htdocs/install/mysql/data/llx_accounting_account_de.sql index 1ff393421ba..41f5b623d7b 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_de.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_de.sql @@ -268,83 +268,83 @@ 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) VALUES (__ENTITY__, 1306, 'SKR03', '0', '898', '870', 'Gesellschafter-Darlehen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1307, 'SKR03', '0', '899', '870', 'Gesellschafter-Darlehen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1309, 'SKR03', '0', '900', '0', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1310, 'SKR03', '0', '901', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1311, 'SKR03', '0', '902', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1312, 'SKR03', '0', '903', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1313, 'SKR03', '0', '904', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1314, 'SKR03', '0', '905', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1315, 'SKR03', '0', '906', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1316, 'SKR03', '0', '907', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1317, 'SKR03', '0', '908', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1318, 'SKR03', '0', '909', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1319, 'SKR03', '0', '910', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1320, 'SKR03', '0', '911', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1321, 'SKR03', '0', '912', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1322, 'SKR03', '0', '913', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1323, 'SKR03', '0', '914', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1324, 'SKR03', '0', '915', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1325, 'SKR03', '0', '916', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1326, 'SKR03', '0', '917', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1327, 'SKR03', '0', '918', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1328, 'SKR03', '0', '919', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1329, 'SKR03', '0', '920', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1330, 'SKR03', '0', '921', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1331, 'SKR03', '0', '922', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1332, 'SKR03', '0', '923', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1333, 'SKR03', '0', '924', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1334, 'SKR03', '0', '925', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1335, 'SKR03', '0', '926', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1336, 'SKR03', '0', '927', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1337, 'SKR03', '0', '928', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1338, 'SKR03', '0', '929', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1341, 'SKR03', '0', '930', '900', 'Sonderposten mit Rücklageanteil steuerfreie Rücklagen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1342, 'SKR03', '0', '931', '930', 'Sonderposten mit Rücklageanteil nach § 6b EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1343, 'SKR03', '0', '932', '930', 'Sonderposten mit Rücklageanteil nach Abschnitt 35 EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1344, 'SKR03', '0', '933', '930', 'Sonderposten mit Rücklageanteil nach § 6d EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1345, 'SKR03', '0', '934', '930', 'Sonderposten mit Rücklageanteil nach § 1 EntwLStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1347, 'SKR03', '0', '935', '900', 'Sonderposten aus der Währungsumstellung auf den Euro'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1348, 'SKR03', '0', '936', '930', 'Sonderposten mit Rücklageanteil nach § 7 d EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1349, 'SKR03', '0', '937', '930', 'Sonderposten mit Rücklageanteil nach § 79 EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1350, 'SKR03', '0', '938', '930', 'Sonderposten mit Rücklageanteil nach § 80 EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1351, 'SKR03', '0', '939', '930', 'Sonderposten mit Rücklageanteil nach § 52 Abs.16 EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1352, 'SKR03', '0', '940', '930', 'Sonderposten mit Rücklageanteil Sonderabschreibungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1353, 'SKR03', '0', '941', '930', 'Sonderposten mit Rücklageanteil § 82 a EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1354, 'SKR03', '0', '942', '930', 'Sonderposten mit Rücklageanteil § 82 d EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1355, 'SKR03', '0', '943', '930', 'Sonderposten mit Rücklageanteil nach § 82 e EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1356, 'SKR03', '0', '944', '930', 'Sonderposten mit Rücklageanteil nach § 14 BerlinFG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1357, 'SKR03', '0', '945', '930', 'Sonderposten mit Rücklageanteil für Förderung nach § 3 Zonen-RFG/§ 4-6 FördergebietsG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1358, 'SKR03', '0', '946', '930', 'Sonderposten mit Rücklageanteil nach § 4d EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1359, 'SKR03', '0', '947', '930', 'Sonderposten mit Rücklageanteil nach § 7g Abs.1 EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1360, 'SKR03', '0', '948', '930', 'Sonderposten mit Rücklageanteil nach § 7g Abs.3 u.7 EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1362, 'SKR03', '0', '949', '900', 'Sonderposten für Zuschüsse und Zulagen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1365, 'SKR03', '0', '950', '900', 'Rückstellungen für Pensionen und ähnliche Verpflichtungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1367, 'SKR03', '0', '955', '900', 'Steuerrückstellungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1368, 'SKR03', '0', '957', '955', 'Gewerbesteuerrückstellung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1369, 'SKR03', '0', '963', '955', 'Körperschaftsteuerrückstellung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1371, 'SKR03', '0', '965', '900', 'Rückstellungen für Personalkosten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1372, 'SKR03', '0', '966', '900', 'Rückstellungen zur Erfüllung der Aufbewahrungspflichten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1373, 'SKR03', '0', '969', '900', 'Rückstellung für latente Steuern'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1374, 'SKR03', '0', '970', '900', 'Sonstige Rückstellungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1375, 'SKR03', '0', '971', '900', 'Rückstellungen für unterlassene Aufwendungen für Instandhaltung Nachholung in den ersten drei Monaten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1376, 'SKR03', '0', '972', '900', 'Rückstellungen für unterlassene Aufwendungen für Instandhaltung Nachholung innerhalb des 4. bis 12. Monats'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1377, 'SKR03', '0', '973', '900', 'Rückstellungen für Abraum- und Abfallbeseitigung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1378, 'SKR03', '0', '974', '900', 'Rückstellungen für Gewährleistungen ( Gegenkonto 4790 )'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1379, 'SKR03', '0', '976', '900', 'Rückstellungen für drohende Verluste aus schwebenden Geschäften'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1380, 'SKR03', '0', '977', '900', 'Rückstellungen für Abschluss- und Prüfungskosten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1381, 'SKR03', '0', '978', '900', 'Aufwandsrückstellungen gemäß § 249 Abs. 2 HGB'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1382, 'SKR03', '0', '979', '900', 'Rückstellungen für Umweltschutz'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1385, 'SKR03', '0', '980', '900', 'Aktive Rechnungsabgrenzung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1387, 'SKR03', '0', '983', '980', 'Abgrenzung aktive latente Steuern'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1388, 'SKR03', '0', '984', '900', 'Als Aufwand berücksichtigte Zölle und Verbrauchsteuern'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1389, 'SKR03', '0', '985', '900', 'Als Aufwand berücksichtigte Umsatzsteuer auf Anzahlungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1390, 'SKR03', '0', '986', '900', 'Damnum / Disagio'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1393, 'SKR03', '0', '990', '900', 'Passive Rechnungsabgrenzung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1395, 'SKR03', '0', '992', '990', 'Abgenzungsposten zur unterjährigen Kostenverrechnung für BWA'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1396, 'SKR03', '0', '993', '990', 'Forderungen aus Lieferungen und Leistungen H-Saldo'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1397, 'SKR03', '0', '996', '990', 'Pauschalwertberichtigung auf Forderungen mit einer Restlaufzeit bis zu 1 Jahr'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1398, 'SKR03', '0', '997', '990', 'Pauschalwertberichtigung auf Forderungen mit einer Restlaufzeit von mehr als 1 Jahr'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1399, 'SKR03', '0', '998', '990', 'Einzelwertberichtigungen auf Forderungen mit einer Restlaufzeit bis zu 1 Jahr'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1400, 'SKR03', '0', '999', '990', 'Einzelwertberichtigungen auf Forderungen mit einer Restlaufzeit von mehr als 1 Jahr'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1310, 'SKR03', '0', '901', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1311, 'SKR03', '0', '902', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1312, 'SKR03', '0', '903', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1313, 'SKR03', '0', '904', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1314, 'SKR03', '0', '905', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1315, 'SKR03', '0', '906', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1316, 'SKR03', '0', '907', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1317, 'SKR03', '0', '908', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1318, 'SKR03', '0', '909', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1319, 'SKR03', '0', '910', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1320, 'SKR03', '0', '911', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1321, 'SKR03', '0', '912', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1322, 'SKR03', '0', '913', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1323, 'SKR03', '0', '914', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1324, 'SKR03', '0', '915', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1325, 'SKR03', '0', '916', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1326, 'SKR03', '0', '917', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1327, 'SKR03', '0', '918', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1328, 'SKR03', '0', '919', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1329, 'SKR03', '0', '920', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1330, 'SKR03', '0', '921', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1331, 'SKR03', '0', '922', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1332, 'SKR03', '0', '923', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1333, 'SKR03', '0', '924', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1334, 'SKR03', '0', '925', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1335, 'SKR03', '0', '926', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1336, 'SKR03', '0', '927', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1337, 'SKR03', '0', '928', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1338, 'SKR03', '0', '929', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1341, 'SKR03', '0', '930', '1309', 'Sonderposten mit Rücklageanteil steuerfreie Rücklagen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1342, 'SKR03', '0', '931', '1341', 'Sonderposten mit Rücklageanteil nach § 6b EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1343, 'SKR03', '0', '932', '1341', 'Sonderposten mit Rücklageanteil nach Abschnitt 35 EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1344, 'SKR03', '0', '933', '1341', 'Sonderposten mit Rücklageanteil nach § 6d EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1345, 'SKR03', '0', '934', '1341', 'Sonderposten mit Rücklageanteil nach § 1 EntwLStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1347, 'SKR03', '0', '935', '1309', 'Sonderposten aus der Währungsumstellung auf den Euro'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1348, 'SKR03', '0', '936', '1341', 'Sonderposten mit Rücklageanteil nach § 7 d EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1349, 'SKR03', '0', '937', '1341', 'Sonderposten mit Rücklageanteil nach § 79 EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1350, 'SKR03', '0', '938', '1341', 'Sonderposten mit Rücklageanteil nach § 80 EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1351, 'SKR03', '0', '939', '1341', 'Sonderposten mit Rücklageanteil nach § 52 Abs.16 EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1352, 'SKR03', '0', '940', '1341', 'Sonderposten mit Rücklageanteil Sonderabschreibungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1353, 'SKR03', '0', '941', '1341', 'Sonderposten mit Rücklageanteil § 82 a EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1354, 'SKR03', '0', '942', '1341', 'Sonderposten mit Rücklageanteil § 82 d EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1355, 'SKR03', '0', '943', '1341', 'Sonderposten mit Rücklageanteil nach § 82 e EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1356, 'SKR03', '0', '944', '1341', 'Sonderposten mit Rücklageanteil nach § 14 BerlinFG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1357, 'SKR03', '0', '945', '1341', 'Sonderposten mit Rücklageanteil für Förderung nach § 3 Zonen-RFG/§ 4-6 FördergebietsG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1358, 'SKR03', '0', '946', '1341', 'Sonderposten mit Rücklageanteil nach § 4d EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1359, 'SKR03', '0', '947', '1341', 'Sonderposten mit Rücklageanteil nach § 7g Abs.1 EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1360, 'SKR03', '0', '948', '1341', 'Sonderposten mit Rücklageanteil nach § 7g Abs.3 u.7 EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1362, 'SKR03', '0', '949', '1309', 'Sonderposten für Zuschüsse und Zulagen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1365, 'SKR03', '0', '950', '1309', 'Rückstellungen für Pensionen und ähnliche Verpflichtungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1367, 'SKR03', '0', '955', '1309', 'Steuerrückstellungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1368, 'SKR03', '0', '957', '1367', 'Gewerbesteuerrückstellung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1369, 'SKR03', '0', '963', '1367', 'Körperschaftsteuerrückstellung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1371, 'SKR03', '0', '965', '1309', 'Rückstellungen für Personalkosten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1372, 'SKR03', '0', '966', '1309', 'Rückstellungen zur Erfüllung der Aufbewahrungspflichten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1373, 'SKR03', '0', '969', '1309', 'Rückstellung für latente Steuern'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1374, 'SKR03', '0', '970', '1309', 'Sonstige Rückstellungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1375, 'SKR03', '0', '971', '1309', 'Rückstellungen für unterlassene Aufwendungen für Instandhaltung Nachholung in den ersten drei Monaten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1376, 'SKR03', '0', '972', '1309', 'Rückstellungen für unterlassene Aufwendungen für Instandhaltung Nachholung innerhalb des 4. bis 12. Monats'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1377, 'SKR03', '0', '973', '1309', 'Rückstellungen für Abraum- und Abfallbeseitigung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1378, 'SKR03', '0', '974', '1309', 'Rückstellungen für Gewährleistungen ( Gegenkonto 4790 )'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1379, 'SKR03', '0', '976', '1309', 'Rückstellungen für drohende Verluste aus schwebenden Geschäften'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1380, 'SKR03', '0', '977', '1309', 'Rückstellungen für Abschluss- und Prüfungskosten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1381, 'SKR03', '0', '978', '1309', 'Aufwandsrückstellungen gemäß § 249 Abs. 2 HGB'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1382, 'SKR03', '0', '979', '1309', 'Rückstellungen für Umweltschutz'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1385, 'SKR03', '0', '980', '1309', 'Aktive Rechnungsabgrenzung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1387, 'SKR03', '0', '983', '1385', 'Abgrenzung aktive latente Steuern'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1388, 'SKR03', '0', '984', '1309', 'Als Aufwand berücksichtigte Zölle und Verbrauchsteuern'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1389, 'SKR03', '0', '985', '1309', 'Als Aufwand berücksichtigte Umsatzsteuer auf Anzahlungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1390, 'SKR03', '0', '986', '1309', 'Damnum / Disagio'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1393, 'SKR03', '0', '990', '1309', 'Passive Rechnungsabgrenzung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1395, 'SKR03', '0', '992', '1393', 'Abgenzungsposten zur unterjährigen Kostenverrechnung für BWA'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1396, 'SKR03', '0', '993', '1393', 'Forderungen aus Lieferungen und Leistungen H-Saldo'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1397, 'SKR03', '0', '996', '1393', 'Pauschalwertberichtigung auf Forderungen mit einer Restlaufzeit bis zu 1 Jahr'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1398, 'SKR03', '0', '997', '1393', 'Pauschalwertberichtigung auf Forderungen mit einer Restlaufzeit von mehr als 1 Jahr'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1399, 'SKR03', '0', '998', '1393', 'Einzelwertberichtigungen auf Forderungen mit einer Restlaufzeit bis zu 1 Jahr'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1400, 'SKR03', '0', '999', '1393', 'Einzelwertberichtigungen auf Forderungen mit einer Restlaufzeit von mehr als 1 Jahr'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1403, 'SKR03', '1', '1000', '0', 'Kasse'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1404, 'SKR03', '1', '1010', '1403', 'Nebenkasse 1'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1405, 'SKR03', '1', '1020', '1403', 'Nebenkasse 2'); @@ -1965,42 +1965,42 @@ 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) VALUES (__ENTITY__, 3071, 'SKR03', '8', '8700', '0', 'Erlösschmälerungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3072, 'SKR03', '8', '8701', '8700', 'Nicht abgerechnete Einnahmen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3073, 'SKR03', '8', '8705', '8700', 'Erlösschmälerungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3074, 'SKR03', '8', '8705', '8700', 'Erlösschmälerungen aus steuerfreien Umsätzen §4 Nr. 1a UStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3075, 'SKR03', '8', '8710', '8700', 'Erlösschmälerungen 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3076, 'SKR03', '8', '8720', '8700', 'Erlösschmälerungen 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3077, 'SKR03', '8', '8721', '8700', 'Erlösschmälerungen 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3078, 'SKR03', '8', '8723', '8700', 'Erlösschmälerungen 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3079, 'SKR03', '8', '8724', '8700', 'Erlösschmälerungen aus steuerfreien innergemeinschaftlichen Lieferung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3080, 'SKR03', '8', '8725', '8700', 'Erlösschmälerungen aus im Inland steuerpflichtigen EG-Lieferungen 7 % USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3081, 'SKR03', '8', '8726', '8700', 'Erlösschmälerungen aus im Inland steuerpflichtigen EG-Lieferungen 19 % USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3082, 'SKR03', '8', '8727', '8700', 'Erlösschmälerungen aus im anderen EG-Land steuerpflichtigen Lieferungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3083, 'SKR03', '8', '8729', '8700', 'Erlösschmälerungen aus im Inland steuerpflichtigen 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3084, 'SKR03', '8', '8730', '8700', 'Gewährte Skonti'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3085, 'SKR03', '8', '8731', '8700', 'Gewährte Skonti 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3086, 'SKR03', '8', '8735', '8700', 'Gewährte Skonti 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3087, 'SKR03', '8', '8736', '8700', 'Gewährte Skonti 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3088, 'SKR03', '8', '8741', '8700', 'Gewährte Skonti aus Lieferungen für die der Leistungsempfänger die Umsatzsteuer nach § 13b UStG schuldet'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3089, 'SKR03', '8', '8743', '8700', 'Gewährte Skonti aus steuerfreien innergemeinschaftlichen Lieferungen § 4 Nr. 1b UStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3090, 'SKR03', '8', '8745', '8700', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3091, 'SKR03', '8', '8746', '8700', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3092, 'SKR03', '8', '8748', '8700', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3093, 'SKR03', '8', '8749', '8700', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3094, 'SKR03', '8', '8750', '8700', 'Gewährte Boni 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3095, 'SKR03', '8', '8751', '8700', 'Gewährte Boni 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3096, 'SKR03', '8', '8760', '8700', 'Gewährte Boni 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3097, 'SKR03', '8', '8761', '8700', 'Gewährte Boni 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3098, 'SKR03', '8', '8764', '8700', 'Gewährte Boni 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3099, 'SKR03', '8', '8765', '8700', 'Gewährte Boni 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3100, 'SKR03', '8', '8769', '8700', 'Gewährte Boni'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3101, 'SKR03', '8', '8770', '8700', 'Gewährte Rabatte'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3102, 'SKR03', '8', '8780', '8700', 'Gewährte Rabatte 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3103, 'SKR03', '8', '8781', '8700', 'Gewährte Rabatte 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3104, 'SKR03', '8', '8790', '8700', 'Gewährte Rabatte 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3105, 'SKR03', '8', '8791', '8700', 'Gewährte Rabatte 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3106, 'SKR03', '8', '8794', '8700', 'Gewährte Rabatte 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3107, 'SKR03', '8', '8795', '8700', 'Gewährte Rabatte 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3072, 'SKR03', '8', '8701', '3071', 'Nicht abgerechnete Einnahmen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3073, 'SKR03', '8', '8705', '3071', 'Erlösschmälerungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3074, 'SKR03', '8', '8705', '3071', 'Erlösschmälerungen aus steuerfreien Umsätzen §4 Nr. 1a UStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3075, 'SKR03', '8', '8710', '3071', 'Erlösschmälerungen 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3076, 'SKR03', '8', '8720', '3071', 'Erlösschmälerungen 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3077, 'SKR03', '8', '8721', '3071', 'Erlösschmälerungen 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3078, 'SKR03', '8', '8723', '3071', 'Erlösschmälerungen 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3079, 'SKR03', '8', '8724', '3071', 'Erlösschmälerungen aus steuerfreien innergemeinschaftlichen Lieferung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3080, 'SKR03', '8', '8725', '3071', 'Erlösschmälerungen aus im Inland steuerpflichtigen EG-Lieferungen 7 % USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3081, 'SKR03', '8', '8726', '3071', 'Erlösschmälerungen aus im Inland steuerpflichtigen EG-Lieferungen 19 % USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3082, 'SKR03', '8', '8727', '3071', 'Erlösschmälerungen aus im anderen EG-Land steuerpflichtigen Lieferungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3083, 'SKR03', '8', '8729', '3071', 'Erlösschmälerungen aus im Inland steuerpflichtigen 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3084, 'SKR03', '8', '8730', '3071', 'Gewährte Skonti'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3085, 'SKR03', '8', '8731', '3071', 'Gewährte Skonti 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3086, 'SKR03', '8', '8735', '3071', 'Gewährte Skonti 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3087, 'SKR03', '8', '8736', '3071', 'Gewährte Skonti 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3088, 'SKR03', '8', '8741', '3071', 'Gewährte Skonti aus Lieferungen für die der Leistungsempfänger die Umsatzsteuer nach § 13b UStG schuldet'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3089, 'SKR03', '8', '8743', '3071', 'Gewährte Skonti aus steuerfreien innergemeinschaftlichen Lieferungen § 4 Nr. 1b UStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3090, 'SKR03', '8', '8745', '3071', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3091, 'SKR03', '8', '8746', '3071', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3092, 'SKR03', '8', '8748', '3071', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3093, 'SKR03', '8', '8749', '3071', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3094, 'SKR03', '8', '8750', '3071', 'Gewährte Boni 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3095, 'SKR03', '8', '8751', '3071', 'Gewährte Boni 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3096, 'SKR03', '8', '8760', '3071', 'Gewährte Boni 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3097, 'SKR03', '8', '8761', '3071', 'Gewährte Boni 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3098, 'SKR03', '8', '8764', '3071', 'Gewährte Boni 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3099, 'SKR03', '8', '8765', '3071', 'Gewährte Boni 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3100, 'SKR03', '8', '8769', '3071', 'Gewährte Boni'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3101, 'SKR03', '8', '8770', '3071', 'Gewährte Rabatte'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3102, 'SKR03', '8', '8780', '3071', 'Gewährte Rabatte 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3103, 'SKR03', '8', '8781', '3071', 'Gewährte Rabatte 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3104, 'SKR03', '8', '8790', '3071', 'Gewährte Rabatte 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3105, 'SKR03', '8', '8791', '3071', 'Gewährte Rabatte 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3106, 'SKR03', '8', '8794', '3071', 'Gewährte Rabatte 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3107, 'SKR03', '8', '8795', '3071', 'Gewährte Rabatte 16% USt'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3109, 'SKR03', '8', '8800', '0', 'Erlöse aus Verkäufen Sachanlagevermögen (Bei Buchverlust)'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3110, 'SKR03', '8', '8801', '3109', 'Erlöse aus Verkäufen Sachanlagevermögen 19% USt (Bei Buchverlust)'); From 5fa6aa0ac16cb704d62f047c766721d7ca4da64f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 01:32:46 +0200 Subject: [PATCH 193/233] Update modMyModule.class.php --- .../template/core/modules/modMyModule.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index e98d66b4277..a20669beca3 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -264,17 +264,17 @@ class modMyModule extends DolibarrModules $r = 0; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ - $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject) $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->read) $r++; - $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject) $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->write) $r++; - $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject) $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->delete) From 17b5228bd329dabf11f05ba8a375ab3dad00473b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 01:34:04 +0200 Subject: [PATCH 194/233] Update modMyModule.class.php --- .../template/core/modules/modMyModule.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index a20669beca3..0314662f13e 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -266,17 +266,17 @@ class modMyModule extends DolibarrModules /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label - $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject) + $this->rights[$r][4] = 'myobject'; $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->read) $r++; $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label - $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject) + $this->rights[$r][4] = 'myobject'; $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->write) $r++; $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label - $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject) + $this->rights[$r][4] = 'myobject'; $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->delete) $r++; /* END MODULEBUILDER PERMISSIONS */ From b078c2dcc9ea627d824ef0b845a8e575a2ec9982 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 01:34:53 +0200 Subject: [PATCH 195/233] Update list.php --- htdocs/fourn/paiement/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 5a9fa544984..f61d1795cba 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -172,7 +172,7 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_payment_type != '') $sql .= " AND c.code='".$db->escape($search_payment_type)."'"; if ($search_cheque_num != '') $sql .= natural_search('p.num_paiement', $search_cheque_num); if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); -if ($search_bank_account > 0) $sql .= ' AND b.fk_account='.$search_bank_account; +if ($search_bank_account > 0) $sql .= ' AND b.fk_account='.((int) $search_bank_account); if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); From 70ddb0e87e1cf13f5f80b7d991c301773ce83205 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 01:41:48 +0200 Subject: [PATCH 196/233] Remove delcaration of no more used library --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index bd81e101cfc..f9d06530c9a 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ "ckeditor/ckeditor" : "4.12.1", "mike42/escpos-php" : "2.2", "mobiledetect/mobiledetectlib" : "2.8.34", - "phpoffice/phpexcel" : "1.8.1", "restler/framework" : "3.0.0-RC6", "tecnickcom/tcpdf" : "6.3.2", "nnnick/chartjs" : "^2.9", From bb8ec90b7978a024c418524d54c4f1afc8d7ee45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 02:50:07 +0200 Subject: [PATCH 197/233] Fix css --- htdocs/accountancy/admin/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 4b18fc03c5b..4ebd9d3bb70 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -430,7 +430,7 @@ if ($resql) { print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); } if (!empty($arrayfields['aa.pcg_type']['checked'])) { - print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); + print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1); } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { From 0adbffd8645457abc155169f9461f8a0b0cd36d1 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 2 Apr 2021 08:24:10 +0200 Subject: [PATCH 198/233] fix typo --- htdocs/install/mysql/tables/llx_product.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 0cae99c3507..da8c2ff693c 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -59,7 +59,7 @@ create table llx_product tobuy tinyint DEFAULT 1, -- Product you buy onportal tinyint DEFAULT 0, -- If it is a product you sell and you want to sell it on portal (module website must be on) tobatch tinyint DEFAULT 0 NOT NULL, -- Is it a product that need a batch management (eat-by or lot management) - batch mask varchar(32), -- If the product has batch feature, you may want to use a batch mask per product + batch_mask varchar(32), -- If the product has batch feature, you may want to use a batch mask per product fk_product_type integer DEFAULT 0, -- Type of product: 0 for regular product, 1 for service, 9 for other (used by external module) duration varchar(6), seuil_stock_alerte float DEFAULT NULL, From fbb3373d40c42a609ef84b7634d499fe272da0a3 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 2 Apr 2021 09:08:08 +0200 Subject: [PATCH 199/233] Update to match eldy's advices --- htdocs/product/stock/massstockmove.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index aac4d66fc88..ce00f59fd83 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -320,6 +320,9 @@ if ($action == 'importCSV' && !empty($user->rights->stock->mouvement->creer)) { } else { $i=0; $data = array(); + $productstatic = new Product($db); + $warehousestatics = new Entrepot($db); + $warehousestatict = new Entrepot($db); while (($i < $nblinesrecord) && !$error) { $data[] = $importcsv->import_read_record(); if (count($data[$i]) == 1) { @@ -329,10 +332,6 @@ if ($action == 'importCSV' && !empty($user->rights->stock->mouvement->creer)) { continue; } //var_dump($data); - $formproduct = new FormProduct($db); - $productstatic = new Product($db); - $warehousestatics = new Entrepot($db); - $warehousestatict = new Entrepot($db); $tmp_id_sw = $data[$i][0]['val']; $tmp_id_tw = $data[$i][1]['val']; $tmp_id_product = $data[$i][2]['val']; @@ -681,6 +680,7 @@ $db->close(); /** * Verify if $haystack startswith $needle + * * @param String $haystack string to test * @param String $needle string to find * @return false if Ko true else @@ -693,6 +693,7 @@ function startsWith($haystack, $needle) /** * Fetch object with ref + * * @param Object $static_object static object to fetch * @param String $tmp_ref ref of the object to fetch * @return <0 if Ko or Id of object From 88b481e5a8ea3bd95b76e0a1f6ebc5142d0eb865 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 2 Apr 2021 11:25:14 +0200 Subject: [PATCH 200/233] keep tab project --- .../class/conferenceorboothattendee.class.php | 6 +++++- .../conferenceorboothattendee_card.php | 9 +++++++-- .../conferenceorboothattendee_list.php | 4 ++-- htdocs/projet/class/project.class.php | 11 +++++++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 3b0795ef2a0..ef5e85c7229 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -104,7 +104,7 @@ class ConferenceOrBoothAttendee extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,), - 'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>1, 'index'=>1,), + 'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>1, 'visible'=>1, 'index'=>1,), 'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), 'amount' => array('type'=>'price', 'label'=>'AmountOfSubscriptionPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), @@ -745,6 +745,10 @@ class ConferenceOrBoothAttendee extends CommonObject if ($option == 'conforboothid') { $url .= '&conforboothid='.$this->fk_actioncomm; } + + if ($option == 'conforboothidproject') { + $url .= '&conforboothid='.$this->fk_actioncomm.'&withproject=1' ; + } } $linkclose = ''; diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index 57cf6baba78..68f6c4eef13 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -110,7 +110,12 @@ if ($reshook < 0) { if (empty($reshook)) { $error = 0; - $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php', 1); + if (!empty($withproject)) { + $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php?withproject=1', 1); + } else { + $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php', 1); + } + if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { @@ -492,7 +497,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; /* diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index d62830de925..0505f6c7461 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -604,7 +604,7 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl, '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -776,7 +776,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'ref') { - print $object->getNomUrl(1, 'conforboothid'); + print $object->getNomUrl(1, (!empty($withproject)?'conforboothidproject':'conforboothid')); } else { print $object->showOutputField($val, $key, $object->$key, ''); } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7fc9646c489..11af1f4ea13 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -115,6 +115,17 @@ class Project extends CommonObject */ public $usage_bill_time; // Is the time spent on project must be invoiced or not + /** + * @var boolean Use opportunities management + */ + public $usage_opportunity; + + /** + * @var boolean Use task management + */ + public $usage_task; + + /** * @var boolean Event organization: Use Event Organization */ From 4cf8c4c685c590077d5b93eab16ad85f16168f16 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 2 Apr 2021 12:06:03 +0200 Subject: [PATCH 201/233] add conf or booth contact tab and roles --- .../conferenceorbooth_card.php | 2 +- .../conferenceorbooth_contact.php | 63 ++++++++++++++++--- ...ventorganization_conferenceorbooth.lib.php | 8 +-- .../install/mysql/data/llx_c_type_contact.sql | 5 +- .../install/mysql/migration/13.0.0-14.0.0.sql | 5 ++ 5 files changed, 69 insertions(+), 14 deletions(-) diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index bcdb2001194..29d6758e259 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -45,7 +45,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'co $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $withproject = GETPOST('withproject', 'int'); -$project_ref = GETPOST('project_ref', 'alpha'); +$mode = GETPOST('mode', 'alpha'); // Initialize technical objects $object = new ConferenceOrBooth($db); diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php index 4efd404d78d..4906a4e05e3 100644 --- a/htdocs/eventorganization/conferenceorbooth_contact.php +++ b/htdocs/eventorganization/conferenceorbooth_contact.php @@ -55,9 +55,10 @@ if (!$res) { require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); - +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; // Load translation files required by the page $langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails")); @@ -66,10 +67,12 @@ $ref = GETPOST('ref', 'alpha'); $lineid = GETPOST('lineid', 'int'); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); +$withproject = GETPOST('withproject', 'int'); // Initialize technical objects $object = new ConferenceOrBooth($db); $extrafields = new ExtraFields($db); +$projectstatic = new Project($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothcontact', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels @@ -85,7 +88,7 @@ if ($user->socid > 0) { $isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -$permission = $user->rights->eventorganization->conferenceorbooth->write; +$permission = $user->rights->eventorganization->write; /* @@ -98,7 +101,7 @@ if ($action == 'addcontact' && $permission) { // Add a new contact $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.(!empty($withproject)?'&withproject=1':'')); exit; } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -116,7 +119,7 @@ if ($action == 'addcontact' && $permission) { // Add a new contact $result = $object->delete_contact($lineid); if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.(!empty($withproject)?'&withproject=1':'')); exit; } else { dol_print_error($db); @@ -144,9 +147,21 @@ $userstatic = new User($db); /* View and edit mode */ /* */ /* *************************************************************************** */ + +$result = $projectstatic->fetch($object->fk_project); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); +} +if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); +} +$withProjectUrl=''; +$object->project = clone $projectstatic; + if (!empty($withproject)) { // Tabs for project $tab = 'eventorganisation'; + $withProjectUrl="&withproject=1"; $head = project_prepare_head($projectstatic); print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); @@ -204,7 +219,7 @@ if (!empty($withproject)) { print '
    '; } if (!empty($conf->eventorganization->enabled)) { - print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); } @@ -265,6 +280,38 @@ if (!empty($withproject)) { print ""; } + print '
    "; + + print '"; + + print '"; + + print '"; + + print '"; + print '
    '; print '     '; $out = (empty($conf->global->MAIN_UPLOAD_DOC) ? ' disabled' : ''); print ''; @@ -594,52 +513,94 @@ if (!empty($conf->global->MAIN_UPLOAD_DOC)) { $out .= ' ('.$langs->trans("UploadDisabled").')'; } print $out; + +print ''; + +print '

    '; + +// Form to add a line +print '
    '; +print ''; +print ''; + + +print '
    '; +print ''; + +$param = ''; + +print ''; +print getTitleFieldOfList($langs->trans('WarehouseSource'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); +print getTitleFieldOfList($langs->trans('WarehouseTarget'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); +print getTitleFieldOfList($langs->trans('ProductRef'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); +if ($conf->productbatch->enabled) { + print getTitleFieldOfList($langs->trans('Batch'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); +} +print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone '); +print getTitleFieldOfList('', 0); +print ''; + +print ''; +// From warehouse +print ''; -print "\n"; +// To warehouse +print ''; +// Product +print ''; +// Batch number +if ($conf->productbatch->enabled) { + print ''; +} +// Qty +print ''; +// Button to add line +print ''; - // Search available files to import - $i = 0; - foreach ($filearray as $key => $val) { - $file = $val['name']; +print ''; - // readdir return value in ISO and we want UTF8 in memory - if (!utf8_check($file)) { - $file = utf8_encode($file); - } +foreach ($listofdata as $key => $val) { + $productstatic->fetch($val['id_product']); + $warehousestatics->fetch($val['id_sw']); + $warehousestatict->fetch($val['id_tw']); - if (preg_match('/^\./', $file)) { - continue; - } - - $modulepart = 'import'; - $urlsource = $_SERVER["PHP_SELF"].'&filetoimport='.urlencode($filetoimport); - $relativepath = $file; - - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->productbatch->enabled) { print ''; - // Affiche taille fichier - print ''; - // Affiche date fichier - print ''; - // Del button - print ''; - // Action button - print ''; - print ''; } + print ''; + print ''; + print ''; } print '
    '; +print img_picto($langs->trans("WarehouseSource"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); print '
    '; +print img_picto($langs->trans("WarehouseTarget"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); +print ''; +$filtertype = 0; +if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $filtertype = ''; +} +if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) { + $limit = ''; +} else { + $limit = $conf->global->PRODUIT_LIMIT_SIZE; +} -// Search available imports -$filearray = dol_dir_list($conf->stock->dir_temp, 'files', 0, '', '', 'name', SORT_DESC); -if (count($filearray) > 0) { - $dir = $conf->stock->dir_temp; +print img_picto($langs->trans("Product"), 'product', 'class="paddingright"'); +print $form->select_produits($id_product, 'productid', $filtertype, $limit, 0, -1, 2, '', 1, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1, '', null, 1); +print ''; + print img_picto($langs->trans("LotSerial"), 'lot', 'class="paddingright"'); + print ''; + print '
    '.img_mime($file).'
    '; + print $warehousestatics->getNomUrl(1); + print ''; + print $warehousestatict->getNomUrl(1); + print ''; + print $productstatic->getNomUrl(1).' - '.$productstatic->label; + print ''; - print ''; - print $file; - print ''; + print $val['batch']; print ''.dol_print_size(dol_filesize($dir.'/'.$file)).''.dol_print_date(dol_filemtime($dir.'/'.$file), 'dayhour').''.img_delete().''; - print ''.img_picto($langs->trans("NewImport"), 'next', 'class="fa-15x"').''; - print '
    '.$val['qty'].''.img_delete($langs->trans("Remove")).'
    '; @@ -649,32 +610,36 @@ print ''; print '
    '; +// Form to validate all movements +if (count($listofdata)) { + print '
    '; + print ''; + print ''; -print ''; -print ''; -print ''; + // Button to record mass movement + $codemove = (GETPOSTISSET("codemove") ? GETPOST("codemove", 'alpha') : dol_print_date(dol_now(), '%Y%m%d%H%M%S')); + $labelmovement = GETPOST("label") ? GETPOST('label') : $langs->trans("StockTransfer").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); -// Button to record mass movement -$codemove = (GETPOSTISSET("codemove") ? GETPOST("codemove", 'alpha') : dol_print_date(dol_now(), '%Y%m%d%H%M%S')); -$labelmovement = GETPOST("label") ? GETPOST('label') : $langs->trans("StockTransfer").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); + print '
    '; + print ''.$langs->trans("InventoryCode").': '; + print '   '; + print ''; + print $langs->trans("MovementLabel").': '; + print '
    '; + print '
    '; -print '
    '; -print ''.$langs->trans("InventoryCode").': '; -print '   '; -print ''; -print $langs->trans("MovementLabel").': '; -print '
    '; -print '
    '; + print '
    '; -print '
    '; + print '
    '; + print '
    '; -print '
    '; -print '
    '; + print '
    '; +} -print ''; if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?urlfile='.urlencode(GETPOST('urlfile')).'&step=3'.$param, $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); } + // End of page llxFooter(); $db->close(); From 3face8b1c4ede4d6d23e3d110ac3a24a9669ecd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 15:15:07 +0200 Subject: [PATCH 155/233] Debug feature to import stock movements from a file. --- htdocs/langs/en_US/stocks.lang | 2 +- htdocs/product/stock/massstockmove.php | 39 +++++++++++++------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 449c1598ec8..5cbf28d2f82 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -248,7 +248,7 @@ DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproduc ImportFromCSV=Import CSV list of movement ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... OrSelectAStockMovementFileToImport=Or select a stock movement file to import -InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields):
    Source_Warehouse_id* | Target_Warehouse_id* | Product_id* | Quantity* | Lot/serial number
    CSV character separator must be %s +InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields):
    Source_Warehouse_id* | Target_Warehouse_id* | Product_id* | Quantity* | Lot/serial number
    CSV character separator must be "%s" LabelOfInventoryMovemement=Inventory %s ReOpen=Reopen ConfirmFinish=Confirm closing diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index bf1291ac428..928418f4139 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -324,39 +324,39 @@ if ($action == 'importCSV' && !empty($user->rights->stock->mouvement->creer)) { $data[] = $importcsv->import_read_record(); if (count($data[$i]) == 1) { // Only 1 empty line - unset($data); + unset($data[$i]); $i++; continue; } //var_dump($data); - $id_sw = $data[$i][0]['val']; - $id_tw = $data[$i][1]['val']; - $id_product = $data[$i][2]['val']; - $qty = $data[$i][3]['val']; - $batch = $data[$i][4]['val']; + $tmp_id_sw = $data[$i][0]['val']; + $tmp_id_tw = $data[$i][1]['val']; + $tmp_id_product = $data[$i][2]['val']; + $tmp_qty = $data[$i][3]['val']; + $tmp_batch = $data[$i][4]['val']; // TODO If product is a ref (not numeric or starts with "ref:..."), retreive the id of product from the ref - if (!($id_product > 0)) { + if (!($tmp_id_product > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); } // TODO If warehouse is a ref (not numeric or starts with "ref:..."), retreive the id of product from the ref - if (!($id_sw > 0)) { + if (!($tmp_id_sw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); } // TODO If warehouse is a ref (not numeric or starts with "ref:..."), retreive the id of product from the ref - if (!($id_tw > 0)) { + if (!($tmp_id_tw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); } - if ($id_sw > 0 && $id_tw == $id_sw) { + if ($tmp_id_sw > 0 && $tmp_id_tw == $tmp_id_sw) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors'); } - if (!$qty) { + if (!$tmp_qty) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); } @@ -364,9 +364,9 @@ if ($action == 'importCSV' && !empty($user->rights->stock->mouvement->creer)) { // Check a batch number is provided if product need it if (!$error) { $producttmp = new Product($db); - $producttmp->fetch($id_product); + $producttmp->fetch($tmp_id_product); if ($producttmp->hasbatch()) { - if (empty($batch)) { + if (empty($tmp_batch)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $producttmp->ref), null, 'errors'); @@ -384,12 +384,12 @@ if ($action == 'importCSV' && !empty($user->rights->stock->mouvement->creer)) { } else { $id = 1; } - $id_product = $data[$key][0]['val']; - $id_sw = $data[$key][1]['val']; - $id_tw = $data[$key][2]['val']; - $qty = $data[$key][3]['val']; - $batch = $data[$key][4]['val']; - $listofdata[$key] = array('id'=>$key, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); + $tmp_id_sw = $data[$key][0]['val']; + $tmp_id_tw = $data[$key][1]['val']; + $tmp_id_product = $data[$key][2]['val']; + $tmp_qty = $data[$key][3]['val']; + $tmp_batch = $data[$key][4]['val']; + $listofdata[$key] = array('id'=>$key, 'id_sw'=>$tmp_id_sw, 'id_tw'=>$tmp_id_tw, 'id_product'=>$tmp_id_product, 'qty'=>$tmp_qty, 'batch'=>$tmp_batch); } } } @@ -455,6 +455,7 @@ print ''; print ''; print ''; print ''; +$importcsv = new ImportCsv($db, 'massstocklist'); print $form->textwithpicto($langs->trans('OrSelectAStockMovementFileToImport'), $langs->transnoentitiesnoconv("InfoTemplateImport", $importcsv->separator)); print ''; From 213544e4a7c2269fef5d6e120a235b1d2f632fcc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 15:26:34 +0200 Subject: [PATCH 156/233] Fix text --- htdocs/langs/en_US/stocks.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 5cbf28d2f82..a1b13dca238 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -248,7 +248,7 @@ DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproduc ImportFromCSV=Import CSV list of movement ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... OrSelectAStockMovementFileToImport=Or select a stock movement file to import -InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields):
    Source_Warehouse_id* | Target_Warehouse_id* | Product_id* | Quantity* | Lot/serial number
    CSV character separator must be "%s" +InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields):
    Source Warehouse* | Target Warehouse* | Product* | Quantity* | Lot/serial number
    CSV character separator must be "%s" LabelOfInventoryMovemement=Inventory %s ReOpen=Reopen ConfirmFinish=Confirm closing From 05d9140f8fdb3b7c83f6f0a1c5af09e98ad476be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 15:28:12 +0200 Subject: [PATCH 157/233] Look and feel --- htdocs/langs/en_US/stocks.lang | 2 +- htdocs/product/stock/massstockmove.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index a1b13dca238..24dc4cef0c6 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -247,7 +247,7 @@ UpdateByScaningLot=Update by scan (lot|serial barcode) DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. ImportFromCSV=Import CSV list of movement ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... -OrSelectAStockMovementFileToImport=Or select a stock movement file to import +SelectAStockMovementFileToImport=select a stock movement file to import InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields):
    Source Warehouse* | Target Warehouse* | Product* | Quantity* | Lot/serial number
    CSV character separator must be "%s" LabelOfInventoryMovemement=Inventory %s ReOpen=Reopen diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 928418f4139..0627a6a1cf7 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -455,8 +455,9 @@ print ''; print ''; print ''; print ''; +print $langs->trans("or").' '; $importcsv = new ImportCsv($db, 'massstocklist'); -print $form->textwithpicto($langs->trans('OrSelectAStockMovementFileToImport'), $langs->transnoentitiesnoconv("InfoTemplateImport", $importcsv->separator)); +print $form->textwithpicto($langs->trans('SelectAStockMovementFileToImport'), $langs->transnoentitiesnoconv("InfoTemplateImport", $importcsv->separator)); print ''; print '     '; From 653ed82bb2fbd3c45a2b59d8092abd5281ffa820 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 16:23:43 +0200 Subject: [PATCH 158/233] Fix empty page --- htdocs/cron/info.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/cron/info.php b/htdocs/cron/info.php index 3f0e46e0104..6adc9da030e 100644 --- a/htdocs/cron/info.php +++ b/htdocs/cron/info.php @@ -36,15 +36,17 @@ if (!$user->rights->cron->read) { $id = GETPOST('id', 'int'); -$mesg = ''; +$object = new Cronjob($db); + /* * View -*/ + */ + +$form = new Form($db); // $form is required as global value into dol_banner_tab llxHeader('', $langs->trans("CronInfo")); -$object = new Cronjob($db); $object->fetch($id); $object->info($id); From d5cc0062504a6ecca9bd296973fe80928abf3a4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 16:45:53 +0200 Subject: [PATCH 159/233] Look and feel v14 --- htdocs/compta/sociales/list.php | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 0ef916c3ef7..8a43924f41a 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -354,7 +354,7 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { // Filter: Ref if (!empty($arrayfields['cs.rowid']['checked'])) { - print '
    '; + print ''; print ''; print ''; - $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone', 1); + print ''; + $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth150', 1); print ''; + print ''; print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', '0', 0, '', 0, '', '', 0, 0, true); } // Filter: Type if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) { - print ''; - $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 16); + print ''; + $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 0, 1, 'maxwidth150'); print ''; - $form->select_comptes($search_account, 'search_account', 0, '', 1); + print ''; + $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth150'); print ''; + print ''; print ''; print ''.$obj->type_label.''.dol_escape_htmltag($obj->type_label).''; if ($obj->periode) { - print 'jdate($obj->periode)).'">'; + print ''; print dol_print_date($db->jdate($obj->periode), 'day'); print ''; } @@ -627,7 +627,7 @@ while ($i < min($num, $limit)) { // Amount if (!empty($arrayfields['cs.amount']['checked'])) { - print ''.price($obj->amount).''.price($obj->amount).''.dol_trunc($obj->label, 42).''.dol_escape_htmltag($obj->label).'
    '.$langs->trans('PaymentMode').''; + print '
    '.$langs->trans('DefaultPaymentMode').''; $form->select_types_paiements(GETPOST('mode_reglement_id', 'int'), 'mode_reglement_id'); print '
    '.$langs->trans('BankAccount').''; + print '
    '.$langs->trans('DefaultBankAccount').''; print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes(GETPOST('fk_account', 'int'), 'fk_account', 0, '', 2, '', 0, '', 1); print '
    '; print ''; if ($action != 'editmode') { print ''; @@ -575,7 +575,7 @@ if ($id > 0) { if (!empty($conf->banque->enabled)) { print ''; if ($user->rights->societe->creer || $user->rights->facture->creer) { print ''; } else { print ''; @@ -626,8 +626,8 @@ if ($socid > 0) { print ''; if ($user->rights->societe->creer || $user->rights->facture->creer) { print ''; } else { print ''; From 5fd86128919f53d1bd12216c8745709f8b3aa5bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 11:01:07 +0200 Subject: [PATCH 177/233] FIX #yogosha5758 --- htdocs/product/agenda.php | 3 ++- htdocs/product/ajax/products.php | 8 +++++++- htdocs/product/document.php | 3 ++- htdocs/product/fournisseurs.php | 3 ++- htdocs/product/index.php | 16 ++++++++-------- htdocs/product/note.php | 3 ++- htdocs/product/popuprop.php | 4 ++-- htdocs/product/price.php | 3 ++- htdocs/product/reassort.php | 11 ++++------- htdocs/product/reassortlot.php | 12 +++++------- htdocs/societe/card.php | 13 +++++++------ 11 files changed, 43 insertions(+), 36 deletions(-) diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index bf25675865f..a03bdb22477 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -52,7 +52,6 @@ $ref = GETPOST('ref', 'alpha'); if ($user->socid) { $id = $user->socid; } -$result = restrictedArea($user, 'produit|service', $id, 'product&product'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -74,6 +73,8 @@ if (!$sortorder) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendathirdparty')); +$result = restrictedArea($user, 'produit|service', $id, 'product&product'); + /* * Actions diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index b09c29f75da..c620320fafe 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -62,6 +62,9 @@ $alsoproductwithnosupplierprice = GETPOST('alsoproductwithnosupplierprice', 'int $warehouseStatus = GETPOST('warehousestatus', 'alpha'); $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); +// Security check +$result = restrictedArea($user, 'produit|service', 0, 'product&product'); + /* * View @@ -216,10 +219,13 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { return; } + // Filter on product to search can be: + // Into an array with key $htmlname123 (we take first one found) + // Into a var with name $htmlname can be 'prodid', 'productid', ... $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); sort($match); - $idprod = (!empty($match[0]) ? $match[0] : ''); + $idprod = (empty($match[0]) ? '' : $match[0]); // Take first param in GET with key answer if (GETPOST($htmlname, 'alpha') == '' && (!$idprod || !GETPOST($idprod, 'alpha'))) { print json_encode(array()); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index c218d753d88..55cf32b7b56 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -52,7 +52,6 @@ $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productdocuments')); @@ -98,6 +97,8 @@ $modulepart = 'produit'; $permissiontoadd = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + /* * Actions diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 6e3b487a429..0d5ea9647f5 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -73,7 +73,6 @@ $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if (empty($user->rights->fournisseur->lire)) { accessforbidden(); @@ -114,6 +113,8 @@ if (!$sortorder) { $sortorder = "ASC"; } +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + /* * Actions diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 9cdbe85cf4b..7d5f59c1ed9 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -41,6 +41,14 @@ if ($type == '' && !$user->rights->service->lire) { $type = '0'; // Force global page on product page only } +// Load translation files required by the page +$langs->loadLangs(array('products', 'stocks')); + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks +$hookmanager->initHooks(array('productindex')); + +$product_static = new Product($db); + // Security check if ($type == '0') { $result = restrictedArea($user, 'produit'); @@ -50,14 +58,6 @@ if ($type == '0') { $result = restrictedArea($user, 'produit|service|expedition'); } -// Load translation files required by the page -$langs->loadLangs(array('products', 'stocks')); - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks -$hookmanager->initHooks(array('productindex')); - -$product_static = new Product($db); - /* * View diff --git a/htdocs/product/note.php b/htdocs/product/note.php index 348d5956588..add915181a2 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -43,7 +43,6 @@ $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); $object = new Product($db); if ($id > 0 || !empty($ref)) { @@ -52,6 +51,8 @@ if ($id > 0 || !empty($ref)) { $permissionnote = $user->rights->produit->creer; // Used by the include of actions_setnotes.inc.php +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + /* * Actions diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 2b84f11ac66..f23b6eae92d 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -42,7 +42,6 @@ $mode = GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : ''; if (!empty($user->socid)) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -61,9 +60,10 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - $staticproduct = new Product($db); +$result = restrictedArea($user, 'produit|service', 0, 'product&product'); + /* * View diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 6647201b719..a08eaa8558b 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -68,7 +68,6 @@ $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if ($id > 0 || !empty($ref)) { $object = new Product($db); @@ -83,6 +82,8 @@ if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productpricecard', 'globalcard')); +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + /* * Actions diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 5e0720e106c..342acb49b6e 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -35,13 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'produit|service'); - - $action = GETPOST('action', 'aZ09'); $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); @@ -99,6 +92,10 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productreassortlist')); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'produit|service', 0, 'product&product'); /* diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index a443fe10f62..38b16cea44a 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -37,13 +37,6 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'productbatch')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'produit|service'); - - $action = GETPOST('action', 'aZ09'); $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); @@ -89,6 +82,11 @@ if (!empty($canvas)) { $objcanvas->getCanvas('product', 'list', $canvas); } +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'produit|service', 0, 'product&product'); /* diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 2a5f2b84a53..68efa8e694c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -117,6 +117,13 @@ if (!empty($canvas)) { $objcanvas->getCanvas('thirdparty', 'card', $canvas); } +$permissiontoread = $user->rights->societe->lire; +$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0); +$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1]; + // Security check $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); @@ -130,12 +137,6 @@ if ($object->id > 0) { } */ -$permissiontoread = $user->rights->societe->lire; -$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0); -$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php -$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1]; /* From ef8c6ec1171b953580c005660b995cbdefddfbbb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 11:18:35 +0200 Subject: [PATCH 178/233] FIX #yogosha5775 --- htdocs/product/ajax/products.php | 12 +++++++----- htdocs/societe/ajax/company.php | 25 ++++++++++++++++++++----- htdocs/societe/document.php | 14 +++++++------- htdocs/societe/note.php | 12 +++++++----- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index c620320fafe..901e2b387e3 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -63,7 +63,7 @@ $warehouseStatus = GETPOST('warehousestatus', 'alpha'); $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); // Security check -$result = restrictedArea($user, 'produit|service', 0, 'product&product'); +restrictedArea($user, 'produit|service', 0, 'product&product'); /* @@ -219,13 +219,13 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { return; } - // Filter on product to search can be: - // Into an array with key $htmlname123 (we take first one found) + // Filter on the product to search can be: + // Into an array with key $htmlname123 (we take first one found). Which page use this ? // Into a var with name $htmlname can be 'prodid', 'productid', ... $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); sort($match); - $idprod = (empty($match[0]) ? '' : $match[0]); // Take first param in GET with key answer + $idprod = (empty($match[0]) ? '' : $match[0]); // Take first key found into GET array with matching $htmlname123 if (GETPOST($htmlname, 'alpha') == '' && (!$idprod || !GETPOST($idprod, 'alpha'))) { print json_encode(array()); @@ -235,7 +235,9 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { // When used from jQuery, the search term is added as GET param "term". $searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : '')); - $form = new Form($db); + if (!is_object($form)) { + $form = new Form($db); + } if (empty($mode) || $mode == 1) { // mode=1: customer $arrayresult = $form->select_produits_list("", $htmlname, $type, 0, $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus); diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 86e6f68c16c..fc10bb3c688 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -51,6 +51,19 @@ $id = GETPOST('id', 'int'); $excludeids = GETPOST('excludeids', 'intcomma'); $showtype = GETPOST('showtype', 'int'); +$object = new Societe($db); +if ($id > 0) { + $object->fetch($id); +} + +// Security check +if ($user->socid > 0) { + unset($action); + $socid = $user->socid; + $object->id = $socid; +} +restrictedArea($user, 'societe', $object->id, '&societe'); + /* * View @@ -64,9 +77,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { $outjson = array(); - $object = new Societe($db); - $ret = $object->fetch($id); - if ($ret > 0) { + if ($object->id > 0) { $outref = $object->ref; $outname = $object->name; $outdesc = ''; @@ -87,12 +98,16 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { return; } + // Filter on the company to search can be: + // Into an array with key $htmlname123 (we take first one found). Which page use this ? + // Into a var with name $htmlname can be 'prodid', 'productid', ... $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); sort($match); - $id = (!empty($match[0]) ? $match[0] : ''); + + $id = (!empty($match[0]) ? $match[0] : ''); // Take first key found into GET array with matching $htmlname123 // When used from jQuery, the search term is added as GET param "term". - $searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : '')); + $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : '')); if (!$searchkey) { return; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 600cb03af1a..746d1c403c7 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -39,13 +39,6 @@ $confirm = GETPOST('confirm'); $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); -// Security check -if ($user->socid > 0) { - unset($action); - $socid = $user->socid; -} -$result = restrictedArea($user, 'societe', $id, '&societe'); - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -84,6 +77,13 @@ if ($id > 0 || !empty($ref)) { $hookmanager->initHooks(array('thirdpartydocument', 'globalcard')); +// Security check +if ($user->socid > 0) { + unset($action); + $socid = $user->socid; +} +$result = restrictedArea($user, 'societe', $object->id, '&societe'); + /* * Actions diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 22f235df7de..2ebe97848f2 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -33,12 +33,7 @@ $action = GETPOST('action', 'aZ09'); $langs->load("companies"); -// Security check $id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); -if ($user->socid) { - $id = $user->socid; -} -$result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); if ($id > 0) { @@ -50,6 +45,13 @@ $permissionnote = $user->rights->societe->creer; // Used by the include of actio // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartynote', 'globalcard')); +// Security check +if ($user->socid > 0) { + unset($action); + $socid = $user->socid; +} +$result = restrictedArea($user, 'societe', $object->id, '&societe'); + /* * Actions From 8e14b4d434a9d4eba60c9141b14d25f247f08eab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 11:27:39 +0200 Subject: [PATCH 179/233] FIX #yogosha5775 --- htdocs/core/class/html.formcompany.class.php | 2 +- htdocs/core/lib/ajax.lib.php | 2 +- htdocs/societe/{ => ajax}/ajaxcompanies.php | 23 +++++- htdocs/societe/ajax/company.php | 1 + htdocs/societe/ajaxcountries.php | 84 -------------------- 5 files changed, 22 insertions(+), 90 deletions(-) rename htdocs/societe/{ => ajax}/ajaxcompanies.php (88%) delete mode 100644 htdocs/societe/ajaxcountries.php diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 7b82e5be253..6677f7f8dce 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -696,7 +696,7 @@ class FormCompany extends Form print "\n".''."\n"; print ''; - print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); + print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT.'/societe/ajax/ajaxcompanies.php', '', $minLength, 0); return $socid; } else { // Search to list thirdparties diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 658d7816001..4108724236d 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -25,7 +25,7 @@ /** - * Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: /societe/ajaxcompanies.php). + * Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: /societe/ajax/ajaxcompanies.php). * The HTML field must be an input text with id=search_$htmlname. * This use the jQuery "autocomplete" function. If we want to use the select2, we must also convert the input into select on funcntions that call this method. * diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajax/ajaxcompanies.php similarity index 88% rename from htdocs/societe/ajaxcompanies.php rename to htdocs/societe/ajax/ajaxcompanies.php index cc327b155fa..9295c363206 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajax/ajaxcompanies.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/societe/ajaxcompanies.php + * \file htdocs/societe/ajax/ajaxcompanies.php * \brief File to return Ajax response on third parties request */ @@ -42,7 +42,22 @@ if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); } -require '../main.inc.php'; +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + +$id = GETPOST('socid', 'int') || GETPOST('id_fourn', 'int'); + +$object = new Societe($db); +if ($id > 0) { + $object->fetch($id); +} + +// Security check +if ($user->socid > 0) { + $socid = $user->socid; + $object->id = $socid; +} +restrictedArea($user, 'societe', $object->id, '&societe'); /* @@ -59,8 +74,8 @@ top_httphead(); //print ''."\n"; -// Generation liste des societes -if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { +// Generate list of companies +if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn', 'int')) { $return_arr = array(); // Define filter on text typed diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index fc10bb3c688..76151bccb97 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -42,6 +42,7 @@ if (!defined('NOCSRFCHECK')) { } require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $htmlname = GETPOST('htmlname', 'alpha'); $filter = GETPOST('filter', 'alpha'); diff --git a/htdocs/societe/ajaxcountries.php b/htdocs/societe/ajaxcountries.php deleted file mode 100644 index aa6cbf70de8..00000000000 --- a/htdocs/societe/ajaxcountries.php +++ /dev/null @@ -1,84 +0,0 @@ - - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/societe/ajaxcountries.php - * \brief File to return Ajax response on country request - */ - -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', 1); // Disables token renewal -} -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} -if (!defined('NOREQUIREHTML')) { - define('NOREQUIREHTML', '1'); -} -if (!defined('NOREQUIREAJAX')) { - define('NOREQUIREAJAX', '1'); -} -if (!defined('NOREQUIRESOC')) { - define('NOREQUIRESOC', '1'); -} -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} - -require '../main.inc.php'; - -$country = GETPOST('country', 'alpha'); - - -/* - * View - */ - -// Ajout directives pour resoudre bug IE -//header('Cache-Control: Public, must-revalidate'); -//header('Pragma: public'); - -//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. -top_httphead(); - -print ''."\n"; - -// Generate list of countries -if (!empty($country)) { - global $langs; - $langs->load("dict"); - - $sql = "SELECT rowid, code, label, active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_country"; - $sql .= " WHERE active = 1 AND label LIKE '%".$db->escape(utf8_decode($country))."%'"; - $sql .= " ORDER BY label ASC"; - - $resql = $db->query($sql); - if ($resql) { - print '
      '; - while ($country = $db->fetch_object($resql)) { - print '
    • '; - // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut - print ($country->code && $langs->trans("Country".$country->code) != "Country".$country->code ? $langs->trans("Country".$country->code) : ($country->label != '-' ? $country->label : ' ')); - print ''; - print '
    • '; - } - print '
    '; - } -} From 3d1c47db35f6b1fd953c19461a2658a5bec29559 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 11:28:35 +0200 Subject: [PATCH 180/233] Fix bad table name for migration --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 4a1cf73eea9..af32340170e 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -350,7 +350,7 @@ create table llx_eventorganization_conferenceorboothattendee_extrafields ALTER TABLE llx_eventorganization_conferenceorboothattendee_extrafields ADD INDEX idx_conferenceorboothattendee_fk_object(fk_object); ALTER TABLE llx_c_ticket_category ADD COLUMN public integer DEFAULT 0; -ALTER TABLE llc_c_ticket_category MODIFY COLUMN pos integer DEFAULT 0 NOT NULL; +ALTER TABLE llx_c_ticket_category MODIFY COLUMN pos integer DEFAULT 0 NOT NULL; ALTER TABLE llx_propal ADD COLUMN date_signature datetime AFTER date_valid; From 354adbde54092b9fb12039eae46b0ba9ceda867a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 12:27:02 +0200 Subject: [PATCH 181/233] Look and feel v14 --- htdocs/comm/propal/card.php | 2 +- htdocs/core/class/html.form.class.php | 16 +++++---- htdocs/core/lib/functions.lib.php | 49 ++++++--------------------- 3 files changed, 21 insertions(+), 46 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4c4881472c8..61bacfb3e66 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1588,7 +1588,7 @@ if ($action == 'create') { // Contacts (ask contact only if thirdparty already defined). print "
    '; // Third party discounts info line diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 60234fa0d70..96a67f4051e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8280,9 +8280,10 @@ class Form } } else { $nophoto = '/public/theme/common/nophoto.png'; - if (in_array($modulepart, array('userphoto', 'contact', 'memberphoto'))) { // For module that are "physical" users - if ($modulepart == 'memberphoto' && strpos($object->morphy, 'mor') !== false) { - $nophoto = '/public/theme/common/company.png'; + $defaultimg = 'identicon'; // For gravatar + if (in_array($modulepart, array('societe', 'userphoto', 'contact', 'memberphoto'))) { // For modules that need a special image when photo not found + if ($modulepart == 'societe' || ($modulepart == 'memberphoto' && strpos($object->morphy, 'mor')) !== false) { + $nophoto = 'company'; } else { $nophoto = '/public/theme/common/user_anonymous.png'; if ($object->gender == 'man') { @@ -8296,13 +8297,14 @@ class Form if (!empty($conf->gravatar->enabled) && $email && empty($noexternsourceoverwrite)) { // see https://gravatar.com/site/implement/images/php/ - global $dolibarr_main_url_root; $ret .= ''; - //$defaultimg=urlencode(dol_buildpath($nophoto,3)); - $defaultimg = 'mm'; $ret .= 'Gravatar avatar'; // gravatar need md5 hash } else { - $ret .= 'No photo'; + if ($nophoto == 'company') { + $ret .= '
    '.img_picto('', 'company').'
    '; + } else { + $ret .= 'No photo'; + } } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5cece48ce5d..d22aa0d40e2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1751,53 +1751,26 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } $modulepart = 'unknown'; - if ($object->element == 'societe') { - $modulepart = 'societe'; - } - if ($object->element == 'contact') { - $modulepart = 'contact'; - } - if ($object->element == 'member') { + if ($object->element == 'societe' || $object->element == 'contact' || $object->element == 'product' || $object->element == 'ticket') { + $modulepart = $object->element; + } elseif ($object->element == 'member') { $modulepart = 'memberphoto'; - } - if ($object->element == 'user') { + } elseif ($object->element == 'user') { $modulepart = 'userphoto'; } - if ($object->element == 'product') { - $modulepart = 'product'; - } - if ($object->element == 'ticket') { - $modulepart = 'ticket'; - } if (class_exists("Imagick")) { - if ($object->element == 'propal') { - $modulepart = 'propal'; - } - if ($object->element == 'commande') { - $modulepart = 'commande'; - } - if ($object->element == 'facture') { - $modulepart = 'facture'; - } - if ($object->element == 'fichinter') { + if ($object->element == 'expensereport' || $object->element == 'propal' || $object->element == 'commande' || $object->element == 'facture' || $object->element == 'supplier_proposal') { + $modulepart = $object->element; + } elseif ($object->element == 'fichinter') { $modulepart = 'ficheinter'; - } - if ($object->element == 'contrat') { + } elseif ($object->element == 'contrat') { $modulepart = 'contract'; - } - if ($object->element == 'supplier_proposal') { - $modulepart = 'supplier_proposal'; - } - if ($object->element == 'order_supplier') { + } elseif ($object->element == 'order_supplier') { $modulepart = 'supplier_order'; - } - if ($object->element == 'invoice_supplier') { + } elseif ($object->element == 'invoice_supplier') { $modulepart = 'supplier_invoice'; } - if ($object->element == 'expensereport') { - $modulepart = 'expensereport'; - } } if ($object->element == 'product') { @@ -1903,7 +1876,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $phototoshow .= ''; } } - } elseif (!$phototoshow) { // example if modulepart = 'photo' + } elseif (!$phototoshow) { // example if modulepart = 'societe' or 'photo' $phototoshow .= $form->showphoto($modulepart, $object, 0, 0, 0, 'photoref', 'small', 1, 0, $maxvisiblephotos); } From 94d1487fde289e17b3e39393d3e916d528b77e05 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 12:29:56 +0200 Subject: [PATCH 182/233] Fix method name --- test/phpunit/SocieteTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index aa57d987238..177458fb621 100755 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -339,7 +339,7 @@ class SocieteTest extends PHPUnit\Framework\TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - $result=$localobject->set_price_level(1, $user); + $result=$localobject->setPriceLevel(1, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); From 166ed32c321265c3e173d72f282d7efdd0b97044 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Thu, 1 Apr 2021 12:52:06 +0200 Subject: [PATCH 183/233] Update llx_20_c_departements.sql Algeria Brazil --- .../mysql/data/llx_20_c_departements.sql | 173 +++++++++--------- 1 file changed, 87 insertions(+), 86 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 2ac7a30a99b..1b5da7602e2 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -41,7 +41,8 @@ -- Australia -- Austria -- Barbados --- Belgium +-- Belgium +-- Brazil -- Canada -- France -- Germany @@ -52,64 +53,64 @@ insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc -- Algeria Provinces (id country=13) -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL01', '', 0, '', 'Wilaya d''Adrar', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL02', '', 0, '', 'Wilaya de Chlef', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL03', '', 0, '', 'Wilaya de Laghouat', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL04', '', 0, '', 'Wilaya d''Oum El Bouaghi', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL05', '', 0, '', 'Wilaya de Batna', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL06', '', 0, '', 'Wilaya de Béjaïa', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL07', '', 0, '', 'Wilaya de Biskra', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL08', '', 0, '', 'Wilaya de Béchar', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL09', '', 0, '', 'Wilaya de Blida', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL10', '', 0, '', 'Wilaya de Bouira', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL11', '', 0, '', 'Wilaya de Tamanrasset', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL12', '', 0, '', 'Wilaya de Tébessa', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL13', '', 0, '', 'Wilaya de Tlemcen', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL14', '', 0, '', 'Wilaya de Tiaret', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL15', '', 0, '', 'Wilaya de Tizi Ouzou', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL16', '', 0, '', 'Wilaya d''Alger', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL17', '', 0, '', 'Wilaya de Djelfa', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL18', '', 0, '', 'Wilaya de Jijel', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL19', '', 0, '', 'Wilaya de Sétif ', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL20', '', 0, '', 'Wilaya de Saïda', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL21', '', 0, '', 'Wilaya de Skikda', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL22', '', 0, '', 'Wilaya de Sidi Bel Abbès', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL23', '', 0, '', 'Wilaya d''Annaba', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL24', '', 0, '', 'Wilaya de Guelma', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL25', '', 0, '', 'Wilaya de Constantine', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL26', '', 0, '', 'Wilaya de Médéa', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL27', '', 0, '', 'Wilaya de Mostaganem', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL28', '', 0, '', 'Wilaya de M''Sila', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL29', '', 0, '', 'Wilaya de Mascara', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL30', '', 0, '', 'Wilaya d''Ouargla', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL31', '', 0, '', 'Wilaya d''Oran', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL32', '', 0, '', 'Wilaya d''El Bayadh', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL33', '', 0, '', 'Wilaya d''Illizi', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL34', '', 0, '', 'Wilaya de Bordj Bou Arreridj', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL35', '', 0, '', 'Wilaya de Boumerdès', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL36', '', 0, '', 'Wilaya d''El Tarf', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL37', '', 0, '', 'Wilaya de Tindouf', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL38', '', 0, '', 'Wilaya de Tissemsilt', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL39', '', 0, '', 'Wilaya d''El Oued', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL40', '', 0, '', 'Wilaya de Khenchela', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL41', '', 0, '', 'Wilaya de Souk Ahras', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL42', '', 0, '', 'Wilaya de Tipaza', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL43', '', 0, '', 'Wilaya de Mila', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL44', '', 0, '', 'Wilaya d''Aïn Defla', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL45', '', 0, '', 'Wilaya de Naâma', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL46', '', 0, '', 'Wilaya d''Aïn Témouchent', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL47', '', 0, '', 'Wilaya de Ghardaia', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL48', '', 0, '', 'Wilaya de Relizane', 1); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL01', '', 0, '', 'Wilaya d''Adrar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL02', '', 0, '', 'Wilaya de Chlef'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL03', '', 0, '', 'Wilaya de Laghouat'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL04', '', 0, '', 'Wilaya d''Oum El Bouaghi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL05', '', 0, '', 'Wilaya de Batna'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL06', '', 0, '', 'Wilaya de Béjaïa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL07', '', 0, '', 'Wilaya de Biskra'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL08', '', 0, '', 'Wilaya de Béchar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL09', '', 0, '', 'Wilaya de Blida'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL10', '', 0, '', 'Wilaya de Bouira'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL11', '', 0, '', 'Wilaya de Tamanrasset'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL12', '', 0, '', 'Wilaya de Tébessa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL13', '', 0, '', 'Wilaya de Tlemcen'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL14', '', 0, '', 'Wilaya de Tiaret'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL15', '', 0, '', 'Wilaya de Tizi Ouzou'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL16', '', 0, '', 'Wilaya d''Alger'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL17', '', 0, '', 'Wilaya de Djelfa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL18', '', 0, '', 'Wilaya de Jijel'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL19', '', 0, '', 'Wilaya de Sétif'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL20', '', 0, '', 'Wilaya de Saïda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL21', '', 0, '', 'Wilaya de Skikda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL22', '', 0, '', 'Wilaya de Sidi Bel Abbès'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL23', '', 0, '', 'Wilaya d''Annaba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL24', '', 0, '', 'Wilaya de Guelma'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL25', '', 0, '', 'Wilaya de Constantine'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL26', '', 0, '', 'Wilaya de Médéa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL27', '', 0, '', 'Wilaya de Mostaganem'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL28', '', 0, '', 'Wilaya de M''Sila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL29', '', 0, '', 'Wilaya de Mascara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL30', '', 0, '', 'Wilaya d''Ouargla'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL31', '', 0, '', 'Wilaya d''Oran'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL32', '', 0, '', 'Wilaya d''El Bayadh'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL33', '', 0, '', 'Wilaya d''Illizi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL34', '', 0, '', 'Wilaya de Bordj Bou Arreridj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL35', '', 0, '', 'Wilaya de Boumerdès'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL36', '', 0, '', 'Wilaya d''El Tarf'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL37', '', 0, '', 'Wilaya de Tindouf'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL38', '', 0, '', 'Wilaya de Tissemsilt'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL39', '', 0, '', 'Wilaya d''El Oued'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL40', '', 0, '', 'Wilaya de Khenchela'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL41', '', 0, '', 'Wilaya de Souk Ahras'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL42', '', 0, '', 'Wilaya de Tipaza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL43', '', 0, '', 'Wilaya de Mila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL44', '', 0, '', 'Wilaya d''Aïn Defla'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL45', '', 0, '', 'Wilaya de Naâma'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL46', '', 0, '', 'Wilaya d''Aïn Témouchent'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL47', '', 0, '', 'Wilaya de Ghardaia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL48', '', 0, '', 'Wilaya de Relizane'); -- Andorra Parròquies (id country=34) -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-002', 'AD100', NULL, NULL, 'Canillo'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-003', 'AD200', NULL, NULL, 'Encamp'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-004', 'AD400', NULL, NULL, 'La Massana'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-005', 'AD300', NULL, NULL, 'Ordino'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-006', 'AD600', NULL, NULL, 'Sant Julià de Lòria'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-007', 'AD500', NULL, NULL, 'Andorra la Vella'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-008', 'AD700', NULL, NULL, 'Escaldes-Engordany'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-002', 'AD100', NULL, NULL, 'Canillo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-003', 'AD200', NULL, NULL, 'Encamp'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-004', 'AD400', NULL, NULL, 'La Massana'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-005', 'AD300', NULL, NULL, 'Ordino'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-006', 'AD600', NULL, NULL, 'Sant Julià de Lòria'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-007', 'AD500', NULL, NULL, 'Andorra la Vella'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-008', 'AD700', NULL, NULL, 'Escaldes-Engordany'); -- Argentina Provinces / provincias (id country=23) @@ -192,6 +193,36 @@ insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201,'11','',2,'NAMUR','Namur'); +-- Brazil Provinces (id country=56) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'AC', 'ACRE', 0, 'AC', 'Acre'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'AL', 'ALAGOAS', 0, 'AL', 'Alagoas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'AP', 'AMAPA', 0, 'AP', 'Amapá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'AM', 'AMAZONAS', 0, 'AM', 'Amazonas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'BA', 'BAHIA', 0, 'BA', 'Bahia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'CE', 'CEARA', 0, 'CE', 'Ceará'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'ES', 'ESPIRITO SANTO', 0, 'ES', 'Espirito Santo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'GO', 'GOIAS', 0, 'GO', 'Goiás'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'MA', 'MARANHAO', 0, 'MA', 'Maranhão'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'MT', 'MATO GROSSO', 0, 'MT', 'Mato Grosso'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'MS', 'MATO GROSSO DO SUL', 0, 'MS', 'Mato Grosso do Sul'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'MG', 'MINAS GERAIS', 0, 'MG', 'Minas Gerais'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PA', 'PARA', 0, 'PA', 'Pará'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PB', 'PARAIBA', 0, 'PB', 'Paraiba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PR', 'PARANA', 0, 'PR', 'Paraná'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PE', 'PERNAMBUCO', 0, 'PE', 'Pernambuco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PI', 'PIAUI', 0, 'PI', 'Piauí'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RJ', 'RIO DE JANEIRO', 0, 'RJ', 'Rio de Janeiro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RN', 'RIO GRANDE DO NORTE', 0, 'RN', 'Rio Grande do Norte'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RS', 'RIO GRANDE DO SUL', 0, 'RS', 'Rio Grande do Sul'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RO', 'RONDONIA', 0, 'RO', 'Rondônia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RR', 'RORAIMA', 0, 'RR', 'Roraima'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'SC', 'SANTA CATARINA', 0, 'SC', 'Santa Catarina'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'SE', 'SERGIPE', 0, 'SE', 'Sergipe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'SP', 'SAO PAULO', 0, 'SP', 'Sao Paulo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'TO', 'TOCANTINS', 0, 'TO', 'Tocantins'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'DF', 'DISTRITO FEDERAL', 0, 'DF', 'Distrito Federal'); + + -- Canada Provinces & Territories (id country=14) insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401,'ON','',1,'','Ontario'); insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401,'QC','',1,'','Quebec'); @@ -1024,36 +1055,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CU', 8601, '', 0, '', 'Cuscatlan', 1); --- Provinces Brazil (id country=56) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AC', 5601, 'ACRE', 0, 'AC', 'Acre', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AL', 5601, 'ALAGOAS', 0, 'AL', 'Alagoas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AP', 5601, 'AMAPA', 0, 'AP', 'Amapá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AM', 5601, 'AMAZONAS', 0, 'AM', 'Amazonas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BA', 5601, 'BAHIA', 0, 'BA', 'Bahia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CE', 5601, 'CEARA', 0, 'CE', 'Ceará', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ES', 5601, 'ESPIRITO SANTO', 0, 'ES', 'Espirito Santo', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GO', 5601, 'GOIAS', 0, 'GO', 'Goiás', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MA', 5601, 'MARANHAO', 0, 'MA', 'Maranhão', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MT', 5601, 'MATO GROSSO', 0, 'MT', 'Mato Grosso', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MS', 5601, 'MATO GROSSO DO SUL', 0, 'MS', 'Mato Grosso do Sul', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MG', 5601, 'MINAS GERAIS', 0, 'MG', 'Minas Gerais', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PA', 5601, 'PARA', 0, 'PA', 'Pará', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PB', 5601, 'PARAIBA', 0, 'PB', 'Paraiba', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PR', 5601, 'PARANA', 0, 'PR', 'Paraná', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PE', 5601, 'PERNAMBUCO', 0, 'PE', 'Pernambuco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PI', 5601, 'PIAUI', 0, 'PI', 'Piauí', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RJ', 5601, 'RIO DE JANEIRO', 0, 'RJ', 'Rio de Janeiro', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RN', 5601, 'RIO GRANDE DO NORTE', 0, 'RN', 'Rio Grande do Norte', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RS', 5601, 'RIO GRANDE DO SUL', 0, 'RS', 'Rio Grande do Sul', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RO', 5601, 'RONDONIA', 0, 'RO', 'Rondônia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RR', 5601, 'RORAIMA', 0, 'RR', 'Roraima', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SC', 5601, 'SANTA CATARINA', 0, 'SC', 'Santa Catarina', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SE', 5601, 'SERGIPE', 0, 'SE', 'Sergipe', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SP', 5601, 'SAO PAULO', 0, 'SP', 'Sao Paulo', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TO', 5601, 'TOCANTINS', 0, 'TO', 'Tocantins', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DF', 5601, 'DISTRITO FEDERAL', 0, 'DF', 'Distrito Federal', 1); - - -- Provinces Chile (id country=67) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('151', 6715, '', 0, '151', 'Arica', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('152', 6715, '', 0, '152', 'Parinacota', 1); From 06078f231b0083462153ac530bbea27f0f04c4cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 13:02:44 +0200 Subject: [PATCH 184/233] NEW Can show the project ref or label into PDF documents --- htdocs/admin/pdf.php | 71 ++++++++++++------- .../commande/doc/pdf_einstein.modules.php | 5 +- .../commande/doc/pdf_eratosthene.modules.php | 5 +- .../modules/facture/doc/pdf_crabe.modules.php | 5 +- .../facture/doc/pdf_sponge.modules.php | 5 +- .../modules/propale/doc/pdf_azur.modules.php | 5 +- .../modules/propale/doc/pdf_cyan.modules.php | 5 +- .../doc/pdf_canelle.modules.php | 13 +++- .../supplier_order/doc/pdf_cornas.modules.php | 13 +++- .../doc/pdf_muscadet.modules.php | 11 +++ .../doc/pdf_standard.modules.php | 13 +++- htdocs/langs/en_US/admin.lang | 2 + .../doc/pdf_standard_myobject.modules.php | 3 +- ...tandard_recruitmentjobposition.modules.php | 15 +++- 14 files changed, 129 insertions(+), 42 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index a34a4d602e1..3ca68b8d82d 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -68,6 +68,17 @@ if ($action == 'update') { dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + if (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'no') { + dolibarr_del_const($db, "PDF_SHOW_PROJECT", $conf->entity); + dolibarr_del_const($db, "PDF_SHOW_PROJECT_TITLE", $conf->entity); + } elseif (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'showprojectref') { + dolibarr_set_const($db, "PDF_SHOW_PROJECT", GETPOST("PDF_SHOW_PROJECT_REF_OR_LABEL"), 'chaine', 0, '', $conf->entity); + dolibarr_del_const($db, "PDF_SHOW_PROJECT_TITLE", $conf->entity); + } elseif (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'showprojectlabel') { + dolibarr_del_const($db, "PDF_SHOW_PROJECT", $conf->entity); + dolibarr_set_const($db, "PDF_SHOW_PROJECT_TITLE", GETPOST("PDF_SHOW_PROJECT_REF_OR_LABEL"), 'chaine', 0, '', $conf->entity); + } + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DESC"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), 'chaine', 0, '', $conf->entity); @@ -290,6 +301,38 @@ print ''; +// Show project + +print ''; + +//Invert sender and recipient + +print ''; + +// Place customer adress to the ISO location + +print ''; + +// Use 2 languages into PDF + +print ''; + //Desc print ''; -//Invert sender and recipient +// SHOW_SUBPRODUCT_REF_IN_PDF - Option to show the detail of product ref for kits. -print ''; - -// Place customer adress to the ISO location - -print ''; +// Show more details in footer print ''; -print ''; - -// SHOW_SUBPRODUCT_REF_IN_PDF - Option to show the detail of product ref for kits. -print ''; - print '
    '; - print $langs->trans('PaymentMode'); + print $langs->trans('DefaultPaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
    '; print ''; @@ -731,7 +731,7 @@ if ($id > 0) { * Actions buttons */ if ($action != 'edit') { - print "
    \n"; + print '
    '."\n"; // Reopen if ($object->paye && $user->rights->tax->charges->creer) { diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index d1ec270fd8b..0ecdaee87a5 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -110,13 +110,13 @@ $arrayfields = array( 'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>50), 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->projet->enabled))), 'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>70), - 'cs.fk_mode_reglement' =>array('checked'=>1, 'position'=>80, 'label'=>"DefaultPaymentMode"), + 'cs.fk_mode_reglement' =>array('checked'=>-1, 'position'=>80, 'label'=>"DefaultPaymentMode"), 'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>100), 'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>110), ); if (!empty($conf->banque->enabled)) { - $arrayfields['cs.fk_account'] = array('checked'=>1, 'position'=>90, 'label'=>"DefaultBankAccount"); + $arrayfields['cs.fk_account'] = array('checked'=>-1, 'position'=>90, 'label'=>"DefaultBankAccount"); } $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -419,7 +419,7 @@ if (!empty($arrayfields['cs.fk_account']['checked'])) { // Filter: Amount if (!empty($arrayfields['cs.amount']['checked'])) { - print '
    '; } From 32f9a0477647a96d33a1200a827d830992008091 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 17:37:45 +0200 Subject: [PATCH 162/233] FIX Must use the server TZ for accounting report --- htdocs/compta/stats/byratecountry.php | 12 ++++++++---- htdocs/compta/stats/cabyprodserv.php | 8 +++++--- htdocs/compta/stats/cabyuser.php | 8 +++++--- htdocs/compta/stats/casoc.php | 9 ++++++--- htdocs/compta/stats/index.php | 10 +++++----- htdocs/compta/stats/supplier_turnover.php | 10 +++++----- .../compta/stats/supplier_turnover_by_prodserv.php | 8 +++++--- .../compta/stats/supplier_turnover_by_thirdparty.php | 8 +++++--- 8 files changed, 44 insertions(+), 29 deletions(-) diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index 1644a4ee5e3..9f40eab226a 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -52,8 +52,8 @@ if (empty($year)) { $month_current = dol_print_date(dol_now(), '%m'); $year_start = $year; } -$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzuserrel'); -$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzuserrel'); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzserver'); // We use timezone of server so report is same from everywhere +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzserver'); // We use timezone of server so report is same from everywhere // Quarter if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int"); @@ -179,7 +179,9 @@ if ($modetax == 2) { } $calcmode .= '
    ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period -$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); $prevyear = $year_start; $prevquarter = $q; if ($prevquarter > 1) { @@ -265,7 +267,9 @@ if ($modecompta == "CREANCES-DETTES") { } elseif ($modecompta == "BOOKKEEPING") { } elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } -$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) { $periodlink = ''.img_previous().' '.img_next().''; } else { diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 6ca284a5f2b..16f4a850f83 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -97,8 +97,8 @@ if (empty($year)) { $month_current = dol_print_date(dol_now(), '%m'); $year_start = $year; } -$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzuserrel'); -$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzuserrel'); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzserver'); // We use timezone of server so report is same from everywhere +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzserver'); // We use timezone of server so report is same from everywhere // Quarter if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int"); @@ -254,7 +254,9 @@ if ($modecompta == "CREANCES-DETTES") { } elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } -$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) { $periodlink = ''.img_previous().' '.img_next().''; } else { diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index feae1f83594..0c0621fde76 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -78,8 +78,8 @@ if (empty($year)) { $month_current = dol_print_date(dol_now(), '%m'); $year_start = $year; } -$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzuserrel'); -$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzuserrel'); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzserver'); // We use timezone of server so report is same from everywhere +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzserver'); // We use timezone of server so report is same from everywhere // Quarter if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q") ?GETPOST("q") : 0; @@ -198,7 +198,9 @@ if ($modecompta == "CREANCES-DETTES") { } elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { // TODO } -$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) { $periodlink = ''.img_previous().' '.img_next().''; } else { diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index aedae20b8f0..1be022cca2f 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -98,8 +98,8 @@ if (empty($year)) { $month_current = dol_print_date(dol_now(), '%m'); $year_start = $year; } -$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzuserrel'); -$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzuserrel'); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzserver'); // We use timezone of server so report is same from everywhere +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzserver'); // We use timezone of server so report is same from everywhere // Quarter if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int") ?GETPOST("q", "int") : 0; @@ -142,6 +142,7 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } else { // TODO We define q } +//print dol_print_date($date_start, 'dayhour', 'gmt'); // $date_start and $date_end are defined. We force $year_start and $nbofyear $tmps = dol_getdate($date_start); @@ -224,7 +225,9 @@ if ($modecompta == "CREANCES-DETTES") { } elseif ($modecompta == "BOOKKEEPING") { } elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } -$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) { $periodlink = ''.img_previous().' '.img_next().''; } else { diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 74589d2e391..057ba461559 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -51,8 +51,8 @@ if (empty($year)) { $month_current = dol_print_date(dol_now(), "%m"); $year_start = $year - ($nbofyear - 1); } -$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzuserrel'); -$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear, 'tzuserrel'); +$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzserver'); +$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear, 'tzserver'); // We define date_start and date_end if (empty($date_start) || empty($date_end)) { // We define date_start and date_end @@ -152,7 +152,6 @@ if ($modecompta == "CREANCES-DETTES") { $calcmode .= '
    ('.$langs->trans("SeeReportInBookkeepingMode", '{link1}', '{link2}').')'; $calcmode = str_replace('{link1}', '', $calcmode); $calcmode = str_replace('{link2}', '', $calcmode); - $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); $description = $langs->trans("RulesCADue"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { @@ -167,7 +166,6 @@ if ($modecompta == "CREANCES-DETTES") { $calcmode = $langs->trans("CalcModeEngagement"); //$calcmode.='
    ('.$langs->trans("SeeReportInDueDebtMode",'','').')'; //$calcmode.='
    ('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; - $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); $description = $langs->trans("RulesCAIn"); $description .= $langs->trans("DepositsAreIncluded"); @@ -180,12 +178,14 @@ if ($modecompta == "CREANCES-DETTES") { $calcmode = str_replace('{link1}', '', $calcmode); $calcmode = str_replace('{link2}', '', $calcmode); //$calcmode.='
    ('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); $description = $langs->trans("RulesCATotalSaleJournal"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); $moreparam = array(); if (!empty($modecompta)) { diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php index bf91d8b4d6a..afec3c3d124 100644 --- a/htdocs/compta/stats/supplier_turnover.php +++ b/htdocs/compta/stats/supplier_turnover.php @@ -47,8 +47,8 @@ if (empty($year)) { $month_current = strftime("%m", dol_now()); $year_start = $year - ($nbofyear - 1); } -$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzuserrel'); -$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear, 'tzuserrel'); +$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzserver'); // We use timezone of server so report is same from everywhere +$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear, 'tzserver'); // We use timezone of server so report is same from everywhere // We define date_start and date_end if (empty($date_start) || empty($date_end)) { // We define date_start and date_end @@ -135,7 +135,6 @@ if ($modecompta == "CREANCES-DETTES") { $calcmode .= '
    ('.$langs->trans("SeeReportInBookkeepingMode", '{link1}', '{link2}').')'; $calcmode = str_replace('{link1}', '', $calcmode); $calcmode = str_replace('{link2}', '', $calcmode); - $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); $description = $langs->trans("RulesPurchaseTurnoverDue"); $builddate = dol_now(); @@ -143,7 +142,6 @@ if ($modecompta == "CREANCES-DETTES") { } elseif ($modecompta == "RECETTES-DEPENSES") { $name = $langs->trans("PurchaseTurnoverCollected"); $calcmode = $langs->trans("CalcModeEngagement"); - $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); $description = $langs->trans("RulesPurchaseTurnoverIn"); $builddate = dol_now(); @@ -154,12 +152,14 @@ if ($modecompta == "CREANCES-DETTES") { $calcmode .= '
    ('.$langs->trans("SeeReportInDueDebtMode", '{link1}', '{link2}').')'; $calcmode = str_replace('{link1}', '', $calcmode); $calcmode = str_replace('{link2}', '', $calcmode); - $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); $description = $langs->trans("RulesPurchaseTurnoverTotalPurchaseJournal"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); $moreparam = array(); if (!empty($modecompta)) { diff --git a/htdocs/compta/stats/supplier_turnover_by_prodserv.php b/htdocs/compta/stats/supplier_turnover_by_prodserv.php index 26659c851f9..1c78b51a185 100644 --- a/htdocs/compta/stats/supplier_turnover_by_prodserv.php +++ b/htdocs/compta/stats/supplier_turnover_by_prodserv.php @@ -79,8 +79,8 @@ if (empty($year)) { $month_current = dol_print_date(dol_now(), '%m'); $year_start = $year; } -$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzuserrel'); -$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzuserrel'); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzserver'); // We use timezone of server so report is same from everywhere +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzserver'); // We use timezone of server so report is same from everywhere // Quarter if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int"); @@ -241,7 +241,9 @@ if ($modecompta == "CREANCES-DETTES") { } elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } -$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) { $periodlink = ''.img_previous().' '.img_next().''; } else { diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 4b64b2e5942..664a4fbc62d 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -81,8 +81,8 @@ if (empty($year)) { $month_current = dol_print_date(dol_now(), '%m'); $year_start = $year; } -$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzuserrel'); -$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzuserrel'); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzserver'); // We use timezone of server so report is same from everywhere +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzserver'); // We use timezone of server so report is same from everywhere // Quarter if (empty($date_start) || empty($date_end)) { // We define date_start and date_end $q = GETPOST("q", "int") ?GETPOST("q", "int") : 0; @@ -212,7 +212,9 @@ if ($modecompta == "CREANCES-DETTES") { } elseif ($modecompta == "BOOKKEEPING") { } elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } -$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) { $periodlink = ''.img_previous().' '.img_next().''; } else { From 27bc05a0397bdba911b5bd2dfea3e558da49841d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 17:59:42 +0200 Subject: [PATCH 163/233] Debug report accountancy --- htdocs/accountancy/bookkeeping/list.php | 4 +++- htdocs/compta/stats/byratecountry.php | 4 ++-- htdocs/compta/stats/cabyprodserv.php | 4 ++-- htdocs/compta/stats/cabyuser.php | 6 ++++-- htdocs/compta/stats/casoc.php | 18 ++++++++++-------- htdocs/compta/stats/index.php | 4 ++-- .../stats/supplier_turnover_by_prodserv.php | 8 ++++---- .../stats/supplier_turnover_by_thirdparty.php | 8 ++++---- 8 files changed, 31 insertions(+), 25 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b3f946e9245..8ffdd18c520 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -727,7 +727,9 @@ if (!empty($arrayfields['t.piece_num']['checked'])) { } // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print '
    '; + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) { diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index 9f40eab226a..d65bed019fc 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -301,6 +301,7 @@ if ($modecompta == 'CREANCES-DETTES') { } print ''; + // Sales invoices $sql = "SELECT fd.tva_tx AS vatrate,"; $sql .= " fd.product_type AS product_type,"; $sql .= " cc.code, cc.label AS country,"; @@ -324,7 +325,6 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label, cc.code "; $sql .= " ORDER BY country, product_type, vatrate"; - dol_syslog("htdocs/compta/tva/index.php sql=".$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -374,7 +374,6 @@ if ($modecompta == 'CREANCES-DETTES') { print $db->lasterror(); // Show last sql error } - print ''; print ''; print ''; @@ -389,6 +388,7 @@ if ($modecompta == 'CREANCES-DETTES') { } print ''; + // Purchase invoices $sql2 = "SELECT ffd.tva_tx AS vatrate,"; $sql2 .= " ffd.product_type AS product_type,"; $sql2 .= " cc.code, cc.label AS country,"; diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 16f4a850f83..d48a931ca2c 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -315,7 +315,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } if ($selected_type >= 0) { - $sql .= " AND l.product_type = ".$selected_type; + $sql .= " AND l.product_type = ".((int) $selected_type); } if ($selected_cat === -2) { // Without any category $sql .= " AND cp.fk_product is null"; @@ -342,7 +342,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= "))"; } if ($selected_soc > 0) { - $sql .= " AND soc.rowid=".$selected_soc; + $sql .= " AND soc.rowid=".((int) $selected_soc); } $sql .= " AND f.entity IN (".getEntity('invoice').")"; diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 0c0621fde76..ce2cb2ad333 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -243,7 +243,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($date_start && $date_end) { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } -} else { +} elseif ($modecompta == "RECETTES-DEPENSES") { /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) @@ -257,6 +257,8 @@ if ($modecompta == 'CREANCES-DETTES') { if ($date_start && $date_end) { $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } +} elseif ($modecompta == "BOOKKEEPING") { +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) { @@ -286,7 +288,7 @@ if ($result) { } // Adding old-version payments, non-bound by "paiement_facture" then without User -if ($modecompta != 'CREANCES-DETTES') { +if ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT -1 as rowidx, '' as name, '' as firstname, sum(DISTINCT p.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 1be022cca2f..52e41c20672 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -267,14 +267,14 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) { // Without any category $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$db->escape($selected_cat); + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$db->escape($selected_cat); + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } -} else { +} elseif ($modecompta == "RECETTES-DEPENSES") { /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) @@ -298,13 +298,15 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) { // Without any category $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$selected_cat; + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$selected_cat; + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } +} elseif ($modecompta == "BOOKKEEPING") { +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } if (!empty($search_societe)) { $sql .= natural_search('s.nom', $search_societe); @@ -316,11 +318,11 @@ if (!empty($search_town)) { $sql .= natural_search('s.town', $search_town); } if ($search_country > 0) { - $sql .= ' AND s.fk_pays = '.$search_country.''; + $sql .= ' AND s.fk_pays = '.((int) $search_country); } $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; + $sql .= " AND f.fk_soc = ".((int) $socid); } $sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays"; $sql .= " ORDER BY s.rowid"; @@ -350,7 +352,7 @@ if ($result) { } // On ajoute les paiements anciennes version, non lies par paiement_facture -if ($modecompta != 'CREANCES-DETTES') { +if ($modecompta == "RECETTES-DEPENSES") { $sql = "SELECT '0' as socid, 'Autres' as name, sum(p.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 057ba461559..81f681d7528 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -209,7 +209,7 @@ if ($modecompta == 'CREANCES-DETTES') { } $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; + $sql .= " AND f.fk_soc = ".((int) $socid); } } elseif ($modecompta == "RECETTES-DEPENSES") { /* @@ -224,7 +224,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND pf.fk_facture = f.rowid"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; + $sql .= " AND f.fk_soc = ".((int) $socid); } } elseif ($modecompta == "BOOKKEEPING") { $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc"; diff --git a/htdocs/compta/stats/supplier_turnover_by_prodserv.php b/htdocs/compta/stats/supplier_turnover_by_prodserv.php index 1c78b51a185..1af51249433 100644 --- a/htdocs/compta/stats/supplier_turnover_by_prodserv.php +++ b/htdocs/compta/stats/supplier_turnover_by_prodserv.php @@ -288,20 +288,20 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } if ($selected_type >= 0) { - $sql .= " AND l.product_type = ".$selected_type; + $sql .= " AND l.product_type = ".((int) $selected_type); } if ($selected_cat === -2) { // Without any category $sql .= " AND cp.fk_product is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$selected_cat; + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$selected_cat; + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; } if ($selected_soc > 0) { - $sql .= " AND soc.rowid=".$selected_soc; + $sql .= " AND soc.rowid=".((int) $selected_soc); } $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")"; $sql .= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type"; diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 664a4fbc62d..4e19d81f94a 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -251,9 +251,9 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) { // Without any category $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$db->escape($selected_cat); + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$db->escape($selected_cat); + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; @@ -278,9 +278,9 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) { // Without any category $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$selected_cat; + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$selected_cat; + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; From 2e3af575be46ebd7b6dbef3c5096ad47a8c6e24b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 18:12:26 +0200 Subject: [PATCH 164/233] Look and feel v14 --- htdocs/accountancy/bookkeeping/list.php | 6 ++---- htdocs/compta/stats/index.php | 6 +++--- .../core/class/html.formaccounting.class.php | 18 +++++++++--------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 8ffdd18c520..498c513b761 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -750,12 +750,10 @@ if (!empty($arrayfields['t.doc_ref']['checked'])) { if (!empty($arrayfields['t.numero_compte']['checked'])) { print ''; } diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 81f681d7528..d1a2d422732 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -199,7 +199,7 @@ if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; + $sql = "SELECT date_format(f.datef, '%Y-%m') as dm, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_statut in (1,2)"; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { @@ -216,7 +216,7 @@ if ($modecompta == 'CREANCES-DETTES') { * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) */ - $sql = "SELECT date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc"; + $sql = "SELECT date_format(p.datep, '%Y-%m') as dm, sum(pf.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; $sql .= ", ".MAIN_DB_PREFIX."paiement as p"; @@ -227,7 +227,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND f.fk_soc = ".((int) $socid); } } elseif ($modecompta == "BOOKKEEPING") { - $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc"; + $sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.credit) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj"; $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities $sql .= " AND aj.entity = ".$conf->entity; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e6ada4d67c7..87706703c23 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -330,15 +330,15 @@ class FormAccounting extends Form /** * Return list of accounts with label by chart of accounts * - * @param string $selectid Preselected id of accounting accounts (depends on $select_in) - * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. - * @param int $showempty 1=Add an empty field, 2=Add an empty field+'None' field - * @param array $event Event options - * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number - * @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number - * @param string $morecss More css non HTML object - * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. - * @return string String with HTML select + * @param string $selectid Preselected id of accounting accounts (depends on $select_in) + * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. + * @param int|string $showempty 1=Add an empty field, 2=Add an empty field+'None' field + * @param array $event Event options + * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number + * @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number + * @param string $morecss More css non HTML object + * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. + * @return string String with HTML select */ public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'minwidth100 maxwidth300 maxwidthonsmartphone', $usecache = '') { From e01b6b67895e1d240c32855ba7527162061061a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 18:39:59 +0200 Subject: [PATCH 165/233] FIX filter on date on invoice list --- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/compta/facture/list.php | 78 +++++++++++++++---- 2 files changed, 65 insertions(+), 15 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 74e2f380d91..3a524a9765f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -292,7 +292,7 @@ class Facture extends CommonInvoice 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), //'increment' =>array('type'=>'varchar(10)', 'label'=>'Increment', 'enabled'=>1, 'visible'=>-1, 'position'=>45), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>50), - 'datef' =>array('type'=>'date', 'label'=>'DateInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>20), + 'datef' =>array('type'=>'date', 'label'=>'DateInvoice', 'enabled'=>1, 'visible'=>1, 'position'=>20), 'date_valid' =>array('type'=>'date', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>22), 'date_lim_reglement' =>array('type'=>'date', 'label'=>'DateDue', 'enabled'=>1, 'visible'=>-1, 'position'=>25), 'date_closing' =>array('type'=>'datetime', 'label'=>'Date closing', 'enabled'=>1, 'visible'=>-1, 'position'=>30), diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 0f595fdc984..c2a663d796f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -110,16 +110,30 @@ $search_country = GETPOST("search_country", 'int'); $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); -$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); -$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); -$search_date_valid_start = dol_mktime(0, 0, 0, GETPOST('search_date_valid_startmonth', 'int'), GETPOST('search_date_valid_startday', 'int'), GETPOST('search_date_valid_startyear', 'int')); -$search_date_valid_end = dol_mktime(23, 59, 59, GETPOST('search_date_valid_endmonth', 'int'), GETPOST('search_date_valid_endday', 'int'), GETPOST('search_date_valid_endyear', 'int')); +$search_date_startday = GETPOST('search_date_startday', 'int'); +$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); +$search_date_startyear = GETPOST('search_date_startyear', 'int'); +$search_date_endday = GETPOST('search_date_endday', 'int'); +$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); +$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver +$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); +$search_date_valid_startday = GETPOST('search_date_valid_startday', 'int'); +$search_date_valid_startmonth = GETPOST('search_date_valid_startmonth', 'int'); +$search_date_valid_startyear = GETPOST('search_date_valid_startyear', 'int'); +$search_date_valid_endday = GETPOST('search_date_valid_endday', 'int'); +$search_date_valid_endmonth = GETPOST('search_date_valid_endmonth', 'int'); +$search_date_valid_endyear = GETPOST('search_date_valid_endyear', 'int'); +$search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver +$search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear); $search_datelimit_start = dol_mktime(0, 0, 0, GETPOST('search_datelimit_startmonth', 'int'), GETPOST('search_datelimit_startday', 'int'), GETPOST('search_datelimit_startyear', 'int')); $search_datelimit_end = dol_mktime(23, 59, 59, GETPOST('search_datelimit_endmonth', 'int'), GETPOST('search_datelimit_endday', 'int'), GETPOST('search_datelimit_endyear', 'int')); $search_categ_cus = GETPOST("search_categ_cus", 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); + + $option = GETPOST('search_option'); if ($option == 'late') { $search_status = '1'; @@ -314,8 +328,20 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_type = ''; $search_country = ''; $search_type_thirdparty = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; $search_date_start = ''; $search_date_end = ''; + $search_date_valid_startday = ''; + $search_date_valid_startmonth = ''; + $search_date_valid_startyear = ''; + $search_date_valid_endday = ''; + $search_date_valid_endmonth = ''; + $search_date_valid_endyear = ''; $search_date_valid_start = ''; $search_date_valid_end = ''; $search_datelimit_start = ''; @@ -761,7 +787,7 @@ if ($resql) { } } - $param = '&socid='.$socid; + $param = '&socid='.urlencode($socid); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -771,17 +797,41 @@ if ($resql) { if ($sall) { $param .= '&sall='.urlencode($sall); } - if ($search_date_start) { - $param .= '&search_date_start='.urlencode($search_date_start); + if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); } - if ($search_date_end) { - $param .= '&search_date_end='.urlencode($search_date_end); + if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); } - if ($search_date_valid_start) { - $param .= '&search_date_valid_start='.urlencode($search_date_valid_start); + if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); } - if ($search_date_valid_end) { - $param .= '&search_date_valid_end='.urlencode($search_date_valid_end); + if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); + } + if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + } + if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); + } + if ($search_date_valid_startday) { + $param .= '&search_date_valid_startday='.urlencode($search_date_valid_startday); + } + if ($search_date_valid_startmonth) { + $param .= '&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth); + } + if ($search_date_valid_startyear) { + $param .= '&search_date_valid_startyear='.urlencode($search_date_valid_startyear); + } + if ($search_date_valid_endday) { + $param .= '&search_date_valid_endday='.urlencode($search_date_valid_endday); + } + if ($search_date_valid_endmonth) { + $param .= '&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth); + } + if ($search_date_valid_endyear) { + $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear); } if ($search_datelimit_start) { $param .= '&search_datelimit_start='.urlencode($search_datelimit_start); @@ -1310,7 +1360,7 @@ if ($resql) { print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['f.datef']['checked'])) { - print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); } if (!empty($arrayfields['f.date_valid']['checked'])) { print_liste_field_titre($arrayfields['f.date_valid']['label'], $_SERVER['PHP_SELF'], 'f.date_valid', '', $param, 'align="center"', $sortfield, $sortorder); From 6831d0e88369c04fee8e362933eed47d57241ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 31 Mar 2021 18:49:19 +0200 Subject: [PATCH 166/233] add dynamic --- htdocs/install/repair.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 320507a648c..ed4fb8dab13 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1282,11 +1282,18 @@ if ($ok && GETPOST('force_utf8mb4_on_tables', 'alpha')) { print ''; } - print ''; + print ''; print ''; if ($annee != $year_end) { print ''; diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php index 6beba492fb5..bb341c6a3a5 100644 --- a/htdocs/compta/stats/supplier_turnover.php +++ b/htdocs/compta/stats/supplier_turnover.php @@ -272,7 +272,13 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { if ($modecompta == 'CREANCES-DETTES') { print ''; } - print ''; + print ''; print ''; if ($annee != $year_end) { print ''; From eed14ad6e1f2c00448ee1e2f71a07d0071feffae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 23:15:33 +0200 Subject: [PATCH 173/233] Fix missing token --- htdocs/admin/dict.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 0f2601f0349..b1a3a96bc3b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2056,7 +2056,7 @@ if ($id) { if ($id == 4) { print ''; - print ''; - print ''; - print ''; - if ($conf->productbatch->enabled) { - print ''; + if ($productstatic->id <= 0) { + $error++; + setEventMessages($langs->trans("ObjectNotFound", $langs->transnoentitiesnoconv("Product")), null, 'errors'); + } + if ($warehousestatics->id <= 0) { + $error++; + setEventMessages($langs->trans("ObjectNotFound", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); + } + if ($warehousestatics->id <= 0) { + $error++; + setEventMessages($langs->trans("ObjectNotFound", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); + } + + if (!$error) { + print ''; + print ''; + print ''; + print ''; + if ($conf->productbatch->enabled) { + print ''; + } + print ''; + print ''; + print ''; } - print ''; - print ''; - print ''; } print '
    '; - print $langs->trans('BankAccount'); + print $langs->trans('DefaultBankAccount'); print ''; if ($action != 'editbankaccount' && $user->rights->tax->charges->creer) { print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).''; + print ''; print ''; print ''; + print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); + print ''.$langs->trans("TotalHT").'
    '.$langs->trans("PurchasebyVatrate").''.$langs->trans("ProductOrService").''.$langs->trans("Country").''.$langs->trans("TotalHT").'
    '; print '
    '; - print $langs->trans('From').' '; - print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); + print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200', 1); print '
    '; print '
    '; - print $langs->trans('to').' '; - print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); + print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200', 1); print '
    '; print '
    '; print $table; - $sql = 'ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'; - print ''; + $sql1 = 'ALTER TABLE '.$table.' ROW_FORMAT=dynamic;'; + $sql2 = 'ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'; + print ''; + print ''; if ($force_utf8mb4_on_tables == 'confirmed') { - $resql = $db->query($sql); - print ' - Done ('.($resql ? 'OK' : 'KO').')'; + $resql1 = $db->query($sql1); + if ($resql1) { + $resql2 = $db->query($sql2); + } else { + $resql2 = false; + } + print ' - Done ('.(($resql1 && $resql2) ? 'OK' : 'KO').')'; } else { print ' - Disabled'; } From 2af8b7078ce8b13825ee9e900e2c028c99853505 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 19:50:43 +0200 Subject: [PATCH 167/233] Fix turnover calculation was wrong. We must include only --- htdocs/accountancy/admin/account.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 1 + htdocs/compta/stats/index.php | 24 ++++++++++++------- htdocs/compta/stats/supplier_turnover.php | 20 ++++++++++++---- .../stats/supplier_turnover_by_thirdparty.php | 2 +- htdocs/langs/en_US/compta.lang | 2 ++ 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 39bf2b07b29..4b18fc03c5b 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -349,7 +349,7 @@ if ($resql) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1"; $sql .= " WHERE a.active = 1"; dol_syslog('accountancy/admin/account.php $sql='.$sql); - print $sql; + $resqlchart = $db->query($sql); if ($resqlchart) { $numbis = $db->num_rows($resqlchart); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index d1361d1296e..e5f52cbc2ea 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -115,6 +115,7 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_sell"; } $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); } diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index d1a2d422732..58d4458ca6a 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -179,7 +179,7 @@ if ($modecompta == "CREANCES-DETTES") { $calcmode = str_replace('{link2}', '', $calcmode); //$calcmode.='
    ('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); - $description = $langs->trans("RulesCATotalSaleJournal"); + $description = $langs->trans("RulesSalesTurnoverOfIncomeAccounts"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -227,17 +227,25 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND f.fk_soc = ".((int) $socid); } } elseif ($modecompta == "BOOKKEEPING") { - $sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.credit) as amount_ttc"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj"; - $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities - $sql .= " AND aj.entity = ".$conf->entity; - $sql .= " AND b.code_journal = aj.code AND aj.nature = 2"; // @todo currently count amount in sale journal, but we need to define a category group for turnover -} + $pcgverid = $conf->global->CHARTOFACCOUNTS; + $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); + if (empty($pcgvercode)) { + $pcgvercode = $pcgverid; + } + $sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.debit) as amount_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,"; + $sql .= " ".MAIN_DB_PREFIX."accounting_account as aa"; + $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities + $sql .= " AND b.numero_compte = aa.account_number"; + $sql .= " AND b.doc_type = 'customer_invoice'"; + $sql .= " AND aa.entity = ".$conf->entity; + $sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; + $sql .= " AND aa.pcg_type = 'INCOME'"; // TODO Be able to use a custom group +} $sql .= " GROUP BY dm"; $sql .= " ORDER BY dm"; // TODO Add a filter on $date_start and $date_end to reduce quantity on data -//print $sql; $minyearmonth = $maxyearmonth = 0; diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php index afec3c3d124..dc8417e58a1 100644 --- a/htdocs/compta/stats/supplier_turnover.php +++ b/htdocs/compta/stats/supplier_turnover.php @@ -153,7 +153,7 @@ if ($modecompta == "CREANCES-DETTES") { $calcmode = str_replace('{link1}', '', $calcmode); $calcmode = str_replace('{link2}', '', $calcmode); $periodlink = ($year_start ? "".img_previous()." ".img_next()."" : ""); - $description = $langs->trans("RulesPurchaseTurnoverTotalPurchaseJournal"); + $description = $langs->trans("RulesPurchaseTurnoverOfExpenseAccounts"); $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -193,11 +193,21 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND f.fk_soc = ".$socid; } } elseif ($modecompta == "BOOKKEEPING") { - $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.debit) as amount_ttc"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj"; + $pcgverid = $conf->global->CHARTOFACCOUNTS; + $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); + if (empty($pcgvercode)) { + $pcgvercode = $pcgverid; + } + + $sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.debit) as amount_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,"; + $sql .= " ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities - $sql .= " AND aj.entity = ".$conf->entity; - $sql .= " AND b.code_journal = aj.code AND aj.nature = 3"; // @todo currently count amount in sale journal, but we need to define a category group for turnover + $sql .= " AND b.doc_type = 'supplier_invoice'"; + $sql .= " AND b.numero_compte = aa.account_number"; + $sql .= " AND aa.entity = ".$conf->entity; + $sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; + $sql .= " AND aa.pcg_type = 'EXPENSE'"; // TODO Be able to use a custom group } $sql .= " GROUP BY dm"; diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 4e19d81f94a..556c4437df7 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -258,7 +258,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= ")"; $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } -} else { +} elseif ($modecompta == "RECETTES-DEPENSES") { $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf"; diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index d42d8845aeb..befb6adf75b 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -175,6 +175,7 @@ RulesResultInOut=- It includes the real payments made on invoices, expenses, VAT RulesCADue=- It includes the customer's due invoices whether they are paid or not.
    - It is based on the billing date of these invoices.
    RulesCAIn=- It includes all the effective payments of invoices received from customers.
    - It is based on the payment date of these invoices
    RulesCATotalSaleJournal=It includes all credit lines from the Sale journal. +RulesSalesTurnoverOfIncomeAccounts=It includes all debit of product accounts in group INCOME RulesAmountOnInOutBookkeepingRecord=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" RulesResultBookkeepingPredefined=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting accounts grouped by personalized groups @@ -280,6 +281,7 @@ PurchaseTurnoverCollected=Purchase turnover collected RulesPurchaseTurnoverDue=- It includes the supplier's due invoices whether they are paid or not.
    - It is based on the invoice date of these invoices.
    RulesPurchaseTurnoverIn=- It includes all the effective payments of invoices done to suppliers.
    - It is based on the payment date of these invoices
    RulesPurchaseTurnoverTotalPurchaseJournal=It includes all debit lines from the purchase journal. +RulesPurchaseTurnoverOfExpenseAccounts=It includes all debit of product accounts in group EXPENSE ReportPurchaseTurnover=Purchase turnover invoiced ReportPurchaseTurnoverCollected=Purchase turnover collected IncludeVarpaysInResults = Include various payments in reports From c3f4e5e2d50fe0ef51063c87263a2a5e86a1b378 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 31 Mar 2021 20:09:13 +0200 Subject: [PATCH 168/233] better attendded woth project tabs --- .../conferenceorboothattendee_card.php | 184 +++++++++++++++++- htdocs/projet/comment.php | 2 - 2 files changed, 183 insertions(+), 3 deletions(-) diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index 7b012a42d8e..57cf6baba78 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -30,6 +30,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array("eventorganization", "other")); @@ -46,10 +48,12 @@ $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); //$lineid = GETPOST('lineid', 'int'); $conf_or_booth_id = GETPOST('conforboothid', 'int'); +$withproject = GETPOST('withproject', 'int'); // Initialize technical objects $object = new ConferenceOrBoothAttendee($db); $extrafields = new ExtraFields($db); +$projectstatic = new Project($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothattendeecard', 'globalcard')); // Note that conf->hooks_modules contains array @@ -166,11 +170,189 @@ $title = $langs->trans("ConferenceOrBoothAttendee"); $help_url = ''; llxHeader('', $title, $help_url); +$result = $projectstatic->fetch($confOrBooth->fk_project); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); +} +if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); +} + +$withProjectUrl=''; +$object->project = clone $projectstatic; + +if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $withProjectUrl="&withproject=1"; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; +} + // Part to create if ($action == 'create') { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")), '', 'object_'.$object->picto); - print '
    '; + print ''; print ''; if ($confOrBooth->id > 0) { diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index 5ddd2cd163b..f4b7d8226d0 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -44,8 +44,6 @@ $objectref = GETPOST("taskref", 'alpha'); // task ref $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $withproject = GETPOST('withproject', 'int'); -$project_ref = GETPOST('project_ref', 'alpha'); -$planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); // Security check $socid = 0; From dd913b2385b2387a9d216498cd059a37e377cc17 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 31 Mar 2021 20:40:26 +0200 Subject: [PATCH 169/233] Update --- htdocs/accountancy/class/accountancyimport.class.php | 4 ++-- htdocs/core/modules/modAccounting.class.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/class/accountancyimport.class.php b/htdocs/accountancy/class/accountancyimport.class.php index c27ff6911ed..230aa392cd7 100644 --- a/htdocs/accountancy/class/accountancyimport.class.php +++ b/htdocs/accountancy/class/accountancyimport.class.php @@ -48,7 +48,7 @@ class AccountancyImport * @param array $listvalues Values list to add * @return int <0 if KO, >0 if OK */ - public function computeMontant(&$arrayrecord, $fieldname, &$listfields, &$listvalues) { + public function computeAmount(&$arrayrecord, $fieldname, &$listfields, &$listvalues) { $fieldArr = explode('.', $fieldname); if (count($fieldArr) > 0) { $fieldname = $fieldArr[1]; @@ -78,7 +78,7 @@ class AccountancyImport * @param array $listvalues Values list to add * @return int <0 if KO, >0 if OK */ - public function computeSens(&$arrayrecord, $fieldname, &$listfields, &$listvalues) { + public function computeDirection(&$arrayrecord, $fieldname, &$listfields, &$listvalues) { $fieldArr = explode('.', $fieldname); if (count($fieldArr) > 0) { $fieldname = $fieldArr[1]; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 8034f98d9a7..d62ede90982 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -350,8 +350,8 @@ class modAccounting extends DolibarrModules 'b.sens'=>'rule-computeSens' ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_convertvalue_array[$r]=array( - 'b.montant' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeMontant', 'element' => 'Accountancy'), - 'b.sens' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeSens', 'element' => 'Accountancy'), + 'b.montant' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeAmount', 'element' => 'Accountancy'), + 'b.sens' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeDirection', 'element' => 'Accountancy'), ); $this->import_regex_array[$r] = array( //'b.doc_date'=>'^\d{4}\d{2}\d{2}$', From 416a09672f2288898da42e67f10006c5d3ad9c14 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 31 Mar 2021 18:43:09 +0000 Subject: [PATCH 170/233] Fixing style errors. --- .../class/accountancyimport.class.php | 100 +++++++++--------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/htdocs/accountancy/class/accountancyimport.class.php b/htdocs/accountancy/class/accountancyimport.class.php index 230aa392cd7..ece843515e2 100644 --- a/htdocs/accountancy/class/accountancyimport.class.php +++ b/htdocs/accountancy/class/accountancyimport.class.php @@ -39,61 +39,63 @@ */ class AccountancyImport { - /** - * Compute amount - * - * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... - * @param string $fieldname Field name with alias - * @param array $listfields Fields list to add - * @param array $listvalues Values list to add - * @return int <0 if KO, >0 if OK - */ - public function computeAmount(&$arrayrecord, $fieldname, &$listfields, &$listvalues) { - $fieldArr = explode('.', $fieldname); - if (count($fieldArr) > 0) { - $fieldname = $fieldArr[1]; - } + /** + * Compute amount + * + * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... + * @param string $fieldname Field name with alias + * @param array $listfields Fields list to add + * @param array $listvalues Values list to add + * @return int <0 if KO, >0 if OK + */ + public function computeAmount(&$arrayrecord, $fieldname, &$listfields, &$listvalues) + { + $fieldArr = explode('.', $fieldname); + if (count($fieldArr) > 0) { + $fieldname = $fieldArr[1]; + } - $debit = trim($arrayrecord[11]['val']); - $credit = trim($arrayrecord[12]['val']); - if (!empty($debit)) { - $amount = $debit; - } else { - $amount = $credit; - } + $debit = trim($arrayrecord[11]['val']); + $credit = trim($arrayrecord[12]['val']); + if (!empty($debit)) { + $amount = $debit; + } else { + $amount = $credit; + } - $listfields[] = $fieldname; - $listvalues[] = "'" . abs($amount) . "'"; + $listfields[] = $fieldname; + $listvalues[] = "'" . abs($amount) . "'"; - return 1; - } + return 1; + } - /** - * Compute sens - * - * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... - * @param string $fieldname Field name with alias - * @param array $listfields Fields list to add - * @param array $listvalues Values list to add - * @return int <0 if KO, >0 if OK - */ - public function computeDirection(&$arrayrecord, $fieldname, &$listfields, &$listvalues) { - $fieldArr = explode('.', $fieldname); - if (count($fieldArr) > 0) { - $fieldname = $fieldArr[1]; - } + /** + * Compute sens + * + * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... + * @param string $fieldname Field name with alias + * @param array $listfields Fields list to add + * @param array $listvalues Values list to add + * @return int <0 if KO, >0 if OK + */ + public function computeDirection(&$arrayrecord, $fieldname, &$listfields, &$listvalues) + { + $fieldArr = explode('.', $fieldname); + if (count($fieldArr) > 0) { + $fieldname = $fieldArr[1]; + } - $debit = trim($arrayrecord[11]['val']); - if (!empty($debit)) { - $sens = 'D'; - } else { - $sens = 'C'; - } + $debit = trim($arrayrecord[11]['val']); + if (!empty($debit)) { + $sens = 'D'; + } else { + $sens = 'C'; + } - $listfields[] = $fieldname; - $listvalues[] = "'" . $sens . "'"; + $listfields[] = $fieldname; + $listvalues[] = "'" . $sens . "'"; - return 1; - } + return 1; + } } From 0fd36d96f318a09545cd4a00391f33d66694c7f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 21:25:01 +0200 Subject: [PATCH 171/233] Fix report --- htdocs/compta/stats/index.php | 3 ++- htdocs/compta/stats/supplier_turnover.php | 3 ++- htdocs/langs/en_US/compta.lang | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 58d4458ca6a..f1e5c241ab0 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -233,7 +233,7 @@ if ($modecompta == 'CREANCES-DETTES') { $pcgvercode = $pcgverid; } - $sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.debit) as amount_ttc"; + $sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.credit - b.debit) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,"; $sql .= " ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities @@ -246,6 +246,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " GROUP BY dm"; $sql .= " ORDER BY dm"; // TODO Add a filter on $date_start and $date_end to reduce quantity on data +//print $sql; $minyearmonth = $maxyearmonth = 0; diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php index dc8417e58a1..6beba492fb5 100644 --- a/htdocs/compta/stats/supplier_turnover.php +++ b/htdocs/compta/stats/supplier_turnover.php @@ -199,7 +199,7 @@ if ($modecompta == 'CREANCES-DETTES') { $pcgvercode = $pcgverid; } - $sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.debit) as amount_ttc"; + $sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.debit - b.credit) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,"; $sql .= " ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities @@ -209,6 +209,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; $sql .= " AND aa.pcg_type = 'EXPENSE'"; // TODO Be able to use a custom group } +//print $sql; $sql .= " GROUP BY dm"; $sql .= " ORDER BY dm"; diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index befb6adf75b..7080810bfea 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -175,7 +175,7 @@ RulesResultInOut=- It includes the real payments made on invoices, expenses, VAT RulesCADue=- It includes the customer's due invoices whether they are paid or not.
    - It is based on the billing date of these invoices.
    RulesCAIn=- It includes all the effective payments of invoices received from customers.
    - It is based on the payment date of these invoices
    RulesCATotalSaleJournal=It includes all credit lines from the Sale journal. -RulesSalesTurnoverOfIncomeAccounts=It includes all debit of product accounts in group INCOME +RulesSalesTurnoverOfIncomeAccounts=It includes (credit - debit) of lines for product accounts in group INCOME RulesAmountOnInOutBookkeepingRecord=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" RulesResultBookkeepingPredefined=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting accounts grouped by personalized groups @@ -281,7 +281,7 @@ PurchaseTurnoverCollected=Purchase turnover collected RulesPurchaseTurnoverDue=- It includes the supplier's due invoices whether they are paid or not.
    - It is based on the invoice date of these invoices.
    RulesPurchaseTurnoverIn=- It includes all the effective payments of invoices done to suppliers.
    - It is based on the payment date of these invoices
    RulesPurchaseTurnoverTotalPurchaseJournal=It includes all debit lines from the purchase journal. -RulesPurchaseTurnoverOfExpenseAccounts=It includes all debit of product accounts in group EXPENSE +RulesPurchaseTurnoverOfExpenseAccounts=It includes (debit - credit) of lines for product accounts in group EXPENSE ReportPurchaseTurnover=Purchase turnover invoiced ReportPurchaseTurnoverCollected=Purchase turnover collected IncludeVarpaysInResults = Include various payments in reports From 3fb69f8ec0d7b7e2182eb28736a4fe3b74058483 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Mar 2021 21:28:07 +0200 Subject: [PATCH 172/233] Fix report --- htdocs/compta/stats/index.php | 8 +++++++- htdocs/compta/stats/supplier_turnover.php | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index f1e5c241ab0..ea3bdabd93d 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -336,7 +336,13 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { if ($modecompta == 'CREANCES-DETTES') { print '
    '.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''; + if ($modecompta == "BOOKKEEPING") { + print $langs->trans("Amount"); + } else { + print $langs->trans("AmountTTC"); + } + print ''.$langs->trans("Delta").' '.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''; + if ($modecompta == "BOOKKEEPING") { + print $langs->trans("Amount"); + } else { + print $langs->trans("AmountTTC"); + } + print ''.$langs->trans("Delta").' '; if ($iserasable) { - print ''.$actl[$obj->favorite].''; + print ''.$actl[$obj->favorite].''; } else { print $langs->trans("AlwaysActive"); } @@ -2066,7 +2066,7 @@ if ($id) { // Active print ''; if ($canbedisabled) { - print ''.$actl[$obj->active].''; + print ''.$actl[$obj->active].''; } else { if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO'))) { print $langs->trans("AlwaysActive"); From fd6822b202afd3d96133bb8abe04068cf979d481 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 1 Apr 2021 09:34:14 +0200 Subject: [PATCH 174/233] Debug feature to import stock movement --- htdocs/langs/en_US/stocks.lang | 2 +- htdocs/product/stock/massstockmove.php | 104 +++++++++++++++++++------ 2 files changed, 83 insertions(+), 23 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 24dc4cef0c6..301d26333cc 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -252,4 +252,4 @@ InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fiel LabelOfInventoryMovemement=Inventory %s ReOpen=Reopen ConfirmFinish=Confirm closing - +ObjectNotFound=%s not found \ No newline at end of file diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 0627a6a1cf7..aac4d66fc88 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -315,7 +315,7 @@ if ($action == 'importCSV' && !empty($user->rights->stock->mouvement->creer)) { $importcsv->import_open_file($fullpath); $labelsrecord = $importcsv->import_read_record(); - if ($nblinesrecord <= 1) { + if ($nblinesrecord < 1) { setEventMessages($langs->trans("BadNumberOfLinesMustHaveAtLeastOneLinePlusTitle"), null, 'errors'); } else { $i=0; @@ -329,28 +329,46 @@ if ($action == 'importCSV' && !empty($user->rights->stock->mouvement->creer)) { continue; } //var_dump($data); - + $formproduct = new FormProduct($db); + $productstatic = new Product($db); + $warehousestatics = new Entrepot($db); + $warehousestatict = new Entrepot($db); $tmp_id_sw = $data[$i][0]['val']; $tmp_id_tw = $data[$i][1]['val']; $tmp_id_product = $data[$i][2]['val']; $tmp_qty = $data[$i][3]['val']; $tmp_batch = $data[$i][4]['val']; - // TODO If product is a ref (not numeric or starts with "ref:..."), retreive the id of product from the ref + if (!is_numeric($tmp_id_product)) { + $result = fetchref($productstatic, $tmp_id_product); + $tmp_id_product = $result; + $data[$i][2]['val'] = $result; + } if (!($tmp_id_product > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); } - // TODO If warehouse is a ref (not numeric or starts with "ref:..."), retreive the id of product from the ref + + if (!is_numeric($tmp_id_sw)) { + $result = fetchref($warehousestatics, $tmp_id_sw); + $tmp_id_sw = $result; + $data[$i][0]['val'] = $result; + } if (!($tmp_id_sw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); } - // TODO If warehouse is a ref (not numeric or starts with "ref:..."), retreive the id of product from the ref + + if (!is_numeric($tmp_id_tw)) { + $result = fetchref($warehousestatict, $tmp_id_tw); + $tmp_id_tw = $result; + $data[$i][1]['val'] = $result; + } if (!($tmp_id_tw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); } + if ($tmp_id_sw > 0 && $tmp_id_tw == $tmp_id_sw) { $error++; $langs->load("errors"); @@ -585,24 +603,39 @@ foreach ($listofdata as $key => $val) { $warehousestatics->fetch($val['id_sw']); $warehousestatict->fetch($val['id_tw']); - print '
    '; - print $warehousestatics->getNomUrl(1); - print ''; - print $warehousestatict->getNomUrl(1); - print ''; - print $productstatic->getNomUrl(1).' - '.$productstatic->label; - print ''; - print $val['batch']; - print '
    '; + print $warehousestatics->getNomUrl(1); + print ''; + print $warehousestatict->getNomUrl(1); + print ''; + print $productstatic->getNomUrl(1).' - '.$productstatic->label; + print ''; + print $val['batch']; + print ''.$val['qty'].''.img_delete($langs->trans("Remove")).'
    '.$val['qty'].''.img_delete($langs->trans("Remove")).'
    '; @@ -645,3 +678,30 @@ if ($action == 'delete') { // End of page llxFooter(); $db->close(); + +/** + * Verify if $haystack startswith $needle + * @param String $haystack string to test + * @param String $needle string to find + * @return false if Ko true else + */ +function startsWith($haystack, $needle) +{ + $length = strlen($needle); + return substr($haystack, 0, $length) === $needle; +} + +/** + * Fetch object with ref + * @param Object $static_object static object to fetch + * @param String $tmp_ref ref of the object to fetch + * @return <0 if Ko or Id of object + */ +function fetchref($static_object, $tmp_ref) +{ + if (startsWith($tmp_ref, 'ref:')) { + $tmp_ref = str_replace('ref:', '', $tmp_ref); + } + $static_object->fetch('', $tmp_ref); + return $static_object->id; +} From 9c92dfd3e157760d12aa3bd5bdd68b3ee0c63606 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 10:05:37 +0200 Subject: [PATCH 175/233] Function set_price_level() has been renamed into setPriceLevel() to follow camelcase rules --- ChangeLog | 2 +- htdocs/comm/multiprix.php | 2 +- htdocs/societe/class/api_thirdparties.class.php | 2 +- htdocs/societe/class/societe.class.php | 4 +--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c784c2f4bf3..ef9dd78bb4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,7 +24,7 @@ Following changes may create regressions for some external modules, but were nec * Field "total" renamed into "total_ttc" for table lx_propal, llx_supplier_proposal for better field name consistency * If your database is PostgreSql, you must use version 9.1.0 or more (Dolibarr need the SQL function CONCAT) * If your database is MySql or MariaDB, you need at least version 5.1 - +* Function set_price_level() has been renamed into setPriceLevel() to follow camelcase rules ***** ChangeLog for 13.0.2 compared to 13.0.1 ***** diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index a409a150778..98c44b3ad3f 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -56,7 +56,7 @@ $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid if ($action == 'setpricelevel') { $soc = new Societe($db); $soc->fetch($id); - $soc->set_price_level(GETPOST("price_level"), $user); + $soc->setPriceLevel(GETPOST("price_level"), $user); header("Location: multiprix.php?id=".$id); exit; diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 6fd5160d8a6..f5eae0be948 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -575,7 +575,7 @@ class Thirdparties extends DolibarrApi throw new RestException(401, 'Access to thirdparty '.$id.' not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->company->set_price_level($priceLevel, DolibarrApiAccess::$user); + $result = $this->company->setPriceLevel($priceLevel, DolibarrApiAccess::$user); if ($result <= 0) { throw new RestException(500, 'Error setting new price level for thirdparty '.$id, array($this->company->db->lasterror())); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6874c4b3b2d..9d449922dd2 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2272,7 +2272,6 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the price level * @@ -2280,9 +2279,8 @@ class Societe extends CommonObject * @param User $user Use making change * @return int <0 if KO, >0 if OK */ - public function set_price_level($price_level, User $user) + public function setPriceLevel($price_level, User $user) { - // phpcs:enable if ($this->id) { $now = dol_now(); From 4b3564592041783664264544bc30384b6029da17 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 10:08:05 +0200 Subject: [PATCH 176/233] FIX #yogosha5753 --- htdocs/comm/multiprix.php | 2 +- htdocs/comm/remx.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 98c44b3ad3f..fb10c6435af 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -53,7 +53,7 @@ $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid * Actions */ -if ($action == 'setpricelevel') { +if ($action == 'setpricelevel' && $user->rights->societe->creer) { $soc = new Societe($db); $soc->fetch($id); $soc->setPriceLevel(GETPOST("price_level"), $user); diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 9abf348095e..8f26d897389 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -62,7 +62,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { exit; } -if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes') { +if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user->rights->societe->creer) { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) @@ -192,7 +192,7 @@ if ($action == 'setremise' && $user->rights->societe->creer) { } } -if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes') { +if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && $user->rights->societe->creer) { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) @@ -487,8 +487,8 @@ if ($socid > 0) { print '
    '; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ' '; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ' 
    ".$langs->trans("DefaultContact").''; print img_picto('', 'contact'); - print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); + print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, '', '', 0, 'minwidth300'); print '
    '.$langs->trans("MAIN_DOCUMENTS_LOGO_HEIGHT").'global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT : 20).'">'; print '
    '.$langs->trans("PDF_SHOW_PROJECT").''; +$tmparray = array('no' => 'No', 'showprojectref' => 'RefProject', 'showprojectlabel' => 'ShowProjectLabel'); +$showprojectref = empty($conf->global->PDF_SHOW_PROJECT) ? (empty($conf->global->PDF_SHOW_PROJECT_TITLE) ? 'no' : 'showprojectlabel') : 'showprojectref'; +print $form->selectarray('PDF_SHOW_PROJECT_REF_OR_LABEL', $tmparray, $showprojectref, 0, 0, 0, '', 1); +print '
    '.$langs->trans("SwapSenderAndRecipientOnPDF").''; +print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1); +print '
    '.$langs->trans("PlaceCustomerAddressToIsoLocation").''; +print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1); +print '
    '.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").''; +//if (! empty($conf->global->MAIN_MULTILANGS)) +//{ +$selected = GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE') ? GETPOST('PDF_USE_ALSO_LANGUAGE_CODE') : (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) ? $conf->global->PDF_USE_ALSO_LANGUAGE_CODE : 0); +print $formadmin->select_language($selected, 'PDF_USE_ALSO_LANGUAGE_CODE', 0, null, 1); +//} else { +// print ''.$langs->trans("MultiLangNotEnabled").''; +//} +print '
    '.$langs->trans("HideDescOnPDF").''; @@ -308,38 +351,18 @@ print '
    '.$langs->trans("HideDetailsOnPDF").''; print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS : 0, 1); print '
    '.$langs->trans("SwapSenderAndRecipientOnPDF").''; -print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1); -print '
    '.$langs->trans("PlaceCustomerAddressToIsoLocation").''; -print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1); +print '
    '.$langs->trans("SHOW_SUBPRODUCT_REF_IN_PDF", $langs->transnoentitiesnoconv("AssociatedProductsAbility"), $langs->transnoentitiesnoconv("Products")).''; +print $form->selectyesno('SHOW_SUBPRODUCT_REF_IN_PDF', (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) ? $conf->global->SHOW_SUBPRODUCT_REF_IN_PDF : 0, 1); print '
    '.$langs->trans("ShowDetailsInPDFPageFoot").''; print $form->selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS : 0)); print '
    '.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").''; -//if (! empty($conf->global->MAIN_MULTILANGS)) -//{ -$selected = GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE') ? GETPOST('PDF_USE_ALSO_LANGUAGE_CODE') : (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) ? $conf->global->PDF_USE_ALSO_LANGUAGE_CODE : 0); -print $formadmin->select_language($selected, 'PDF_USE_ALSO_LANGUAGE_CODE', 0, null, 1); -//} else { -// print ''.$langs->trans("MultiLangNotEnabled").''; -//} -print '
    '.$langs->trans("SHOW_SUBPRODUCT_REF_IN_PDF", $langs->transnoentitiesnoconv("AssociatedProductsAbility"), $langs->transnoentitiesnoconv("Products")).''; -print $form->selectyesno('SHOW_SUBPRODUCT_REF_IN_PDF', (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) ? $conf->global->SHOW_SUBPRODUCT_REF_IN_PDF : 0, 1); -print '
    '; print ''; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 73a50ea47c2..15c5d54b94e 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1329,17 +1329,18 @@ class pdf_einstein extends ModelePDFCommandes $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 708bb491610..f97d7abee28 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1506,17 +1506,18 @@ class pdf_eratosthene extends ModelePDFCommandes $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 847901c0147..1d3211407c5 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1703,17 +1703,18 @@ class pdf_crabe extends ModelePDFFactures $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index d7d69fc4a18..22402e91a92 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1962,17 +1962,18 @@ class pdf_sponge extends ModelePDFFactures $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index a02390d0ff8..f3aade80bf8 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1490,17 +1490,18 @@ class pdf_azur extends ModelePDFPropales $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index f5838d576d0..5d63a2fe3f5 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1598,17 +1598,18 @@ class pdf_cyan extends ModelePDFPropales $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } 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 e37caab3ed1..a43e66ff774 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -1125,14 +1125,25 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('', '', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 4; $pdf->SetXY($posx, $posy); $langs->load("projects"); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } 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 fc5cbd1027e..f2f75031d3b 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1269,14 +1269,25 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 4; $pdf->SetXY($posx, $posy); $langs->load("projects"); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } 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 9ca3031f037..de283265931 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -1178,9 +1178,20 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 4; $pdf->SetXY($posx, $posy); $langs->load("projects"); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 25dde592779..138a6210904 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -688,16 +688,27 @@ class pdf_standard extends ModelePDFSuppliersPayments $pdf->SetFont('','', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + if (! empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (! empty($object->project->ref)) { + $outputlangs->load("projects"); $posy+=4; $pdf->SetXY($posx,$posy); $langs->load("projects"); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->project->ref), '', 'R'); } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6f7515a01ac..857ef41bbc2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2085,6 +2085,8 @@ MakeAnonymousPing=Make an anonymous Ping '+1' to the Dolibarr foundation server FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled EmailTemplate=Template for email EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax +PDF_SHOW_PROJECT=Show project on document +ShowProjectLabel=Project Label PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book. FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled 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 3d900bc06e7..ca3c925dd51 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 @@ -1018,10 +1018,11 @@ class pdf_standard_myobject extends ModelePDFMyObject if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } 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 21ff7c2a7ba..fcbbdb76930 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 @@ -929,13 +929,24 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio } } - if (!empty($conf->global->PDF_SHOW_PROJECT)) { + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); if (!empty($object->project->ref)) { $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + + if (!empty($conf->global->PDF_SHOW_PROJECT)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $outputlangs->load("projects"); + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } From fb83d66d27213c1ccab9273c766fa9c4de629d50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Apr 2021 13:04:24 +0200 Subject: [PATCH 185/233] NEW Can show the project ref or label into PDF documents --- htdocs/admin/pdf.php | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 3ca68b8d82d..a5c2770a9c4 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -68,15 +68,18 @@ if ($action == 'update') { dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); - if (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'no') { - dolibarr_del_const($db, "PDF_SHOW_PROJECT", $conf->entity); - dolibarr_del_const($db, "PDF_SHOW_PROJECT_TITLE", $conf->entity); - } elseif (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'showprojectref') { - dolibarr_set_const($db, "PDF_SHOW_PROJECT", GETPOST("PDF_SHOW_PROJECT_REF_OR_LABEL"), 'chaine', 0, '', $conf->entity); - dolibarr_del_const($db, "PDF_SHOW_PROJECT_TITLE", $conf->entity); - } elseif (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'showprojectlabel') { - dolibarr_del_const($db, "PDF_SHOW_PROJECT", $conf->entity); - dolibarr_set_const($db, "PDF_SHOW_PROJECT_TITLE", GETPOST("PDF_SHOW_PROJECT_REF_OR_LABEL"), 'chaine', 0, '', $conf->entity); + + if (!empty($conf->projet->enabled)) { + if (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'no') { + dolibarr_del_const($db, "PDF_SHOW_PROJECT", $conf->entity); + dolibarr_del_const($db, "PDF_SHOW_PROJECT_TITLE", $conf->entity); + } elseif (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'showprojectref') { + dolibarr_set_const($db, "PDF_SHOW_PROJECT", GETPOST("PDF_SHOW_PROJECT_REF_OR_LABEL"), 'chaine', 0, '', $conf->entity); + dolibarr_del_const($db, "PDF_SHOW_PROJECT_TITLE", $conf->entity); + } elseif (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'showprojectlabel') { + dolibarr_del_const($db, "PDF_SHOW_PROJECT", $conf->entity); + dolibarr_set_const($db, "PDF_SHOW_PROJECT_TITLE", GETPOST("PDF_SHOW_PROJECT_REF_OR_LABEL"), 'chaine', 0, '', $conf->entity); + } } dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity); @@ -303,11 +306,13 @@ print '
    '.$langs->trans("PDF_SHOW_PROJECT").''; -$tmparray = array('no' => 'No', 'showprojectref' => 'RefProject', 'showprojectlabel' => 'ShowProjectLabel'); -$showprojectref = empty($conf->global->PDF_SHOW_PROJECT) ? (empty($conf->global->PDF_SHOW_PROJECT_TITLE) ? 'no' : 'showprojectlabel') : 'showprojectref'; -print $form->selectarray('PDF_SHOW_PROJECT_REF_OR_LABEL', $tmparray, $showprojectref, 0, 0, 0, '', 1); -print '
    '.$langs->trans("PDF_SHOW_PROJECT").''; + $tmparray = array('no' => 'No', 'showprojectref' => 'RefProject', 'showprojectlabel' => 'ShowProjectLabel'); + $showprojectref = empty($conf->global->PDF_SHOW_PROJECT) ? (empty($conf->global->PDF_SHOW_PROJECT_TITLE) ? 'no' : 'showprojectlabel') : 'showprojectref'; + print $form->selectarray('PDF_SHOW_PROJECT_REF_OR_LABEL', $tmparray, $showprojectref, 0, 0, 0, '', 1); + print '
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + print "
    '; print '
    '; @@ -282,7 +329,7 @@ if ($object->id) { /* * Show tabs */ - $head = conferenceorboothPrepareHead($object); + $head = conferenceorboothPrepareHead($object, $withproject); print dol_get_fiche_head($head, 'contact', $langs->trans("ConferenceOrBooth"), -1, $object->picto); diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index f822bdea743..7d6339a2ed0 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -47,10 +47,10 @@ function conferenceorboothPrepareHead($object, $with_project = 0) $head[$h][2] = 'card'; $h++; - //$head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_contact.php", 1).'?conforboothid='.$object->id.$withProjectUrl; - //$head[$h][1] = $langs->trans("Contact/Adress"); - //$head[$h][2] = 'attendees'; - //$h++; + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_contact.php", 1).'?id='.$object->id.$withProjectUrl; + $head[$h][1] = $langs->trans("ContactsAddresses"); + $head[$h][2] = 'contact'; + $h++; $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?conforboothid='.$object->id.$withProjectUrl; $head[$h][1] = $langs->trans("Attendees"); diff --git a/htdocs/install/mysql/data/llx_c_type_contact.sql b/htdocs/install/mysql/data/llx_c_type_contact.sql index f16cf5ca5df..78fdade6e9a 100644 --- a/htdocs/install/mysql/data/llx_c_type_contact.sql +++ b/htdocs/install/mysql/data/llx_c_type_contact.sql @@ -93,9 +93,12 @@ INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, m INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, module) VALUES(158, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1, NULL); -- Supplier proposal - insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110, 'supplier_proposal', 'internal', 'SALESREPFOLL', 'Responsable suivi de la demande', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (111, 'supplier_proposal', 'external', 'BILLING', 'Contact fournisseur facturation', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (112, 'supplier_proposal', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (113, 'supplier_proposal', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); +-- Event Organization +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (210, 'conferenceorbooth', 'internal', 'MANAGER', 'Conference or Booth manager', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (211, 'conferenceorbooth', 'external', 'SPEAKER', 'Conference Speaker', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (212, 'conferenceorbooth', 'external', 'RESPONSIBLE', 'Booth responsible', 1); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index af32340170e..ab7ed5b8423 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -359,3 +359,8 @@ ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (f UPDATE llx_propal SET fk_user_signature = fk_user_cloture WHERE fk_user_signature IS NULL AND fk_user_cloture IS NOT NULL; UPDATE llx_propal SET date_signature = date_cloture WHERE date_signature IS NULL AND date_cloture IS NOT NULL; + + +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (210, 'conferenceorbooth', 'internal', 'MANAGER', 'Conference or Booth manager', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (211, 'conferenceorbooth', 'external', 'SPEAKER', 'Conference Speaker', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (212, 'conferenceorbooth', 'external', 'RESPONSIBLE', 'Booth responsible', 1); From c23610f851b5840452d4c4003cb7306ade428322 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 13:31:03 +0200 Subject: [PATCH 202/233] Rename const --- htdocs/core/customreports.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index c5e0137b98d..e178bd393f9 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -15,7 +15,7 @@ * along with this program. If not, see . * * Note: This tool can be included into a list page with : - * define('USE_CUSTOME_REPORT_AS_INCLUDE', 1); + * define('USE_CUSTOM_REPORT_AS_INCLUDE', 1); * include DOL_DOCUMENT_ROOT.'/core/customreports.php'; */ @@ -25,7 +25,7 @@ * \brief Page to make custom reports */ -if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { +if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) { require '../main.inc.php'; // Get parameters @@ -194,7 +194,7 @@ $arrayofvaluesforgroupby = array(); $form = new Form($db); $formother = new FormOther($db); -if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { +if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) { llxHeader('', $langs->transnoentitiesnoconv('CustomReports'), ''); print dol_get_fiche_head($head, 'customreports', $title, -1, $picto); @@ -790,7 +790,7 @@ if ($sql) { print '
    '; -if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { +if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) { print dol_get_fiche_end(); } From b23712667914853b0b82ac22a8109d8c7a6e8b6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 13:33:41 +0200 Subject: [PATCH 203/233] Clean code --- htdocs/core/customreports.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index e178bd393f9..ca6e61e3b1c 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -151,8 +151,6 @@ if ($user->socid > 0) { // Protection if external user accessforbidden(); } -$result = restrictedArea($user, $object->element, 0, ''); - // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); //$extrafields->fetch_name_optionals_label($object->table_element_line); @@ -177,6 +175,7 @@ $arrayofgroupby = array(); $arrayofyaxis = array(); $arrayofvaluesforgroupby = array(); +$result = restrictedArea($user, $object->element, 0, ''); /* From 0a03ee5cd4cb3b391f2a9910fadb71d233973857 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 15:44:06 +0200 Subject: [PATCH 204/233] Comment --- .../install/mysql/tables/llx_c_ticket_category.sql | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.sql index 317be25e142..10d16331a06 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_category.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_category.sql @@ -1,4 +1,5 @@ -- Copyright (C) 2013-2018 Jean-François FERRY +-- Copyright (C) 2020-2021 Laurent Destailleur -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -12,20 +13,22 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . + -- --- +-- Table with the categories of a ticket +-- create table llx_c_ticket_category ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1, - code varchar(32) NOT NULL, + code varchar(32) NOT NULL, -- Example: TIGRP-COMMERCIAL, TIGRP-TECHNICALISSUE, ... label varchar(128) NOT NULL, - pos integer DEFAULT 0 NOT NULL, public integer DEFAULT 0, use_default integer DEFAULT 1, - active integer DEFAULT 1, fk_parent integer DEFAULT 0 NOT NULL, -- Parent group force_severity varchar(32) NULL, -- To force the severity if we choosed this category - description varchar(255) + description varchar(255), -- A long description of ticket + pos integer DEFAULT 0 NOT NULL, + active integer DEFAULT 1 )ENGINE=innodb; From 9677d35aca5e88aba9f275dac25ccd4730a5c617 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:18:14 +0200 Subject: [PATCH 205/233] Update llx_10_c_regions.sql --- .../install/mysql/data/llx_10_c_regions.sql | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index b054ca383ef..09981e7d339 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -47,6 +47,17 @@ -- 7 United Kingdom (NOT England) -- +-- CONTENT ------------------------------------------------------------------- +-- +-- Algeria +-- Argentina +-- Australia +-- Austria +-- Barbados +-- Belgium +-- Bolivia +-- Brazil + -- TEMPLATE ---------------------------------------------------------------------------------------- insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 0, 0, '0',0,'-'); @@ -73,7 +84,7 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4 -- Barbados Regions (id country=46) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 46, 4601, '', 0, 'Barbados'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 46, 4601, '', 0, 'Barbados'); -- Belgium Regions (id country=2) @@ -82,6 +93,18 @@ insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2 insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2, 203, '',3,'Bruxelles-Capitale'); +-- Bolivia Regions (id country=52) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5201, '', 0, 'Chuquisaca'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5202, '', 0, 'La Paz'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5203, '', 0, 'Cochabamba'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5204, '', 0, 'Oruro'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5205, '', 0, 'Potosí'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5206, '', 0, 'Tarija'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5207, '', 0, 'Santa Cruz'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5208, '', 0, 'El Beni'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5209, '', 0, 'Pando'); + + -- Brazil Regions (id country=56) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 56, 5601, '', 0, 'Brasil'); @@ -90,6 +113,10 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 5 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 14, 1401, '', 0, 'Canada'); +-- Colombie Regions (id country=70) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 70, 7001, '', 0, 'Colombie'); + + -- Regions France (id country=1) insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 1,'97105',3,'Guadeloupe'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 2,'97209',3,'Martinique'); @@ -217,21 +244,6 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) va INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 17, 1701, '', 0,'Provincies van Nederland ', 1); --- Regions Bolivia (id country=52) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5201, '', 0, 'Chuquisaca', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5202, '', 0, 'La Paz', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5203, '', 0, 'Cochabamba', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5204, '', 0, 'Oruro', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5205, '', 0, 'Potosí', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5206, '', 0, 'Tarija', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5207, '', 0, 'Santa Cruz', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5208, '', 0, 'El Beni', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5209, '', 0, 'Pando', 1); - - --- Regions Colombie (id country=70) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 70, 7001, '', 0, 'Colombie', 1); - -- Regions Chile (id country=67) INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6701, 67, NULL, NULL, 'Tarapacá', 1); INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6702, 67, NULL, NULL, 'Antofagasta', 1); From 473134cc46b3fe1cc02cdc36651e946b4da04e9e Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:26:11 +0200 Subject: [PATCH 206/233] Update llx_20_c_departements.sql Angola - up & fix fk_region 'xx' --- .../mysql/data/llx_20_c_departements.sql | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 1b5da7602e2..d41f2a7454a 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -32,11 +32,12 @@ -- Do not concatenate the values in a single query, for the same reason. --- NOTES ----------------------------------------------------------------------- +-- NOTES/CONTENT --------------------------------------------------------------- -- Departements/Cantons/Provinces/States -- -- Algeria -- Andorra +-- Angola -- Argentina -- Australia -- Austria @@ -113,6 +114,27 @@ INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-008', 'AD700', NULL, NULL, 'Escaldes-Engordany'); +-- Angola Provinces (postal districts) (id country=35) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-ABO', NULL, NULL, 'BENGO', 'Bengo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-BGU', NULL, NULL, 'BENGUELA', 'Benguela'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-BIE', NULL, NULL, 'BIÉ', 'Bié'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CAB', NULL, NULL, 'CABINDA', 'Cabinda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CCU', NULL, NULL, 'KUANDO KUBANGO', 'Kuando Kubango'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CNO', NULL, NULL, 'KWANZA NORTE', 'Kwanza Norte'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CUS', NULL, NULL, 'KWANZA SUL', 'Kwanza Sul'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CNN', NULL, NULL, 'CUNENE', 'Cunene'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-HUA', NULL, NULL, 'HUAMBO', 'Huambo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-HUI', NULL, NULL, 'HUÍLA', 'Huila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-LUA', NULL, NULL, 'LUANDA', 'Luanda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-LNO', NULL, NULL, 'LUNDA-NORTE', 'Lunda-Norte'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-LSU',NULL, NULL, 'LUNDA-SUL', 'Lunda-Sul'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-MAL', NULL, NULL, 'MALANGE', 'Malange'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-MOX', NULL, NULL, 'MOXICO', 'Moxico'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-NAM', NULL, NULL, 'NAMÍBE', 'Namíbe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-UIG', NULL, NULL, 'UÍGE', 'Uíge'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-ZAI', NULL, NULL, 'ZAÍRE', 'Zaíre'); + + -- Argentina Provinces / provincias (id country=23) INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2301', '', 0, 'CATAMARCA', 'Catamarca'); INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2302', '', 0, 'JUJUY', 'Jujuy'); @@ -1638,25 +1660,6 @@ INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('20204', 'SI043', NULL, NULL, 'GORIZIA', 'Gorizia'); INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('20204', 'SI044', NULL, NULL, 'COASTAL–KARST', 'Coastal–Karst'); --- Provinces (postal districts) Angola (rowid country=35) -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-ABO', NULL, NULL, 'BENGO', 'Bengo'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-BGU', NULL, NULL, 'BENGUELA', 'Benguela'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-BIE', NULL, NULL, 'BIÉ', 'Bié'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CAB', NULL, NULL, 'CABINDA', 'Cabinda'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CCU', NULL, NULL, 'KUANDO KUBANGO', 'Kuando Kubango'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CNO', NULL, NULL, 'KWANZA NORTE', 'Kwanza Norte'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CUS', NULL, NULL, 'KWANZA SUL', 'Kwanza Sul'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CNN', NULL, NULL, 'CUNENE', 'Cunene'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-HUA', NULL, NULL, 'HUAMBO', 'Huambo'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-HUI', NULL, NULL, 'HUÍLA', 'Huila'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-LUA', NULL, NULL, 'LUANDA', 'Luanda'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-LNO', NULL, NULL, 'LUNDA-NORTE', 'Lunda-Norte'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-LSU',NULL, NULL, 'LUNDA-SUL', 'Lunda-Sul'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-MAL', NULL, NULL, 'MALANGE', 'Malange'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-MOX', NULL, NULL, 'MOXICO', 'Moxico'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-NAM', NULL, NULL, 'NAMÍBE', 'Namíbe'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-UIG', NULL, NULL, 'UÍGE', 'Uíge'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-ZAI', NULL, NULL, 'ZAÍRE', 'Zaíre'); -- Provinces Taiwan (rowid country=886) INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, nom) VALUES (21301, 'TW-KLU', 'KLU', NULL, '基隆市'); From 8f53ca17edaed9747bc2c61b439b2b6f16df010a Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:35:40 +0200 Subject: [PATCH 207/233] Update workstation_document.php $help_url = 'EN:Module_Workstation'; --- htdocs/workstation/workstation_document.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/workstation/workstation_document.php b/htdocs/workstation/workstation_document.php index a85dd8e0e31..2c1a9906c8e 100755 --- a/htdocs/workstation/workstation_document.php +++ b/htdocs/workstation/workstation_document.php @@ -97,8 +97,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); $title = $langs->trans("Workstation").' - '.$langs->trans("Files"); -$help_url = ''; -//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; + +$help_url = 'EN:Module_Workstation'; + llxHeader('', $title, $help_url); if ($object->id) { From 13b586f0b9ecc1638d21a818edad485786cfa27c Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:38:43 +0200 Subject: [PATCH 208/233] Update workstation_list.php $help_url = 'EN:Module_Workstation'; llxHeader('', $title, $help_url); --- htdocs/workstation/workstation_list.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 7803139ef6d..59dbfc658d3 100755 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -213,10 +213,13 @@ $formresource = new FormResource($db); $now = dol_now(); -//$help_url="EN:Module_Workstation|FR:Module_Workstation_FR|ES:Módulo_Workstation"; -$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Workstations")); +//$help_url="EN:Module_Workstation|FR:Module_Workstation_FR|ES:Módulo_Workstation"; +$help_url = 'EN:Module_Workstation'; + +llxHeader('', $title, $help_url); + // Build and execute select // -------------------------------------------------------------------- From a745aad24ba5c0ecf0343e7fde48b8008b3887bd Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:40:22 +0200 Subject: [PATCH 209/233] Update workstation_note.php $help_url = 'EN:Module_Workstation'; --- htdocs/workstation/workstation_note.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/workstation/workstation_note.php b/htdocs/workstation/workstation_note.php index 6cc6a36a3fd..f2fa055102a 100755 --- a/htdocs/workstation/workstation_note.php +++ b/htdocs/workstation/workstation_note.php @@ -75,8 +75,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); -//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; -$help_url = ''; +$help_url = 'EN:Module_Workstation'; + llxHeader('', $langs->trans('Workstation'), $help_url); if ($id > 0 || !empty($ref)) { From b988c5973f42db9c3b30292f66306cd0d7ba5a6c Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:41:49 +0200 Subject: [PATCH 210/233] Update workstation_agenda.php $help_url = 'EN:Module_Workstation'; --- htdocs/workstation/workstation_agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index 385aa3c41f1..8096aa3d771 100755 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -125,7 +125,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = ''; + $help_url = 'EN:Module_Workstation'; llxHeader('', $title, $help_url); if (!empty($conf->notification->enabled)) { From acdbd2d1722e7691d194617019c9830bb78df2f4 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:48:23 +0200 Subject: [PATCH 211/233] Create index.html --- htdocs/debugbar/class/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/debugbar/class/index.html diff --git a/htdocs/debugbar/class/index.html b/htdocs/debugbar/class/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/debugbar/class/index.html @@ -0,0 +1 @@ + From 58dda89b7abe5244cac8cc2ee592472377d0c299 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:49:00 +0200 Subject: [PATCH 212/233] Create index.html --- htdocs/debugbar/class/DataCollector/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/debugbar/class/DataCollector/index.html diff --git a/htdocs/debugbar/class/DataCollector/index.html b/htdocs/debugbar/class/DataCollector/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/index.html @@ -0,0 +1 @@ + From fbc0a0fce78388f2dead553ec63443a476991735 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:50:04 +0200 Subject: [PATCH 213/233] Create index.html --- htdocs/debugbar/js/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/debugbar/js/index.html diff --git a/htdocs/debugbar/js/index.html b/htdocs/debugbar/js/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/debugbar/js/index.html @@ -0,0 +1 @@ + From 828345b69f8007ff7176de3131c73c0bb8fe9f9d Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:58:08 +0200 Subject: [PATCH 214/233] Update contact.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit $help_url = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen'; llxHeader('', $langs->trans('Order'), $help_url); --- htdocs/expedition/contact.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 9d5b7c4a8af..cd9febc685d 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -121,7 +121,10 @@ elseif ($action == 'setaddress' && $user->rights->expedition->creer) * View */ -llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:expeditions_Clients|ES:Pedidos de clientes'); + +$help_url = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen'; + +llxHeader('', $langs->trans('Order'), $help_url); $form = new Form($db); $formcompany = new FormCompany($db); From 769ce7165049e79762b842b7f56e39ca85cd7978 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 21:04:53 +0200 Subject: [PATCH 215/233] Create index.html --- scripts/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/index.html diff --git a/scripts/index.html b/scripts/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/scripts/index.html @@ -0,0 +1 @@ + From 62129c722a977e8cd819797d6c3f3833a4d5181c Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 21:39:25 +0200 Subject: [PATCH 216/233] Update README --- build/sitemap/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/sitemap/README b/build/sitemap/README index b98b5cc48d8..a06bd58f259 100644 --- a/build/sitemap/README +++ b/build/sitemap/README @@ -1,5 +1,5 @@ # Format of sitemap file is available at -# http://www.sitemaps.org/protocol.html +# https://www.sitemaps.org/protocol.html # To build a sitemap from urllist-bing.txt, run # google-sitemapgen --config=config-bing.xml --testing From cadef101dbaaacac02b03898dcb5fd2feae6da39 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 21:40:33 +0200 Subject: [PATCH 217/233] Fix var name --- htdocs/core/boxes/box_members_by_type.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 5bc05b6fabd..c961ffe3f4a 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -93,7 +93,7 @@ class box_members_by_type extends ModeleBoxes if ($user->rights->adherent->lire) { $MembersToValidate = array(); $MembersValidated = array(); - $MemberUpToDate = array(); + $MembersUpToDate = array(); $MembersExcluded = array(); $MembersResiliated = array(); @@ -164,7 +164,7 @@ class box_members_by_type extends ModeleBoxes $i = 0; while ($i < $num2) { $objp = $this->db->fetch_object($result); - $MemberUpToDate[$objp->fk_adherent_type] = $objp->somme; + $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme; $i++; } $this->db->free($result); @@ -215,12 +215,12 @@ class box_members_by_type extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : '') . ' ' . $staticmember->LibStatut(1, 1, 0, 3), + 'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : '') . ' ' . $staticmember->LibStatut(1, 1, 0, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(1, 1, $now, 3), + 'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(1, 1, $now, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( From 05bc027f7cf0d7dfd69d067fcb89e9e08c70e115 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 21:42:02 +0200 Subject: [PATCH 218/233] Update htmldoc_en.book --- build/pdf/htmldoc_en.book | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/pdf/htmldoc_en.book b/build/pdf/htmldoc_en.book index f6c407f1bd2..5757128c7f5 100644 --- a/build/pdf/htmldoc_en.book +++ b/build/pdf/htmldoc_en.book @@ -1,4 +1,4 @@ #HTMLDOC 1.8.27 -t pdf14 -f "../../doc/dolibarr_en.pdf" --webpage --no-title --logoimage "../../doc/images/dolibarr_256x256.png" --linkcolor #2200c0 --linkstyle plain --size Universal --left 0.30in --right 0.30in --top 0.40in --bottom 0.30in --header ... --header1 ... --footer c/d --nup 1 --tocheader ... --tocfooter ... --portrait --color --no-pscommands --no-xrxcomments --compression=9 --jpeg=50 --fontsize 10.0 --fontspacing 1.0 --headingfont Helvetica --bodyfont Helvetica --headfootsize 9.0 --headfootfont Helvetica --charset iso-8859-1 --links --no-embedfonts --pagemode document --pagelayout single --firstpage p1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password "" --user-password "" --browserwidth 680 --no-strict --no-overflow -http://wiki.dolibarr.org/index.php/Main_Page -http://wiki.dolibarr.org/index.php/What_Dolibarr_Do +https://wiki.dolibarr.org/index.php/Home +https://wiki.dolibarr.org/index.php/What_Dolibarr_Does From e0cb1752083e189c492e1d05e64e37a2d1891911 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 21:49:21 +0200 Subject: [PATCH 219/233] Doxygen --- htdocs/projet/class/project.class.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7fc9646c489..ddbb92fc668 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -111,22 +111,32 @@ class Project extends CommonObject public $budget_amount; /** - * @var boolean Use to bill task spend time + * @var integer Can use projects to follow opportunities + */ + public $usage_opportunity; + + /** + * @var integer Can follow tasks on project and enter time spent on it + */ + public $usage_task; + + /** + * @var integer Use to bill task spend time */ public $usage_bill_time; // Is the time spent on project must be invoiced or not /** - * @var boolean Event organization: Use Event Organization + * @var integer Event organization: Use Event Organization */ public $usage_organize_event; /** - * @var boolean Event organization: Allow unknown people to suggest conferences + * @var integer Event organization: Allow unknown people to suggest new conferences */ public $accept_conference_suggestions; /** - * @var boolean Event organization: Allow unknown people to suggest booth + * @var integer Event organization: Allow unknown people to suggest new booth */ public $accept_booth_suggestions; From 38f1ce183143645373f9591bb1b1adcecd61f3fe Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 21:54:12 +0200 Subject: [PATCH 220/233] Update generate-product.php --- dev/initdata/generate-product.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/initdata/generate-product.php b/dev/initdata/generate-product.php index 97b02fa3ac9..ea40710824c 100755 --- a/dev/initdata/generate-product.php +++ b/dev/initdata/generate-product.php @@ -102,8 +102,8 @@ for ($s = 0; $s < GEN_NUMBER_PRODUIT; $s++) { $produit->ref = ($produit->type?'S':'P').time().$s; $produit->label = 'Label '.time().$s; $produit->description = 'Description '.time().$s; - $produit->price = mt_rand(1, 1000); - $produit->tva_tx = "19.6"; + $produit->price = mt_rand(1, 999.99); + $produit->tva_tx = "20.0"; $ret=$produit->create($user); if ($ret < 0) { print "Error $ret - ".$produit->error."\n"; From 3f090a39decc51b55508ad0c93661308d912a2fc Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 22:05:16 +0200 Subject: [PATCH 221/233] Update company_ids.txt Spain URL invalid --- dev/resources/iso-normes/company_ids.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/resources/iso-normes/company_ids.txt b/dev/resources/iso-normes/company_ids.txt index 69c2af1d665..586628a4aac 100644 --- a/dev/resources/iso-normes/company_ids.txt +++ b/dev/resources/iso-normes/company_ids.txt @@ -1,2 +1,2 @@ -Spain https://incwell.eu/en/company-formation-spain/ + France https://www.economie.gouv.fr/entreprises/numeros-identification-entreprise From 54ae4655a44a62328db85bddc845ba5a7d6324f3 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Apr 2021 22:08:26 +0200 Subject: [PATCH 222/233] Update README-DE.md --- doc/user/README-DE.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/user/README-DE.md b/doc/user/README-DE.md index ea9458f4563..4c7a635a522 100644 --- a/doc/user/README-DE.md +++ b/doc/user/README-DE.md @@ -6,7 +6,10 @@ Benutzeranleitung -------------------------------- Alle Dolibarr-Informationen sind online verfuegbar ueber die Webseiten: -https://www.dolibarr.de -oder -https://www.dolibarr.org -https://wiki.dolibarr.org + + +https://www.dolibarr.de (de) oder https://www.dolibarr.org (intl) + + +https://wiki.dolibarr.org/index.php/Hauptseite (de) + From 51ee0b07c01d1cf133a3838fa5fdafd9d990aeff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 22:32:52 +0200 Subject: [PATCH 223/233] Removed duplicate comment --- htdocs/api/class/api.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 8ddcf9f2dc3..356caa24ec2 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -237,8 +237,6 @@ class DolibarrApi // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * Check user access to a resource - * * Check access by user to a given resource * * @param string $resource element to check From 5ce9bc5801968e64c902860e89e8d2b8acaad9c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Apr 2021 23:23:44 +0200 Subject: [PATCH 224/233] FIX #yogosha5748 --- htdocs/core/lib/security.lib.php | 4 ++- htdocs/salaries/card.php | 33 +++++++++++-------- htdocs/salaries/document.php | 20 ++++++------ htdocs/salaries/info.php | 8 ++++- htdocs/salaries/list.php | 14 ++++----- htdocs/salaries/paiement_salary.php | 42 +++++++++++++++---------- htdocs/salaries/payment_salary/card.php | 3 +- htdocs/salaries/payments.php | 12 ++++--- 8 files changed, 81 insertions(+), 55 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 57e3db85402..b6b71f6d8a6 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -563,6 +563,8 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand foreach ($featuresarray as $feature) { $sql = ''; + //var_dump($feature); + // For backward compatibility if ($feature == 'member') { $feature = 'adherent'; @@ -574,7 +576,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $feature = 'projet_task'; } - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'website'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salary', 'website'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index afd152fb785..323e2c74c5a 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -45,6 +45,7 @@ if (!empty($conf->projet->enabled)) { } $id = GETPOSTINT('id'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0; @@ -63,13 +64,6 @@ $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday $label = GETPOST('label', 'alphanohtml'); $fk_user = GETPOSTINT('userid'); -// Security check -$socid = GETPOSTINT('socid'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'salaries', '', '', ''); - $object = new Salary($db); $extrafields = new ExtraFields($db); @@ -79,6 +73,18 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('salarycard', 'globalcard')); +$object = new Salary($db); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} + +// Security check +$socid = GETPOSTINT('socid'); +if ($user->socid) { + $socid = $user->socid; +} +restrictedArea($user, 'salaries', $object->id, 'salary', ''); + /** * Actions @@ -885,21 +891,22 @@ if ($id) { /* * Action bar */ + print '
    '."\n"; if ($action != 'edit') { // Reopen if ($object->paye && $user->rights->salaries->write) { - print ""; + print ""; } // Edit if ($object->paye == 0 && $user->rights->salaries->write) { - print ""; + print ""; } // Emit payment if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->salaries->write) { - print ""; + print ""; } // Classify 'paid' @@ -909,16 +916,16 @@ if ($id) { || (round($resteapayer) >= 0 && $object->amount < 0) ) && $user->rights->salaries->write) { - print ""; + print ""; } // Clone if ($user->rights->salaries->write) { - print ""; + print ""; } if (!empty($user->rights->salaries->delete) && empty($totalpaye)) { - print ''; + print ''; } else { print ''; } diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php index 9534d074d5f..5772de8af3a 100644 --- a/htdocs/salaries/document.php +++ b/htdocs/salaries/document.php @@ -44,14 +44,6 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -// Security check -$socid = GETPOST("socid", "int"); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'salaries', '', '', ''); - - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -70,13 +62,21 @@ if (!$sortfield) { $sortfield = "name"; } - $object = new Salary($db); -$object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} $upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id); $modulepart = 'salaries'; +// Security check +$socid = GETPOSTINT('socid'); +if ($user->socid) { + $socid = $user->socid; +} +restrictedArea($user, 'salaries', $object->id, 'salary', ''); + /* * Actions diff --git a/htdocs/salaries/info.php b/htdocs/salaries/info.php index e0e6aec7f3c..1b81a80189f 100644 --- a/htdocs/salaries/info.php +++ b/htdocs/salaries/info.php @@ -33,14 +33,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm")); $id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); +$object = new Salary($db); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'salaries', '', '', ''); +restrictedArea($user, 'salaries', $object->id, 'salary', ''); /* diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index d60a583c3f8..7c4f0a2cec3 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -108,13 +108,6 @@ if (!GETPOST('search_type_id', 'int')) { $childids = $user->getAllChildIds(1); -// Security check -$socid = GETPOST("socid", "int"); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'salaries', '', '', ''); - // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); @@ -161,6 +154,13 @@ $permissiontoread = $user->rights->salaries->read; $permissiontoadd = $user->rights->salaries->write; $permissiontodelete = $user->rights->salaries->delete; +// Security check +$socid = GETPOST("socid", "int"); +if ($user->socid) { + $socid = $user->socid; +} +restrictedArea($user, 'salaries', '', 'salary', ''); + /* * Actions diff --git a/htdocs/salaries/paiement_salary.php b/htdocs/salaries/paiement_salary.php index 6c282eac94d..2f4a0c85905 100644 --- a/htdocs/salaries/paiement_salary.php +++ b/htdocs/salaries/paiement_salary.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/compta/paiement_charge.php - * \ingroup tax - * \brief Page to add payment of a tax + * \file htdocs/compta/paiement_salary.php + * \ingroup salary + * \brief Page to add payment of a salary */ require '../main.inc.php'; @@ -31,16 +31,25 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->load("bills"); -$chid = GETPOST("id", 'int'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); + +$id = GETPOSTINT('id'); +$ref = GETPOST('ref', 'alpha'); $amounts = array(); +$object = new Salary($db); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} + // Security check -$socid = 0; +$socid = GETPOST("socid", "int"); if ($user->socid > 0) { $socid = $user->socid; } +restrictedArea($user, 'salaries', $object->id, 'salary', ''); /* @@ -51,7 +60,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y $error = 0; if ($cancel) { - $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$chid; + $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$id; header("Location: ".$loc); exit; } @@ -96,7 +105,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y // Create a line of payments $paiement = new PaymentSalary($db); - $paiement->chid = $chid; + $paiement->chid = $id; $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Tableau de montant $paiement->paiementtype = GETPOST("paiementtype", 'alphanohtml'); @@ -124,7 +133,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y if (!$error) { $db->commit(); - $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$chid; + $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$id; header('Location: '.$loc); exit; } else { @@ -139,15 +148,16 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y * View */ -llxHeader(); - $form = new Form($db); +$help_url = ''; + +llxHeader('', '', $help_url); + +$salary = $object; // Formulaire de creation d'un paiement de charge if ($action == 'create') { - $salary = new Salary($db); // Salary to pay - $salary->fetch($chid); $salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid; $salary->paiementtype = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype; @@ -171,15 +181,15 @@ if ($action == 'create') { print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print dol_get_fiche_head(); print ''; - print ''; + print ''; print '\n"; print '\n"; print '\n"; @@ -188,7 +198,7 @@ if ($action == 'create') { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " WHERE p.fk_salary = ".((int) $chid); + $sql .= " WHERE p.fk_salary = ".((int) $id); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/salaries/payment_salary/card.php b/htdocs/salaries/payment_salary/card.php index 51f80b23efd..ae711719585 100644 --- a/htdocs/salaries/payment_salary/card.php +++ b/htdocs/salaries/payment_salary/card.php @@ -41,14 +41,13 @@ $id = GETPOST("id", 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); if ($user->socid) $socid = $user->socid; -// TODO ajouter regle pour restreindre acces paiement -//$result = restrictedArea($user, 'facture', $id,''); $object = new PaymentSalary($db); if ($id > 0) { $result = $object->fetch($id); if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); } +restrictedArea($user, 'salaries', $object->fk_salary, 'salary', ''); // $object is payment of salary /* diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 09c90854f22..d5b8f009707 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -97,11 +97,6 @@ if (!GETPOST('search_type_id', 'int')) { $childids = $user->getAllChildIds(1); -// Security check -$socid = GETPOST("socid", "int"); -if ($user->socid) $socid = $user->socid; -$result = restrictedArea($user, 'salaries', '', '', ''); - // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); @@ -119,6 +114,13 @@ $permissiontoread = $user->rights->salaries->read; $permissiontoadd = $user->rights->salaries->write; $permissiontodelete = $user->rights->salaries->delete; +// Security check +$socid = GETPOST("socid", "int"); +if ($user->socid > 0) { + $socid = $user->socid; +} +restrictedArea($user, 'salaries', 0, 'salary', ''); + /* * Actions From 858693d6319b9eebcf72567f48b74030d4052b95 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Apr 2021 01:39:08 +0200 Subject: [PATCH 225/233] CSS --- htdocs/salaries/payments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index d5b8f009707..f0602e88a5c 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -518,7 +518,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } // Amount - print ''; + print ''; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; $totalarray['val']['totalttcfield'] += $obj->amount; From 231f4418766e017463f8571cff716962328fecf7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Apr 2021 02:11:16 +0200 Subject: [PATCH 226/233] Look and feel v14 --- htdocs/compta/sociales/card.php | 17 ++++++----- htdocs/compta/sociales/document.php | 13 ++++----- htdocs/compta/sociales/info.php | 9 ++++-- htdocs/compta/sociales/list.php | 16 +++++------ htdocs/compta/sociales/payments.php | 34 +++++++++++----------- htdocs/compta/tva/card.php | 20 ++++++++----- htdocs/compta/tva/clients.php | 31 ++++++++++---------- htdocs/compta/tva/document.php | 15 +++++----- htdocs/compta/tva/index.php | 17 +++++------ htdocs/compta/tva/info.php | 7 ++--- htdocs/compta/tva/list.php | 16 +++++------ htdocs/compta/tva/payments.php | 21 ++++++++------ htdocs/compta/tva/quadri_detail.php | 4 ++- htdocs/fourn/facture/list.php | 29 ++++++++++--------- htdocs/fourn/paiement/list.php | 44 ++++++++++++++--------------- 15 files changed, 156 insertions(+), 137 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index e4ac225a624..b2ac294021c 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -56,20 +56,23 @@ $label = GETPOST('label', 'alpha'); $actioncode = GETPOST('actioncode'); $fk_user = GETPOST('userid', 'int'); +$object = new ChargeSociales($db); +if ($id > 0) { + $object->fetch($id); +} + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); +$result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges'); -$object = new ChargeSociales($db); -/* *************************************************************************** */ -/* */ -/* Actions */ -/* */ -/* *************************************************************************** */ + +/* + * Actions + */ // Classify paid if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') { diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 542804b866c..129f7b7d685 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -45,13 +45,6 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); - - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -79,6 +72,12 @@ if ($id > 0) { $upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref); $modulepart = 'tax'; +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges'); + /* * Actions diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index 1ab9b9b0ada..eefd667b964 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -36,14 +36,17 @@ $langs->loadLangs(array('compta', 'bills')); $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); +$object = new ChargeSociales($db); +if ($id > 0) { + $object->fetch($id); +} + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); - -$object = new ChargeSociales($db); +$result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges'); /* diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 0ecdaee87a5..ffebc7dcc73 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -28,14 +28,6 @@ */ require '../../main.inc.php'; - -// Security check -$socid = isset($_GET["socid"]) ? $_GET["socid"] : ''; -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'tax', '', '', 'charges'); - require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; @@ -125,6 +117,14 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); $hookmanager->initHooks(array('sclist')); $object = new ChargeSociales($db); +// Security check +$socid = GETPOST("socid", 'int'); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges'); + + /* * Actions */ diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index e8e4102b5cc..b2ee4ffce5e 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -38,7 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; - $hookmanager = new HookManager($db); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array @@ -47,12 +46,6 @@ $hookmanager->initHooks(array('specialexpensesindex')); // Load translation files required by the page $langs->loadLangs(array('compta', 'bills', 'hrm')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); - $year = GETPOST("year", 'int'); $search_sc_type = GETPOST('search_sc_type', 'int'); @@ -60,7 +53,7 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { +if (empty($page) || $page < 0) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; @@ -73,9 +66,11 @@ if (!$sortorder) { $sortorder = "DESC"; } -if (empty($conf->tax->enabled) || empty($user->rights->tax->charges->lire)) { - accessforbidden(); +// Security check +if ($user->socid) { + $socid = $user->socid; } +$result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges'); /* @@ -104,8 +99,9 @@ $accountlinestatic = new AccountLine($db); $formsocialcontrib = new FormSocialContrib($db); $title = $langs->trans("SocialContributionsPayments"); +$help_url = ''; -llxHeader('', $title); +llxHeader('', $title, $help_url); $param = ''; @@ -300,10 +296,12 @@ while ($i < min($num, $limit)) { } // Type payment - print ''; print ''; @@ -311,12 +309,12 @@ while ($i < min($num, $limit)) { // Account if (!empty($conf->banque->enabled)) { // Bank transaction - print ''; - print ''; } + // Expected to pay - print ''; + print ''; + // Paid print ''; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index bbf4bc9ac2b..da07472719b 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -57,18 +57,21 @@ if (empty($refund)) { $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int')); +$object = new Tva($db); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('taxvatcard', 'globalcard')); + +if ($id > 0) { + $object->fetch($id); +} // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); - -$object = new Tva($db); - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('taxvatcard', 'globalcard')); +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); /** @@ -330,6 +333,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char } } + /* * View */ @@ -338,7 +342,8 @@ $form = new Form($db); $title = $langs->trans("VAT")." - ".$langs->trans("Card"); $help_url = ''; -llxHeader("", $title, $helpurl); + +llxHeader("", $title, $help_url); if ($id) { @@ -438,6 +443,7 @@ if ($action == 'create') { if (!empty($conf->banque->enabled)) { print ''; } diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 7860f7e3c02..f7b860cd792 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -65,7 +65,7 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); @@ -496,14 +496,14 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // Total HT if ($modetax != 1) { - print ''; + print ''; } // Payment @@ -523,7 +523,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); } - print price(price2num($fields['payment_amount'], 'MT')); + print ''.price(price2num($fields['payment_amount'], 'MT')).''; if (isset($fields['payment_amount'])) { print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; } @@ -532,17 +532,17 @@ if (!is_array($x_coll) || !is_array($x_paye)) { } // Total collected - print ''; + print ''; // VAT - print ''; + print ''; print ''; $subtot_coll_total_ht += $temp_ht; @@ -550,6 +550,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $x_coll_sum += $temp_vat; } } + // Total customers for this vat rate print ''; print ''; @@ -686,14 +687,14 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // Total HT if ($modetax != 1) { - print ''; + print ''; } // Payment @@ -713,7 +714,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); } - print price(price2num($fields['payment_amount'], 'MT')); + print ''.price(price2num($fields['payment_amount'], 'MT')).''; if (isset($fields['payment_amount'])) { print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; } @@ -722,17 +723,17 @@ if (!is_array($x_coll) || !is_array($x_paye)) { } // VAT paid - print ''; + print ''; // VAT - print ''; + print ''; print ''; $subtot_paye_total_ht += $temp_ht; diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 38d88fb3d12..ea06d0dca06 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -46,13 +46,6 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'tax', '', 'vat', 'charges'); - - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -71,8 +64,8 @@ if (!$sortfield) { $sortfield = "name"; } - $object = new Tva($db); + if ($id > 0) { $object->fetch($id); } @@ -80,6 +73,12 @@ if ($id > 0) { $upload_dir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($object->ref); $modulepart = 'tax-vat'; +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); + /* * Actions diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 63b834d7821..e1ac3f96a2d 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -62,7 +62,7 @@ $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); /** @@ -106,8 +106,8 @@ function pt($db, $sql, $date) if ($obj->mode == 'claimed' && !empty($previousmode)) { print ''; print '\n"; - print '\n"; - print '\n"; + print '\n"; + print '\n"; print "\n"; $amountclaimed = 0; @@ -126,8 +126,8 @@ function pt($db, $sql, $date) if ($obj->mode == 'paid') { print ''; print '\n"; - print '\n"; - print '\n"; + print '\n"; + print '\n"; print "\n"; $amountclaimed = 0; $amountpaid = 0; @@ -438,7 +438,7 @@ if ($refresh === true) { $x_coll_sum += $temp_vat; } } - print ''; + print ''; $x_paye_sum = 0; foreach (array_keys($x_paye) as $rate) { @@ -478,7 +478,7 @@ if ($refresh === true) { $x_paye_sum += $temp_vat; } } - print ''; + print ''; $subtotalcoll = $subtotalcoll + $x_coll_sum; $subtotalpaye = $subtotalpaye + $x_paye_sum; @@ -487,10 +487,11 @@ if ($refresh === true) { $total = $total + $diff; $subtotal = price2num($subtotal + $diff, 'MT'); - print '' . "\n"; + print '' . "\n"; print "\n"; print "\n"; + // Total $i++; $m++; if ($i > 2) { diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index fb3d0c62d86..96eed7ce20b 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -32,15 +32,14 @@ $langs->loadLangs(array('compta', 'bills')); $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); +$object = new Tva($db); + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); - -$object = new Tva($db); - +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); /* diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index ac9e7b55ecd..17237732cea 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -28,13 +28,6 @@ require '../../main.inc.php'; -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'tax', '', '', 'charges'); - require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -99,6 +92,13 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); $hookmanager->initHooks(array('salestaxeslist')); $object = new Tva($db); +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); + /* * Actions @@ -509,7 +509,7 @@ while ($i < min($num, $limit)) { // Amount if (!empty($arrayfields['t.amount']['checked'])) { $total = $total + $obj->amount; - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 134f840d196..57e70e70a3d 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -38,12 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'bills')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); - $mode = GETPOST("mode", 'alpha'); $year = GETPOST("year", 'int'); $filtre = GETPOST("filtre", 'alpha'); @@ -68,6 +62,15 @@ if (!$sortorder) { $sortorder = "DESC"; } +$object = new Tva($db); + +// Security check +if ($user->socid) { + $socid = $user->socid; +} +//$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); + /* * View @@ -233,11 +236,11 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // Expected to pay print ''; // Paid - print ''; + print ''; print ''; $total = $total + $obj->total; @@ -245,6 +248,8 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $totalpaye = $totalpaye + $obj->totalpaye; $i++; } + + // Total print ''; print ''; // A total here has no sense print ''; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index acf0bec8899..4b44959bc1a 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -66,12 +66,14 @@ if (empty($modetax)) { $modetax = 0; } +$object = new Tva($db); + // Security check $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); /* diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 3efc19f86cc..b5b6fc1c783 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1042,7 +1042,7 @@ if ($resql) { } print ''; $formother->select_year($year_lim ? $year_lim : -1, 'year_lim', 1, 20, 5); - print '
    '.$langs->trans("Late"); + print '
    '; print ''; } // Project @@ -1541,7 +1541,7 @@ if ($resql) { // Amount HT if (!empty($arrayfields['f.total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1552,7 +1552,7 @@ if ($resql) { } // Amount VAT if (!empty($arrayfields['f.total_vat']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1563,7 +1563,7 @@ if ($resql) { } // Amount LocalTax1 if (!empty($arrayfields['f.total_localtax1']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1574,7 +1574,7 @@ if ($resql) { } // Amount LocalTax2 if (!empty($arrayfields['f.total_localtax2']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1585,7 +1585,7 @@ if ($resql) { } // Amount TTC if (!empty($arrayfields['f.total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1612,7 +1612,7 @@ if ($resql) { } if (!empty($arrayfields['dynamount_payed']['checked'])) { - print ''; // TODO Use a denormalized field + print ''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } @@ -1652,27 +1652,27 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount VAT if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount TTC if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { - print ''; // TODO Use a denormalized field + print ''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } @@ -1680,9 +1680,9 @@ if ($resql) { // Pending amount if (!empty($arrayfields['multicurrency_rtp']['checked'])) { - print ''; // TODO Use a denormalized field + print ''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } @@ -1695,6 +1695,7 @@ if ($resql) { $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Date creation if (!empty($arrayfields['f.datec']['checked'])) { print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } From 17437670b1a3db565e5f6aba40ff94d6e61a0cfb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Apr 2021 13:24:34 +0200 Subject: [PATCH 227/233] Set include of js as async --- htdocs/core/lib/website2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index e66ef50b161..a44db7c9201 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -250,7 +250,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, // Add js $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; // Add headers $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; From e30f7fb6e602118c470afece2e969af8865ef5a2 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 16:45:53 +0200 Subject: [PATCH 228/233] Create index.html --- htdocs/modulebuilder/admin/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/modulebuilder/admin/index.html diff --git a/htdocs/modulebuilder/admin/index.html b/htdocs/modulebuilder/admin/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/admin/index.html @@ -0,0 +1 @@ + From fa1e46cc6a81253bf43408ed3fd3ea076ec5bfba Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 16:48:03 +0200 Subject: [PATCH 229/233] Create index.html --- htdocs/modulebuilder/template/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/modulebuilder/template/index.html diff --git a/htdocs/modulebuilder/template/index.html b/htdocs/modulebuilder/template/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/index.html @@ -0,0 +1 @@ + From bf59287770e11e2c16f607361295f8a966d5890e Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 17:19:16 +0200 Subject: [PATCH 230/233] Update llx_10_c_regions.sql --- .../install/mysql/data/llx_10_c_regions.sql | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 09981e7d339..f1dc9b05bf6 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -49,14 +49,19 @@ -- CONTENT ------------------------------------------------------------------- -- --- Algeria +-- Algeria -> for Departmements +-- Andorra -> for Departmements +-- Angola -> for Departmements -- Argentina --- Australia --- Austria --- Barbados +-- Australia -> for Departmements +-- Austria -> for Departmements +-- Barbados -> for Departmements -- Belgium -- Bolivia --- Brazil +-- Brazil -> for Departmements +-- Canada -> for Departmements +-- Colombie -> for Departmements + -- TEMPLATE ---------------------------------------------------------------------------------------- @@ -67,6 +72,14 @@ insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 0 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 13, 1301, '', 0, 'Algerie'); +-- Andorra Regions (id country=18) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 34, 34000, 'AD', NULL, 'Andorra'); + + +-- Angola Regions (id country=35) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 35, 35001, 'AO', NULL, 'Angola'); + + -- Argentina Regions (id country=23) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2301, '', 0, 'Norte'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2302, '', 0, 'Litoral'); @@ -364,8 +377,6 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) va -- Regions United Arab Emirates (rowid country=227) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 227, 22701, '', 0, 'United Arab Emirates', 1); --- Regions Andorra (rowid country=18) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (34, 34000, 'AD', NULL, 'Andorra'); -- Regions Hungary (rowid country=18) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (18, 183100, 'HU31', NULL, 'Northern Hungary'); @@ -420,8 +431,6 @@ insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9, 932 insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9, 933, '港',0,'香港特别行政区'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9, 934, '澳',0,'澳门特别行政区'); --- Regions Angola (rowid country=35) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (35, 35001, 'AO', NULL, 'Angola'); -- Regions Taiwan (rowid country=213) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (213, 21301, 'TW', NULL, 'Taiwan'); From 44b8ea2b5f1a0e73ea9c84e55a20879d8eed5445 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 17:38:31 +0200 Subject: [PATCH 231/233] Update llx_20_c_departements.sql Colombia Departamentos --- .../mysql/data/llx_20_c_departements.sql | 72 ++++++++++--------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index d41f2a7454a..bd5d4c15977 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -45,6 +45,7 @@ -- Belgium -- Brazil -- Canada +-- Colombia -- France -- Germany @@ -258,6 +259,42 @@ insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401,'NL','',1,'','Newfoundland and Labrador'); +-- Colombia Departamentos (id country=70) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ANT', '', 0, 'ANT', 'Antioquia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOL', '', 0, 'BOL', 'Bolívar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOY', '', 0, 'BOY', 'Boyacá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAL', '', 0, 'CAL', 'Caldas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAU', '', 0, 'CAU', 'Cauca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CUN', '', 0, 'CUN', 'Cundinamarca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'HUI', '', 0, 'HUI', 'Huila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'LAG', '', 0, 'LAG', 'La Guajira'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'MET', '', 0, 'MET', 'Meta'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'NAR', '', 0, 'NAR', 'Nariño'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'NDS', '', 0, 'NDS', 'Norte de Santander'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'SAN', '', 0, 'SAN', 'Santander'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'SUC', '', 0, 'SUC', 'Sucre'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'TOL', '', 0, 'TOL', 'Tolima'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'VAC', '', 0, 'VAC', 'Valle del Cauca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'RIS', '', 0, 'RIS', 'Risalda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ATL', '', 0, 'ATL', 'Atlántico'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'COR', '', 0, 'COR', 'Córdoba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'SAP', '', 0, 'SAP', 'San Andrés, Providencia y Santa Catalina'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ARA', '', 0, 'ARA', 'Arauca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAS', '', 0, 'CAS', 'Casanare'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'AMA', '', 0, 'AMA', 'Amazonas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAQ', '', 0, 'CAQ', 'Caquetá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CHO', '', 0, 'CHO', 'Chocó'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'GUA', '', 0, 'GUA', 'Guainía'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'GUV', '', 0, 'GUV', 'Guaviare'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'PUT', '', 0, 'PUT', 'Putumayo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'QUI', '', 0, 'QUI', 'Quindío'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'VAU', '', 0, 'VAU', 'Vaupés'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOG', '', 0, 'BOG', 'Bogotá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'VID', '', 0, 'VID', 'Vichada'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CES', '', 0, 'CES', 'Cesar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'MAG', '', 0, 'MAG', 'Magdalena'); + + -- France Departements (id country=1) insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 1,'971','97105',3,'GUADELOUPE','Guadeloupe'); insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 2,'972','97209',3,'MARTINIQUE','Martinique'); @@ -1242,41 +1279,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ZAC', 15401, '', 0, 'ZAC', 'Zacatecas', 1); --- Provinces Colombia (id country=70) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ANT', 7001, '', 0, 'ANT', 'Antioquia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOL', 7001, '', 0, 'BOL', 'Bolívar', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOY', 7001, '', 0, 'BOY', 'Boyacá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAL', 7001, '', 0, 'CAL', 'Caldas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAU', 7001, '', 0, 'CAU', 'Cauca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CUN', 7001, '', 0, 'CUN', 'Cundinamarca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('HUI', 7001, '', 0, 'HUI', 'Huila', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LAG', 7001, '', 0, 'LAG', 'La Guajira', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MET', 7001, '', 0, 'MET', 'Meta', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('NAR', 7001, '', 0, 'NAR', 'Nariño', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('NDS', 7001, '', 0, 'NDS', 'Norte de Santander', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SAN', 7001, '', 0, 'SAN', 'Santander', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SUC', 7001, '', 0, 'SUC', 'Sucre', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TOL', 7001, '', 0, 'TOL', 'Tolima', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VAC', 7001, '', 0, 'VAC', 'Valle del Cauca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RIS', 7001, '', 0, 'RIS', 'Risalda', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ATL', 7001, '', 0, 'ATL', 'Atlántico', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('COR', 7001, '', 0, 'COR', 'Córdoba', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SAP', 7001, '', 0, 'SAP', 'San Andrés, Providencia y Santa Catalina', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ARA', 7001, '', 0, 'ARA', 'Arauca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAS', 7001, '', 0, 'CAS', 'Casanare', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AMA', 7001, '', 0, 'AMA', 'Amazonas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAQ', 7001, '', 0, 'CAQ', 'Caquetá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CHO', 7001, '', 0, 'CHO', 'Chocó', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GUA', 7001, '', 0, 'GUA', 'Guainía', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GUV', 7001, '', 0, 'GUV', 'Guaviare', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PUT', 7001, '', 0, 'PUT', 'Putumayo', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('QUI', 7001, '', 0, 'QUI', 'Quindío', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VAU', 7001, '', 0, 'VAU', 'Vaupés', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOG', 7001, '', 0, 'BOG', 'Bogotá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VID', 7001, '', 0, 'VID', 'Vichada', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CES', 7001, '', 0, 'CES', 'Cesar', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MAG', 7001, '', 0, 'MAG', 'Magdalena', 1); - -- Provinces Honduras (id country=114) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AT', 11401, '', 0, 'AT', 'Atlántida', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CH', 11401, '', 0, 'CH', 'Choluteca', 1); From d72c0a1c3b3dd8ca8e5092f813a303749ee22038 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Apr 2021 17:56:16 +0200 Subject: [PATCH 232/233] Update .gitattributes *.conf text eol=lf *.jpeg binary --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index 4b0ed3d14b5..d1002263778 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,6 +18,7 @@ *.pp text eol=lf *.sh text eol=lf *.yaml text eol=lf +*.conf text eol=lf .bash_aliases text eol=lf @@ -26,6 +27,7 @@ *.ico binary *.png binary *.jpg binary +*.jpeg binary *.odt binary *.odf binary *.frm binary From 1a70aebba6bc19815552600ada0e2a2048948558 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Apr 2021 01:12:25 +0200 Subject: [PATCH 233/233] NEW Can set a target image in dolcropresize function. --- htdocs/core/lib/files.lib.php | 5 +-- htdocs/core/lib/images.lib.php | 65 +++++++++++++++++++--------------- test/phpunit/ImagesLibTest.php | 16 +++++++++ 3 files changed, 56 insertions(+), 30 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 8c73ca6fd1c..431cdffccf4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1840,14 +1840,15 @@ function deleteFilesIntoDatabaseIndex($dir, $file, $mode = 'uploaded') /** - * Convert an image file into another format. - * This need Imagick php extension. + * Convert an image file or a PDF into another image format. + * This need Imagick php extension. You can use dol_imageResizeOrCrop() for a function that need GD. * * @param string $fileinput Input file name * @param string $ext Format of target file (It is also extension added to file if fileoutput is not provided). * @param string $fileoutput Output filename * @param string $page Page number if we convert a PDF into png * @return int <0 if KO, 0=Nothing done, >0 if OK + * @see dol_imageResizeOrCrop() */ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = '') { diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 7041eabfc5e..4803b5e0770 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -97,7 +97,7 @@ function image_format_supported($file, $acceptsvg = 0) /** - * Return size of image file on disk (Supported extensions are gif, jpg, png and bmp) + * Return size of image file on disk (Supported extensions are gif, jpg, png, bmp and webp) * * @param string $file Full path name of file * @param bool $url Image with url (true or false) @@ -127,17 +127,19 @@ function dol_getImageSize($file, $url = false) /** - * Resize or crop an image file (Supported extensions are gif, jpg, png and bmp) + * Resize or crop an image file (Supported extensions are gif, jpg, png, bmp and webp) * - * @param string $file Path of file to resize/crop - * @param int $mode 0=Resize, 1=Crop - * @param int $newWidth Largeur maximum que dois faire l'image destination (0=keep ratio) - * @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio) - * @param int $src_x Position of croping image in source image (not use if mode=0) - * @param int $src_y Position of croping image in source image (not use if mode=0) - * @return string File name if OK, error message if KO + * @param string $file Path of source file to resize/crop + * @param int $mode 0=Resize, 1=Crop + * @param int $newWidth Largeur maximum que dois faire l'image destination (0=keep ratio) + * @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio) + * @param int $src_x Position of croping image in source image (not use if mode=0) + * @param int $src_y Position of croping image in source image (not use if mode=0) + * @param string $filetowrite Path of file to write (overwrite source file if not provided) + * @return string File name if OK, error message if KO + * @see dol_convert_file() */ -function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0) +function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0, $filetowrite = '') { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -159,8 +161,8 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, return 'This filename '.$file.' does not seem to be an image filename.'; } elseif (!is_numeric($newWidth) && !is_numeric($newHeight)) { return 'Wrong value for parameter newWidth or newHeight'; - } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) { - return 'At least newHeight or newWidth must be defined for resizing'; + } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0 && (empty($filetowrite) || $filetowrite == $file)) { + return 'At least newHeight or newWidth must be defined for resizing, or a target filename must be set to convert'; } elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) { return 'Both newHeight or newWidth must be defined for croping'; } @@ -172,6 +174,11 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $imgHeight = $infoImg[1]; // Hauteur de l'image if ($mode == 0) { // If resize, we check parameters + if (!empty($filetowrite) && $filetowrite != $file && $newWidth <= 0 && $newHeight <= 0) { + $newWidth = $imgWidth; + $newHeight = $imgHeight; + } + if ($newWidth <= 0) { $newWidth = intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio } @@ -280,34 +287,36 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee - $imgThumbName = $file; + $imgTargetName = ($filetowrite ? $filetowrite : $file); // Check if permission are ok - //$fp = fopen($imgThumbName, "w"); + //$fp = fopen($imgTargetName, "w"); //fclose($fp); - // Create image on disk - switch ($infoImg[2]) { - case 1: // Gif - imagegif($imgThumb, $imgThumbName); + $newExt = strtolower(pathinfo($imgTargetName, PATHINFO_EXTENSION)); + + // Create image on disk (overwrite file if exists) + switch ($newExt) { + case 'gif': // Gif + imagegif($imgThumb, $imgTargetName); break; - case 2: // Jpg - imagejpeg($imgThumb, $imgThumbName, $newquality); + case 'jpg': // Jpg + imagejpeg($imgThumb, $imgTargetName, $newquality); break; - case 3: // Png - imagepng($imgThumb, $imgThumbName, $newquality); + case 'png': // Png + imagepng($imgThumb, $imgTargetName, $newquality); break; - case 4: // Bmp - imagewbmp($imgThumb, $imgThumbName); + case 'bmp': // Bmp + imagewbmp($imgThumb, $imgTargetName); break; - case 18: // Webp - imagewebp($imgThumb, $imgThumbName, $newquality); + case 'webp': // Webp + imagewebp($imgThumb, $imgTargetName, $newquality); break; } // Set permissions on file if (!empty($conf->global->MAIN_UMASK)) { - @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + @chmod($imgTargetName, octdec($conf->global->MAIN_UMASK)); } // Free memory. This does not delete image. @@ -316,7 +325,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, clearstatcache(); // File was replaced by a modified one, so we clear file caches. - return $imgThumbName; + return $imgTargetName; } diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index d50d90b9069..5d956fcf3c7 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -152,4 +152,20 @@ class ImagesLibTest extends PHPUnit\Framework\TestCase return 1; } + + /** + * testDolImageResizeOrCrop + * + * @return int + */ + public function testDolImageResizeOrCrop() + { + global $conf; + + $file=dirname(__FILE__).'/img250x20.png'; + $filetarget=$conf->admin->dir_temp.'/img250x20.webp'; + $result = dol_imageResizeOrCrop($file, 0, 0, 0, 0, 0, $filetarget); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($filetarget, $result, 'Failed to convert into webp'); + } }
    '.$langs->trans("Ref").''.$chid.'
    '.$langs->trans("Ref").''.$id.'
    '.$langs->trans("DateStart")."".dol_print_date($salary->datesp, 'day')."
    '.$langs->trans("DateEnd")."".dol_print_date($salary->dateep, 'day')."
    '.$langs->trans("Label").''.$salary->label."
    '.price($obj->amount).''.price($obj->amount).''; + $labelpayment = ''; if ($obj->payment_code) { - print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + $labelpayment = $langs->trans("PaymentTypeShort".$obj->payment_code); } + print ''; + print $labelpayment; print ''.$obj->num_payment.''; + print ''; $accountlinestatic->id = $obj->fk_bank; print $accountlinestatic->getNomUrl(1); print ''; + print ''; if ($obj->bid > 0) { $accountstatic->id = $obj->bid; $accountstatic->ref = $obj->bref; @@ -334,12 +332,14 @@ while ($i < min($num, $limit)) { } print ''.price($obj->total).''.price($obj->total).''; if ($obj->totalpaye) { - print price($obj->totalpaye); + print ''.price($obj->totalpaye).''; } print '
    '.$langs->trans("BankAccount").''; + print img_picto('', 'bank_account', 'pictofixedwidth'); $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 1); // List of bank account available print '
    '; + print ''; print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } - print ''; + print ''; $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); - print ''; + print ''; $temp_vat = $fields['vat'] * $ratiopaymentinvoice; print price(price2num($temp_vat, 'MT'), 1); //print price($fields['vat']); - print '
    '; + print ''; print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } - print ''; + print ''; $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); - print ''; + print ''; $temp_vat = $fields['vat'] * $ratiopaymentinvoice; print price(price2num($temp_vat, 'MT'), 1); //print price($fields['vat']); - print '
    '.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."'.price($amountclaimed)."'.price($amountpaid)."
    '.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."'.price($amountclaimed)."'.price($amountpaid)."
    ' . price(price2num($x_coll_sum, 'MT')) . '' . price(price2num($x_coll_sum, 'MT')) . '' . price(price2num($x_paye_sum, 'MT')) . '' . price(price2num($x_paye_sum, 'MT')) . '' . price(price2num($diff, 'MT')) . '' . price(price2num($diff, 'MT')) . ' 
    ' . price($obj->amount) . '' . price($obj->amount) . ''.price($obj->total).''; + print ''; if ($obj->totalpaye) { print price($obj->totalpaye); } - print '
    '.$langs->trans("Total").' '.price($obj->total_ht)."'.price($obj->total_ht)."'.price($obj->total_vat)."'.price($obj->total_vat)."'.price($obj->total_localtax1)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'.price($obj->total_ttc)."'.(!empty($totalpay) ?price($totalpay, 0, $langs) : ' ').''.(!empty($totalpay) ?price($totalpay, 0, $langs) : '').''.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'.price($obj->multicurrency_total_ttc)."'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').''.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '').''; - print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ' '); - print ''; + print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ''); + print ''; diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index a876f5753b9..000b5def498 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -34,28 +34,9 @@ */ require '../../main.inc.php'; - -// Security check -if ($user->socid) { - $socid = $user->socid; -} - -// doesn't work :-( -// restrictedArea($user, 'fournisseur'); - -// doesn't work :-( -// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -// $object = new PaiementFourn($db); -// restrictedArea($user, $object->element); - -if (!$user->rights->fournisseur->facture->lire) { - accessforbidden(); -} - require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'banks', 'compta')); @@ -120,9 +101,28 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); $hookmanager->initHooks(array('paymentsupplierlist')); $object = new PaiementFourn($db); +// Security check +if ($user->socid) { + $socid = $user->socid; +} + +// doesn't work :-( +// restrictedArea($user, 'fournisseur'); +// doesn't work :-( +// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +// $object = new PaiementFourn($db); +// restrictedArea($user, $object->element); +if (empty($conf->fournisseur->enabled)) { + accessforbidden(); +} +if (!$user->rights->fournisseur->facture->lire) { + accessforbidden(); +} + + /* -* Actions -*/ + * Actions + */ $parameters = array('socid'=>$socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -520,7 +520,7 @@ while ($i < min($num, $limit)) { // Amount if (!empty($arrayfields['p.amount']['checked'])) { - print ''.price($objp->pamount).''.price($objp->pamount).'