dolibarr 24.0.0-beta
modProduct.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2014 Christophe Battarel <contact@altairis.fr>
9 * Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
10 * Copyright (C) 2020-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
11 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
12 * Copyright (C) 2025-2026 Frédéric France <frederic.france@free.fr>
13 * Copyright (C) 2025 Pierre Ardoin <developpeur@lesmetiersdubatiment.fr>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
36include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
37
38
43{
49 public function __construct($db)
50 {
51 global $conf, $mysoc;
52
53 $this->db = $db;
54 $this->numero = 50;
55
56 $this->family = "products";
57 $this->module_position = '26';
58 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
59 $this->name = preg_replace('/^mod/i', '', get_class($this));
60 $this->description = "Product management";
61
62 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
63 $this->version = 'dolibarr';
64
65 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
66 $this->picto = 'product';
67
68 // Data directories to create when module is enabled
69 $this->dirs = array("/product/temp");
70
71 // Dependencies
72 $this->hidden = false; // A condition to hide module
73 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
74 $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants", "modBom"); // List of module ids to disable if this one is disabled
75 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
76 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
77
78 // Config pages
79 $this->config_page_url = array("product.php@product");
80 $this->langfiles = array("products", "companies", "stocks", "bills");
81
82 // Constants
83 $this->const = [
84 [
85 "PRODUCT_CODEPRODUCT_ADDON",
86 "chaine",
87 "mod_codeproduct_leopard",
88 'Module to control product codes',
89 0,
90 ],
91 [
92
93 "PRODUCT_PRICE_UNIQ",
94 "chaine",
95 "1",
96 'pricing rule by default',
97 0,
98 ],
99 /*[
100 "PRODUCT_ADDON_PDF",
101 "chaine",
102 "standard",
103 'Default module for document generation',
104 0,
105 ],*/
106 ];
107
108 // Boxes
109 $this->boxes = array(
110 0 => array('file' => 'box_produits.php', 'enabledbydefaulton' => 'Home'),
111 1 => array('file' => 'box_produits_alerte_stock.php', 'enabledbydefaulton' => 'Home'),
112 2 => array('file' => 'box_graph_product_distribution.php', 'enabledbydefaulton' => 'Home')
113 );
114
115 // Permissions
116 $this->rights = array();
117 $this->rights_class = 'produit';
118 $r = 0;
119
120 $this->rights[$r][0] = 31; // id de la permission
121 $this->rights[$r][1] = 'Read products'; // libelle de la permission
122 $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
123 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
124 $this->rights[$r][4] = 'lire';
125 $r++;
126
127 $this->rights[$r][0] = 32; // id de la permission
128 $this->rights[$r][1] = 'Create/modify products'; // libelle de la permission
129 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
130 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
131 $this->rights[$r][4] = 'creer';
132 $r++;
133
134 $this->rights[$r][0] = 33; // id de la permission
135 $this->rights[$r][1] = 'Read prices products'; // libelle de la permission
136 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
137 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
138 $this->rights[$r][4] = 'product_advance';
139 $this->rights[$r][5] = 'read_prices';
140 $r++;
141
142 $this->rights[$r][0] = 35; // id de la permission
143 $this->rights[$r][1] = 'Read supplier prices'; // libelle de la permission
144 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
145 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
146 $this->rights[$r][4] = 'product_advance';
147 $this->rights[$r][5] = 'read_supplier_prices';
148 $r++;
149
150 // EN: Advanced permission to write supplier prices
151 $this->rights[$r][0] = 36; // id de la permission
152 $this->rights[$r][1] = 'Write supplier prices'; // libelle de la permission
153 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
154 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
155 $this->rights[$r][4] = 'product_advance';
156 $this->rights[$r][5] = 'write_supplier_prices';
157 $r++;
158
159 $this->rights[$r][0] = 34; // id de la permission
160 $this->rights[$r][1] = 'Delete products'; // libelle de la permission
161 $this->rights[$r][2] = 'd'; // type de la permission (deprecated)
162 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
163 $this->rights[$r][4] = 'supprimer';
164 $r++;
165
166 $this->rights[$r][0] = 38; // Must be same permission than in service module
167 $this->rights[$r][1] = 'Export products';
168 $this->rights[$r][2] = 'r';
169 $this->rights[$r][3] = 0;
170 $this->rights[$r][4] = 'export';
171 $r++;
172
173 $this->rights[$r][0] = 39;
174 $this->rights[$r][1] = 'Ignore minimum price';
175 $this->rights[$r][2] = 'r';
176 $this->rights[$r][3] = 0;
177 $this->rights[$r][4] = 'ignore_price_min_advance';
178 $r++;
179
180 // Menus
181 //-------
182
183 $this->menu = 1; // This module adds menu entries. They are coded into menu manager.
184 /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts
185 $r = 0;
186 $this->menu[$r] = array(
187 // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
188 'fk_menu' => 'fk_mainmenu=home,fk_leftmenu=admintools',
189 // This is a Left menu entry
190 'type' => 'left',
191 'titre' => 'ProductVatMassChange',
192 'url' => '/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools',
193 // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
194 'langs' => 'products',
195 'position' => 300,
196 // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
197 'enabled' => 'isModEnabled("product") && preg_match(\'/^(admintools|all)/\',$leftmenu)',
198 // Use 'perms'=>'$user->hasRight("mymodule","level1","level2")' if you want your menu with a permission rules
199 'perms' => '1',
200 'target' => '',
201 // 0=Menu for internal users, 1=external users, 2=both
202 'user' => 0
203 );
204 $r++;
205 */
206
207 $usenpr = 0;
208 if (is_object($mysoc)) {
209 $usenpr = $mysoc->useNPR();
210 }
211
212 // Exports
213 //--------
214 $r = 0;
215
216 $alias_product_perentity = !getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') ? "p" : "ppe";
217
218 $r++;
219 $this->export_code[$r] = $this->rights_class.'_'.$r;
220 $this->export_label[$r] = "Products"; // Translation key (used only if key ExportDataset_xxx_z not found)
221 $this->export_permission[$r] = array(array("produit", "export"));
222 $this->export_fields_array[$r] = array(
223 'p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label",
224 'p.fk_product_type' => 'Type', 'p.tosell' => "OnSell", 'p.tobuy' => "OnBuy",
225 'p.description' => "Description", 'p.url' => "PublicUrl",
226 'p.customcode' => 'CustomsCode', 'p.fk_country' => 'IDCountry',
227 $alias_product_perentity . '.accountancy_code_sell' => "ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",
228 $alias_product_perentity . '.accountancy_code_sell_export' => "ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy' => "ProductAccountancyBuyCode",
229 $alias_product_perentity . '.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",
230 'p.note' => "NotePrivate", 'p.note_public' => 'NotePublic',
231 '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",
232 'p.surface' => "Surface", 'p.surface_units' => "SurfaceUnits", 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits",
233 'p.duration' => "Duration",
234 'p.finished' => 'Nature',
235 'p.price_base_type' => "PriceBase", 'p.price' => "UnitPriceHT", 'p.price_ttc' => "UnitPriceTTC",
236 'p.price_min' => "MinPriceHT",'p.price_min_ttc' => "MinPriceTTC",
237 'p.tva_tx' => 'VATRate',
238 'p.datec' => 'DateCreation', 'p.tms' => 'DateModification'
239 );
240 if (is_object($mysoc) && $usenpr) {
241 $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';
242 }
243 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {
244 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price' => 'CostPrice'));
245 }
246 if (isModEnabled('stock')) {
247 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('e.ref' => 'DefaultWarehouse', 'p.tobatch' => 'ManageLotSerial', 'p.stock' => 'Stock', 'p.seuil_stock_alerte' => 'StockLimit', 'p.desiredstock' => 'DesiredStock', 'p.pmp' => 'PMPValue'));
248 }
249 if (isModEnabled('barcode')) {
250 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode' => 'BarCode'));
251 }
252 $keyforselect = 'product';
253 $keyforelement = 'product';
254 $keyforaliasextra = 'extra';
255 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
256 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
257 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom' => 'Supplier', 'pf.ref_fourn' => 'SupplierRef', 'pf.quantity' => 'QtyMin', 'pf.remise_percent' => 'DiscountQtyMin', 'pf.unitprice' => 'BuyingPrice', 'pf.delivery_time_days' => 'NbDaysToDelivery'));
258 }
259 if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {
260 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('group_concat(cat.label)' => 'Categories'));
261 }
262 if (getDolGlobalInt('MAIN_MULTILANGS')) {
263 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('l.lang' => 'Language', 'l.label' => 'TranslatedLabel', 'l.description' => 'TranslatedDescription', 'l.note' => 'TranslatedNote'));
264 }
265 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
266 $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
267 }
268 $this->export_TypeFields_array[$r] = array(
269 'p.ref' => "Text", 'p.label' => "Text",
270 'p.fk_product_type' => 'Numeric', 'p.tosell' => "Boolean", 'p.tobuy' => "Boolean",
271 'p.description' => "Text", 'p.url' => "Text",
272 $alias_product_perentity . '.accountancy_code_sell' => "Text", $alias_product_perentity . '.accountancy_code_sell_intra' => "Text", $alias_product_perentity . '.accountancy_code_sell_export' => "Text",
273 $alias_product_perentity . '.accountancy_code_buy' => "Text", $alias_product_perentity . '.accountancy_code_buy_intra' => "Text", $alias_product_perentity . '.accountancy_code_buy_export' => "Text",
274 'p.note' => "Text", 'p.note_public' => "Text",
275 'p.weight' => "Numeric", 'p.length' => "Numeric", 'p.width' => "Numeric", 'p.height' => "Numeric", 'p.surface' => "Numeric", 'p.volume' => "Numeric",
276 'p.customcode' => 'Text',
277 'p.duration' => "Text",
278 'p.finished' => 'Numeric',
279 'p.price_base_type' => "Text", 'p.price' => "Numeric", 'p.price_ttc' => "Numeric",
280 'p.price_min' => "Numeric", 'p.price_min_ttc' => "Numeric",
281 'p.tva_tx' => 'Numeric',
282 'p.datec' => 'Date', 'p.tms' => 'Date'
283 );
284 if (isModEnabled('stock')) {
285 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('e.ref' => 'Text', 'p.tobatch' => 'Numeric', 'p.stock' => 'Numeric', 'p.seuil_stock_alerte' => 'Numeric', 'p.desiredstock' => 'Numeric', 'p.pmp' => 'Numeric', 'p.cost_price' => 'Numeric'));
286 }
287 if (isModEnabled('barcode')) {
288 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode' => 'Text'));
289 }
290 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
291 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom' => 'Text', 'pf.ref_fourn' => 'Text', 'pf.unitprice' => 'Numeric', 'pf.quantity' => 'Numeric', 'pf.remise_percent' => 'Numeric', 'pf.delivery_time_days' => 'Numeric'));
292 }
293 if (getDolGlobalInt('MAIN_MULTILANGS')) {
294 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('l.lang' => 'Text', 'l.label' => 'Text', 'l.description' => 'Text', 'l.note' => 'Text'));
295 }
296 if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {
297 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)" => 'Text'));
298 }
299 $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
300 if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {
301 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array("group_concat(cat.label)" => 'category'));
302 }
303 if (isModEnabled('stock')) {
304 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock' => 'product', 'p.pmp' => 'product'));
305 }
306 if (isModEnabled('barcode')) {
307 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode' => 'product'));
308 }
309 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
310 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom' => 'product_supplier_ref', 'pf.ref_fourn' => 'product_supplier_ref', 'pf.unitprice' => 'product_supplier_ref', 'pf.quantity' => 'product_supplier_ref', 'pf.remise_percent' => 'product_supplier_ref', 'pf.delivery_time_days' => 'product_supplier_ref'));
311 }
312 if (getDolGlobalInt('MAIN_MULTILANGS')) {
313 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang' => 'translation', 'l.label' => 'translation', 'l.description' => 'translation', 'l.note' => 'translation'));
314 }
315 if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {
316 $this->export_dependencies_array[$r] = array('category' => 'p.rowid');
317 }
318 if (isModEnabled('stock')) {
319 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock' => 'product', 'p.pmp' => 'product'));
320 }
321 if (isModEnabled('barcode')) {
322 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode' => 'product'));
323 }
324 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
325 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom' => 'product_supplier_ref', 'pf.ref_fourn' => 'product_supplier_ref', 'pf.unitprice' => 'product_supplier_ref', 'pf.quantity' => 'product_supplier_ref', 'pf.remise_percent' => 'product_supplier_ref', 'pf.delivery_time_days' => 'product_supplier_ref'));
326 }
327 if (getDolGlobalInt('MAIN_MULTILANGS')) {
328 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('l.lang' => 'translation', 'l.label' => 'translation', 'l.description' => 'translation', 'l.note' => 'translation'));
329 }
330 if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {
331 $this->export_dependencies_array[$r] = array('category' => 'p.rowid');
332 }
333 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
334 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
335 if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
336 $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
337 }
338 if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {
339 $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';
340 }
341 if (getDolGlobalInt('MAIN_MULTILANGS')) {
342 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid';
343 }
344 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
345 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
346 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
347 }
348 if (isModEnabled('stock')) {
349 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON e.rowid = p.fk_default_warehouse';
350 }
351 $this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')';
352 if (getDolGlobalString('EXPORTTOOL_CATEGORIES')) {
353 $this->export_sql_order[$r] = ' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields"
354 }
355
356 if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
357 // Exports product multiprice
358 $r++;
359 $this->export_code[$r] = $this->rights_class.'_'.$r;
360 $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found)
361 $this->export_permission[$r] = array(array("produit", "export"));
362 $this->export_fields_array[$r] = array(
363 'p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label",
364 'pr.price_base_type' => "PriceBase", 'pr.price_level' => "PriceLevel",
365 'pr.price' => "PriceLevelUnitPriceHT", 'pr.price_ttc' => "PriceLevelUnitPriceTTC",
366 'pr.price_min' => "MinPriceLevelUnitPriceHT", 'pr.price_min_ttc' => "MinPriceLevelUnitPriceTTC",
367 'pr.tva_tx' => 'PriceLevelVATRate',
368 'pr.date_price' => 'DateCreation'
369 );
370 if (is_object($mysoc) && $usenpr) {
371 $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
372 }
373 //$this->export_TypeFields_array[$r]=array(
374 // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",
375 // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text',
376 // 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",
377 // 'p.datec'=>'Date','p.tms'=>'Date'
378 //);
379 $this->export_entities_array[$r] = array(
380 'p.rowid' => "product", 'p.ref' => "product", 'p.label' => "Label",
381 'pr.price_base_type' => "product", 'pr.price_level' => "product", 'pr.price' => "product",
382 'pr.price_ttc' => "product",
383 'pr.price_min' => "product", 'pr.price_min_ttc' => "product",
384 'pr.tva_tx' => 'product',
385 'pr.recuperableonly' => 'product',
386 'pr.date_price' => "product"
387 );
388 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
389 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
390 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity
391 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price_extrafields as extra ON pr.rowid = extra.fk_object';
392 $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
393 $this->export_sql_end[$r] .= ' AND pr.date_price = (SELECT MAX(pr2.date_price) FROM '.MAIN_DB_PREFIX.'product_price as pr2 WHERE pr2.fk_product = pr.fk_product AND pr2.price_level = pr.price_level AND pr2.entity IN ('.getEntity('product').'))'; // export only latest prices not full history
394 // $this->export_sql_end[$r] .= ' ORDER BY p.ref, pr.price_level';
395 global $keyforselect, $keyforelement, $keyforaliasextra;
396 $keyforselect = 'product_price';
397 $keyforelement = 'product';
398 $keyforaliasextra = 'extra';
399 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
400 }
401
402 if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
403 // Exports product multiprice
404 $r++;
405 $this->export_code[$r] = $this->rights_class.'_'.$r;
406 $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)
407 $this->export_permission[$r] = array(array("produit", "export"));
408 $this->export_fields_array[$r] = array('p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label",
409 's.nom' => 'ThirdParty',
410 's.code_client' => 'CodeClient',
411 'pr.date_begin' => "AppliedPricesFrom",
412 'pr.date_end' => "AppliedPricesTo",
413 'pr.price_base_type' => "PriceBase",
414 'pr.price' => "PriceUnitPriceHT", 'pr.price_ttc' => "PriceUnitPriceTTC",
415 'pr.price_min' => "MinPriceUnitPriceHT", 'pr.price_min_ttc' => "MinPriceUnitPriceTTC",
416 'pr.tva_tx' => 'PriceVATRate',
417 'pr.default_vat_code' => 'PriceVATCode',
418 'pr.discount_percent' => 'Discount',
419 'pr.datec' => 'DateCreation');
420 if (is_object($mysoc) && $usenpr) {
421 $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
422 }
423 $this->export_entities_array[$r] = array('p.rowid' => "product", 'p.ref' => "product", 'p.label' => "Label",
424 's.nom' => 'company',
425 's.code_client' => 'company',
426 'pr.date_begin' => "product",
427 'pr.date_end' => "product",
428 'pr.price_base_type' => "product", 'pr.price' => "product",
429 'pr.price_ttc' => "product",
430 'pr.price_min' => "product", 'pr.price_min_ttc' => "product",
431 'pr.tva_tx' => 'product',
432 'pr.default_vat_code' => 'product',
433 'pr.discount_percent' => 'product',
434 'pr.recuperableonly' => 'product',
435 'pr.datec' => "product");
436 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
437 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
438 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity
439 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid';
440 $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
441 }
442
443 if (getDolGlobalString('PRODUIT_SOUSPRODUITS')) {
444 // Exports virtual products
445 $r++;
446 $this->export_code[$r] = $this->rights_class.'_'.$r;
447 $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)
448 $this->export_permission[$r] = array(array("produit", "export"));
449 $this->export_fields_array[$r] = array(
450 'p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label", 'p.description' => "Description", 'p.url' => "PublicUrl",
451 $alias_product_perentity . '.accountancy_code_sell' => "ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",
452 $alias_product_perentity . '.accountancy_code_sell_export' => "ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy' => "ProductAccountancyBuyCode",
453 $alias_product_perentity . '.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",
454 'p.note' => "NotePrivate", 'p.note_public' => 'NotePublic',
455 'p.weight' => "Weight", 'p.length' => "Length", 'p.surface' => "Surface", 'p.volume' => "Volume", 'p.customcode' => 'CustomsCode',
456 'p.price_base_type' => "PriceBase", 'p.price' => "UnitPriceHT", 'p.price_ttc' => "UnitPriceTTC", 'p.tva_tx' => 'VATRate', 'p.tosell' => "OnSell",
457 'p.tobuy' => "OnBuy", 'p.datec' => 'DateCreation', 'p.tms' => 'DateModification'
458 );
459 if (isModEnabled('stock')) {
460 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock' => 'Stock', 'p.seuil_stock_alerte' => 'StockLimit', 'p.desiredstock' => 'DesiredStock', 'p.pmp' => 'PMPValue'));
461 }
462 if (isModEnabled('barcode')) {
463 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode' => 'BarCode'));
464 }
465 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty' => 'Qty', 'pa.incdec' => 'ComposedProductIncDecStock'));
466 $this->export_TypeFields_array[$r] = array(
467 'p.ref' => "Text", 'p.label' => "Text", 'p.description' => "Text", 'p.url' => "Text",
468 $alias_product_perentity . '.accountancy_code_sell' => "Text", $alias_product_perentity . '.accountancy_code_sell_intra' => "Text", $alias_product_perentity . '.accountancy_code_sell_export' => "Text",
469 $alias_product_perentity . '.accountancy_code_buy' => "Text", $alias_product_perentity . '.accountancy_code_buy_intra' => "Text", $alias_product_perentity . '.accountancy_code_buy_export' => "Text",
470 'p.note' => "Text", 'p.note_public' => "Text",
471 'p.weight' => "Numeric", 'p.length' => "Numeric", 'p.surface' => "Numeric", 'p.volume' => "Numeric", 'p.customcode' => 'Text',
472 'p.price_base_type' => "Text", 'p.price' => "Numeric", 'p.price_ttc' => "Numeric", 'p.tva_tx' => 'Numeric', 'p.tosell' => "Boolean", 'p.tobuy' => "Boolean",
473 'p.datec' => 'Date', 'p.tms' => 'Date'
474 );
475 if (isModEnabled('stock')) {
476 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock' => 'Numeric', 'p.seuil_stock_alerte' => 'Numeric', 'p.desiredstock' => 'Numeric', 'p.pmp' => 'Numeric', 'p.cost_price' => 'Numeric'));
477 }
478 if (isModEnabled('barcode')) {
479 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode' => 'Text'));
480 }
481 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty' => 'Numeric'));
482 $this->export_entities_array[$r] = array(
483 'p.rowid' => "virtualproduct", 'p.ref' => "virtualproduct", 'p.label' => "virtualproduct", 'p.description' => "virtualproduct", 'p.url' => "virtualproduct",
484 $alias_product_perentity . '.accountancy_code_sell' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_intra' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_export' => 'virtualproduct',
485 $alias_product_perentity . '.accountancy_code_buy' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_intra' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_export' => 'virtualproduct',
486 'p.note' => "virtualproduct", 'p.length' => "virtualproduct",
487 'p.surface' => "virtualproduct", 'p.volume' => "virtualproduct", 'p.weight' => "virtualproduct", 'p.customcode' => 'virtualproduct',
488 'p.price_base_type' => "virtualproduct", 'p.price' => "virtualproduct", 'p.price_ttc' => "virtualproduct", 'p.tva_tx' => "virtualproduct",
489 'p.tosell' => "virtualproduct", 'p.tobuy' => "virtualproduct", 'p.datec' => "virtualproduct", 'p.tms' => "virtualproduct"
490 );
491 if (isModEnabled('stock')) {
492 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock' => 'virtualproduct', 'p.seuil_stock_alerte' => 'virtualproduct', 'p.desiredstock' => 'virtualproduct', 'p.pmp' => 'virtualproduct'));
493 }
494 if (isModEnabled('barcode')) {
495 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode' => 'virtualproduct'));
496 }
497 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty' => "subproduct", 'pa.incdec' => 'subproduct'));
498 $keyforselect = 'product';
499 $keyforelement = 'product';
500 $keyforaliasextra = 'extra';
501 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
502 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid' => "Id", 'p2.ref' => "Ref", 'p2.label' => "Label", 'p2.description' => "Description"));
503 $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"));
504 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
505 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
506 if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
507 $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
508 }
509 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';
510 $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';
511 $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
512 $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';
513 }
514
515 // Imports
516 //--------
517 $r = 0;
518
519 // Import list of products
520
521 $r++;
522 $this->import_code[$r] = $this->rights_class.'_'.$r;
523 $this->import_label[$r] = "Products"; // Translation key
524 $this->import_icon[$r] = $this->picto;
525 $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon
526 $this->import_tables_array[$r] = array('p' => MAIN_DB_PREFIX.'product', 'extra' => MAIN_DB_PREFIX.'product_extrafields');
527 $this->import_tables_creator_array[$r] = array('p' => 'fk_user_author'); // Fields to store import user id
528 $this->import_fields_array[$r] = array(
529 'p.ref' => "Ref*",
530 'p.label' => "Label*",
531 'p.fk_product_type' => "Type*",
532 'p.tosell' => "OnSell*",
533 'p.tobuy' => "OnBuy*",
534 'p.description' => "Description",
535 'p.url' => "PublicUrl",
536 'p.customcode' => 'CustomsCode',
537 'p.fk_country' => 'CountryCode',
538 'p.accountancy_code_sell' => "ProductAccountancySellCode",
539 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",
540 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",
541 'p.accountancy_code_buy' => "ProductAccountancyBuyCode",
542 'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode",
543 'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",
544 'p.note_public' => "NotePublic",
545 'p.note' => "NotePrivate",
546 'p.weight' => "Weight",
547 'p.weight_units' => "WeightUnits",
548 'p.length' => "Length",
549 'p.length_units' => "LengthUnits",
550 'p.width' => "Width",
551 'p.width_units' => "WidthUnits",
552 'p.height' => "Height",
553 'p.height_units' => "HeightUnits",
554 'p.surface' => "Surface",
555 'p.surface_units' => "SurfaceUnits",
556 'p.volume' => "Volume",
557 'p.volume_units' => "VolumeUnits",
558 'p.duration' => "Duration", //duration of service
559 'p.finished' => 'Nature',
560 'p.price' => "SellingPriceHT", //without
561 'p.price_min' => "MinPrice",
562 'p.price_ttc' => "SellingPriceTTC", //with tax
563 'p.price_min_ttc' => "SellingMinPriceTTC",
564 'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card
565 'p.tva_tx' => 'VATRate',
566 'p.default_vat_code' => 'VATCode', // to use the correct vat line when there is several lines with the same vat rate for your country
567 'p.datec' => 'DateCreation',
568 'p.cost_price' => "CostPrice"
569 );
570
571 $this->import_convertvalue_array[$r] = array(
572 'p.weight_units' => array(
573 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
574 'classfile' => '/core/class/cunits.class.php',
575 'class' => 'CUnits',
576 'method' => 'fetch',
577 'units' => 'weight',
578 'dict' => 'DictionaryMeasuringUnits'
579 ),
580 'p.length_units' => array(
581 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
582 'classfile' => '/core/class/cunits.class.php',
583 'class' => 'CUnits',
584 'method' => 'fetch',
585 'units' => 'size',
586 'dict' => 'DictionaryMeasuringUnits'
587 ),
588 'p.width_units' => array(
589 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
590 'classfile' => '/core/class/cunits.class.php',
591 'class' => 'CUnits',
592 'method' => 'fetch',
593 'units' => 'size',
594 'dict' => 'DictionaryMeasuringUnits'
595 ),
596 'p.height_units' => array(
597 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
598 'classfile' => '/core/class/cunits.class.php',
599 'class' => 'CUnits',
600 'method' => 'fetch',
601 'units' => 'size',
602 'dict' => 'DictionaryMeasuringUnits'
603 ),
604 'p.surface_units' => array(
605 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
606 'classfile' => '/core/class/cunits.class.php',
607 'class' => 'CUnits',
608 'method' => 'fetch',
609 'units' => 'surface',
610 'dict' => 'DictionaryMeasuringUnits'
611 ),
612 'p.volume_units' => array(
613 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
614 'classfile' => '/core/class/cunits.class.php',
615 'class' => 'CUnits',
616 'method' => 'fetch',
617 'units' => 'volume',
618 'dict' => 'DictionaryMeasuringUnits'
619 ),
620 'p.fk_country' => array(
621 'rule' => 'fetchidfromcodeid',
622 'classfile' => '/core/class/ccountry.class.php',
623 'class' => 'Ccountry',
624 'method' => 'fetch',
625 'dict' => 'DictionaryCountry'
626 ),
627 'p.finished' => array(
628 'rule' => 'fetchidfromcodeorlabel',
629 'classfile' => '/core/class/cproductnature.class.php',
630 'class' => 'CProductNature',
631 'method' => 'fetch',
632 'dict' => 'DictionaryProductNature'
633 ),
634 'p.accountancy_code_sell' => array('rule' => 'accountingaccount'),
635 'p.accountancy_code_sell_intra' => array('rule' => 'accountingaccount'),
636 'p.accountancy_code_sell_export' => array('rule' => 'accountingaccount'),
637 'p.accountancy_code_buy' => array('rule' => 'accountingaccount'),
638 'p.accountancy_code_buy_intra' => array('rule' => 'accountingaccount'),
639 'p.accountancy_code_buy_export' => array('rule' => 'accountingaccount'),
640 );
641
642 $this->import_regex_array[$r] = array(
643 'p.ref' => '[^ ]',
644 'p.price_base_type' => '\AHT\z|\ATTC\z',
645 'p.tosell' => '^[0|1]$',
646 'p.tobuy' => '^[0|1]$',
647 'p.fk_product_type' => '^[0|1]$',
648 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
649 'p.recuperableonly' => '^[0|1]$',
650 );
651
652 // Complete if Stock module enabled
653 if (isModEnabled('stock')) {
654 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
655 'p.fk_default_warehouse' => 'DefaultWarehouse',
656 'p.tobatch' => 'ManageLotSerial',
657 'p.sell_or_eat_by_mandatory' => 'SellOrEatByMandatory',
658 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning
659 'p.pmp' => 'PMPValue', //weighted average price
660 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature
661 ));
662
663 $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(
664 'p.tobatch' => '^[0|1|2]$',
665 'p.sell_or_eat_by_mandatory' => '^[0-3]$'
666 ));
667
668 $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
669 'p.fk_default_warehouse' => array(
670 'rule' => 'fetchidfromref',
671 'classfile' => '/product/stock/class/entrepot.class.php',
672 'class' => 'Entrepot',
673 'method' => 'fetch',
674 'element' => 'Warehouse'
675 )
676 ));
677 }
678
679 if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
680 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
681 'p.packaging' => 'PackagingForThisProductSell',
682 ));
683 }
684
685 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {
686 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price' => 'CostPrice'));
687 }
688 if (is_object($mysoc) && $usenpr) {
689 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly' => 'NPR'));
690 }
691 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
692 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx' => 'LT1', 'p.localtax1_type' => 'LT1Type'));
693 }
694 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
695 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx' => 'LT2', 'p.localtax2_type' => 'LT2Type'));
696 }
697 if (isModEnabled('barcode')) {
698 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode' => 'BarCode'));
699 }
700 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
701 $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
702 }
703
704 // Add extra fields
705 $import_extrafield_sample = array();
706 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0, ".$conf->entity.")";
707 $resql = $this->db->query($sql);
708 if ($resql) { // This can fail when class is used on old database (during migration for example)
709 while ($obj = $this->db->fetch_object($resql)) {
710 $fieldname = 'extra.'.$obj->name;
711 $fieldlabel = ucfirst($obj->label);
712 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
713 $import_extrafield_sample[$fieldname] = $fieldlabel;
714 }
715 }
716 // End add extra fields
717 $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
718
719 // field order as per structure of table llx_product
720 $import_sample = array(
721 'p.ref' => "ref:PREF123456",
722 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),
723 'p.label' => "Product name in default language",
724 'p.description' => "Product description in default language",
725 'p.note_public' => "a public note (free text)",
726 'p.note' => "a private note (free text)",
727 'p.customcode' => 'customs code',
728 'p.fk_country' => 'FR',
729 'p.price' => "100",
730 'p.price_min' => "100",
731 'p.price_ttc' => "110",
732 'p.price_min_ttc' => "110",
733 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
734 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country
735 'p.default_vat_code' => '', // to use the correct vat line when there is several lines with the same vat rate for your country
736 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",
737 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
738 'p.fk_product_type' => "0 (product) / 1 (service)",
739 'p.duration' => "eg. 365d/12m/1y",
740 'p.url' => 'link to product (no https)',
741 'p.accountancy_code_sell' => "",
742 'p.accountancy_code_sell_intra' => "",
743 'p.accountancy_code_sell_export' => "",
744 'p.accountancy_code_buy' => "",
745 'p.accountancy_code_buy_intra' => "",
746 'p.accountancy_code_buy_export' => "",
747 'p.weight' => "",
748 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units',
749 'p.length' => "",
750 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
751 'p.width' => "",
752 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
753 'p.height' => "",
754 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
755 'p.surface' => "",
756 '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',
757 'p.volume' => "",
758 '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',
759 'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.'c_product_nature"'
760 );
761 //clauses copied from import_fields_array
762 if (isModEnabled('stock')) {
763 $import_sample = array_merge($import_sample, array(
764 'p.tobatch' => "0 (don't use) / 1 (use batch) / 2 (use serial number)",
765 'p.sell_or_eat_by_mandatory' => "0 (none) / 1 (sell-by) / 2 (eat-by) / 3 (sell+eat)",
766 'p.seuil_stock_alerte' => '',
767 'p.pmp' => '0',
768 'p.desiredstock' => ''
769 ));
770 }
771 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {
772 $import_sample = array_merge($import_sample, array('p.cost_price' => '90'));
773 }
774 if (is_object($mysoc) && $usenpr) {
775 $import_sample = array_merge($import_sample, array('p.recuperableonly' => '0'));
776 }
777 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
778 $import_sample = array_merge($import_sample, array('p.localtax1_tx' => '', 'p.localtax1_type' => ''));
779 }
780 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
781 $import_sample = array_merge($import_sample, array('p.localtax2_tx' => '', 'p.localtax2_type' => ''));
782 }
783 if (isModEnabled('barcode')) {
784 $import_sample = array_merge($import_sample, array('p.barcode' => ''));
785 }
786 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
787 $import_sample = array_merge(
788 $import_sample,
789 array(
790 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"'
791 )
792 );
793
794 if (!is_array($this->import_convertvalue_array[$r])) {
795 $this->import_convertvalue_array[$r] = array();
796 }
797 $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
798 'p.fk_unit' => array(
799 'rule' => 'fetchidfromcodeorlabel',
800 'classfile' => '/core/class/cunits.class.php',
801 'class' => 'CUnits',
802 'method' => 'fetch',
803 'dict' => 'DictionaryUnits'
804 )
805 ));
806 }
807
808 if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
809 $import_sample = array_merge($import_sample, array(
810 'p.packaging' => "2",
811 ));
812 }
813
814 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
815 $this->import_updatekeys_array[$r] = array('p.ref' => 'Ref');
816 if (isModEnabled('barcode')) {
817 $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode' => 'BarCode')); //only show/allow barcode as update key if Barcode module enabled
818 }
819
820 if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE')) {
821 // Import products limit and desired stock by product and warehouse
822 $r++;
823 $this->import_code[$r] = $this->rights_class.'_stock_by_warehouse';
824 $this->import_label[$r] = "ProductStockWarehouse"; // Translation key
825 $this->import_icon[$r] = $this->picto;
826 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
827 $this->import_tables_array[$r] = array('pwp' => MAIN_DB_PREFIX.'product_warehouse_properties');
828 $this->import_fields_array[$r] = array('pwp.fk_product' => "Product*",
829 'pwp.fk_entrepot' => "Warehouse*", 'pwp.seuil_stock_alerte' => "StockLimit",
830 'pwp.desiredstock' => "DesiredStock");
831 $this->import_regex_array[$r] = array(
832 'pwp.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product',
833 'pwp.fk_entrepot' => 'rowid@'.MAIN_DB_PREFIX.'entrepot',
834 );
835 $this->import_convertvalue_array[$r] = array(
836 'pwp.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
837 ,'pwp.fk_entrepot' => array('rule' => 'fetchidfromref', 'classfile' => '/product/stock/class/entrepot.class.php', 'class' => 'Entrepot', 'method' => 'fetch', 'element' => 'Entrepot')
838 );
839 $this->import_examplevalues_array[$r] = array('pwp.fk_product' => "ref:PRODUCT_REF or id:123456",
840 'pwp.fk_entrepot' => "ref:WAREHOUSE_REF or id:123456",
841 'pwp.seuil_stock_alerte' => "100",
842 'pwp.desiredstock' => "110"
843 );
844 $this->import_updatekeys_array[$r] = array('pwp.fk_product' => 'Product', 'pwp.fk_entrepot' => 'Warehouse');
845 }
846
847 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
848 // Import suppliers prices (note: this code is duplicated in module Service)
849 $r++;
850 $this->import_code[$r] = $this->rights_class.'_supplierprices';
851 $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key
852 $this->import_icon[$r] = $this->picto;
853 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
854 $this->import_tables_array[$r] = array('sp' => MAIN_DB_PREFIX.'product_fournisseur_price', 'extra' => MAIN_DB_PREFIX.'product_fournisseur_price_extrafields');
855 $this->import_tables_creator_array[$r] = array('sp' => 'fk_user');
856 $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields
857 'sp.fk_product' => "ProductOrService*",
858 'sp.fk_soc' => "Supplier*",
859 'sp.ref_fourn' => 'SupplierRef*',
860 'sp.quantity' => "QtyMin*",
861 'sp.tva_tx' => 'VATRate',
862 'sp.default_vat_code' => 'VATCode',
863 'sp.delivery_time_days' => 'NbDaysToDelivery',
864 'sp.supplier_reputation' => 'SupplierReputation',
865 'sp.status' => 'Status',
866 'sp.datec' => 'DateCreation'
867 );
868 if (is_object($mysoc) && $usenpr) {
869 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly' => 'VATNPR'));
870 }
871 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
872 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx' => 'LT1', 'sp.localtax1_type' => 'LT1Type'));
873 }
874 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
875 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx' => 'LT2', 'sp.localtax2_type' => 'LT2Type'));
876 }
877 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
878 'sp.price' => "PriceQtyMinHT*",
879 'sp.unitprice' => 'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
880 'sp.remise_percent' => 'DiscountQtyMin'
881 ));
882
883 if (isModEnabled("multicurrency")) {
884 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
885 'sp.fk_multicurrency' => 'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line
886 'sp.multicurrency_code' => 'CurrencyCode',
887 'sp.multicurrency_tx' => 'CurrencyRate',
888 'sp.multicurrency_unitprice' => 'CurrencyUnitPrice',
889 'sp.multicurrency_price' => 'CurrencyPrice',
890 ));
891 }
892
893 if (getDolGlobalString('PRODUCT_USE_SUPPLIER_PACKAGING')) {
894 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.packaging' => 'PackagingForThisProduct'));
895 }
896
897 // Add extra fields
898 $import_extrafield_sample = array();
899 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product_fournisseur_price' AND entity IN (0, ".$conf->entity.")";
900 $resql = $this->db->query($sql);
901 if ($resql) { // This can fail when class is used on old database (during migration for example)
902 while ($obj = $this->db->fetch_object($resql)) {
903 $fieldname = 'extra.'.$obj->name;
904 $fieldlabel = ucfirst($obj->label);
905 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
906 $import_extrafield_sample[$fieldname] = $fieldlabel;
907 }
908 }
909 // End add extra fields
910
911 // Add some field automatically (if they are not yet provided explicitly)
912 $this->import_fieldshidden_array[$r] = array(
913 'sp.datec' => 'const-'.dol_print_date(dol_now(), 'standard'),
914 'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'product_fournisseur_price'
915 ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent or 'const-xxxx')
916
917 $this->import_convertvalue_array[$r] = array(
918 'sp.fk_soc' => array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
919 'sp.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
920 );
921
922 $this->import_regex_array[$r] = array(
923 'sp.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$'
924 );
925
926 $this->import_examplevalues_array[$r] = array(
927 'sp.fk_product' => "ref:PRODUCT_REF or id:123456",
928 'sp.fk_soc' => "My Supplier",
929 'sp.ref_fourn' => "XYZ-F123456",
930 'sp.quantity' => "5",
931 'sp.tva_tx' => '10',
932 'sp.default_vat_code' => '',
933 'sp.price' => "50",
934 'sp.unitprice' => '50',
935 'sp.remise_percent' => '0',
936 'sp.delivery_time_days' => '5',
937 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER',
938 'sp.status' => '1',
939 'sp.datec' => dol_print_date(dol_now(), '%Y-%m-%d %H:%M:%S'),
940 );
941 if (is_object($mysoc) && $usenpr) {
942 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly' => ''));
943 }
944 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
945 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx' => 'LT1', 'sp.localtax1_type' => 'LT1Type'));
946 }
947 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
948 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx' => 'LT2', 'sp.localtax2_type' => 'LT2Type'));
949 }
950 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
951 'sp.price' => "50.00",
952 'sp.unitprice' => '10',
953 // TODO Make this field not required and calculate it from price and qty
954 'sp.remise_percent' => '20'
955 ));
956 if (isModEnabled("multicurrency")) {
957 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
958 'sp.fk_multicurrency' => 'eg: 2 = the rowid for code of multicurrency currency',
959 'sp.multicurrency_code' => 'GBP',
960 'sp.multicurrency_tx' => '1.12345',
961 'sp.multicurrency_unitprice' => '',
962 // TODO Make this field not required and calculate it from price and qty
963 'sp.multicurrency_price' => ''
964 ));
965 }
966 if (getDolGlobalString('PRODUCT_USE_SUPPLIER_PACKAGING')) {
967 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
968 'sp.packaging' => '10',
969 ));
970 }
971
972 $this->import_updatekeys_array[$r] = array('sp.fk_product' => 'ProductOrService', 'sp.ref_fourn' => 'SupplierRef', 'sp.fk_soc' => 'Supplier', 'sp.quantity' => "QtyMin");
973 }
974
975 if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
976 // Import products multiprices
977 $r++;
978 $this->import_code[$r] = $this->rights_class.'_multiprice';
979 $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key
980 $this->import_icon[$r] = $this->picto;
981 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
982 $this->import_tables_array[$r] = array('pr' => MAIN_DB_PREFIX.'product_price', 'extra' => MAIN_DB_PREFIX.'product_price_extrafields');
983 $this->import_tables_creator_array[$r] = array('pr' => 'fk_user_author'); // Fields to store import user id
984 $this->import_fields_array[$r] = array('pr.fk_product' => "ProductOrService*",
985 'pr.price_base_type' => "PriceBase", 'pr.price_level' => "PriceLevel",
986 'pr.price' => "PriceLevelUnitPriceHT", 'pr.price_ttc' => "PriceLevelUnitPriceTTC",
987 'pr.price_min' => "MinPriceLevelUnitPriceHT", 'pr.price_min_ttc' => "MinPriceLevelUnitPriceTTC",
988 'pr.date_price' => 'DateCreation*');
989 if (getDolGlobalString('PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL')) {
990 $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate';
991 }
992 if (is_object($mysoc) && $usenpr) {
993 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly' => 'NPR'));
994 }
995
996 // Add extra fields
997 $import_extrafield_sample = array();
998 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product_price' AND entity IN (0, ".$conf->entity.")";
999 $resql = $this->db->query($sql);
1000 if ($resql) { // This can fail when class is used on old database (during migration for example)
1001 while ($obj = $this->db->fetch_object($resql)) {
1002 $fieldname = 'extra.'.$obj->name;
1003 $fieldlabel = ucfirst($obj->label);
1004 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
1005 $import_extrafield_sample[$fieldname] = $fieldlabel;
1006 }
1007 }
1008 // End add extra fields
1009 $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'product_price'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
1010
1011 $this->import_regex_array[$r] = array(
1012 'pr.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
1013 'pr.recuperableonly' => '^[0|1]$'
1014 );
1015
1016 $this->import_convertvalue_array[$r] = array(
1017 'pr.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
1018 );
1019 $this->import_examplevalues_array[$r] = array('pr.fk_product' => "ref:PRODUCT_REF or id:123456",
1020 'pr.price_base_type' => "HT (for excl tax) or TTC (for inc tax)", 'pr.price_level' => "1",
1021 'pr.price' => "100", 'pr.price_ttc' => "110",
1022 'pr.price_min' => "100", 'pr.price_min_ttc' => "110",
1023 'pr.tva_tx' => '20',
1024 'pr.recuperableonly' => '0',
1025 'pr.date_price' => '2020-12-31');
1026 }
1027
1028
1029 if (getDolGlobalInt('PRODUIT_CUSTOMER_PRICES')) {
1030 $r++;
1031 $this->import_code[$r] = $this->rights_class.'_productcustomerprice';
1032 $this->import_label[$r] = "ProductsPricePerCustomer"; // Translation key
1033 $this->import_icon[$r] = $this->picto;
1034 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
1035 $this->import_tables_array[$r] = array('sp' => $this->db->prefix().'product_customer_price', 'extra' => $this->db->prefix().'product_customer_price_extrafields');
1036 $this->import_tables_creator_array[$r] = array('sp' => 'fk_user'); // Fields to store import user id
1037 $this->import_fields_array[$r] = array(
1038 'sp.fk_product' => "Products*",
1039 'sp.fk_soc' => "Customer*",
1040 'sp.ref_customer' => "RefCustomer",
1041 'sp.date_begin' => "AppliedPricesFrom*",
1042 'sp.date_end' => "AppliedPricesTo",
1043 'sp.tva_tx' => "VATRate*",
1044 'sp.default_vat_code' => 'VATCode',
1045 'sp.discount_percent' => 'Discount',
1046 'sp.price_base_type' => "PriceBase*",
1047 'sp.price' => "SellingUnitPriceHT*",
1048 'sp.price_min' => "SellingUnitMinPriceHT",
1049 'sp.price_ttc' => "SellingUnitPriceTTC",
1050 'sp.price_min_ttc' => "SellingUnitMinPriceTTC",
1051 'sp.datec' => "DateCreation");
1052
1053 $this->import_convertvalue_array[$r] = array(
1054 'sp.fk_soc' => array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
1055 'sp.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
1056 );
1057
1058 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
1059 $this->import_examplevalues_array[$r] = array(
1060 'sp.fk_product' => "ref:PRODUCT_REF or id:123456",
1061 'sp.fk_soc' => "My Supplier",
1062 'sp.ref_customer' => "XYZ-F123456",
1063 'sp.date_begin' => "2025-06-30",
1064 'sp.date_end' => "2027-06-30",
1065 'sp.tva_tx' => '20',
1066 'sp.default_vat_code' => '5',
1067 'sp.discount_percent' => '30',
1068 'sp.price_base_type'=> 'HT (for excl tax) or TTC (for inc tax)',
1069 'sp.price' => "100",
1070 'sp.price_min' => "80",
1071 'sp.price_ttc' => "120",
1072 'sp.price_min_ttc' => "96",
1073 'sp.datec' => "2025-09-30"
1074 );
1075 }
1076
1077 if (getDolGlobalInt('MAIN_MULTILANGS')) {
1078 // Import translations of product names and descriptions
1079 $r++;
1080 $this->import_code[$r] = $this->rights_class.'_languages';
1081 $this->import_label[$r] = "ProductsOrServicesTranslations";
1082 $this->import_icon[$r] = $this->picto;
1083 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
1084 $this->import_tables_array[$r] = array('l' => MAIN_DB_PREFIX.'product_lang');
1085 // multiline translation, one line per translation
1086 $this->import_fields_array[$r] = array('l.fk_product' => 'ProductOrService*', 'l.lang' => 'Language*', 'l.label' => 'TranslatedLabel', 'l.description' => 'TranslatedDescription');
1087 //$this->import_fields_array[$r]['l.note']='TranslatedNote';
1088 $this->import_convertvalue_array[$r] = array(
1089 'l.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
1090 );
1091 $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');
1092 $this->import_updatekeys_array[$r] = array('l.fk_product' => 'ProductOrService', 'l.lang' => 'Language');
1093 }
1094
1095 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
1096 // Import products kit
1097 $r++;
1098 $this->import_code[$r] = $this->rights_class . '_' . $r;
1099 $this->import_label[$r] = "AssociatedProducts"; // Translation key
1100 $this->import_icon[$r] = $this->picto;
1101 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
1102 $this->import_tables_array[$r] = array('pa' => MAIN_DB_PREFIX . 'product_association');
1103 $this->import_fields_array[$r] = array('pa.fk_product_pere' => 'ParentProducts', 'pa.fk_product_fils' => 'ComposedProduct', 'pa.qty' => 'Qty', 'pa.incdec' => 'ComposedProductIncDecStock', 'pa.rang' => 'rang');
1104
1105 $this->import_convertvalue_array[$r] = array(
1106 'pa.fk_product_pere' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product'),
1107 'pa.fk_product_fils' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
1108 );
1109 $this->import_examplevalues_array[$r] = array(
1110 'pa.fk_product_pere' => "ref:PREF123456",
1111 'pa.fk_product_fils' => "ref:PREF123456",
1112 'pa.qty' => "100",
1113 'pa.incdec' => "0",
1114 'pa.rang' => "1");
1115 $this->import_regex_array[$r] = array('pa.fk_product_pere' => 'rowid@'.MAIN_DB_PREFIX.'product', 'pa.fk_product_fils' => 'rowid@'.MAIN_DB_PREFIX.'product');
1116 $this->import_updatekeys_array[$r] = array('pa.fk_product_pere' => 'ref parent', 'pa.fk_product_fils' => "ref enfant");
1117 }
1118 }
1119
1120
1129 public function init($options = '')
1130 {
1131 $this->remove($options);
1132
1133 $sql = array();
1134
1135 return $this->_init($sql, $options);
1136 }
1137}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
Class descriptor of Product module.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
global $mysoc
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_now($mode='gmt')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133