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