30 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
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(5, 4);
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] = 534;
106 $this->rights[$r][1] =
'Delete les services';
107 $this->rights[$r][2] =
'd';
108 $this->rights[$r][3] = 0;
109 $this->rights[$r][4] =
'supprimer';
112 $this->rights[$r][0] = 538;
113 $this->rights[$r][1] =
'Export services';
114 $this->rights[$r][2] =
'r';
115 $this->rights[$r][3] = 0;
116 $this->rights[$r][4] =
'export';
138 if (is_object($mysoc)) $usenpr = $mysoc->useNPR();
145 $this->export_code[$r] = $this->rights_class.
'_'.$r;
146 $this->export_label[$r] =
"Services";
147 $this->export_permission[$r] = array(array(
"service",
"export"));
148 $this->export_fields_array[$r] = array(
149 'p.rowid'=>
"Id",
'p.ref'=>
"Ref",
'p.label'=>
"Label",
150 'p.fk_product_type'=>
'Type',
'p.tosell'=>
"OnSell",
'p.tobuy'=>
"OnBuy",
151 'p.description'=>
"Description",
'p.url'=>
"PublicUrl",
152 'p.customcode'=>
'CustomCode',
'p.fk_country'=>
'IDCountry',
153 'p.accountancy_code_sell'=>
"ProductAccountancySellCode",
'p.accountancy_code_sell_intra'=>
"ProductAccountancySellIntraCode",
154 'p.accountancy_code_sell_export'=>
"ProductAccountancySellExportCode",
'p.accountancy_code_buy'=>
"ProductAccountancyBuyCode",
155 'p.accountancy_code_buy_intra'=>
"ProductAccountancyBuyIntraCode",
'p.accountancy_code_buy_export'=>
"ProductAccountancyBuyExportCode",
156 'p.note'=>
"NotePrivate",
'p.note_public'=>
'NotePublic',
157 'p.weight'=>
"Weight",
'p.length'=>
"Length",
'p.width'=>
"Width",
'p.height'=>
"Height",
'p.surface'=>
"Surface",
'p.volume'=>
"Volume",
158 'p.duration'=>
"Duration",
159 'p.finished' =>
'Nature',
160 'p.price_base_type'=>
"PriceBase",
'p.price'=>
"UnitPriceHT",
'p.price_ttc'=>
"UnitPriceTTC",
161 'p.tva_tx'=>
'VATRate',
162 'p.datec'=>
'DateCreation',
'p.tms'=>
'DateModification'
164 if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r][
'p.recuperableonly'] =
'NPR';
165 if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.cost_price'=>
'CostPrice'));
166 if (!empty($conf->stock->enabled)) $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'));
167 if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode'=>
'BarCode'));
168 $keyforselect =
'product'; $keyforelement =
'product'; $keyforaliasextra =
'extra';
169 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
170 if (!empty($conf->fournisseur->enabled)) $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'));
171 if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'group_concat(cat.label)'=>
'Categories'));
172 if (!empty($conf->global->MAIN_MULTILANGS)) $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'));
173 if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r][
'p.fk_unit'] =
'Unit';
174 $this->export_TypeFields_array[$r] = array(
175 'p.ref'=>
"Text",
'p.label'=>
"Text",
176 'p.fk_product_type'=>
'Numeric',
'p.tosell'=>
"Boolean",
'p.tobuy'=>
"Boolean",
177 'p.description'=>
"Text",
'p.url'=>
"Text",
'p.accountancy_code_sell'=>
"Text",
178 'p.accountancy_code_sell_intra'=>
"Text",
'p.accountancy_code_sell_export'=>
"Text",
'p.accountancy_code_buy'=>
"Text",
179 'p.accountancy_code_buy_intra'=>
"Text",
'p.accountancy_code_buy_export'=>
"Text",
180 'p.note'=>
"Text",
'p.note_public'=>
"Text",
181 'p.weight'=>
"Numeric",
'p.length'=>
"Numeric",
'p.width'=>
"Numeric",
'p.height'=>
"Numeric",
'p.surface'=>
"Numeric",
'p.volume'=>
"Numeric",
182 'p.customcode'=>
'Text',
183 'p.duration'=>
"Text",
184 'p.finished' =>
'Numeric',
185 'p.price_base_type'=>
"Text",
'p.price'=>
"Numeric",
'p.price_ttc'=>
"Numeric",
'p.tva_tx'=>
'Numeric',
186 'p.datec'=>
'Date',
'p.tms'=>
'Date'
188 if (!empty($conf->stock->enabled)) $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'));
189 if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode'=>
'Text'));
190 if (!empty($conf->fournisseur->enabled)) $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'));
191 if (!empty($conf->global->MAIN_MULTILANGS)) $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'));
192 if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
"group_concat(cat.label)"=>
'Text'));
193 $this->export_entities_array[$r] = array();
194 if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
"group_concat(cat.label)"=>
'category'));
195 if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.stock'=>
'product',
'p.pmp'=>
'product'));
196 if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode'=>
'product'));
197 if (!empty($conf->fournisseur->enabled)) $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'));
198 if (!empty($conf->global->MAIN_MULTILANGS)) $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'));
199 if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array(
'category'=>
'p.rowid');
200 if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.stock'=>
'product',
'p.pmp'=>
'product'));
201 if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode'=>
'product'));
202 if (!empty($conf->fournisseur->enabled)) $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'));
203 if (!empty($conf->global->MAIN_MULTILANGS)) $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'));
204 if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r] = array(
'category'=>
'p.rowid');
205 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
206 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
207 if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $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';
208 if (!empty($conf->global->MAIN_MULTILANGS)) $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lang as l ON l.fk_product = p.rowid';
209 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON p.rowid = extra.fk_object';
210 if (!empty($conf->fournisseur->enabled)) $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';
211 $this->export_sql_end[$r] .=
' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity(
'product').
')';
212 if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =
' GROUP BY p.rowid';
214 if (empty($conf->product->enabled))
216 if (!empty($conf->global->PRODUIT_MULTIPRICES))
220 $this->export_code[$r] = $this->rights_class.
'_'.$r;
221 $this->export_label[$r] =
"ProductsMultiPrice";
222 $this->export_permission[$r] = array(array(
"produit",
"export"));
223 $this->export_fields_array[$r] = array(
'p.rowid'=>
"Id",
'p.ref'=>
"Ref",
224 'pr.price_base_type'=>
"PriceBase",
'pr.price_level'=>
"PriceLevel",
225 'pr.price'=>
"PriceLevelUnitPriceHT",
'pr.price_ttc'=>
"PriceLevelUnitPriceTTC",
226 'pr.price_min'=>
"MinPriceLevelUnitPriceHT",
'pr.price_min_ttc'=>
"MinPriceLevelUnitPriceTTC",
227 'pr.tva_tx'=>
'PriceLevelVATRate',
228 'pr.date_price'=>
'DateCreation');
229 if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r][
'pr.recuperableonly'] =
'NPR';
236 $this->export_entities_array[$r] = array(
'p.rowid'=>
"product",
'p.ref'=>
"product",
237 'pr.price_base_type'=>
"product",
'pr.price_level'=>
"product",
'pr.price'=>
"product",
238 'pr.price_ttc'=>
"product",
239 'pr.price_min'=>
"product",
'pr.price_min_ttc'=>
"product",
240 'pr.tva_tx'=>
'product',
241 'pr.recuperableonly'=>
'product',
242 'pr.date_price'=>
"product");
243 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
244 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
245 $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;
246 $this->export_sql_end[$r] .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
249 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))
253 $this->export_code[$r] = $this->rights_class.
'_'.$r;
254 $this->export_label[$r] =
"ProductsPricePerCustomer";
255 $this->export_permission[$r] = array(array(
"produit",
"export"));
256 $this->export_fields_array[$r] = array(
'p.rowid'=>
"Id",
'p.ref'=>
"Ref",
257 's.nom'=>
'ThirdParty',
258 'pr.price_base_type'=>
"PriceBase",
259 'pr.price'=>
"PriceUnitPriceHT",
'pr.price_ttc'=>
"PriceUnitPriceTTC",
260 'pr.price_min'=>
"MinPriceUnitPriceHT",
'pr.price_min_ttc'=>
"MinPriceUnitPriceTTC",
261 'pr.tva_tx'=>
'PriceVATRate',
262 'pr.default_vat_code'=>
'PriceVATCode',
263 'pr.datec'=>
'DateCreation');
264 if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r][
'pr.recuperableonly'] =
'NPR';
265 $this->export_entities_array[$r] = array(
'p.rowid'=>
"product",
'p.ref'=>
"product",
267 'pr.price_base_type'=>
"product",
'pr.price'=>
"product",
268 'pr.price_ttc'=>
"product",
269 'pr.price_min'=>
"product",
'pr.price_min_ttc'=>
"product",
270 'pr.tva_tx'=>
'product',
271 'pr.default_vat_code'=>
'product',
272 'pr.recuperableonly'=>
'product',
273 'pr.datec'=>
"product");
274 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
275 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
276 $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;
277 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON pr.fk_soc = s.rowid';
278 $this->export_sql_end[$r] .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
281 if (!empty($conf->global->PRODUIT_SOUSPRODUITS))
285 $this->export_code[$r] = $this->rights_class.
'_'.$r;
286 $this->export_label[$r] =
"AssociatedProducts";
287 $this->export_permission[$r] = array(array(
"produit",
"export"));
288 $this->export_fields_array[$r] = array(
289 'p.rowid'=>
"Id",
'p.ref'=>
"Ref",
'p.label'=>
"Label",
'p.description'=>
"Description",
'p.url'=>
"PublicUrl",
290 'p.accountancy_code_sell'=>
"ProductAccountancySellCode",
'p.accountancy_code_sell_intra'=>
"ProductAccountancySellIntraCode",
291 'p.accountancy_code_sell_export'=>
"ProductAccountancySellExportCode",
'p.accountancy_code_buy'=>
"ProductAccountancyBuyCode",
292 'p.accountancy_code_buy_intra'=>
"ProductAccountancyBuyIntraCode",
'p.accountancy_code_buy_export'=>
"ProductAccountancyBuyExportCode",
293 'p.note'=>
"NotePrivate",
'p.note_public'=>
'NotePublic',
294 'p.weight'=>
"Weight",
'p.length'=>
"Length",
'p.surface'=>
"Surface",
'p.volume'=>
"Volume",
'p.customcode'=>
'CustomCode',
295 'p.price_base_type'=>
"PriceBase",
'p.price'=>
"UnitPriceHT",
'p.price_ttc'=>
"UnitPriceTTC",
'p.tva_tx'=>
'VATRate',
'p.tosell'=>
"OnSell",
296 'p.tobuy'=>
"OnBuy",
'p.datec'=>
'DateCreation',
'p.tms'=>
'DateModification'
298 if (!empty($conf->stock->enabled)) $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'));
299 if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode'=>
'BarCode'));
300 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'pa.qty'=>
'Qty',
'pa.incdec'=>
'ComposedProductIncDecStock'));
301 $this->export_TypeFields_array[$r] = array(
302 'p.ref'=>
"Text",
'p.label'=>
"Text",
'p.description'=>
"Text",
'p.url'=>
"Text",
303 'p.accountancy_code_sell'=>
"Text",
'p.accountancy_code_sell_intra'=>
"Text",
'p.accountancy_code_sell_export'=>
"Text",
304 'p.accountancy_code_buy'=>
"Text",
'p.accountancy_code_buy_intra'=>
"Text",
'p.accountancy_code_buy_export'=>
"Text",
305 'p.note'=>
"Text",
'p.note_public'=>
"Text",
306 'p.weight'=>
"Numeric",
'p.length'=>
"Numeric",
'p.surface'=>
"Numeric",
'p.volume'=>
"Numeric",
'p.customcode'=>
'Text',
307 'p.price_base_type'=>
"Text",
'p.price'=>
"Numeric",
'p.price_ttc'=>
"Numeric",
'p.tva_tx'=>
'Numeric',
'p.tosell'=>
"Boolean",
'p.tobuy'=>
"Boolean",
308 'p.datec'=>
'Date',
'p.tms'=>
'Date'
310 if (!empty($conf->stock->enabled)) $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'));
311 if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode'=>
'Text'));
312 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'pa.qty'=>
'Numeric'));
313 $this->export_entities_array[$r] = array(
314 'p.rowid'=>
"virtualproduct",
'p.ref'=>
"virtualproduct",
'p.label'=>
"virtualproduct",
'p.description'=>
"virtualproduct",
'p.url'=>
"virtualproduct",
315 'p.accountancy_code_sell'=>
'virtualproduct',
'p.accountancy_code_sell_intra'=>
'virtualproduct',
'p.accountancy_code_sell_export'=>
'virtualproduct',
316 'p.accountancy_code_buy'=>
'virtualproduct',
'p.accountancy_code_buy_intra'=>
'virtualproduct',
'p.accountancy_code_buy_export'=>
'virtualproduct',
317 'p.note'=>
"virtualproduct",
'p.length'=>
"virtualproduct",
318 'p.surface'=>
"virtualproduct",
'p.volume'=>
"virtualproduct",
'p.weight'=>
"virtualproduct",
'p.customcode'=>
'virtualproduct',
319 'p.price_base_type'=>
"virtualproduct",
'p.price'=>
"virtualproduct",
'p.price_ttc'=>
"virtualproduct",
'p.tva_tx'=>
"virtualproduct",
320 'p.tosell'=>
"virtualproduct",
'p.tobuy'=>
"virtualproduct",
'p.datec'=>
"virtualproduct",
'p.tms'=>
"virtualproduct"
322 if (!empty($conf->stock->enabled)) $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'));
323 if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode'=>
'virtualproduct'));
324 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'pa.qty'=>
"subproduct",
'pa.incdec'=>
'subproduct'));
325 $keyforselect =
'product'; $keyforelement =
'product'; $keyforaliasextra =
'extra';
326 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
327 $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"));
328 $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"));
329 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
330 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
331 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON p.rowid = extra.fk_object,';
332 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'product_association as pa, '.MAIN_DB_PREFIX.
'product as p2';
333 $this->export_sql_end[$r] .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
334 $this->export_sql_end[$r] .=
' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';
345 $this->import_code[$r] = $this->rights_class.
'_'.$r;
346 $this->import_label[$r] =
"Products";
347 $this->import_icon[$r] = $this->picto;
348 $this->import_entities_array[$r] = array();
349 $this->import_tables_array[$r] = array(
'p'=>MAIN_DB_PREFIX.
'product',
'extra'=>MAIN_DB_PREFIX.
'product_extrafields');
350 $this->import_tables_creator_array[$r] = array(
'p'=>
'fk_user_author');
351 $this->import_fields_array[$r] = array(
353 'p.label' =>
"Label*",
354 'p.fk_product_type' =>
"Type*",
355 'p.tosell' =>
"OnSell*",
356 'p.tobuy' =>
"OnBuy*",
357 'p.description' =>
"Description",
358 'p.url' =>
"PublicUrl",
359 'p.customcode' =>
'CustomCode',
360 'p.fk_country' =>
'CountryCode',
361 'p.accountancy_code_sell' =>
"ProductAccountancySellCode",
362 'p.accountancy_code_sell_intra' =>
"ProductAccountancySellIntraCode",
363 'p.accountancy_code_sell_export' =>
"ProductAccountancySellExportCode",
364 'p.accountancy_code_buy' =>
"ProductAccountancyBuyCode",
365 'p.accountancy_code_buy_intra' =>
"ProductAccountancyBuyIntraCode",
366 'p.accountancy_code_buy_export' =>
"ProductAccountancyBuyExportCode",
367 'p.note_public' =>
"NotePublic",
368 'p.note' =>
"NotePrivate",
369 'p.weight' =>
"Weight",
370 'p.weight_units' =>
"WeightUnits",
371 'p.length' =>
"Length",
372 'p.length_units' =>
"LengthUnit",
373 'p.width' =>
"Width",
374 'p.width_units' =>
"WidthUnits",
375 'p.height' =>
"Height",
376 'p.height_units' =>
"HeightUnit",
377 'p.surface' =>
"Surface",
378 'p.surface_units' =>
"SurfaceUnit",
379 'p.volume' =>
"Volume",
380 'p.volume_units' =>
"VolumeUnits",
381 'p.duration' =>
"Duration",
382 'p.finished' =>
'Nature',
383 'p.price' =>
"SellingPriceHT",
384 'p.price_min' =>
"MinPrice",
385 'p.price_ttc' =>
"SellingPriceTTC",
386 'p.price_min_ttc' =>
"SellingMinPriceTTC",
387 'p.price_base_type' =>
"PriceBaseType",
388 'p.tva_tx' =>
'VATRate',
389 'p.datec' =>
'DateCreation',
390 'p.cost_price' =>
"CostPrice",
392 if (!empty($conf->stock->enabled)) {
393 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
394 'p.seuil_stock_alerte' =>
'StockLimit',
395 'p.pmp' =>
'PMPValue',
396 'p.desiredstock' =>
'DesiredStock'
400 $this->import_convertvalue_array[$r] = array(
401 'p.weight_units' => array(
402 'rule' =>
'fetchscalefromcodeunits',
403 'classfile' =>
'/core/class/cunits.class.php',
407 'dict' =>
'DictionaryMeasuringUnits'
409 'p.length_units' => array(
410 'rule' =>
'fetchscalefromcodeunits',
411 'classfile' =>
'/core/class/cunits.class.php',
415 'dict' =>
'DictionaryMeasuringUnits'
417 'p.width_units' => array(
418 'rule' =>
'fetchscalefromcodeunits',
419 'classfile' =>
'/core/class/cunits.class.php',
423 'dict' =>
'DictionaryMeasuringUnits'
425 'p.height_units' => array(
426 'rule' =>
'fetchscalefromcodeunits',
427 'classfile' =>
'/core/class/cunits.class.php',
431 'dict' =>
'DictionaryMeasuringUnits'
433 'p.surface_units' => array(
434 'rule' =>
'fetchscalefromcodeunits',
435 'classfile' =>
'/core/class/cunits.class.php',
438 'units' =>
'surface',
439 'dict' =>
'DictionaryMeasuringUnits'
441 'p.volume_units' => array(
442 'rule' =>
'fetchscalefromcodeunits',
443 'classfile' =>
'/core/class/cunits.class.php',
447 'dict' =>
'DictionaryMeasuringUnits'
449 'p.fk_country' => array(
450 'rule' =>
'fetchidfromcodeid',
451 'classfile' =>
'/core/class/ccountry.class.php',
452 'class' =>
'Ccountry',
454 'dict' =>
'DictionaryCountry'
457 if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.cost_price'=>
'CostPrice'));
458 if (is_object($mysoc) && $usenpr) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.recuperableonly'=>
'NPR'));
459 if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.localtax1_tx'=>
'LT1',
'p.localtax1_type'=>
'LT1Type'));
460 if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.localtax2_tx'=>
'LT2',
'p.localtax2_type'=>
'LT2Type'));
461 if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.barcode'=>
'BarCode'));
462 if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r][
'p.fk_unit'] =
'Unit';
464 $import_extrafield_sample = array();
465 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.
")";
469 while ($obj = $this->
db->fetch_object(
$resql))
471 $fieldname =
'extra.'.$obj->name;
472 $fieldlabel = ucfirst($obj->label);
473 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
474 $import_extrafield_sample[$fieldname] = $fieldlabel;
478 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'product');
479 $this->import_regex_array[$r] = array(
481 'p.price_base_type' =>
'\AHT\z|\ATTC\z',
482 'p.tosell'=>
'^[0|1]$',
483 'p.tobuy'=>
'^[0|1]$',
484 'p.fk_product_type'=>
'^[0|1]$',
485 'p.datec'=>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
486 'p.recuperableonly' =>
'^[0|1]$',
487 'p.finished' =>
'^[0|1]$'
490 $import_sample = array(
491 'p.ref' =>
"PREF123456",
493 'p.label' =>
"Product name in default language",
494 'p.description' =>
"Product description in default language",
495 'p.note_public' =>
"a public note (free text)",
496 'p.note' =>
"a private note (free text)",
497 'p.customcode' =>
'customs code',
498 'p.fk_country' =>
'FR',
500 'p.price_min' =>
"100",
501 'p.price_ttc' =>
"110",
502 'p.price_min_ttc' =>
"110",
503 'p.price_base_type' =>
"HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
505 'p.tosell' =>
"0 (not for sale to customer, eg. raw material) / 1 (for sale)",
506 'p.tobuy' =>
"0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
507 'p.fk_product_type' =>
"0 (product) / 1 (service)",
508 'p.duration' =>
"eg. 365d/12m/1y",
509 'p.url' =>
'link to product (no https)',
510 'p.accountancy_code_sell' =>
"",
511 'p.accountancy_code_sell_intra' =>
"",
512 'p.accountancy_code_sell_export' =>
"",
513 'p.accountancy_code_buy' =>
"",
514 'p.accountancy_code_buy_intra' =>
"",
515 'p.accountancy_code_buy_export' =>
"",
517 'p.weight_units' =>
'kg',
519 'p.length_units' =>
'm',
521 'p.width_units' =>
'm',
523 'p.height_units' =>
'm',
525 'p.surface_units' =>
'm2',
527 'p.volume_units' =>
'm3',
528 'p.finished' =>
'0 (raw material) / 1 (finished goods)'
531 if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array(
532 'p.seuil_stock_alerte' =>
'',
534 'p.desiredstock' =>
''
536 if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array(
'p.cost_price'=>
'90'));
537 if (is_object($mysoc) && $usenpr) $import_sample = array_merge($import_sample, array(
'p.recuperableonly'=>
'0'));
538 if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array(
'p.localtax1_tx'=>
'',
'p.localtax1_type'=>
''));
539 if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array(
'p.localtax2_tx'=>
'',
'p.localtax2_type'=>
''));
540 if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array(
'p.barcode'=>
''));
541 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
542 $import_sample = array_merge(
545 '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"'
549 if (!is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array();
550 $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
551 'p.fk_unit' => array(
552 'rule' =>
'fetchidfromcodeorlabel',
553 'classfile' =>
'/core/class/cunits.class.php',
556 'dict' =>
'DictionaryUnits'
560 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
561 $this->import_updatekeys_array[$r] = array(
'p.ref'=>
'Ref');
562 if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array(
'p.barcode'=>
'BarCode'));
564 if (empty($conf->product->enabled))
566 if (!empty($conf->fournisseur->enabled))
570 $this->import_code[$r] = $this->rights_class.
'_supplierprices';
571 $this->import_label[$r] =
"SuppliersPricesOfProductsOrServices";
572 $this->import_icon[$r] = $this->picto;
573 $this->import_entities_array[$r] = array();
574 $this->import_tables_array[$r] = array(
'sp'=>MAIN_DB_PREFIX.
'product_fournisseur_price');
575 $this->import_tables_creator_array[$r] = array(
'sp'=>
'fk_user');
576 $this->import_fields_array[$r] = array(
577 'sp.fk_product'=>
"ProductOrService*",
578 'sp.fk_soc' =>
"Supplier*",
579 'sp.ref_fourn' =>
'SupplierRef*',
580 'sp.quantity' =>
"QtyMin*",
581 'sp.tva_tx' =>
'VATRate',
582 'sp.default_vat_code' =>
'VATCode',
583 'sp.delivery_time_days' =>
'DeliveryDelay',
584 'sp.supplier_reputation' =>
'SupplierReputation'
586 if (is_object($mysoc) && $usenpr) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.recuperableonly'=>
'VATNPR'));
587 if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.localtax1_tx'=>
'LT1',
'sp.localtax1_type'=>
'LT1Type'));
588 if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'sp.localtax2_tx'=>
'LT2',
'sp.localtax2_type'=>
'LT2Type'));
589 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
590 'sp.price'=>
"PriceQtyMinHT*",
591 'sp.unitprice'=>
'UnitPriceHT*',
592 'sp.remise_percent'=>
'DiscountQtyMin'
595 if (!empty($conf->multicurrency->enabled))
597 $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
598 'sp.fk_multicurrency'=>
'CurrencyCodeId',
599 'sp.multicurrency_code'=>
'CurrencyCode',
600 'sp.multicurrency_tx'=>
'CurrencyRate',
601 'sp.multicurrency_unitprice'=>
'CurrencyUnitPrice',
602 'sp.multicurrency_price'=>
'CurrencyPrice',
606 $this->import_convertvalue_array[$r] = array(
607 'sp.fk_soc'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/societe/class/societe.class.php',
'class'=>
'Societe',
'method'=>
'fetch',
'element'=>
'ThirdParty'),
608 'sp.fk_product'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/product/class/product.class.php',
'class'=>
'Product',
'method'=>
'fetch',
'element'=>
'Product')
610 $this->import_examplevalues_array[$r] = array(
611 'sp.fk_product' =>
"PRODUCT_REF or id:123456",
612 'sp.fk_soc' =>
"My Supplier",
613 'sp.ref_fourn' =>
"XYZ-F123456",
614 'sp.quantity' =>
"5",
617 'sp.unitprice'=>
'50',
618 'sp.remise_percent'=>
'0',
619 'sp.default_vat_code' =>
'',
620 'sp.delivery_time_days' =>
'5',
621 'sp.supplier_reputation' =>
'FAVORITE / NOTTHGOOD / DONOTORDER'
623 if (is_object($mysoc) && $usenpr) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.recuperableonly'=>
''));
624 if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.localtax1_tx'=>
'LT1',
'sp.localtax1_type'=>
'LT1Type'));
625 if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.localtax2_tx'=>
'LT2',
'sp.localtax2_type'=>
'LT2Type'));
626 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
627 'sp.price' =>
"50.00",
628 'sp.unitprice' =>
'10',
630 'sp.remise_percent' =>
'20'
632 if (!empty($conf->multicurrency->enabled))
634 $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
635 'sp.fk_multicurrency'=>
'eg: 2, rowid for code of multicurrency currency',
636 'sp.multicurrency_code'=>
'GBP',
637 'sp.multicurrency_tx'=>
'1.12345',
638 'sp.multicurrency_unitprice'=>
'',
640 'sp.multicurrency_price'=>
''
644 $this->import_updatekeys_array[$r] = array(
'sp.fk_product'=>
'ProductOrService',
'sp.ref_fourn'=>
'SupplierRef',
'sp.fk_soc'=>
'Supplier');
647 if (!empty($conf->global->PRODUIT_MULTIPRICES))
651 $this->import_code[$r] = $this->rights_class.
'_multiprice';
652 $this->import_label[$r] =
"ProductsOrServiceMultiPrice";
653 $this->import_icon[$r] = $this->picto;
654 $this->import_entities_array[$r] = array();
655 $this->import_tables_array[$r] = array(
'pr'=>MAIN_DB_PREFIX.
'product_price');
656 $this->import_tables_creator_array[$r] = array(
'pr'=>
'fk_user_author');
657 $this->import_fields_array[$r] = array(
'pr.fk_product'=>
"ProductOrService*",
658 'pr.price_base_type'=>
"PriceBase",
'pr.price_level'=>
"PriceLevel",
659 'pr.price'=>
"PriceLevelUnitPriceHT",
'pr.price_ttc'=>
"PriceLevelUnitPriceTTC",
660 'pr.price_min'=>
"MinPriceLevelUnitPriceHT",
'pr.price_min_ttc'=>
"MinPriceLevelUnitPriceTTC",
661 'pr.date_price'=>
'DateCreation*');
662 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r][
'pr.tva_tx'] =
'VATRate';
663 if (is_object($mysoc) && $usenpr) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'pr.recuperableonly'=>
'NPR'));
664 $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]$');
665 $this->import_convertvalue_array[$r] = array(
666 'pr.fk_product'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/product/class/product.class.php',
'class'=>
'Product',
'method'=>
'fetch',
'element'=>
'Product')
668 $this->import_examplevalues_array[$r] = array(
'pr.fk_product'=>
"SERVICE_REF or id:123456",
669 'pr.price_base_type'=>
"HT (for excl tax) or TTC (for inc tax)",
'pr.price_level'=>
"1",
670 'pr.price'=>
"100",
'pr.price_ttc'=>
"110",
671 'pr.price_min'=>
"100",
'pr.price_min_ttc'=>
"110",
673 'pr.recuperableonly'=>
'0',
674 'pr.date_price'=>
'2013-04-10');
677 if (!empty($conf->global->MAIN_MULTILANGS))
681 $this->import_code[$r] = $this->rights_class.
'_languages';
682 $this->import_label[$r] =
"ProductsOrServicesTranslations";
683 $this->import_icon[$r] = $this->picto;
684 $this->import_entities_array[$r] = array();
685 $this->import_tables_array[$r] = array(
'l'=>MAIN_DB_PREFIX.
'product_lang');
687 $this->import_fields_array[$r] = array(
'l.fk_product'=>
'ProductOrService*',
'l.lang'=>
'Language*',
'l.label'=>
'TranslatedLabel',
'l.description'=>
'TranslatedDescription');
689 $this->import_convertvalue_array[$r] = array(
690 'l.fk_product'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/product/class/product.class.php',
'class'=>
'Product',
'method'=>
'fetch',
'element'=>
'Product')
692 $this->import_examplevalues_array[$r] = array(
'l.fk_product'=>
'SERVICE_REF or id:123456',
'l.lang'=>
'en_US',
'l.label'=>
'Label in en_US',
'l.description'=>
'Desc in en_US');
693 $this->import_updatekeys_array[$r] = array(
'l.fk_product'=>
'ProductOrService',
'l.lang'=>
'Language');
707 public function init($options =
'')
709 $this->
remove($options);
713 return $this->
_init($sql, $options);
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode= 'auto')
Return date for now.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
Class to describe and enable module Service.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
_init($array_sql, $options= '')
Enables a module.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
init($options= '')
Function called when module is enabled.
__construct($db)
Constructor.