From 0e23fbc6dfd8be42a2cd417a40320b2d6ba42da3 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Fri, 4 Oct 2019 10:04:02 +0200 Subject: [PATCH 1/6] NEW add country code in import product model --- htdocs/core/modules/import/import_csv.modules.php | 8 ++++---- htdocs/core/modules/import/import_xlsx.modules.php | 8 ++++---- htdocs/core/modules/modProduct.class.php | 11 ++++++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index bde888157dd..1e4284dec7f 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -509,12 +509,12 @@ class ImportCsv extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value + if ($classinstance->id != '') // id may be 0, it is a found value { - $newval=$classinstance->code; + $newval=$classinstance->id; } else { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index a67a0c90c4b..b83199e2ac6 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -536,12 +536,12 @@ class ImportXlsx extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, '', $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value + if ($classinstance->id != '') // id may be 0, it is a found value { - $newval=$classinstance->code; + $newval=$classinstance->id; } else { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 019f5251e60..03c268d6968 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -354,6 +354,7 @@ class modProduct extends DolibarrModules 'p.note_public' => "PublicNote",//public note 'p.note' => "PrivateNote",//private note 'p.customcode' => 'CustomCode', + 'p.fk_country' => 'CountryCode', 'p.price' => "SellingPriceHT",//without 'p.price_min' => "MinPrice", 'p.price_ttc' => "SellingPriceTTC",//with tax @@ -440,7 +441,14 @@ class modProduct extends DolibarrModules 'method' => 'fetch', 'units' => 'volume', 'dict' => 'DictionaryMeasuringUnits' - ) + ), + 'p.fk_country' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/ccountry.class.php', + 'class' => 'Ccountry', + 'method' => 'fetch', + 'dict' => 'DictionaryCountry' + ) ); 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')); @@ -485,6 +493,7 @@ class modProduct extends DolibarrModules 'p.note_public' => "a public note (free text)", 'p.note' => "a private note (free text)", 'p.customcode' => 'customs code', + 'p.fk_country' => 'FR', 'p.price' => "price ex-vat eg. 100", 'p.price_min' => "price ex-vat eg. 100", 'p.price_ttc' => "price inc-vat eg. 110", From 10671e3266627c49aeeeaeb4eddb496e3c129284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 5 Oct 2019 21:15:13 +0200 Subject: [PATCH 2/6] api supplier price delete --- htdocs/product/class/api_products.class.php | 33 +++++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 866eeb116cf..da7cd9fa780 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -15,10 +15,11 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; /** * API class for products @@ -41,6 +42,11 @@ class Products extends DolibarrApi */ public $product; + /** + * @var ProductFournisseur $productsupplier {@type ProductFournisseur} + */ + public $productsupplier; + /** * Constructor */ @@ -49,6 +55,7 @@ class Products extends DolibarrApi global $db, $conf; $this->db = $db; $this->product = new Product($this->db); + $this->productsupplier = new ProductFournisseur($this->db); } /** @@ -475,7 +482,7 @@ class Products extends DolibarrApi * * @url DELETE {id}/purchase_prices/{priceid} * - * @return array + * @return int * * @throws 401 * @throws 404 @@ -494,13 +501,13 @@ class Products extends DolibarrApi if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - - if($result) { - $this->product = new ProductFournisseur($this->db); - $this->product->fetch($id); + $resultsupplier = 0; + if ($result) { + $this->productsupplier->fetch($id); + $resultsupplier = $this->product->remove_product_fournisseur_price($priceid); } - return $this->product->remove_product_fournisseur_price($priceid); + return $resultsupplier; } /** @@ -632,13 +639,13 @@ class Products extends DolibarrApi } if ($includestockdata) { - $this->product->load_stock(); + $this->product->load_stock(); } if($result) { - $this->product = new ProductFournisseur($this->db); - $this->product->fetch($id, $ref); - $this->product->list_product_fournisseur_price($id, '', '', 0, 0); + $this->product = new ProductFournisseur($this->db); + $this->product->fetch($id, $ref); + $this->product->list_product_fournisseur_price($id, '', '', 0, 0); } return $this->_cleanObjectDatas($this->product); From b895f8a78f4d03b5c6acbc0c785d79e260dc166b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 5 Oct 2019 21:19:55 +0200 Subject: [PATCH 3/6] api supplier get purchase prices --- htdocs/product/class/api_products.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index da7cd9fa780..346aef06a91 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -642,13 +642,12 @@ class Products extends DolibarrApi $this->product->load_stock(); } - if($result) { - $this->product = new ProductFournisseur($this->db); - $this->product->fetch($id, $ref); - $this->product->list_product_fournisseur_price($id, '', '', 0, 0); + if ($result) { + $this->productsupplier->fetch($id, $ref); + $this->productsupplier->list_product_fournisseur_price($id, '', '', 0, 0); } - return $this->_cleanObjectDatas($this->product); + return $this->_cleanObjectDatas($this->productsupplier); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From bfd8bc839e38565d384a29d7f78809bc3cb28906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 6 Oct 2019 10:28:09 +0200 Subject: [PATCH 4/6] Update card.php --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 4bd5ceb4d8f..4b7695bb503 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1622,7 +1622,7 @@ if ($id > 0) // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''.$langs->trans("Type").''.$object->type.''; + print ''.$langs->trans("Type").''.$langs->trans($object->type).''; } // Full day event From 8a9f08d5a39b17bf67cee2a2a0414d3431ac0c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 6 Oct 2019 11:29:24 +0200 Subject: [PATCH 5/6] lang file for holidays is holiday --- htdocs/core/modules/holiday/modules_holiday.php | 4 ++-- htdocs/holiday/document.php | 4 +--- htdocs/holiday/list.php | 2 +- htdocs/index.php | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php index 74cbb0dbfd5..c5f5dc16b25 100644 --- a/htdocs/core/modules/holiday/modules_holiday.php +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -96,7 +96,7 @@ class ModelNumRefHolidays public function info() { global $langs; - $langs->load("holidays"); + $langs->load("holiday"); return $langs->trans("NoDescription"); } @@ -108,7 +108,7 @@ class ModelNumRefHolidays public function getExample() { global $langs; - $langs->load("holidays"); + $langs->load("holiday"); return $langs->trans("NoExample"); } diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index 00bc7ac1b24..05ddf164105 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files required by the page -$langs->loadLangs(array('other', 'holidays', 'companies')); +$langs->loadLangs(array('other', 'holiday', 'companies')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -48,8 +48,6 @@ $confirm = GETPOST('confirm', 'alpha'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'holiday', $id, 'holiday'); -$langs->load("holiday"); - // Get parameters $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index cbf2e2f01aa..d6e44261fe8 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('users', 'holidays', 'hrm')); +$langs->loadLangs(array('users', 'holiday', 'hrm')); // Protection if external user if ($user->societe_id > 0) accessforbidden(); diff --git a/htdocs/index.php b/htdocs/index.php index 050058cd819..7279eebe80f 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -301,7 +301,7 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT "supplier_proposal", "projects", "trips", - "holidays", + "holiday", "donations" ); From 0b9213f4f13bd124cf957394d3ccf686003517f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 7 Oct 2019 08:11:23 +0200 Subject: [PATCH 6/6] Update contrat.class.php --- htdocs/contrat/class/contrat.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index c6462cba9b9..99a5f78691f 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2077,7 +2077,7 @@ class Contrat extends CommonObject * Return list of line rowid * * @param int $statut Status of lines to get - * @return array Array of line's rowid + * @return array|int Array of line's rowid or <0 if error */ public function array_detail($statut = -1) { @@ -2114,7 +2114,7 @@ class Contrat extends CommonObject * Return list of other contracts for same company than current contract * * @param string $option 'all' or 'others' - * @return array Array of contracts id + * @return array|int Array of contracts id or <0 if error */ public function getListOfContracts($option = 'all') {