51 $this->family =
"products";
52 $this->module_position =
'29';
54 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
58 $this->version =
'dolibarr';
60 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
61 $this->picto =
'service';
64 $this->dirs = array(
"/product/temp");
67 $this->hidden =
false;
68 $this->depends = array();
69 $this->requiredby = array();
70 $this->conflictwith = array();
71 $this->phpmin = array(7, 0);
74 $this->config_page_url = array(
"product.php@product");
75 $this->langfiles = array(
"products",
"companies",
"stocks",
"bills");
78 $this->
const = array();
82 0 => array(
'file' =>
'box_services_contracts.php',
'enabledbydefaulton' =>
'Home'),
83 1 => array(
'file' =>
'box_graph_product_distribution.php',
'enabledbydefaulton' =>
'Home')
87 $this->rights = array();
88 $this->rights_class =
'service';
91 $this->rights[$r][0] = 531;
92 $this->rights[$r][1] =
'Read services';
93 $this->rights[$r][2] =
'r';
94 $this->rights[$r][3] = 0;
95 $this->rights[$r][4] =
'lire';
98 $this->rights[$r][0] = 532;
99 $this->rights[$r][1] =
'Create/modify services';
100 $this->rights[$r][2] =
'w';
101 $this->rights[$r][3] = 0;
102 $this->rights[$r][4] =
'creer';
105 $this->rights[$r][0] = 533;
106 $this->rights[$r][1] =
'Read prices services';
107 $this->rights[$r][2] =
'w';
108 $this->rights[$r][3] = 0;
109 $this->rights[$r][4] =
'service_advance';
110 $this->rights[$r][5] =
'read_prices';
113 $this->rights[$r][0] = 534;
114 $this->rights[$r][1] =
'Delete les services';
115 $this->rights[$r][2] =
'd';
116 $this->rights[$r][3] = 0;
117 $this->rights[$r][4] =
'supprimer';
120 $this->rights[$r][0] = 538;
121 $this->rights[$r][1] =
'Export services';
122 $this->rights[$r][2] =
'r';
123 $this->rights[$r][3] = 0;
124 $this->rights[$r][4] =
'export';
146 if (is_object($mysoc)) {
147 $usenpr = $mysoc->useNPR();
154 $alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
157 $this->export_code[$r] = $this->rights_class.
'_'.$r;
158 $this->export_label[$r] =
"Services";
159 $this->export_permission[$r] = array(array(
"service",
"export"));
160 $this->export_fields_array[$r] = array(
161 'p.rowid' =>
"Id",
'p.ref' =>
"Ref",
'p.label' =>
"Label",
162 'p.fk_product_type' =>
'Type',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
"OnBuy",
163 'p.description' =>
"Description",
'p.url' =>
"PublicUrl",
164 'p.customcode' =>
'CustomCode',
'p.fk_country' =>
'IDCountry',
165 $alias_product_perentity .
'.accountancy_code_sell' =>
"ProductAccountancySellCode", $alias_product_perentity .
'.accountancy_code_sell_intra' =>
"ProductAccountancySellIntraCode",
166 $alias_product_perentity .
'.accountancy_code_sell_export' =>
"ProductAccountancySellExportCode", $alias_product_perentity .
'.accountancy_code_buy' =>
"ProductAccountancyBuyCode",
167 $alias_product_perentity .
'.accountancy_code_buy_intra' =>
"ProductAccountancyBuyIntraCode", $alias_product_perentity .
'.accountancy_code_buy_export' =>
"ProductAccountancyBuyExportCode",
168 'p.note' =>
"NotePrivate",
'p.note_public' =>
'NotePublic',
169 'p.weight' =>
"Weight",
'p.length' =>
"Length",
'p.width' =>
"Width",
'p.height' =>
"Height",
'p.surface' =>
"Surface",
'p.volume' =>
"Volume",
170 'p.duration' =>
"Duration",
171 'p.finished' =>
'Nature',
172 'p.price_base_type' =>
"PriceBase",
'p.price' =>
"UnitPriceHT",
'p.price_ttc' =>
"UnitPriceTTC",
173 'p.tva_tx' =>
'VATRate',
174 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification'
176 if (is_object($mysoc) && $usenpr) {
177 $this->export_fields_array[$r][
'p.recuperableonly'] =
'NPR';
179 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice") || isModEnabled(
'margin')) {
180 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.cost_price' =>
'CostPrice'));
182 if (isModEnabled(
'stock')) {
183 $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'));
185 if (isModEnabled(
'barcode')) {
186 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
188 $keyforselect =
'product';
189 $keyforelement =
'product';
190 $keyforaliasextra =
'extra';
191 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
192 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
193 $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'));
196 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'group_concat(cat.label)' =>
'Categories'));
199 $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'));
202 $this->export_fields_array[$r][
'p.fk_unit'] =
'Unit';
204 $this->export_TypeFields_array[$r] = array(
205 'p.ref' =>
"Text",
'p.label' =>
"Text",
206 'p.fk_product_type' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
207 'p.description' =>
"Text",
'p.url' =>
"Text",
208 $alias_product_perentity .
'.accountancy_code_sell' =>
"Text", $alias_product_perentity .
'.accountancy_code_sell_intra' =>
"Text", $alias_product_perentity .
'.accountancy_code_sell_export' =>
"Text",
209 $alias_product_perentity .
'.accountancy_code_buy' =>
"Text", $alias_product_perentity .
'.accountancy_code_buy_intra' =>
"Text", $alias_product_perentity .
'.accountancy_code_buy_export' =>
"Text",
210 'p.note' =>
"Text",
'p.note_public' =>
"Text",
211 'p.weight' =>
"Numeric",
'p.length' =>
"Numeric",
'p.width' =>
"Numeric",
'p.height' =>
"Numeric",
'p.surface' =>
"Numeric",
'p.volume' =>
"Numeric",
212 'p.customcode' =>
'Text',
213 'p.duration' =>
"Text",
214 'p.finished' =>
'Numeric',
215 'p.price_base_type' =>
"Text",
'p.price' =>
"Numeric",
'p.price_ttc' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
216 'p.datec' =>
'Date',
'p.tms' =>
'Date'
218 if (isModEnabled(
'stock')) {
219 $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'));
221 if (isModEnabled(
'barcode')) {
222 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
224 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
225 $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'));
228 $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'));
231 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
"group_concat(cat.label)" =>
'Text'));
233 $this->export_entities_array[$r] = array();
235 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
"group_concat(cat.label)" =>
'category'));
237 if (isModEnabled(
'stock')) {
238 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.stock' =>
'product',
'p.pmp' =>
'product'));
240 if (isModEnabled(
'barcode')) {
241 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
243 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
244 $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'));
247 $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'));
250 $this->export_dependencies_array[$r] = array(
'category' =>
'p.rowid');
252 if (isModEnabled(
'stock')) {
253 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.stock' =>
'product',
'p.pmp' =>
'product'));
255 if (isModEnabled(
'barcode')) {
256 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
258 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
259 $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'));
262 $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'));
265 $this->export_dependencies_array[$r] = array(
'category' =>
'p.rowid');
267 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
268 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
270 $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);
273 $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';
276 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lang as l ON l.fk_product = p.rowid';
278 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON p.rowid = extra.fk_object';
279 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
280 $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';
282 $this->export_sql_end[$r] .=
' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity(
'product').
')';
284 $this->export_sql_order[$r] =
' GROUP BY p.rowid';
287 if (!isModEnabled(
"product")) {
291 $this->export_code[$r] = $this->rights_class.
'_'.$r;
292 $this->export_label[$r] =
"ProductsMultiPrice";
293 $this->export_permission[$r] = array(array(
"service",
"export"));
294 $this->export_fields_array[$r] = array(
'p.rowid' =>
"Id",
'p.ref' =>
"Ref",
295 'pr.price_base_type' =>
"PriceBase",
'pr.price_level' =>
"PriceLevel",
296 'pr.price' =>
"PriceLevelUnitPriceHT",
'pr.price_ttc' =>
"PriceLevelUnitPriceTTC",
297 'pr.price_min' =>
"MinPriceLevelUnitPriceHT",
'pr.price_min_ttc' =>
"MinPriceLevelUnitPriceTTC",
298 'pr.tva_tx' =>
'PriceLevelVATRate',
299 'pr.date_price' =>
'DateCreation');
300 if (is_object($mysoc) && $usenpr) {
301 $this->export_fields_array[$r][
'pr.recuperableonly'] =
'NPR';
309 $this->export_entities_array[$r] = array(
'p.rowid' =>
"product",
'p.ref' =>
"product",
310 'pr.price_base_type' =>
"product",
'pr.price_level' =>
"product",
'pr.price' =>
"product",
311 'pr.price_ttc' =>
"product",
312 'pr.price_min' =>
"product",
'pr.price_min_ttc' =>
"product",
313 'pr.tva_tx' =>
'product',
314 'pr.recuperableonly' =>
'product',
315 'pr.date_price' =>
"product");
316 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
317 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
318 $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;
319 $this->export_sql_end[$r] .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
325 $this->export_code[$r] = $this->rights_class.
'_'.$r;
326 $this->export_label[$r] =
"ProductsPricePerCustomer";
327 $this->export_permission[$r] = array(array(
"service",
"export"));
328 $this->export_fields_array[$r] = array(
'p.rowid' =>
"Id",
'p.ref' =>
"Ref",
329 's.nom' =>
'ThirdParty',
330 'pr.price_base_type' =>
"PriceBase",
331 'pr.price' =>
"PriceUnitPriceHT",
'pr.price_ttc' =>
"PriceUnitPriceTTC",
332 'pr.price_min' =>
"MinPriceUnitPriceHT",
'pr.price_min_ttc' =>
"MinPriceUnitPriceTTC",
333 'pr.tva_tx' =>
'PriceVATRate',
334 'pr.default_vat_code' =>
'PriceVATCode',
335 'pr.datec' =>
'DateCreation');
336 if (is_object($mysoc) && $usenpr) {
337 $this->export_fields_array[$r][
'pr.recuperableonly'] =
'NPR';
339 $this->export_entities_array[$r] = array(
'p.rowid' =>
"product",
'p.ref' =>
"product",
340 's.nom' =>
'company',
341 'pr.price_base_type' =>
"product",
'pr.price' =>
"product",
342 'pr.price_ttc' =>
"product",
343 'pr.price_min' =>
"product",
'pr.price_min_ttc' =>
"product",
344 'pr.tva_tx' =>
'product',
345 'pr.default_vat_code' =>
'product',
346 'pr.recuperableonly' =>
'product',
347 'pr.datec' =>
"product");
348 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
349 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
350 $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;
351 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON pr.fk_soc = s.rowid';
352 $this->export_sql_end[$r] .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
358 $this->export_code[$r] = $this->rights_class.
'_'.$r;
359 $this->export_label[$r] =
"AssociatedProducts";
360 $this->export_permission[$r] = array(array(
"service",
"export"));
361 $this->export_fields_array[$r] = array(
362 'p.rowid' =>
"Id",
'p.ref' =>
"Ref",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.url' =>
"PublicUrl",
363 $alias_product_perentity .
'.accountancy_code_sell' =>
"ProductAccountancySellCode", $alias_product_perentity .
'.accountancy_code_sell_intra' =>
"ProductAccountancySellIntraCode",
364 $alias_product_perentity .
'.accountancy_code_sell_export' =>
"ProductAccountancySellExportCode", $alias_product_perentity .
'.accountancy_code_buy' =>
"ProductAccountancyBuyCode",
365 $alias_product_perentity .
'.accountancy_code_buy_intra' =>
"ProductAccountancyBuyIntraCode", $alias_product_perentity .
'.accountancy_code_buy_export' =>
"ProductAccountancyBuyExportCode",
366 'p.note' =>
"NotePrivate",
'p.note_public' =>
'NotePublic',
367 'p.weight' =>
"Weight",
'p.length' =>
"Length",
'p.surface' =>
"Surface",
'p.volume' =>
"Volume",
'p.customcode' =>
'CustomCode',
368 'p.price_base_type' =>
"PriceBase",
'p.price' =>
"UnitPriceHT",
'p.price_ttc' =>
"UnitPriceTTC",
'p.tva_tx' =>
'VATRate',
'p.tosell' =>
"OnSell",
369 'p.tobuy' =>
"OnBuy",
'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification'
371 if (isModEnabled(
'stock')) {
372 $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'));
374 if (isModEnabled(
'barcode')) {
375 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
377 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'pa.qty' =>
'Qty',
'pa.incdec' =>
'ComposedProductIncDecStock'));
378 $this->export_TypeFields_array[$r] = array(
379 'p.ref' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.url' =>
"Text",
380 $alias_product_perentity .
'p.accountancy_code_sell' =>
"Text", $alias_product_perentity .
'.accountancy_code_sell_intra' =>
"Text", $alias_product_perentity .
'.accountancy_code_sell_export' =>
"Text",
381 $alias_product_perentity .
'p.accountancy_code_buy' =>
"Text", $alias_product_perentity .
'.accountancy_code_buy_intra' =>
"Text", $alias_product_perentity .
'.accountancy_code_buy_export' =>
"Text",
382 'p.note' =>
"Text",
'p.note_public' =>
"Text",
383 'p.weight' =>
"Numeric",
'p.length' =>
"Numeric",
'p.surface' =>
"Numeric",
'p.volume' =>
"Numeric",
'p.customcode' =>
'Text',
384 'p.price_base_type' =>
"Text",
'p.price' =>
"Numeric",
'p.price_ttc' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
385 'p.datec' =>
'Date',
'p.tms' =>
'Date'
387 if (isModEnabled(
'stock')) {
388 $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'));
390 if (isModEnabled(
'barcode')) {
391 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
393 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'pa.qty' =>
'Numeric'));
394 $this->export_entities_array[$r] = array(
395 'p.rowid' =>
"virtualproduct",
'p.ref' =>
"virtualproduct",
'p.label' =>
"virtualproduct",
'p.description' =>
"virtualproduct",
'p.url' =>
"virtualproduct",
396 $alias_product_perentity .
'.accountancy_code_sell' =>
'virtualproduct', $alias_product_perentity .
'.accountancy_code_sell_intra' =>
'virtualproduct', $alias_product_perentity .
'.accountancy_code_sell_export' =>
'virtualproduct',
397 $alias_product_perentity .
'.accountancy_code_buy' =>
'virtualproduct', $alias_product_perentity .
'.accountancy_code_buy_intra' =>
'virtualproduct', $alias_product_perentity .
'.accountancy_code_buy_export' =>
'virtualproduct',
398 'p.note' =>
"virtualproduct",
'p.length' =>
"virtualproduct",
399 'p.surface' =>
"virtualproduct",
'p.volume' =>
"virtualproduct",
'p.weight' =>
"virtualproduct",
'p.customcode' =>
'virtualproduct',
400 'p.price_base_type' =>
"virtualproduct",
'p.price' =>
"virtualproduct",
'p.price_ttc' =>
"virtualproduct",
'p.tva_tx' =>
"virtualproduct",
401 'p.tosell' =>
"virtualproduct",
'p.tobuy' =>
"virtualproduct",
'p.datec' =>
"virtualproduct",
'p.tms' =>
"virtualproduct"
403 if (isModEnabled(
'stock')) {
404 $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'));
406 if (isModEnabled(
'barcode')) {
407 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'virtualproduct'));
409 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'pa.qty' =>
"subproduct",
'pa.incdec' =>
'subproduct'));
410 $keyforselect =
'product';
411 $keyforelement =
'product';
412 $keyforaliasextra =
'extra';
413 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
414 $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"));
415 $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"));
416 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
417 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
419 $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);
421 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON p.rowid = extra.fk_object,';
422 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'product_association as pa, '.MAIN_DB_PREFIX.
'product as p2';
423 $this->export_sql_end[$r] .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
424 $this->export_sql_end[$r] .=
' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';
435 $this->import_code[$r] = $this->rights_class.
'_'.$r;
436 $this->import_label[$r] =
"Products";
437 $this->import_icon[$r] = $this->picto;
438 $this->import_entities_array[$r] = array();
439 $this->import_tables_array[$r] = array(
'p' => MAIN_DB_PREFIX.
'product',
'extra' => MAIN_DB_PREFIX.
'product_extrafields');
440 $this->import_tables_creator_array[$r] = array(
'p' =>
'fk_user_author');
441 $this->import_fields_array[$r] = array(
443 'p.label' =>
"Label*",
444 'p.fk_product_type' =>
"Type*",
445 'p.tosell' =>
"OnSell*",
446 'p.tobuy' =>
"OnBuy*",
447 'p.description' =>
"Description",
448 'p.url' =>
"PublicUrl",
449 'p.customcode' =>
'CustomCode',
450 'p.fk_country' =>
'CountryCode',
451 'p.accountancy_code_sell' =>
"ProductAccountancySellCode",
452 'p.accountancy_code_sell_intra' =>
"ProductAccountancySellIntraCode",
453 'p.accountancy_code_sell_export' =>
"ProductAccountancySellExportCode",
454 'p.accountancy_code_buy' =>
"ProductAccountancyBuyCode",
455 'p.accountancy_code_buy_intra' =>
"ProductAccountancyBuyIntraCode",
456 'p.accountancy_code_buy_export' =>
"ProductAccountancyBuyExportCode",
457 'p.note_public' =>
"NotePublic",
458 'p.note' =>
"NotePrivate",
459 'p.weight' =>
"Weight",
460 'p.weight_units' =>
"WeightUnits",
461 'p.length' =>
"Length",
462 'p.length_units' =>
"LengthUnits",
463 'p.width' =>
"Width",
464 'p.width_units' =>
"WidthUnits",
465 'p.height' =>
"Height",
466 'p.height_units' =>
"HeightUnits",
467 'p.surface' =>
"Surface",
468 'p.surface_units' =>
"SurfaceUnits",
469 'p.volume' =>
"Volume",
470 'p.volume_units' =>
"VolumeUnits",
471 'p.duration' =>
"Duration",
472 'p.finished' =>
'Nature',
473 'p.price' =>
"SellingPriceHT",
474 'p.price_min' =>
"MinPrice",
475 'p.price_ttc' =>
"SellingPriceTTC",
476 'p.price_min_ttc' =>
"SellingMinPriceTTC",
477 'p.price_base_type' =>
"PriceBaseType",
478 'p.tva_tx' =>
'VATRate',
479 'p.datec' =>
'DateCreation',
480 'p.cost_price' =>
"CostPrice",
483 $this->import_convertvalue_array[$r] = array(
484 'p.weight_units' => array(
485 'rule' =>
'fetchscalefromcodeunits',
486 'classfile' =>
'/core/class/cunits.class.php',
490 'dict' =>
'DictionaryMeasuringUnits'
492 'p.length_units' => array(
493 'rule' =>
'fetchscalefromcodeunits',
494 'classfile' =>
'/core/class/cunits.class.php',
498 'dict' =>
'DictionaryMeasuringUnits'
500 'p.width_units' => array(
501 'rule' =>
'fetchscalefromcodeunits',
502 'classfile' =>
'/core/class/cunits.class.php',
506 'dict' =>
'DictionaryMeasuringUnits'
508 'p.height_units' => array(
509 'rule' =>
'fetchscalefromcodeunits',
510 'classfile' =>
'/core/class/cunits.class.php',
514 'dict' =>
'DictionaryMeasuringUnits'
516 'p.surface_units' => array(
517 'rule' =>
'fetchscalefromcodeunits',
518 'classfile' =>
'/core/class/cunits.class.php',
521 'units' =>
'surface',
522 'dict' =>
'DictionaryMeasuringUnits'
524 'p.volume_units' => array(
525 'rule' =>
'fetchscalefromcodeunits',
526 'classfile' =>
'/core/class/cunits.class.php',
530 'dict' =>
'DictionaryMeasuringUnits'
532 'p.fk_country' => array(
533 'rule' =>
'fetchidfromcodeid',
534 'classfile' =>
'/core/class/ccountry.class.php',
535 'class' =>
'Ccountry',
537 'dict' =>
'DictionaryCountry'
541 $this->import_regex_array[$r] = array(
543 'p.price_base_type' =>
'\AHT\z|\ATTC\z',
544 'p.tosell' =>
'^[0|1]$',
545 'p.tobuy' =>
'^[0|1]$',
546 'p.fk_product_type' =>
'^[0|1]$',
547 'p.datec' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
548 'p.recuperableonly' =>
'^[0|1]$',
551 if (isModEnabled(
'stock')) {
552 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
553 'p.fk_default_warehouse' =>
'DefaultWarehouse',
554 'p.tobatch' =>
'ManageLotSerial',
555 'p.seuil_stock_alerte' =>
'StockLimit',
556 'p.pmp' =>
'PMPValue',
557 'p.desiredstock' =>
'DesiredStock'
560 $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(
561 'p.tobatch' =>
'^[0|1|2]$'
564 $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
565 'p.fk_default_warehouse' => array(
566 'rule' =>
'fetchidfromref',
567 'classfile' =>
'/product/stock/class/entrepot.class.php',
568 'class' =>
'Entrepot',
570 'element' =>
'Warehouse'
575 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice") || isModEnabled(
'margin')) {
576 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.cost_price' =>
'CostPrice'));
578 if (is_object($mysoc) && $usenpr) {
579 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.recuperableonly' =>
'NPR'));
581 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
582 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.localtax1_tx' =>
'LT1',
'p.localtax1_type' =>
'LT1Type'));
584 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
585 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.localtax2_tx' =>
'LT2',
'p.localtax2_type' =>
'LT2Type'));
587 if (isModEnabled(
'barcode')) {
588 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
591 $this->import_fields_array[$r][
'p.fk_unit'] =
'Unit';
594 $import_extrafield_sample = array();
595 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0,".$conf->entity.
")";
596 $resql = $this->db->query($sql);
598 while ($obj = $this->db->fetch_object($resql)) {
599 $fieldname =
'extra.'.$obj->name;
600 $fieldlabel = ucfirst($obj->label);
601 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
602 $import_extrafield_sample[$fieldname] = $fieldlabel;
606 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'product');
607 $this->import_regex_array[$r] = array(
609 'p.price_base_type' =>
'HT|TTC',
610 'p.tosell' =>
'^[0|1]$',
611 'p.tobuy' =>
'^[0|1]$',
612 'p.fk_product_type' =>
'^[0|1]$',
613 'p.datec' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
614 'p.recuperableonly' =>
'^[0|1]$',
615 'p.finished' =>
'^[0|1]$'
618 $import_sample = array(
619 'p.ref' =>
"ref:PREF123456",
621 'p.label' =>
"Product name in default language",
622 'p.description' =>
"Product description in default language",
623 'p.note_public' =>
"a public note (free text)",
624 'p.note' =>
"a private note (free text)",
625 'p.customcode' =>
'customs code',
626 'p.fk_country' =>
'FR',
628 'p.price_min' =>
"100",
629 'p.price_ttc' =>
"110",
630 'p.price_min_ttc' =>
"110",
631 'p.price_base_type' =>
"HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
633 'p.tosell' =>
"0 (not for sale to customer, eg. raw material) / 1 (for sale)",
634 'p.tobuy' =>
"0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
635 'p.fk_product_type' =>
"0 (product) / 1 (service)",
636 'p.duration' =>
"eg. 365d/12m/1y",
637 'p.url' =>
'link to product (no https)',
638 'p.accountancy_code_sell' =>
"",
639 'p.accountancy_code_sell_intra' =>
"",
640 'p.accountancy_code_sell_export' =>
"",
641 'p.accountancy_code_buy' =>
"",
642 'p.accountancy_code_buy_intra' =>
"",
643 'p.accountancy_code_buy_export' =>
"",
645 'p.weight_units' =>
'kg',
647 'p.length_units' =>
'm',
649 'p.width_units' =>
'm',
651 'p.height_units' =>
'm',
653 'p.surface_units' =>
'm2',
655 'p.volume_units' =>
'm3',
656 'p.finished' =>
'0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.
'c_product_nature"'
659 if (isModEnabled(
'stock')) {
660 $import_sample = array_merge($import_sample, array(
661 'p.seuil_stock_alerte' =>
'',
663 'p.desiredstock' =>
''
666 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice") || isModEnabled(
'margin')) {
667 $import_sample = array_merge($import_sample, array(
'p.cost_price' =>
'90'));
669 if (is_object($mysoc) && $usenpr) {
670 $import_sample = array_merge($import_sample, array(
'p.recuperableonly' =>
'0'));
672 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
673 $import_sample = array_merge($import_sample, array(
'p.localtax1_tx' =>
'',
'p.localtax1_type' =>
''));
675 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
676 $import_sample = array_merge($import_sample, array(
'p.localtax2_tx' =>
'',
'p.localtax2_type' =>
''));
678 if (isModEnabled(
'barcode')) {
679 $import_sample = array_merge($import_sample, array(
'p.barcode' =>
''));
682 $import_sample = array_merge(
685 '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"'
689 if (!is_array($this->import_convertvalue_array[$r])) {
690 $this->import_convertvalue_array[$r] = array();
692 $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
693 'p.fk_unit' => array(
694 'rule' =>
'fetchidfromcodeorlabel',
695 'classfile' =>
'/core/class/cunits.class.php',
698 'dict' =>
'DictionaryUnits'
702 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
703 $this->import_updatekeys_array[$r] = array(
'p.ref' =>
'Ref');
704 if (isModEnabled(
'barcode')) {
705 $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array(
'p.barcode' =>
'BarCode'));
708 if (!isModEnabled(
"product")) {
709 if (isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
712 $this->import_code[$r] = $this->rights_class.
'_supplierprices';
713 $this->import_label[$r] =
"SuppliersPricesOfProductsOrServices";
714 $this->import_icon[$r] = $this->picto;
715 $this->import_entities_array[$r] = array();
716 $this->import_tables_array[$r] = array(
'sp' => MAIN_DB_PREFIX.
'product_fournisseur_price');
717 $this->import_tables_creator_array[$r] = array(
'sp' =>
'fk_user');
718 $this->import_fields_array[$r] = array(
719 'sp.fk_product' =>
"ProductOrService*",
720 'sp.fk_soc' =>
"Supplier*",
721 'sp.ref_fourn' =>
'SupplierRef*',
722 'sp.quantity' =>
"QtyMin*",
723 'sp.tva_tx' =>
'VATRate',
724 'sp.default_vat_code' =>
'VATCode',
725 'sp.delivery_time_days' =>
'NbDaysToDelivery',
726 'sp.supplier_reputation' =>
'SupplierReputation'
728 if (is_object($mysoc) && $usenpr) {
729 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.recuperableonly' =>
'VATNPR'));
731 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
732 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.localtax1_tx' =>
'LT1',
'sp.localtax1_type' =>
'LT1Type'));
734 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
735 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.localtax2_tx' =>
'LT2',
'sp.localtax2_type' =>
'LT2Type'));
737 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
738 'sp.price' =>
"PriceQtyMinHT*",
739 'sp.unitprice' =>
'UnitPriceHT*',
740 'sp.remise_percent' =>
'DiscountQtyMin'
743 if (isModEnabled(
"multicurrency")) {
744 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
745 'sp.fk_multicurrency' =>
'CurrencyCodeId',
746 'sp.multicurrency_code' =>
'CurrencyCode',
747 'sp.multicurrency_tx' =>
'CurrencyRate',
748 'sp.multicurrency_unitprice' =>
'CurrencyUnitPrice',
749 'sp.multicurrency_price' =>
'CurrencyPrice',
753 $this->import_convertvalue_array[$r] = array(
754 'sp.fk_soc' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/societe/class/societe.class.php',
'class' =>
'Societe',
'method' =>
'fetch',
'element' =>
'ThirdParty'),
755 'sp.fk_product' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/class/product.class.php',
'class' =>
'Product',
'method' =>
'fetch',
'element' =>
'Product')
757 $this->import_examplevalues_array[$r] = array(
758 'sp.fk_product' =>
"ref:PRODUCT_REF or id:123456",
759 'sp.fk_soc' =>
"My Supplier",
760 'sp.ref_fourn' =>
"XYZ-F123456",
761 'sp.quantity' =>
"5",
764 'sp.unitprice' =>
'50',
765 'sp.remise_percent' =>
'0',
766 'sp.default_vat_code' =>
'',
767 'sp.delivery_time_days' =>
'5',
768 'sp.supplier_reputation' =>
'FAVORITE / NOTTHGOOD / DONOTORDER'
770 if (is_object($mysoc) && $usenpr) {
771 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.recuperableonly' =>
''));
773 if (is_object($mysoc) && $mysoc->useLocalTax(1)) {
774 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.localtax1_tx' =>
'LT1',
'sp.localtax1_type' =>
'LT1Type'));
776 if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
777 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.localtax2_tx' =>
'LT2',
'sp.localtax2_type' =>
'LT2Type'));
779 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
780 'sp.price' =>
"50.00",
781 'sp.unitprice' =>
'10',
783 'sp.remise_percent' =>
'20'
785 if (isModEnabled(
"multicurrency")) {
786 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
787 'sp.fk_multicurrency' =>
'eg: 2, rowid for code of multicurrency currency',
788 'sp.multicurrency_code' =>
'GBP',
789 'sp.multicurrency_tx' =>
'1.12345',
790 'sp.multicurrency_unitprice' =>
'',
792 'sp.multicurrency_price' =>
''
796 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
797 'sp.packaging' =>
'10',
801 $this->import_updatekeys_array[$r] = array(
'sp.fk_product' =>
'ProductOrService',
'sp.ref_fourn' =>
'SupplierRef',
'sp.fk_soc' =>
'Supplier');
807 $this->import_code[$r] = $this->rights_class.
'_multiprice';
808 $this->import_label[$r] =
"ProductsOrServiceMultiPrice";
809 $this->import_icon[$r] = $this->picto;
810 $this->import_entities_array[$r] = array();
811 $this->import_tables_array[$r] = array(
'pr' => MAIN_DB_PREFIX.
'product_price');
812 $this->import_tables_creator_array[$r] = array(
'pr' =>
'fk_user_author');
813 $this->import_fields_array[$r] = array(
'pr.fk_product' =>
"ProductOrService*",
814 'pr.price_base_type' =>
"PriceBase",
'pr.price_level' =>
"PriceLevel",
815 'pr.price' =>
"PriceLevelUnitPriceHT",
'pr.price_ttc' =>
"PriceLevelUnitPriceTTC",
816 'pr.price_min' =>
"MinPriceLevelUnitPriceHT",
'pr.price_min_ttc' =>
"MinPriceLevelUnitPriceTTC",
817 'pr.date_price' =>
'DateCreation*');
819 $this->import_fields_array[$r][
'pr.tva_tx'] =
'VATRate';
821 if (is_object($mysoc) && $usenpr) {
822 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'pr.recuperableonly' =>
'NPR'));
824 $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]$');
825 $this->import_convertvalue_array[$r] = array(
826 'pr.fk_product' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/class/product.class.php',
'class' =>
'Product',
'method' =>
'fetch',
'element' =>
'Product')
828 $this->import_examplevalues_array[$r] = array(
'pr.fk_product' =>
"ref:SERVICE_REF or id:123456",
829 'pr.price_base_type' =>
"HT (for excl tax) or TTC (for inc tax)",
'pr.price_level' =>
"1",
830 'pr.price' =>
"100",
'pr.price_ttc' =>
"110",
831 'pr.price_min' =>
"100",
'pr.price_min_ttc' =>
"110",
833 'pr.recuperableonly' =>
'0',
834 'pr.date_price' =>
'2013-04-10');
840 $this->import_code[$r] = $this->rights_class.
'_languages';
841 $this->import_label[$r] =
"ProductsOrServicesTranslations";
842 $this->import_icon[$r] = $this->picto;
843 $this->import_entities_array[$r] = array();
844 $this->import_tables_array[$r] = array(
'l' => MAIN_DB_PREFIX.
'product_lang');
846 $this->import_fields_array[$r] = array(
'l.fk_product' =>
'ProductOrService*',
'l.lang' =>
'Language*',
'l.label' =>
'TranslatedLabel',
'l.description' =>
'TranslatedDescription');
848 $this->import_convertvalue_array[$r] = array(
849 'l.fk_product' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/class/product.class.php',
'class' =>
'Product',
'method' =>
'fetch',
'element' =>
'Product')
851 $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');
852 $this->import_updatekeys_array[$r] = array(
'l.fk_product' =>
'ProductOrService',
'l.lang' =>
'Language');