50 $this->family =
"products";
51 $this->module_position =
'29';
53 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
57 $this->version =
'dolibarr';
59 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
60 $this->picto =
'service';
63 $this->dirs = array(
"/product/temp");
66 $this->hidden =
false;
67 $this->depends = array();
68 $this->requiredby = array();
69 $this->conflictwith = array();
70 $this->phpmin = array(7, 0);
73 $this->config_page_url = array(
"product.php@product");
74 $this->langfiles = array(
"products",
"companies",
"stocks",
"bills");
77 $this->
const = array();
81 0=>array(
'file'=>
'box_services_contracts.php',
'enabledbydefaulton'=>
'Home'),
82 1=>array(
'file'=>
'box_graph_product_distribution.php',
'enabledbydefaulton'=>
'Home')
86 $this->rights = array();
87 $this->rights_class =
'service';
90 $this->rights[$r][0] = 531;
91 $this->rights[$r][1] =
'Read services';
92 $this->rights[$r][2] =
'r';
93 $this->rights[$r][3] = 0;
94 $this->rights[$r][4] =
'lire';
97 $this->rights[$r][0] = 532;
98 $this->rights[$r][1] =
'Create/modify services';
99 $this->rights[$r][2] =
'w';
100 $this->rights[$r][3] = 0;
101 $this->rights[$r][4] =
'creer';
104 $this->rights[$r][0] = 533;
105 $this->rights[$r][1] =
'Read prices services';
106 $this->rights[$r][2] =
'w';
107 $this->rights[$r][3] = 0;
108 $this->rights[$r][4] =
'service_advance';
109 $this->rights[$r][5] =
'read_prices';
112 $this->rights[$r][0] = 534;
113 $this->rights[$r][1] =
'Delete les services';
114 $this->rights[$r][2] =
'd';
115 $this->rights[$r][3] = 0;
116 $this->rights[$r][4] =
'supprimer';
119 $this->rights[$r][0] = 538;
120 $this->rights[$r][1] =
'Export services';
121 $this->rights[$r][2] =
'r';
122 $this->rights[$r][3] = 0;
123 $this->rights[$r][4] =
'export';
145 if (is_object($mysoc)) {
146 $usenpr = $mysoc->useNPR();
153 $alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
156 $this->export_code[$r] = $this->rights_class.
'_'.$r;
157 $this->export_label[$r] =
"Services";
158 $this->export_permission[$r] = array(array(
"service",
"export"));
159 $this->export_fields_array[$r] = array(
160 'p.rowid'=>
"Id",
'p.ref'=>
"Ref",
'p.label'=>
"Label",
161 'p.fk_product_type'=>
'Type',
'p.tosell'=>
"OnSell",
'p.tobuy'=>
"OnBuy",
162 'p.description'=>
"Description",
'p.url'=>
"PublicUrl",
163 'p.customcode'=>
'CustomCode',
'p.fk_country'=>
'IDCountry',
164 $alias_product_perentity .
'.accountancy_code_sell'=>
"ProductAccountancySellCode", $alias_product_perentity .
'.accountancy_code_sell_intra'=>
"ProductAccountancySellIntraCode",
165 $alias_product_perentity .
'.accountancy_code_sell_export'=>
"ProductAccountancySellExportCode", $alias_product_perentity .
'.accountancy_code_buy'=>
"ProductAccountancyBuyCode",
166 $alias_product_perentity .
'.accountancy_code_buy_intra'=>
"ProductAccountancyBuyIntraCode", $alias_product_perentity .
'.accountancy_code_buy_export'=>
"ProductAccountancyBuyExportCode",
167 'p.note'=>
"NotePrivate",
'p.note_public'=>
'NotePublic',
168 'p.weight'=>
"Weight",
'p.length'=>
"Length",
'p.width'=>
"Width",
'p.height'=>
"Height",
'p.surface'=>
"Surface",
'p.volume'=>
"Volume",
169 'p.duration'=>
"Duration",
170 'p.finished' =>
'Nature',
171 'p.price_base_type'=>
"PriceBase",
'p.price'=>
"UnitPriceHT",
'p.price_ttc'=>
"UnitPriceTTC",
172 'p.tva_tx'=>
'VATRate',
173 'p.datec'=>
'DateCreation',
'p.tms'=>
'DateModification'
175 if (is_object($mysoc) && $usenpr) {
176 $this->export_fields_array[$r][
'p.recuperableonly'] =
'NPR';
178 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice") || isModEnabled(
'margin')) {
179 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.cost_price'=>
'CostPrice'));
181 if (isModEnabled(
'stock')) {
182 $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'));
184 if (isModEnabled(
'barcode')) {
185 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode'=>
'BarCode'));
187 $keyforselect =
'product';
188 $keyforelement =
'product';
189 $keyforaliasextra =
'extra';
190 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
191 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
192 $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'));
195 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'group_concat(cat.label)'=>
'Categories'));
198 $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'));
201 $this->export_fields_array[$r][
'p.fk_unit'] =
'Unit';
203 $this->export_TypeFields_array[$r] = array(
204 'p.ref'=>
"Text",
'p.label'=>
"Text",
205 'p.fk_product_type'=>
'Numeric',
'p.tosell'=>
"Boolean",
'p.tobuy'=>
"Boolean",
206 'p.description'=>
"Text",
'p.url'=>
"Text",
207 $alias_product_perentity .
'.accountancy_code_sell'=>
"Text", $alias_product_perentity .
'.accountancy_code_sell_intra'=>
"Text", $alias_product_perentity .
'.accountancy_code_sell_export'=>
"Text",
208 $alias_product_perentity .
'.accountancy_code_buy'=>
"Text", $alias_product_perentity .
'.accountancy_code_buy_intra'=>
"Text", $alias_product_perentity .
'.accountancy_code_buy_export'=>
"Text",
209 'p.note'=>
"Text",
'p.note_public'=>
"Text",
210 'p.weight'=>
"Numeric",
'p.length'=>
"Numeric",
'p.width'=>
"Numeric",
'p.height'=>
"Numeric",
'p.surface'=>
"Numeric",
'p.volume'=>
"Numeric",
211 'p.customcode'=>
'Text',
212 'p.duration'=>
"Text",
213 'p.finished' =>
'Numeric',
214 'p.price_base_type'=>
"Text",
'p.price'=>
"Numeric",
'p.price_ttc'=>
"Numeric",
'p.tva_tx'=>
'Numeric',
215 'p.datec'=>
'Date',
'p.tms'=>
'Date'
217 if (isModEnabled(
'stock')) {
218 $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'));
220 if (isModEnabled(
'barcode')) {
221 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode'=>
'Text'));
223 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
224 $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'));
227 $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'));
230 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
"group_concat(cat.label)"=>
'Text'));
232 $this->export_entities_array[$r] = array();
234 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
"group_concat(cat.label)"=>
'category'));
236 if (isModEnabled(
'stock')) {
237 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.stock'=>
'product',
'p.pmp'=>
'product'));
239 if (isModEnabled(
'barcode')) {
240 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode'=>
'product'));
242 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
243 $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'));
246 $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'));
249 $this->export_dependencies_array[$r] = array(
'category'=>
'p.rowid');
251 if (isModEnabled(
'stock')) {
252 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.stock'=>
'product',
'p.pmp'=>
'product'));
254 if (isModEnabled(
'barcode')) {
255 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode'=>
'product'));
257 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
258 $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'));
261 $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'));
264 $this->export_dependencies_array[$r] = array(
'category'=>
'p.rowid');
266 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
267 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
269 $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);
272 $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';
275 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lang as l ON l.fk_product = p.rowid';
277 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON p.rowid = extra.fk_object';
278 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
279 $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';
281 $this->export_sql_end[$r] .=
' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity(
'product').
')';
283 $this->export_sql_order[$r] =
' GROUP BY p.rowid';
286 if (!isModEnabled(
"product")) {
290 $this->export_code[$r] = $this->rights_class.
'_'.$r;
291 $this->export_label[$r] =
"ProductsMultiPrice";
292 $this->export_permission[$r] = array(array(
"service",
"export"));
293 $this->export_fields_array[$r] = array(
'p.rowid'=>
"Id",
'p.ref'=>
"Ref",
294 'pr.price_base_type'=>
"PriceBase",
'pr.price_level'=>
"PriceLevel",
295 'pr.price'=>
"PriceLevelUnitPriceHT",
'pr.price_ttc'=>
"PriceLevelUnitPriceTTC",
296 'pr.price_min'=>
"MinPriceLevelUnitPriceHT",
'pr.price_min_ttc'=>
"MinPriceLevelUnitPriceTTC",
297 'pr.tva_tx'=>
'PriceLevelVATRate',
298 'pr.date_price'=>
'DateCreation');
299 if (is_object($mysoc) && $usenpr) {
300 $this->export_fields_array[$r][
'pr.recuperableonly'] =
'NPR';
308 $this->export_entities_array[$r] = array(
'p.rowid'=>
"product",
'p.ref'=>
"product",
309 'pr.price_base_type'=>
"product",
'pr.price_level'=>
"product",
'pr.price'=>
"product",
310 'pr.price_ttc'=>
"product",
311 'pr.price_min'=>
"product",
'pr.price_min_ttc'=>
"product",
312 'pr.tva_tx'=>
'product',
313 'pr.recuperableonly'=>
'product',
314 'pr.date_price'=>
"product");
315 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
316 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
317 $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;
318 $this->export_sql_end[$r] .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
324 $this->export_code[$r] = $this->rights_class.
'_'.$r;
325 $this->export_label[$r] =
"ProductsPricePerCustomer";
326 $this->export_permission[$r] = array(array(
"service",
"export"));
327 $this->export_fields_array[$r] = array(
'p.rowid'=>
"Id",
'p.ref'=>
"Ref",
328 's.nom'=>
'ThirdParty',
329 'pr.price_base_type'=>
"PriceBase",
330 'pr.price'=>
"PriceUnitPriceHT",
'pr.price_ttc'=>
"PriceUnitPriceTTC",
331 'pr.price_min'=>
"MinPriceUnitPriceHT",
'pr.price_min_ttc'=>
"MinPriceUnitPriceTTC",
332 'pr.tva_tx'=>
'PriceVATRate',
333 'pr.default_vat_code'=>
'PriceVATCode',
334 'pr.datec'=>
'DateCreation');
335 if (is_object($mysoc) && $usenpr) {
336 $this->export_fields_array[$r][
'pr.recuperableonly'] =
'NPR';
338 $this->export_entities_array[$r] = array(
'p.rowid'=>
"product",
'p.ref'=>
"product",
340 'pr.price_base_type'=>
"product",
'pr.price'=>
"product",
341 'pr.price_ttc'=>
"product",
342 'pr.price_min'=>
"product",
'pr.price_min_ttc'=>
"product",
343 'pr.tva_tx'=>
'product',
344 'pr.default_vat_code'=>
'product',
345 'pr.recuperableonly'=>
'product',
346 'pr.datec'=>
"product");
347 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
348 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
349 $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;
350 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON pr.fk_soc = s.rowid';
351 $this->export_sql_end[$r] .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
357 $this->export_code[$r] = $this->rights_class.
'_'.$r;
358 $this->export_label[$r] =
"AssociatedProducts";
359 $this->export_permission[$r] = array(array(
"service",
"export"));
360 $this->export_fields_array[$r] = array(
361 'p.rowid'=>
"Id",
'p.ref'=>
"Ref",
'p.label'=>
"Label",
'p.description'=>
"Description",
'p.url'=>
"PublicUrl",
362 $alias_product_perentity .
'.accountancy_code_sell'=>
"ProductAccountancySellCode", $alias_product_perentity .
'.accountancy_code_sell_intra'=>
"ProductAccountancySellIntraCode",
363 $alias_product_perentity .
'.accountancy_code_sell_export'=>
"ProductAccountancySellExportCode", $alias_product_perentity .
'.accountancy_code_buy'=>
"ProductAccountancyBuyCode",
364 $alias_product_perentity .
'.accountancy_code_buy_intra'=>
"ProductAccountancyBuyIntraCode", $alias_product_perentity .
'.accountancy_code_buy_export'=>
"ProductAccountancyBuyExportCode",
365 'p.note'=>
"NotePrivate",
'p.note_public'=>
'NotePublic',
366 'p.weight'=>
"Weight",
'p.length'=>
"Length",
'p.surface'=>
"Surface",
'p.volume'=>
"Volume",
'p.customcode'=>
'CustomCode',
367 'p.price_base_type'=>
"PriceBase",
'p.price'=>
"UnitPriceHT",
'p.price_ttc'=>
"UnitPriceTTC",
'p.tva_tx'=>
'VATRate',
'p.tosell'=>
"OnSell",
368 'p.tobuy'=>
"OnBuy",
'p.datec'=>
'DateCreation',
'p.tms'=>
'DateModification'
370 if (isModEnabled(
'stock')) {
371 $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'));
373 if (isModEnabled(
'barcode')) {
374 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode'=>
'BarCode'));
376 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'pa.qty'=>
'Qty',
'pa.incdec'=>
'ComposedProductIncDecStock'));
377 $this->export_TypeFields_array[$r] = array(
378 'p.ref'=>
"Text",
'p.label'=>
"Text",
'p.description'=>
"Text",
'p.url'=>
"Text",
379 $alias_product_perentity .
'p.accountancy_code_sell'=>
"Text", $alias_product_perentity .
'.accountancy_code_sell_intra'=>
"Text", $alias_product_perentity .
'.accountancy_code_sell_export'=>
"Text",
380 $alias_product_perentity .
'p.accountancy_code_buy'=>
"Text", $alias_product_perentity .
'.accountancy_code_buy_intra'=>
"Text", $alias_product_perentity .
'.accountancy_code_buy_export'=>
"Text",
381 'p.note'=>
"Text",
'p.note_public'=>
"Text",
382 'p.weight'=>
"Numeric",
'p.length'=>
"Numeric",
'p.surface'=>
"Numeric",
'p.volume'=>
"Numeric",
'p.customcode'=>
'Text',
383 'p.price_base_type'=>
"Text",
'p.price'=>
"Numeric",
'p.price_ttc'=>
"Numeric",
'p.tva_tx'=>
'Numeric',
'p.tosell'=>
"Boolean",
'p.tobuy'=>
"Boolean",
384 'p.datec'=>
'Date',
'p.tms'=>
'Date'
386 if (isModEnabled(
'stock')) {
387 $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'));
389 if (isModEnabled(
'barcode')) {
390 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode'=>
'Text'));
392 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'pa.qty'=>
'Numeric'));
393 $this->export_entities_array[$r] = array(
394 'p.rowid'=>
"virtualproduct",
'p.ref'=>
"virtualproduct",
'p.label'=>
"virtualproduct",
'p.description'=>
"virtualproduct",
'p.url'=>
"virtualproduct",
395 $alias_product_perentity .
'.accountancy_code_sell'=>
'virtualproduct', $alias_product_perentity .
'.accountancy_code_sell_intra'=>
'virtualproduct', $alias_product_perentity .
'.accountancy_code_sell_export'=>
'virtualproduct',
396 $alias_product_perentity .
'.accountancy_code_buy'=>
'virtualproduct', $alias_product_perentity .
'.accountancy_code_buy_intra'=>
'virtualproduct', $alias_product_perentity .
'.accountancy_code_buy_export'=>
'virtualproduct',
397 'p.note'=>
"virtualproduct",
'p.length'=>
"virtualproduct",
398 'p.surface'=>
"virtualproduct",
'p.volume'=>
"virtualproduct",
'p.weight'=>
"virtualproduct",
'p.customcode'=>
'virtualproduct',
399 'p.price_base_type'=>
"virtualproduct",
'p.price'=>
"virtualproduct",
'p.price_ttc'=>
"virtualproduct",
'p.tva_tx'=>
"virtualproduct",
400 'p.tosell'=>
"virtualproduct",
'p.tobuy'=>
"virtualproduct",
'p.datec'=>
"virtualproduct",
'p.tms'=>
"virtualproduct"
402 if (isModEnabled(
'stock')) {
403 $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'));
405 if (isModEnabled(
'barcode')) {
406 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode'=>
'virtualproduct'));
408 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'pa.qty'=>
"subproduct",
'pa.incdec'=>
'subproduct'));
409 $keyforselect =
'product';
410 $keyforelement =
'product';
411 $keyforaliasextra =
'extra';
412 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
413 $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"));
414 $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"));
415 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
416 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
418 $this->export_sql_end[$r] .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int) $conf->entity);
420 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON p.rowid = extra.fk_object,';
421 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'product_association as pa, '.MAIN_DB_PREFIX.
'product as p2';
422 $this->export_sql_end[$r] .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
423 $this->export_sql_end[$r] .=
' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';
434 $this->import_code[$r] = $this->rights_class.
'_'.$r;
435 $this->import_label[$r] =
"Products";
436 $this->import_icon[$r] = $this->picto;
437 $this->import_entities_array[$r] = array();
438 $this->import_tables_array[$r] = array(
'p'=>MAIN_DB_PREFIX.
'product',
'extra'=>MAIN_DB_PREFIX.
'product_extrafields');
439 $this->import_tables_creator_array[$r] = array(
'p'=>
'fk_user_author');
440 $this->import_fields_array[$r] = array(
442 'p.label' =>
"Label*",
443 'p.fk_product_type' =>
"Type*",
444 'p.tosell' =>
"OnSell*",
445 'p.tobuy' =>
"OnBuy*",
446 'p.description' =>
"Description",
447 'p.url' =>
"PublicUrl",
448 'p.customcode' =>
'CustomCode',
449 'p.fk_country' =>
'CountryCode',
450 'p.accountancy_code_sell' =>
"ProductAccountancySellCode",
451 'p.accountancy_code_sell_intra' =>
"ProductAccountancySellIntraCode",
452 'p.accountancy_code_sell_export' =>
"ProductAccountancySellExportCode",
453 'p.accountancy_code_buy' =>
"ProductAccountancyBuyCode",
454 'p.accountancy_code_buy_intra' =>
"ProductAccountancyBuyIntraCode",
455 'p.accountancy_code_buy_export' =>
"ProductAccountancyBuyExportCode",
456 'p.note_public' =>
"NotePublic",
457 'p.note' =>
"NotePrivate",
458 'p.weight' =>
"Weight",
459 'p.weight_units' =>
"WeightUnits",
460 'p.length' =>
"Length",
461 'p.length_units' =>
"LengthUnits",
462 'p.width' =>
"Width",
463 'p.width_units' =>
"WidthUnits",
464 'p.height' =>
"Height",
465 'p.height_units' =>
"HeightUnits",
466 'p.surface' =>
"Surface",
467 'p.surface_units' =>
"SurfaceUnits",
468 'p.volume' =>
"Volume",
469 'p.volume_units' =>
"VolumeUnits",
470 'p.duration' =>
"Duration",
471 'p.finished' =>
'Nature',
472 'p.price' =>
"SellingPriceHT",
473 'p.price_min' =>
"MinPrice",
474 'p.price_ttc' =>
"SellingPriceTTC",
475 'p.price_min_ttc' =>
"SellingMinPriceTTC",
476 'p.price_base_type' =>
"PriceBaseType",
477 'p.tva_tx' =>
'VATRate',
478 'p.datec' =>
'DateCreation',
479 'p.cost_price' =>
"CostPrice",
482 $this->import_convertvalue_array[$r] = array(
483 'p.weight_units' => array(
484 'rule' =>
'fetchscalefromcodeunits',
485 'classfile' =>
'/core/class/cunits.class.php',
489 'dict' =>
'DictionaryMeasuringUnits'
491 'p.length_units' => array(
492 'rule' =>
'fetchscalefromcodeunits',
493 'classfile' =>
'/core/class/cunits.class.php',
497 'dict' =>
'DictionaryMeasuringUnits'
499 'p.width_units' => array(
500 'rule' =>
'fetchscalefromcodeunits',
501 'classfile' =>
'/core/class/cunits.class.php',
505 'dict' =>
'DictionaryMeasuringUnits'
507 'p.height_units' => array(
508 'rule' =>
'fetchscalefromcodeunits',
509 'classfile' =>
'/core/class/cunits.class.php',
513 'dict' =>
'DictionaryMeasuringUnits'
515 'p.surface_units' => array(
516 'rule' =>
'fetchscalefromcodeunits',
517 'classfile' =>
'/core/class/cunits.class.php',
520 'units' =>
'surface',
521 'dict' =>
'DictionaryMeasuringUnits'
523 'p.volume_units' => array(
524 'rule' =>
'fetchscalefromcodeunits',
525 'classfile' =>
'/core/class/cunits.class.php',
529 'dict' =>
'DictionaryMeasuringUnits'
531 'p.fk_country' => array(
532 'rule' =>
'fetchidfromcodeid',
533 'classfile' =>
'/core/class/ccountry.class.php',
534 'class' =>
'Ccountry',
536 'dict' =>
'DictionaryCountry'
540 $this->import_regex_array[$r] = array(
542 'p.price_base_type' =>
'\AHT\z|\ATTC\z',
543 'p.tosell' =>
'^[0|1]$',
544 'p.tobuy' =>
'^[0|1]$',
545 'p.fk_product_type' =>
'^[0|1]$',
546 'p.datec' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
547 'p.recuperableonly' =>
'^[0|1]$',
550 if (isModEnabled(
'stock')) {
551 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
552 'p.fk_default_warehouse'=>
'DefaultWarehouse',
553 'p.tobatch'=>
'ManageLotSerial',
554 'p.seuil_stock_alerte' =>
'StockLimit',
555 'p.pmp' =>
'PMPValue',
556 'p.desiredstock' =>
'DesiredStock'
559 $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(
560 'p.tobatch' =>
'^[0|1|2]$'
563 $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
564 'p.fk_default_warehouse' => array(
565 'rule' =>
'fetchidfromref',
566 'classfile' =>
'/product/stock/class/entrepot.class.php',
567 'class' =>
'Entrepot',
569 'element'=>
'Warehouse'
574 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice") || isModEnabled(
'margin')) {
575 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.cost_price'=>
'CostPrice'));
577 if (is_object($mysoc) && $usenpr) {
578 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.recuperableonly'=>
'NPR'));
580 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
581 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.localtax1_tx'=>
'LT1',
'p.localtax1_type'=>
'LT1Type'));
583 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
584 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.localtax2_tx'=>
'LT2',
'p.localtax2_type'=>
'LT2Type'));
586 if (isModEnabled(
'barcode')) {
587 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.barcode'=>
'BarCode'));
590 $this->import_fields_array[$r][
'p.fk_unit'] =
'Unit';
593 $import_extrafield_sample = array();
594 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0,".$conf->entity.
")";
595 $resql = $this->db->query($sql);
597 while ($obj = $this->db->fetch_object($resql)) {
598 $fieldname =
'extra.'.$obj->name;
599 $fieldlabel = ucfirst($obj->label);
600 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
601 $import_extrafield_sample[$fieldname] = $fieldlabel;
605 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'product');
606 $this->import_regex_array[$r] = array(
608 'p.price_base_type' =>
'HT|TTC',
609 'p.tosell'=>
'^[0|1]$',
610 'p.tobuy'=>
'^[0|1]$',
611 'p.fk_product_type'=>
'^[0|1]$',
612 'p.datec'=>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
613 'p.recuperableonly' =>
'^[0|1]$',
614 'p.finished' =>
'^[0|1]$'
617 $import_sample = array(
618 'p.ref' =>
"ref:PREF123456",
620 'p.label' =>
"Product name in default language",
621 'p.description' =>
"Product description in default language",
622 'p.note_public' =>
"a public note (free text)",
623 'p.note' =>
"a private note (free text)",
624 'p.customcode' =>
'customs code',
625 'p.fk_country' =>
'FR',
627 'p.price_min' =>
"100",
628 'p.price_ttc' =>
"110",
629 'p.price_min_ttc' =>
"110",
630 'p.price_base_type' =>
"HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
632 'p.tosell' =>
"0 (not for sale to customer, eg. raw material) / 1 (for sale)",
633 'p.tobuy' =>
"0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
634 'p.fk_product_type' =>
"0 (product) / 1 (service)",
635 'p.duration' =>
"eg. 365d/12m/1y",
636 'p.url' =>
'link to product (no https)',
637 'p.accountancy_code_sell' =>
"",
638 'p.accountancy_code_sell_intra' =>
"",
639 'p.accountancy_code_sell_export' =>
"",
640 'p.accountancy_code_buy' =>
"",
641 'p.accountancy_code_buy_intra' =>
"",
642 'p.accountancy_code_buy_export' =>
"",
644 'p.weight_units' =>
'kg',
646 'p.length_units' =>
'm',
648 'p.width_units' =>
'm',
650 'p.height_units' =>
'm',
652 'p.surface_units' =>
'm2',
654 'p.volume_units' =>
'm3',
655 'p.finished' =>
'0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.
'c_product_nature"'
658 if (isModEnabled(
'stock')) {
659 $import_sample = array_merge($import_sample, array(
660 'p.seuil_stock_alerte' =>
'',
662 'p.desiredstock' =>
''
665 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice") || isModEnabled(
'margin')) {
666 $import_sample = array_merge($import_sample, array(
'p.cost_price'=>
'90'));
668 if (is_object($mysoc) && $usenpr) {
669 $import_sample = array_merge($import_sample, array(
'p.recuperableonly'=>
'0'));
671 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
672 $import_sample = array_merge($import_sample, array(
'p.localtax1_tx'=>
'',
'p.localtax1_type'=>
''));
674 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
675 $import_sample = array_merge($import_sample, array(
'p.localtax2_tx'=>
'',
'p.localtax2_type'=>
''));
677 if (isModEnabled(
'barcode')) {
678 $import_sample = array_merge($import_sample, array(
'p.barcode'=>
''));
681 $import_sample = array_merge(
684 '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"'
688 if (!is_array($this->import_convertvalue_array[$r])) {
689 $this->import_convertvalue_array[$r] = array();
691 $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
692 'p.fk_unit' => array(
693 'rule' =>
'fetchidfromcodeorlabel',
694 'classfile' =>
'/core/class/cunits.class.php',
697 'dict' =>
'DictionaryUnits'
701 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
702 $this->import_updatekeys_array[$r] = array(
'p.ref'=>
'Ref');
703 if (isModEnabled(
'barcode')) {
704 $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array(
'p.barcode'=>
'BarCode'));
707 if (!isModEnabled(
"product")) {
708 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
711 $this->import_code[$r] = $this->rights_class.
'_supplierprices';
712 $this->import_label[$r] =
"SuppliersPricesOfProductsOrServices";
713 $this->import_icon[$r] = $this->picto;
714 $this->import_entities_array[$r] = array();
715 $this->import_tables_array[$r] = array(
'sp'=>MAIN_DB_PREFIX.
'product_fournisseur_price');
716 $this->import_tables_creator_array[$r] = array(
'sp'=>
'fk_user');
717 $this->import_fields_array[$r] = array(
718 'sp.fk_product'=>
"ProductOrService*",
719 'sp.fk_soc' =>
"Supplier*",
720 'sp.ref_fourn' =>
'SupplierRef*',
721 'sp.quantity' =>
"QtyMin*",
722 'sp.tva_tx' =>
'VATRate',
723 'sp.default_vat_code' =>
'VATCode',
724 'sp.delivery_time_days' =>
'NbDaysToDelivery',
725 'sp.supplier_reputation' =>
'SupplierReputation'
727 if (is_object($mysoc) && $usenpr) {
728 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.recuperableonly'=>
'VATNPR'));
730 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
731 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.localtax1_tx'=>
'LT1',
'sp.localtax1_type'=>
'LT1Type'));
733 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
734 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.localtax2_tx'=>
'LT2',
'sp.localtax2_type'=>
'LT2Type'));
736 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
737 'sp.price'=>
"PriceQtyMinHT*",
738 'sp.unitprice'=>
'UnitPriceHT*',
739 'sp.remise_percent'=>
'DiscountQtyMin'
742 if (isModEnabled(
"multicurrency")) {
743 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
744 'sp.fk_multicurrency'=>
'CurrencyCodeId',
745 'sp.multicurrency_code'=>
'CurrencyCode',
746 'sp.multicurrency_tx'=>
'CurrencyRate',
747 'sp.multicurrency_unitprice'=>
'CurrencyUnitPrice',
748 'sp.multicurrency_price'=>
'CurrencyPrice',
752 $this->import_convertvalue_array[$r] = array(
753 'sp.fk_soc'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/societe/class/societe.class.php',
'class'=>
'Societe',
'method'=>
'fetch',
'element'=>
'ThirdParty'),
754 'sp.fk_product'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/product/class/product.class.php',
'class'=>
'Product',
'method'=>
'fetch',
'element'=>
'Product')
756 $this->import_examplevalues_array[$r] = array(
757 'sp.fk_product' =>
"ref:PRODUCT_REF or id:123456",
758 'sp.fk_soc' =>
"My Supplier",
759 'sp.ref_fourn' =>
"XYZ-F123456",
760 'sp.quantity' =>
"5",
763 'sp.unitprice'=>
'50',
764 'sp.remise_percent'=>
'0',
765 'sp.default_vat_code' =>
'',
766 'sp.delivery_time_days' =>
'5',
767 'sp.supplier_reputation' =>
'FAVORITE / NOTTHGOOD / DONOTORDER'
769 if (is_object($mysoc) && $usenpr) {
770 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.recuperableonly'=>
''));
772 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
773 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.localtax1_tx'=>
'LT1',
'sp.localtax1_type'=>
'LT1Type'));
775 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
776 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.localtax2_tx'=>
'LT2',
'sp.localtax2_type'=>
'LT2Type'));
778 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
779 'sp.price' =>
"50.00",
780 'sp.unitprice' =>
'10',
782 'sp.remise_percent' =>
'20'
784 if (isModEnabled(
"multicurrency")) {
785 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
786 'sp.fk_multicurrency'=>
'eg: 2, rowid for code of multicurrency currency',
787 'sp.multicurrency_code'=>
'GBP',
788 'sp.multicurrency_tx'=>
'1.12345',
789 'sp.multicurrency_unitprice'=>
'',
791 'sp.multicurrency_price'=>
''
795 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
796 'sp.packagning'=>
'10',
800 $this->import_updatekeys_array[$r] = array(
'sp.fk_product'=>
'ProductOrService',
'sp.ref_fourn'=>
'SupplierRef',
'sp.fk_soc'=>
'Supplier');
806 $this->import_code[$r] = $this->rights_class.
'_multiprice';
807 $this->import_label[$r] =
"ProductsOrServiceMultiPrice";
808 $this->import_icon[$r] = $this->picto;
809 $this->import_entities_array[$r] = array();
810 $this->import_tables_array[$r] = array(
'pr'=>MAIN_DB_PREFIX.
'product_price');
811 $this->import_tables_creator_array[$r] = array(
'pr'=>
'fk_user_author');
812 $this->import_fields_array[$r] = array(
'pr.fk_product'=>
"ProductOrService*",
813 'pr.price_base_type'=>
"PriceBase",
'pr.price_level'=>
"PriceLevel",
814 'pr.price'=>
"PriceLevelUnitPriceHT",
'pr.price_ttc'=>
"PriceLevelUnitPriceTTC",
815 'pr.price_min'=>
"MinPriceLevelUnitPriceHT",
'pr.price_min_ttc'=>
"MinPriceLevelUnitPriceTTC",
816 'pr.date_price'=>
'DateCreation*');
818 $this->import_fields_array[$r][
'pr.tva_tx'] =
'VATRate';
820 if (is_object($mysoc) && $usenpr) {
821 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'pr.recuperableonly'=>
'NPR'));
823 $this->import_regex_array[$r] = array(
'pr.datec'=>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
'pr.recuperableonly'=>
'^[0|1]$');
824 $this->import_convertvalue_array[$r] = array(
825 'pr.fk_product'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/product/class/product.class.php',
'class'=>
'Product',
'method'=>
'fetch',
'element'=>
'Product')
827 $this->import_examplevalues_array[$r] = array(
'pr.fk_product'=>
"ref:SERVICE_REF or id:123456",
828 'pr.price_base_type'=>
"HT (for excl tax) or TTC (for inc tax)",
'pr.price_level'=>
"1",
829 'pr.price'=>
"100",
'pr.price_ttc'=>
"110",
830 'pr.price_min'=>
"100",
'pr.price_min_ttc'=>
"110",
832 'pr.recuperableonly'=>
'0',
833 'pr.date_price'=>
'2013-04-10');
839 $this->import_code[$r] = $this->rights_class.
'_languages';
840 $this->import_label[$r] =
"ProductsOrServicesTranslations";
841 $this->import_icon[$r] = $this->picto;
842 $this->import_entities_array[$r] = array();
843 $this->import_tables_array[$r] = array(
'l'=>MAIN_DB_PREFIX.
'product_lang');
845 $this->import_fields_array[$r] = array(
'l.fk_product'=>
'ProductOrService*',
'l.lang'=>
'Language*',
'l.label'=>
'TranslatedLabel',
'l.description'=>
'TranslatedDescription');
847 $this->import_convertvalue_array[$r] = array(
848 'l.fk_product'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/product/class/product.class.php',
'class'=>
'Product',
'method'=>
'fetch',
'element'=>
'Product')
850 $this->import_examplevalues_array[$r] = array(
'l.fk_product'=>
'ref:SERVICE_REF or id:123456',
'l.lang'=>
'en_US',
'l.label'=>
'Label in en_US',
'l.description'=>
'Desc in en_US');
851 $this->import_updatekeys_array[$r] = array(
'l.fk_product'=>
'ProductOrService',
'l.lang'=>
'Language');