dolibarr 23.0.4
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 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('p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label",
363 'pr.price_base_type' => "PriceBase", 'pr.price_level' => "PriceLevel",
364 'pr.price' => "PriceLevelUnitPriceHT", 'pr.price_ttc' => "PriceLevelUnitPriceTTC",
365 'pr.price_min' => "MinPriceLevelUnitPriceHT", 'pr.price_min_ttc' => "MinPriceLevelUnitPriceTTC",
366 'pr.tva_tx' => 'PriceLevelVATRate',
367 'pr.date_price' => 'DateCreation');
368 if (is_object($mysoc) && $usenpr) {
369 $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
370 }
371 //$this->export_TypeFields_array[$r]=array(
372 // 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",
373 // 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text',
374 // 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",
375 // 'p.datec'=>'Date','p.tms'=>'Date'
376 //);
377 $this->export_entities_array[$r] = array('p.rowid' => "product", 'p.ref' => "product", 'p.label' => "Label",
378 'pr.price_base_type' => "product", 'pr.price_level' => "product", 'pr.price' => "product",
379 'pr.price_ttc' => "product",
380 'pr.price_min' => "product", 'pr.price_min_ttc' => "product",
381 'pr.tva_tx' => 'product',
382 'pr.recuperableonly' => 'product',
383 'pr.date_price' => "product");
384 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
385 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
386 // Entity scope must be identical in the JOIN and in the MAX() subquery, else products whose latest price is in a shared entity are dropped
387 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity IN ('.getEntity('productprice').')';
388 $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
389 $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('productprice').'))'; // export only latest prices not full history
390 $this->export_sql_end[$r] .= ' ORDER BY p.ref, pr.price_level';
391 }
392
393 if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
394 // Exports product multiprice
395 $r++;
396 $this->export_code[$r] = $this->rights_class.'_'.$r;
397 $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)
398 $this->export_permission[$r] = array(array("produit", "export"));
399 $this->export_fields_array[$r] = array('p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label",
400 's.nom' => 'ThirdParty',
401 's.code_client' => 'CodeClient',
402 'pr.date_begin' => "AppliedPricesFrom",
403 'pr.date_end' => "AppliedPricesTo",
404 'pr.price_base_type' => "PriceBase",
405 'pr.price' => "PriceUnitPriceHT", 'pr.price_ttc' => "PriceUnitPriceTTC",
406 'pr.price_min' => "MinPriceUnitPriceHT", 'pr.price_min_ttc' => "MinPriceUnitPriceTTC",
407 'pr.tva_tx' => 'PriceVATRate',
408 'pr.default_vat_code' => 'PriceVATCode',
409 'pr.discount_percent' => 'Discount',
410 'pr.datec' => 'DateCreation');
411 if (is_object($mysoc) && $usenpr) {
412 $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
413 }
414 $this->export_entities_array[$r] = array('p.rowid' => "product", 'p.ref' => "product", 'p.label' => "Label",
415 's.nom' => 'company',
416 's.code_client' => 'company',
417 'pr.date_begin' => "product",
418 'pr.date_end' => "product",
419 'pr.price_base_type' => "product", 'pr.price' => "product",
420 'pr.price_ttc' => "product",
421 'pr.price_min' => "product", 'pr.price_min_ttc' => "product",
422 'pr.tva_tx' => 'product',
423 'pr.default_vat_code' => 'product',
424 'pr.discount_percent' => 'product',
425 'pr.recuperableonly' => 'product',
426 'pr.datec' => "product");
427 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
428 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
429 $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
430 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid';
431 $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
432 }
433
434 if (getDolGlobalString('PRODUIT_SOUSPRODUITS')) {
435 // Exports virtual products
436 $r++;
437 $this->export_code[$r] = $this->rights_class.'_'.$r;
438 $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)
439 $this->export_permission[$r] = array(array("produit", "export"));
440 $this->export_fields_array[$r] = array(
441 'p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label", 'p.description' => "Description", 'p.url' => "PublicUrl",
442 $alias_product_perentity . '.accountancy_code_sell' => "ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",
443 $alias_product_perentity . '.accountancy_code_sell_export' => "ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy' => "ProductAccountancyBuyCode",
444 $alias_product_perentity . '.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",
445 'p.note' => "NotePrivate", 'p.note_public' => 'NotePublic',
446 'p.weight' => "Weight", 'p.length' => "Length", 'p.surface' => "Surface", 'p.volume' => "Volume", 'p.customcode' => 'CustomsCode',
447 'p.price_base_type' => "PriceBase", 'p.price' => "UnitPriceHT", 'p.price_ttc' => "UnitPriceTTC", 'p.tva_tx' => 'VATRate', 'p.tosell' => "OnSell",
448 'p.tobuy' => "OnBuy", 'p.datec' => 'DateCreation', 'p.tms' => 'DateModification'
449 );
450 if (isModEnabled('stock')) {
451 $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'));
452 }
453 if (isModEnabled('barcode')) {
454 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode' => 'BarCode'));
455 }
456 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty' => 'Qty', 'pa.incdec' => 'ComposedProductIncDecStock'));
457 $this->export_TypeFields_array[$r] = array(
458 'p.ref' => "Text", 'p.label' => "Text", 'p.description' => "Text", 'p.url' => "Text",
459 $alias_product_perentity . '.accountancy_code_sell' => "Text", $alias_product_perentity . '.accountancy_code_sell_intra' => "Text", $alias_product_perentity . '.accountancy_code_sell_export' => "Text",
460 $alias_product_perentity . '.accountancy_code_buy' => "Text", $alias_product_perentity . '.accountancy_code_buy_intra' => "Text", $alias_product_perentity . '.accountancy_code_buy_export' => "Text",
461 'p.note' => "Text", 'p.note_public' => "Text",
462 'p.weight' => "Numeric", 'p.length' => "Numeric", 'p.surface' => "Numeric", 'p.volume' => "Numeric", 'p.customcode' => 'Text',
463 'p.price_base_type' => "Text", 'p.price' => "Numeric", 'p.price_ttc' => "Numeric", 'p.tva_tx' => 'Numeric', 'p.tosell' => "Boolean", 'p.tobuy' => "Boolean",
464 'p.datec' => 'Date', 'p.tms' => 'Date'
465 );
466 if (isModEnabled('stock')) {
467 $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'));
468 }
469 if (isModEnabled('barcode')) {
470 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode' => 'Text'));
471 }
472 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty' => 'Numeric'));
473 $this->export_entities_array[$r] = array(
474 'p.rowid' => "virtualproduct", 'p.ref' => "virtualproduct", 'p.label' => "virtualproduct", 'p.description' => "virtualproduct", 'p.url' => "virtualproduct",
475 $alias_product_perentity . '.accountancy_code_sell' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_intra' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_export' => 'virtualproduct',
476 $alias_product_perentity . '.accountancy_code_buy' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_intra' => 'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_export' => 'virtualproduct',
477 'p.note' => "virtualproduct", 'p.length' => "virtualproduct",
478 'p.surface' => "virtualproduct", 'p.volume' => "virtualproduct", 'p.weight' => "virtualproduct", 'p.customcode' => 'virtualproduct',
479 'p.price_base_type' => "virtualproduct", 'p.price' => "virtualproduct", 'p.price_ttc' => "virtualproduct", 'p.tva_tx' => "virtualproduct",
480 'p.tosell' => "virtualproduct", 'p.tobuy' => "virtualproduct", 'p.datec' => "virtualproduct", 'p.tms' => "virtualproduct"
481 );
482 if (isModEnabled('stock')) {
483 $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'));
484 }
485 if (isModEnabled('barcode')) {
486 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode' => 'virtualproduct'));
487 }
488 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty' => "subproduct", 'pa.incdec' => 'subproduct'));
489 $keyforselect = 'product';
490 $keyforelement = 'product';
491 $keyforaliasextra = 'extra';
492 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
493 $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"));
494 $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"));
495 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
496 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
497 if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
498 $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);
499 }
500 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';
501 $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';
502 $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
503 $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';
504 }
505
506 // Imports
507 //--------
508 $r = 0;
509
510 // Import list of products
511
512 $r++;
513 $this->import_code[$r] = $this->rights_class.'_'.$r;
514 $this->import_label[$r] = "Products"; // Translation key
515 $this->import_icon[$r] = $this->picto;
516 $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon
517 $this->import_tables_array[$r] = array('p' => MAIN_DB_PREFIX.'product', 'extra' => MAIN_DB_PREFIX.'product_extrafields');
518 $this->import_tables_creator_array[$r] = array('p' => 'fk_user_author'); // Fields to store import user id
519 $this->import_fields_array[$r] = array(
520 'p.ref' => "Ref*",
521 'p.label' => "Label*",
522 'p.fk_product_type' => "Type*",
523 'p.tosell' => "OnSell*",
524 'p.tobuy' => "OnBuy*",
525 'p.description' => "Description",
526 'p.url' => "PublicUrl",
527 'p.customcode' => 'CustomsCode',
528 'p.fk_country' => 'CountryCode',
529 'p.accountancy_code_sell' => "ProductAccountancySellCode",
530 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",
531 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",
532 'p.accountancy_code_buy' => "ProductAccountancyBuyCode",
533 'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode",
534 'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",
535 'p.note_public' => "NotePublic",
536 'p.note' => "NotePrivate",
537 'p.weight' => "Weight",
538 'p.weight_units' => "WeightUnits",
539 'p.length' => "Length",
540 'p.length_units' => "LengthUnits",
541 'p.width' => "Width",
542 'p.width_units' => "WidthUnits",
543 'p.height' => "Height",
544 'p.height_units' => "HeightUnits",
545 'p.surface' => "Surface",
546 'p.surface_units' => "SurfaceUnits",
547 'p.volume' => "Volume",
548 'p.volume_units' => "VolumeUnits",
549 'p.duration' => "Duration", //duration of service
550 'p.finished' => 'Nature',
551 'p.price' => "SellingPriceHT", //without
552 'p.price_min' => "MinPrice",
553 'p.price_ttc' => "SellingPriceTTC", //with tax
554 'p.price_min_ttc' => "SellingMinPriceTTC",
555 'p.price_base_type' => "PriceBaseType*", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card
556 'p.tva_tx' => 'VATRate',
557 'p.default_vat_code' => 'VATCode', // to use the correct vat line when there is several lines with the same vat rate for your country
558 'p.datec' => 'DateCreation',
559 'p.cost_price' => "CostPrice"
560 );
561
562 $this->import_convertvalue_array[$r] = array(
563 'p.weight_units' => array(
564 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
565 'classfile' => '/core/class/cunits.class.php',
566 'class' => 'CUnits',
567 'method' => 'fetch',
568 'units' => 'weight',
569 'dict' => 'DictionaryMeasuringUnits'
570 ),
571 'p.length_units' => array(
572 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
573 'classfile' => '/core/class/cunits.class.php',
574 'class' => 'CUnits',
575 'method' => 'fetch',
576 'units' => 'size',
577 'dict' => 'DictionaryMeasuringUnits'
578 ),
579 'p.width_units' => array(
580 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
581 'classfile' => '/core/class/cunits.class.php',
582 'class' => 'CUnits',
583 'method' => 'fetch',
584 'units' => 'size',
585 'dict' => 'DictionaryMeasuringUnits'
586 ),
587 'p.height_units' => array(
588 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
589 'classfile' => '/core/class/cunits.class.php',
590 'class' => 'CUnits',
591 'method' => 'fetch',
592 'units' => 'size',
593 'dict' => 'DictionaryMeasuringUnits'
594 ),
595 'p.surface_units' => array(
596 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
597 'classfile' => '/core/class/cunits.class.php',
598 'class' => 'CUnits',
599 'method' => 'fetch',
600 'units' => 'surface',
601 'dict' => 'DictionaryMeasuringUnits'
602 ),
603 'p.volume_units' => array(
604 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
605 'classfile' => '/core/class/cunits.class.php',
606 'class' => 'CUnits',
607 'method' => 'fetch',
608 'units' => 'volume',
609 'dict' => 'DictionaryMeasuringUnits'
610 ),
611 'p.fk_country' => array(
612 'rule' => 'fetchidfromcodeid',
613 'classfile' => '/core/class/ccountry.class.php',
614 'class' => 'Ccountry',
615 'method' => 'fetch',
616 'dict' => 'DictionaryCountry'
617 ),
618 'p.finished' => array(
619 'rule' => 'fetchidfromcodeorlabel',
620 'classfile' => '/core/class/cproductnature.class.php',
621 'class' => 'CProductNature',
622 'method' => 'fetch',
623 'dict' => 'DictionaryProductNature'
624 ),
625 'p.accountancy_code_sell' => array('rule' => 'accountingaccount'),
626 'p.accountancy_code_sell_intra' => array('rule' => 'accountingaccount'),
627 'p.accountancy_code_sell_export' => array('rule' => 'accountingaccount'),
628 'p.accountancy_code_buy' => array('rule' => 'accountingaccount'),
629 'p.accountancy_code_buy_intra' => array('rule' => 'accountingaccount'),
630 'p.accountancy_code_buy_export' => array('rule' => 'accountingaccount'),
631 );
632
633 $this->import_regex_array[$r] = array(
634 'p.ref' => '[^ ]',
635 'p.price_base_type' => '\AHT\z|\ATTC\z',
636 'p.tosell' => '^[0|1]$',
637 'p.tobuy' => '^[0|1]$',
638 'p.fk_product_type' => '^[0|1]$',
639 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
640 'p.recuperableonly' => '^[0|1]$',
641 );
642
643 // Complete if Stock module enabled
644 if (isModEnabled('stock')) {
645 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
646 'p.fk_default_warehouse' => 'DefaultWarehouse',
647 'p.tobatch' => 'ManageLotSerial',
648 'p.sell_or_eat_by_mandatory' => 'SellOrEatByMandatory',
649 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning
650 'p.pmp' => 'PMPValue', //weighted average price
651 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature
652 ));
653
654 $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(
655 'p.tobatch' => '^[0|1|2]$',
656 'p.sell_or_eat_by_mandatory' => '^[0-3]$'
657 ));
658
659 $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
660 'p.fk_default_warehouse' => array(
661 'rule' => 'fetchidfromref',
662 'classfile' => '/product/stock/class/entrepot.class.php',
663 'class' => 'Entrepot',
664 'method' => 'fetch',
665 'element' => 'Warehouse'
666 )
667 ));
668 }
669
670 if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
671 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
672 'p.packaging' => 'PackagingForThisProductSell',
673 ));
674 }
675
676 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {
677 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price' => 'CostPrice'));
678 }
679 if (is_object($mysoc) && $usenpr) {
680 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly' => 'NPR'));
681 }
682 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
683 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx' => 'LT1', 'p.localtax1_type' => 'LT1Type'));
684 }
685 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
686 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx' => 'LT2', 'p.localtax2_type' => 'LT2Type'));
687 }
688 if (isModEnabled('barcode')) {
689 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode' => 'BarCode'));
690 }
691 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
692 $this->import_fields_array[$r]['p.fk_unit'] = 'Unit';
693 }
694
695 // Add extra fields
696 $import_extrafield_sample = array();
697 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0, ".$conf->entity.")";
698 $resql = $this->db->query($sql);
699 if ($resql) { // This can fail when class is used on old database (during migration for example)
700 while ($obj = $this->db->fetch_object($resql)) {
701 $fieldname = 'extra.'.$obj->name;
702 $fieldlabel = ucfirst($obj->label);
703 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
704 $import_extrafield_sample[$fieldname] = $fieldlabel;
705 }
706 }
707 // End add extra fields
708 $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
709
710 // field order as per structure of table llx_product
711 $import_sample = array(
712 'p.ref' => "ref:PREF123456",
713 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),
714 'p.label' => "Product name in default language",
715 'p.description' => "Product description in default language",
716 'p.note_public' => "a public note (free text)",
717 'p.note' => "a private note (free text)",
718 'p.customcode' => 'customs code',
719 'p.fk_country' => 'FR',
720 'p.price' => "100",
721 'p.price_min' => "100",
722 'p.price_ttc' => "110",
723 'p.price_min_ttc' => "110",
724 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
725 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country
726 'p.default_vat_code' => '', // to use the correct vat line when there is several lines with the same vat rate for your country
727 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",
728 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
729 'p.fk_product_type' => "0 (product) / 1 (service)",
730 'p.duration' => "eg. 365d/12m/1y",
731 'p.url' => 'link to product (no https)',
732 'p.accountancy_code_sell' => "",
733 'p.accountancy_code_sell_intra' => "",
734 'p.accountancy_code_sell_export' => "",
735 'p.accountancy_code_buy' => "",
736 'p.accountancy_code_buy_intra' => "",
737 'p.accountancy_code_buy_export' => "",
738 'p.weight' => "",
739 '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',
740 'p.length' => "",
741 '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',
742 'p.width' => "",
743 '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',
744 'p.height' => "",
745 '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',
746 'p.surface' => "",
747 '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',
748 'p.volume' => "",
749 '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',
750 'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.'c_product_nature"'
751 );
752 //clauses copied from import_fields_array
753 if (isModEnabled('stock')) {
754 $import_sample = array_merge($import_sample, array(
755 'p.tobatch' => "0 (don't use) / 1 (use batch) / 2 (use serial number)",
756 'p.sell_or_eat_by_mandatory' => "0 (none) / 1 (sell-by) / 2 (eat-by) / 3 (sell+eat)",
757 'p.seuil_stock_alerte' => '',
758 'p.pmp' => '0',
759 'p.desiredstock' => ''
760 ));
761 }
762 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || isModEnabled('margin')) {
763 $import_sample = array_merge($import_sample, array('p.cost_price' => '90'));
764 }
765 if (is_object($mysoc) && $usenpr) {
766 $import_sample = array_merge($import_sample, array('p.recuperableonly' => '0'));
767 }
768 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
769 $import_sample = array_merge($import_sample, array('p.localtax1_tx' => '', 'p.localtax1_type' => ''));
770 }
771 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
772 $import_sample = array_merge($import_sample, array('p.localtax2_tx' => '', 'p.localtax2_type' => ''));
773 }
774 if (isModEnabled('barcode')) {
775 $import_sample = array_merge($import_sample, array('p.barcode' => ''));
776 }
777 if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
778 $import_sample = array_merge(
779 $import_sample,
780 array(
781 '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"'
782 )
783 );
784
785 if (!is_array($this->import_convertvalue_array[$r])) {
786 $this->import_convertvalue_array[$r] = array();
787 }
788 $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
789 'p.fk_unit' => array(
790 'rule' => 'fetchidfromcodeorlabel',
791 'classfile' => '/core/class/cunits.class.php',
792 'class' => 'CUnits',
793 'method' => 'fetch',
794 'dict' => 'DictionaryUnits'
795 )
796 ));
797 }
798
799 if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
800 $import_sample = array_merge($import_sample, array(
801 'p.packaging' => "2",
802 ));
803 }
804
805 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
806 $this->import_updatekeys_array[$r] = array('p.ref' => 'Ref');
807 if (isModEnabled('barcode')) {
808 $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
809 }
810
811 if (getDolGlobalString('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE')) {
812 // Import products limit and desired stock by product and warehouse
813 $r++;
814 $this->import_code[$r] = $this->rights_class.'_stock_by_warehouse';
815 $this->import_label[$r] = "ProductStockWarehouse"; // Translation key
816 $this->import_icon[$r] = $this->picto;
817 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
818 $this->import_tables_array[$r] = array('pwp' => MAIN_DB_PREFIX.'product_warehouse_properties');
819 $this->import_fields_array[$r] = array('pwp.fk_product' => "Product*",
820 'pwp.fk_entrepot' => "Warehouse*", 'pwp.seuil_stock_alerte' => "StockLimit",
821 'pwp.desiredstock' => "DesiredStock");
822 $this->import_regex_array[$r] = array(
823 'pwp.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product',
824 'pwp.fk_entrepot' => 'rowid@'.MAIN_DB_PREFIX.'entrepot',
825 );
826 $this->import_convertvalue_array[$r] = array(
827 'pwp.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
828 ,'pwp.fk_entrepot' => array('rule' => 'fetchidfromref', 'classfile' => '/product/stock/class/entrepot.class.php', 'class' => 'Entrepot', 'method' => 'fetch', 'element' => 'Entrepot')
829 );
830 $this->import_examplevalues_array[$r] = array('pwp.fk_product' => "ref:PRODUCT_REF or id:123456",
831 'pwp.fk_entrepot' => "ref:WAREHOUSE_REF or id:123456",
832 'pwp.seuil_stock_alerte' => "100",
833 'pwp.desiredstock' => "110"
834 );
835 $this->import_updatekeys_array[$r] = array('pwp.fk_product' => 'Product', 'pwp.fk_entrepot' => 'Warehouse');
836 }
837
838 if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
839 // Import suppliers prices (note: this code is duplicated in module Service)
840 $r++;
841 $this->import_code[$r] = $this->rights_class.'_supplierprices';
842 $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key
843 $this->import_icon[$r] = $this->picto;
844 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
845 $this->import_tables_array[$r] = array('sp' => MAIN_DB_PREFIX.'product_fournisseur_price', 'extra' => MAIN_DB_PREFIX.'product_fournisseur_price_extrafields');
846 $this->import_tables_creator_array[$r] = array('sp' => 'fk_user');
847 $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields
848 'sp.fk_product' => "ProductOrService*",
849 'sp.fk_soc' => "Supplier*",
850 'sp.ref_fourn' => 'SupplierRef*',
851 'sp.quantity' => "QtyMin*",
852 'sp.tva_tx' => 'VATRate',
853 'sp.default_vat_code' => 'VATCode',
854 'sp.delivery_time_days' => 'NbDaysToDelivery',
855 'sp.supplier_reputation' => 'SupplierReputation',
856 'sp.status' => 'Status',
857 'sp.datec' => 'DateCreation'
858 );
859 if (is_object($mysoc) && $usenpr) {
860 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly' => 'VATNPR'));
861 }
862 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
863 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx' => 'LT1', 'sp.localtax1_type' => 'LT1Type'));
864 }
865 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
866 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx' => 'LT2', 'sp.localtax2_type' => 'LT2Type'));
867 }
868 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
869 'sp.price' => "PriceQtyMinHT*",
870 'sp.unitprice' => 'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
871 'sp.remise_percent' => 'DiscountQtyMin'
872 ));
873
874 if (isModEnabled("multicurrency")) {
875 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
876 'sp.fk_multicurrency' => 'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line
877 'sp.multicurrency_code' => 'CurrencyCode',
878 'sp.multicurrency_tx' => 'CurrencyRate',
879 'sp.multicurrency_unitprice' => 'CurrencyUnitPrice',
880 'sp.multicurrency_price' => 'CurrencyPrice',
881 ));
882 }
883
884 if (getDolGlobalString('PRODUCT_USE_SUPPLIER_PACKAGING')) {
885 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.packaging' => 'PackagingForThisProduct'));
886 }
887
888 // Add extra fields
889 $import_extrafield_sample = array();
890 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product_fournisseur_price' AND entity IN (0, ".$conf->entity.")";
891 $resql = $this->db->query($sql);
892 if ($resql) { // This can fail when class is used on old database (during migration for example)
893 while ($obj = $this->db->fetch_object($resql)) {
894 $fieldname = 'extra.'.$obj->name;
895 $fieldlabel = ucfirst($obj->label);
896 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
897 $import_extrafield_sample[$fieldname] = $fieldlabel;
898 }
899 }
900 // End add extra fields
901
902 // Add some field automatically (if they are not yet provided explicitly)
903 $this->import_fieldshidden_array[$r] = array(
904 'sp.datec' => 'const-'.dol_print_date(dol_now(), 'standard'),
905 'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'product_fournisseur_price'
906 ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent or 'const-xxxx')
907
908 $this->import_convertvalue_array[$r] = array(
909 'sp.fk_soc' => array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
910 'sp.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
911 );
912
913 $this->import_regex_array[$r] = array(
914 '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]$'
915 );
916
917 $this->import_examplevalues_array[$r] = array(
918 'sp.fk_product' => "ref:PRODUCT_REF or id:123456",
919 'sp.fk_soc' => "My Supplier",
920 'sp.ref_fourn' => "XYZ-F123456",
921 'sp.quantity' => "5",
922 'sp.tva_tx' => '10',
923 'sp.default_vat_code' => '',
924 'sp.price' => "50",
925 'sp.unitprice' => '50',
926 'sp.remise_percent' => '0',
927 'sp.delivery_time_days' => '5',
928 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER',
929 'sp.status' => '1',
930 'sp.datec' => dol_print_date(dol_now(), '%Y-%m-%d %H:%M:%S'),
931 );
932 if (is_object($mysoc) && $usenpr) {
933 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly' => ''));
934 }
935 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
936 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx' => 'LT1', 'sp.localtax1_type' => 'LT1Type'));
937 }
938 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
939 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx' => 'LT2', 'sp.localtax2_type' => 'LT2Type'));
940 }
941 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
942 'sp.price' => "50.00",
943 'sp.unitprice' => '10',
944 // TODO Make this field not required and calculate it from price and qty
945 'sp.remise_percent' => '20'
946 ));
947 if (isModEnabled("multicurrency")) {
948 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
949 'sp.fk_multicurrency' => 'eg: 2 = the rowid for code of multicurrency currency',
950 'sp.multicurrency_code' => 'GBP',
951 'sp.multicurrency_tx' => '1.12345',
952 'sp.multicurrency_unitprice' => '',
953 // TODO Make this field not required and calculate it from price and qty
954 'sp.multicurrency_price' => ''
955 ));
956 }
957 if (getDolGlobalString('PRODUCT_USE_SUPPLIER_PACKAGING')) {
958 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
959 'sp.packaging' => '10',
960 ));
961 }
962
963 $this->import_updatekeys_array[$r] = array('sp.fk_product' => 'ProductOrService', 'sp.ref_fourn' => 'SupplierRef', 'sp.fk_soc' => 'Supplier', 'sp.quantity' => "QtyMin");
964 }
965
966 if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
967 // Import products multiprices
968 $r++;
969 $this->import_code[$r] = $this->rights_class.'_multiprice';
970 $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key
971 $this->import_icon[$r] = $this->picto;
972 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
973 $this->import_tables_array[$r] = array('pr' => MAIN_DB_PREFIX.'product_price', 'extra' => MAIN_DB_PREFIX.'product_price_extrafields');
974 $this->import_tables_creator_array[$r] = array('pr' => 'fk_user_author'); // Fields to store import user id
975 $this->import_fields_array[$r] = array('pr.fk_product' => "ProductOrService*",
976 'pr.price_base_type' => "PriceBase", 'pr.price_level' => "PriceLevel",
977 'pr.price' => "PriceLevelUnitPriceHT", 'pr.price_ttc' => "PriceLevelUnitPriceTTC",
978 'pr.price_min' => "MinPriceLevelUnitPriceHT", 'pr.price_min_ttc' => "MinPriceLevelUnitPriceTTC",
979 'pr.date_price' => 'DateCreation*');
980 if (getDolGlobalString('PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL')) {
981 $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate';
982 }
983 if (is_object($mysoc) && $usenpr) {
984 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly' => 'NPR'));
985 }
986
987 // Add extra fields
988 $import_extrafield_sample = array();
989 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'product_price' AND entity IN (0, ".$conf->entity.")";
990 $resql = $this->db->query($sql);
991 if ($resql) { // This can fail when class is used on old database (during migration for example)
992 while ($obj = $this->db->fetch_object($resql)) {
993 $fieldname = 'extra.'.$obj->name;
994 $fieldlabel = ucfirst($obj->label);
995 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
996 $import_extrafield_sample[$fieldname] = $fieldlabel;
997 }
998 }
999 // End add extra fields
1000 $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'product_price'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
1001
1002 $this->import_regex_array[$r] = array(
1003 'pr.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
1004 'pr.recuperableonly' => '^[0|1]$'
1005 );
1006
1007 $this->import_convertvalue_array[$r] = array(
1008 'pr.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
1009 );
1010 $this->import_examplevalues_array[$r] = array('pr.fk_product' => "ref:PRODUCT_REF or id:123456",
1011 'pr.price_base_type' => "HT (for excl tax) or TTC (for inc tax)", 'pr.price_level' => "1",
1012 'pr.price' => "100", 'pr.price_ttc' => "110",
1013 'pr.price_min' => "100", 'pr.price_min_ttc' => "110",
1014 'pr.tva_tx' => '20',
1015 'pr.recuperableonly' => '0',
1016 'pr.date_price' => '2020-12-31');
1017 }
1018
1019
1020 if (getDolGlobalInt('PRODUIT_CUSTOMER_PRICES')) {
1021 $r++;
1022 $this->import_code[$r] = $this->rights_class.'_productcustomerprice';
1023 $this->import_label[$r] = "ProductsPricePerCustomer"; // Translation key
1024 $this->import_icon[$r] = $this->picto;
1025 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
1026 $this->import_tables_array[$r] = array('sp' => $this->db->prefix().'product_customer_price', 'extra' => $this->db->prefix().'product_customer_price_extrafields');
1027 $this->import_tables_creator_array[$r] = array('sp' => 'fk_user'); // Fields to store import user id
1028 $this->import_fields_array[$r] = array(
1029 'sp.fk_product' => "Products*",
1030 'sp.fk_soc' => "Customer*",
1031 'sp.ref_customer' => "RefCustomer",
1032 'sp.date_begin' => "AppliedPricesFrom*",
1033 'sp.date_end' => "AppliedPricesTo",
1034 'sp.tva_tx' => "VATRate*",
1035 'sp.default_vat_code' => 'VATCode',
1036 'sp.discount_percent' => 'Discount',
1037 'sp.price_base_type' => "PriceBase*",
1038 'sp.price' => "SellingUnitPriceHT*",
1039 'sp.price_min' => "SellingUnitMinPriceHT",
1040 'sp.price_ttc' => "SellingUnitPriceTTC",
1041 'sp.price_min_ttc' => "SellingUnitMinPriceTTC",
1042 'sp.datec' => "DateCreation");
1043
1044 $this->import_convertvalue_array[$r] = array(
1045 'sp.fk_soc' => array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
1046 'sp.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
1047 );
1048
1049 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
1050 $this->import_examplevalues_array[$r] = array(
1051 'sp.fk_product' => "ref:PRODUCT_REF or id:123456",
1052 'sp.fk_soc' => "My Supplier",
1053 'sp.ref_customer' => "XYZ-F123456",
1054 'sp.date_begin' => "2025-06-30",
1055 'sp.date_end' => "2027-06-30",
1056 'sp.tva_tx' => '20',
1057 'sp.default_vat_code' => '5',
1058 'sp.discount_percent' => '30',
1059 'sp.price_base_type'=> 'HT (for excl tax) or TTC (for inc tax)',
1060 'sp.price' => "100",
1061 'sp.price_min' => "80",
1062 'sp.price_ttc' => "120",
1063 'sp.price_min_ttc' => "96",
1064 'sp.datec' => "2025-09-30"
1065 );
1066 }
1067
1068 if (getDolGlobalInt('MAIN_MULTILANGS')) {
1069 // Import translations of product names and descriptions
1070 $r++;
1071 $this->import_code[$r] = $this->rights_class.'_languages';
1072 $this->import_label[$r] = "ProductsOrServicesTranslations";
1073 $this->import_icon[$r] = $this->picto;
1074 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
1075 $this->import_tables_array[$r] = array('l' => MAIN_DB_PREFIX.'product_lang');
1076 // multiline translation, one line per translation
1077 $this->import_fields_array[$r] = array('l.fk_product' => 'ProductOrService*', 'l.lang' => 'Language*', 'l.label' => 'TranslatedLabel', 'l.description' => 'TranslatedDescription');
1078 //$this->import_fields_array[$r]['l.note']='TranslatedNote';
1079 $this->import_convertvalue_array[$r] = array(
1080 'l.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
1081 );
1082 $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');
1083 $this->import_updatekeys_array[$r] = array('l.fk_product' => 'ProductOrService', 'l.lang' => 'Language');
1084 }
1085
1086 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
1087 // Import products kit
1088 $r++;
1089 $this->import_code[$r] = $this->rights_class . '_' . $r;
1090 $this->import_label[$r] = "AssociatedProducts"; // Translation key
1091 $this->import_icon[$r] = $this->picto;
1092 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
1093 $this->import_tables_array[$r] = array('pa' => MAIN_DB_PREFIX . 'product_association');
1094 $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');
1095
1096 $this->import_convertvalue_array[$r] = array(
1097 'pa.fk_product_pere' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product'),
1098 'pa.fk_product_fils' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
1099 );
1100 $this->import_examplevalues_array[$r] = array(
1101 'pa.fk_product_pere' => "ref:PREF123456",
1102 'pa.fk_product_fils' => "ref:PREF123456",
1103 'pa.qty' => "100",
1104 'pa.incdec' => "0",
1105 'pa.rang' => "1");
1106 $this->import_regex_array[$r] = array('pa.fk_product_pere' => 'rowid@'.MAIN_DB_PREFIX.'product', 'pa.fk_product_fils' => 'rowid@'.MAIN_DB_PREFIX.'product');
1107 $this->import_updatekeys_array[$r] = array('pa.fk_product_pere' => 'ref parent', 'pa.fk_product_fils' => "ref enfant");
1108 }
1109 }
1110
1111
1120 public function init($options = '')
1121 {
1122 $this->remove($options);
1123
1124 $sql = array();
1125
1126 return $this->_init($sql, $options);
1127 }
1128}
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.
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:135