52 $this->family =
"products";
53 $this->module_position =
'39';
55 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
59 $this->version =
'dolibarr';
61 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
62 $this->picto =
'stock';
65 $this->dirs = array(
"/stock/temp");
67 $this->config_page_url = array(
"stock.php");
70 $this->hidden =
false;
71 $this->depends = array(
"modProduct");
72 $this->requiredby = array(
"modProductBatch");
73 $this->conflictwith = [];
74 $this->langfiles = array(
"stocks");
79 'STOCK_DISALLOW_NEGATIVE_TRANSFER',
89 'Name of PDF model of stock',
93 "MOUVEMENT_ADDON_PDF",
95 "standard_movement_stock",
96 'Name of PDF model of stock movement',
100 "STOCK_ADDON_PDF_ODT_PATH",
102 "DOL_DATA_ROOT".($conf->entity > 1 ?
'/'.$conf->entity :
'').
"/doctemplates/stocks",
107 "MOUVEMENT_ADDON_PDF_ODT_PATH",
109 "DOL_DATA_ROOT".($conf->entity > 1 ?
'/'.$conf->entity :
'').
"/doctemplates/stocks/movements",
120 $this->rights_class =
'stock';
124 $this->rights[$r][0] = 1001;
125 $this->rights[$r][1] =
'Read stocks';
126 $this->rights[$r][2] =
'r';
127 $this->rights[$r][3] = 0;
128 $this->rights[$r][4] =
'lire';
129 $this->rights[$r][5] =
'';
132 $this->rights[$r][0] = 1002;
133 $this->rights[$r][1] =
'Create/Modify stocks';
134 $this->rights[$r][2] =
'w';
135 $this->rights[$r][3] = 0;
136 $this->rights[$r][4] =
'creer';
137 $this->rights[$r][5] =
'';
140 $this->rights[$r][0] = 1003;
141 $this->rights[$r][1] =
'Delete stock';
142 $this->rights[$r][2] =
'd';
143 $this->rights[$r][3] = 0;
144 $this->rights[$r][4] =
'supprimer';
145 $this->rights[$r][5] =
'';
148 $this->rights[$r][0] = 1004;
149 $this->rights[$r][1] =
'Read stock movements';
150 $this->rights[$r][2] =
'r';
151 $this->rights[$r][3] = 0;
152 $this->rights[$r][4] =
'mouvement';
153 $this->rights[$r][5] =
'lire';
156 $this->rights[$r][0] = 1005;
157 $this->rights[$r][1] =
'Create/modify stock movements';
158 $this->rights[$r][2] =
'w';
159 $this->rights[$r][3] = 0;
160 $this->rights[$r][4] =
'mouvement';
161 $this->rights[$r][5] =
'creer';
166 $this->rights[$r][0] = 1008;
167 $this->rights[$r][1] =
'Read stock value';
168 $this->rights[$r][2] =
'w';
169 $this->rights[$r][3] = 0;
170 $this->rights[$r][4] =
'value_advance';
171 $this->rights[$r][5] =
'read';
175 $this->rights[$r][0] = 1011;
176 $this->rights[$r][1] =
'inventoryReadPermission';
177 $this->rights[$r][3] = 0;
178 $this->rights[$r][4] =
'inventory_advance';
179 $this->rights[$r][5] =
'read';
182 $this->rights[$r][0] = 1012;
183 $this->rights[$r][1] =
'inventoryCreatePermission';
184 $this->rights[$r][3] = 0;
185 $this->rights[$r][4] =
'inventory_advance';
186 $this->rights[$r][5] =
'write';
189 $this->rights[$r][0] = 1013;
190 $this->rights[$r][1] =
'inventoryDeletePermission';
191 $this->rights[$r][3] = 0;
192 $this->rights[$r][4] =
'inventory_advance';
193 $this->rights[$r][5] =
'delete';
197 $this->rights[$r][0] = 1014;
198 $this->rights[$r][1] =
'inventoryValidatePermission';
199 $this->rights[$r][3] = 0;
200 $this->rights[$r][4] =
'inventory_advance';
201 $this->rights[$r][5] =
'validate';
204 $this->rights[$r][0] = 1015;
205 $this->rights[$r][1] =
'inventoryChangePMPPermission';
206 $this->rights[$r][3] = 0;
207 $this->rights[$r][4] =
'inventory_advance';
208 $this->rights[$r][5] =
'changePMP';
226 $this->export_code[$r] = $this->rights_class.
'_emplacement';
227 $this->export_label[$r] =
"Warehouses";
228 $this->export_icon[$r] =
"warehouse";
229 $this->export_permission[$r] = array(array(
"stock",
"lire"));
230 $this->export_fields_array[$r] = array(
231 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
232 'd.code_departement' =>
'Departement',
'c.code' =>
'CountryCode',
233 'e.phone' =>
'Phone',
'e.fax' =>
'Fax',
'e.statut' =>
'Status',
'pe.rowid' =>
'ParentWarehouse',
'pe.ref' =>
'LocationSummary'
235 $this->export_TypeFields_array[$r] = array(
236 'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
237 'd.code_departement' =>
'List:c_departements:code_departement:code_departement:',
'c.code' =>
'List:c_country:code:code:',
238 'e.phone' =>
'Text',
'e.fax' =>
'Text',
'e.statut' =>
'Text',
'pe.rowid' =>
'List:entrepot:ref:rowid:stock',
'pe.ref' =>
'Text'
240 $this->export_entities_array[$r] = [];
241 $this->export_aggregate_array[$r] = [];
242 $keyforselect =
'entrepot';
243 $keyforelement =
'entrepot';
244 $keyforaliasextra =
'extra';
245 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
247 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
248 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'entrepot as e';
249 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON d.rowid = e.fk_departement';
250 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON c.rowid = e.fk_pays';
251 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as pe ON pe.rowid = e.fk_parent';
252 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot_extrafields as extra ON extra.fk_object = e.rowid';
253 $this->export_sql_end[$r] .=
' WHERE e.entity IN ('.getEntity(
'stock').
')';
257 $this->export_code[$r] = $this->rights_class.
'_emplacement_product';
258 $this->export_label[$r] =
"Stocks";
259 $this->export_icon[$r] =
"warehouse";
260 $this->export_permission[$r] = array(array(
"stock",
"lire"));
261 $this->export_fields_array[$r] = array(
262 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
263 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
264 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
265 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
266 'p.seuil_stock_alerte' =>
'StockLimit',
'p.barcode' =>
'BarCode',
'bt.libelle' =>
'BarcodeType',
269 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
271 $this->export_TypeFields_array[$r] = array(
272 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
273 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
274 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
275 'p.datec' =>
'Date',
'p.tms' =>
'Date',
'p.pmp' =>
'Numeric',
'p.cost_price' =>
'Numeric',
276 'ps.reel' =>
'Numeric',
277 'p.seuil_stock_alerte' =>
'Numeric',
'p.barcode' =>
'Text',
'bt.libelle' =>
'List:c_barcode_type:libelle',
280 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
282 $this->export_entities_array[$r] = array(
283 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
284 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
285 'p.datec' =>
'product',
'p.tms' =>
'product',
'p.pmp' =>
'product',
'p.cost_price' =>
'product',
286 'ps.reel' =>
'stock',
287 'p.seuil_stock_alerte' =>
'product',
'p.barcode' =>
'product',
'bt.libelle' =>
'product',
290 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
292 $this->export_aggregate_array[$r] = array(
'ps.reel' =>
'SUM');
293 $this->export_dependencies_array[$r] = array(
'stock' => array(
'p.rowid',
'e.rowid'));
294 $keyforselect =
'product';
295 $keyforelement =
'product';
296 $keyforaliasextra =
'extra';
297 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
298 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'ps.reel' =>
'Stock'));
300 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
301 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
302 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON extra.fk_object = p.rowid';
303 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_barcode_type as bt ON bt.rowid = p.fk_barcode_type';
304 $this->export_sql_end[$r] .=
', '.MAIN_DB_PREFIX.
'product_stock as ps, '.MAIN_DB_PREFIX.
'entrepot as e';
305 $this->export_sql_end[$r] .=
' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
306 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
310 $langs->load(
"productbatch");
315 $this->export_code[$r] = $this->rights_class.
'_emplacement_product_lot';
316 $this->export_label[$r] =
"StocksWithBatch";
317 $this->export_icon[$r] =
"warehouse";
318 $this->export_permission[$r] = array(array(
"stock",
"lire"));
319 $this->export_fields_array[$r] = array(
320 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
321 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
322 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
323 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
'lcpn.label'=>
'Nature',
324 'pb.rowid' =>
'Id',
'pb.batch' =>
'Batch',
'pb.qty' =>
'Qty',
325 'pl.eatby' =>
'EatByDate',
'pl.sellby' =>
'SellByDate',
'none.dateLastMovement' =>
'LastMovement'
328 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
330 $this->export_TypeFields_array[$r] = array(
331 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.lieu' =>
'Text',
'e.description' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
332 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
333 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
334 'p.datec' =>
'Date',
'p.tms' =>
'Date',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
'lcpn.label'=>
'Text',
335 'pb.batch' =>
'Text',
'pb.qty' =>
'Numeric',
336 'pl.eatby' =>
'Date',
'pl.sellby' =>
'Date',
'none.dateLastMovement' =>
'Date'
339 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
341 $this->export_entities_array[$r] = array(
342 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
343 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
344 'p.datec' =>
'product',
'p.tms' =>
'product',
'p.pmp' =>
'product',
'p.cost_price' =>
'product',
'lcpn.label'=>
'product',
345 'pb.rowid' =>
'batch',
'pb.batch' =>
'batch',
'pb.qty' =>
'batch',
'none.dateLastMovement' =>
'movement',
346 'pl.eatby' =>
'batch',
'pl.sellby' =>
'batch'
348 $this->export_special_array[$r] = array(
349 'none.dateLastMovement'=>array(
'rule'=>
'compute',
'classfile'=>
'/product/stock/class/mouvementstock.class.php',
'class'=>
'MouvementStock',
'method'=>
'getDateLastMovementProductBatch',
'method_params'=>[
'e_rowid',
'p_rowid',
'pb_batch']),
352 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
354 $this->export_aggregate_array[$r] = array(
'ps.reel' =>
'SUM');
355 $this->export_dependencies_array[$r] = array(
'stockbatch' => array(
'pb.rowid'),
'batch' => array(
'pb.rowid'));
356 $keyforselect =
'product_lot';
357 $keyforelement =
'batch';
358 $keyforaliasextra =
'extra';
359 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
361 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
362 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product_batch as pb';
363 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product_stock as ps ON ps.rowid = pb.fk_product_stock';
364 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product as p ON p.rowid = ps.fk_product';
365 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lot as pl ON pl.fk_product = p.rowid AND pl.batch = pb.batch';
366 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lot_extrafields as extra ON extra.fk_object = pl.rowid';
367 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_product_nature as lcpn on lcpn.code = p.finished,';
368 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'entrepot as e';
369 $this->export_sql_end[$r] .=
' WHERE ps.fk_entrepot = e.rowid';
370 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
375 $this->export_code[$r] = $this->rights_class.
'_movement';
376 $this->export_label[$r] =
"StockMovements";
377 $this->export_icon[$r] =
"movement";
378 $this->export_permission[$r] = array(array(
"stock",
"lire"));
379 $this->export_fields_array[$r] = array(
380 'sm.rowid' =>
'MovementId',
'sm.value' =>
'Qty',
'sm.datem' =>
'DateMovement',
'sm.label' =>
'MovementLabel',
'sm.inventorycode' =>
'InventoryCode',
381 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
382 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
383 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification'
386 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
388 $this->export_TypeFields_array[$r] = array(
389 'sm.rowid' =>
'Numeric',
'sm.value' =>
'Numeric',
'sm.datem' =>
'Date',
'sm.batch' =>
'Text',
'sm.label' =>
'Text',
'sm.inventorycode' =>
'Text',
390 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
391 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
392 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
'p.datec' =>
'Date',
'p.tms' =>
'Date'
395 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
397 $this->export_entities_array[$r] = array(
398 'e.rowid' =>
'warehouse',
'e.ref' =>
'warehouse',
'e.description' =>
'warehouse',
'e.lieu' =>
'warehouse',
'e.address' =>
'warehouse',
'e.zip' =>
'warehouse',
'e.town' =>
'warehouse',
399 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
400 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
'p.datec' =>
'product',
'p.tms' =>
'product'
403 $this->export_fields_array[$r][
'sm.batch'] =
'Batch';
404 $this->export_TypeFields_array[$r][
'sm.batch'] =
'Text';
405 $this->export_entities_array[$r][
'sm.batch'] =
'movement';
408 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
410 $this->export_aggregate_array[$r] = array(
'sm.value' =>
'SUM');
411 $this->export_dependencies_array[$r] = array(
'movement' => array(
'sm.rowid'));
413 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
414 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p, '.MAIN_DB_PREFIX.
'stock_mouvement as sm, '.MAIN_DB_PREFIX.
'entrepot as e';
415 $this->export_sql_end[$r] .=
' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid';
416 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
421 $this->export_code[$r] = $this->rights_class.
'_inventory';
422 $this->export_label[$r] =
"Inventories";
423 $this->export_icon[$r] =
"inventory";
424 $this->export_permission[$r] = array(array(
"stock",
"lire"));
425 $this->export_fields_array[$r] = array(
426 'i.rowid' =>
'InventoryId',
'i.ref' =>
'InventoryRef',
'i.date_inventory' =>
'DateInventory',
'i.status' =>
'InventoryStatus',
'i.title' =>
'InventoryTitle',
427 'id.rowid' =>
'InventoryLineId',
'id.qty_view' =>
'QtyViewed',
'id.qty_stock' =>
'QtyStock',
'id.qty_regulated' =>
'QtyRegulated',
428 'id.batch' =>
'Lotserial',
429 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
430 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
431 'p.barcode' =>
"Barcode",
'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification'
434 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
436 $this->export_TypeFields_array[$r] = array(
437 'id.rowid' =>
'Numeric',
438 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
439 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
440 'p.barcode' =>
"Text",
'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
'p.datec' =>
'Date',
'p.tms' =>
'Date',
441 'i.rowid' =>
'Numeric',
'i.ref' =>
'Text',
'i.date_inventory' =>
'Date',
'i.status' =>
'Numeric',
'i.title' =>
'Text',
442 'id.qty_view' =>
'Numeric',
'id.qty_stock' =>
'Numeric',
'id.batch' =>
'Text',
443 'id.qty_regulated' =>
'Numeric',
'id.fk_warehouse' =>
'Numeric',
446 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
448 $this->export_entities_array[$r] = array(
449 'id.qty_view' =>
'inventory_line',
'id.qty_stock' =>
'inventory_line',
'id.batch' =>
'inventory_line',
'id.qty_regulated' =>
'inventory_line',
'id.fk_warehouse' =>
'inventory_line',
'id.rowid' =>
'inventory_line',
'e.rowid' =>
'warehouse',
'e.ref' =>
'warehouse',
'e.description' =>
'warehouse',
'e.lieu' =>
'warehouse',
'e.address' =>
'warehouse',
'e.zip' =>
'warehouse',
'e.town' =>
'warehouse',
450 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
451 'p.barcode' =>
"product",
'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
'p.datec' =>
'product',
'p.tms' =>
'product'
454 $this->export_fields_array[$r][
'id.batch'] =
'Batch';
455 $this->export_TypeFields_array[$r][
'id.batch'] =
'Text';
456 $this->export_entities_array[$r][
'id.batch'] =
'inventory_line';
459 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
461 $this->export_aggregate_array[$r] = array(
'sm.value' =>
'SUM');
462 $this->export_dependencies_array[$r] = array(
'movement' => array(
'sm.rowid'));
464 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
465 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p, '.MAIN_DB_PREFIX.
'inventory as i, '.MAIN_DB_PREFIX.
'inventorydet as id, '.MAIN_DB_PREFIX.
'entrepot as e';
466 $this->export_sql_end[$r] .=
' WHERE p.rowid = id.fk_product AND id.fk_inventory = i.rowid AND id.fk_warehouse = e.rowid';
467 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
477 $this->import_code[$r] = $this->rights_class.
'_'.$r;
478 $this->import_label[$r] =
"Warehouses";
479 $this->import_icon[$r] =
"warehouse";
480 $this->import_entities_array[$r] = [];
481 $this->import_tables_array[$r] = array(
'e' => MAIN_DB_PREFIX.
'entrepot',
'extra' => MAIN_DB_PREFIX.
'entrepot_extrafields');
482 $this->import_tables_creator_array[$r] = array(
'e' =>
'fk_user_author');
483 $this->import_fields_array[$r] = array(
'e.ref' =>
"LocationSummary*",
484 'e.description' =>
"DescWareHouse",
485 'e.lieu' =>
"LieuWareHouse",
486 'e.address' =>
"Address",
488 'e.fk_departement' =>
'StateCode',
489 'e.fk_pays' =>
'CountryCode',
490 'e.phone' =>
'Phone',
492 'e.statut' =>
'Status',
493 'e.fk_parent' =>
'ParentWarehouse'
496 $this->import_convertvalue_array[$r] = array(
497 'e.fk_departement' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/cstate.class.php',
'class' =>
'Cstate',
'method' =>
'fetch',
'dict' =>
'DictionaryStateCode'),
498 'e.fk_pays' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/ccountry.class.php',
'class' =>
'Ccountry',
'method' =>
'fetch',
'dict' =>
'DictionaryCountry'),
499 'e.fk_parent' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/stock/class/entrepot.class.php',
'class' =>
'Entrepot',
'method' =>
'fetch',
'element' =>
'ref')
501 $this->import_regex_array[$r] = array(
'e.statut' =>
'^[0|1]');
503 $import_extrafield_sample = [];
504 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'entrepot' AND entity IN (0, ".
$conf->entity.
")";
505 $resql = $this->db->query($sql);
507 while ($obj = $this->db->fetch_object($resql)) {
508 $fieldname =
'extra.'.$obj->name;
509 $fieldlabel = ucfirst($obj->label);
510 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
511 $import_extrafield_sample[$fieldname] = $fieldlabel;
515 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'entrepot');
517 $this->import_examplevalues_array[$r] = array_merge(array(
'e.ref' =>
"ALM001",
518 'e.description' =>
"Central Warehouse",
519 'e.lieu' =>
"Central",
520 'e.address' =>
"Route 66",
522 'e.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
523 'e.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
524 'e.phone' =>
'(+33)(0)123456789',
525 'e.fax' =>
'(+33)(0)123456790',
527 'e.fk_parent' =>
'id or ref of warehouse'
528 ), $import_extrafield_sample);
529 $this->import_updatekeys_array[$r] = array(
'p.ref' =>
'Ref');
533 $this->import_code[$r] = $this->rights_class.
'_'.$r;
534 $this->import_label[$r] =
"Stocks";
535 $this->import_icon[$r] =
"stock";
536 $this->import_entities_array[$r] = [];
537 $this->import_tables_array[$r] = array(
'ps' => MAIN_DB_PREFIX.
'product_stock');
538 $this->import_fields_array[$r] = array(
'ps.fk_product' =>
"Product*",
'ps.fk_entrepot' =>
"Warehouse*",
'ps.reel' =>
"Stock*");
540 $this->import_convertvalue_array[$r] = array(
541 'ps.fk_product' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/class/product.class.php',
'class' =>
'Product',
'method' =>
'fetch',
'element' =>
'product'),
542 'ps.fk_entrepot' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/stock/class/entrepot.class.php',
'class' =>
'Entrepot',
'method' =>
'fetch',
'element' =>
'ref')
544 $this->import_examplevalues_array[$r] = array(
545 'ps.fk_product' =>
"id or ref of product",
'ps.fk_entrepot' =>
"id or ref of warehouse",
'ps.reel' =>
"10"
547 $this->import_updatekeys_array[$r] = array(
'ps.fk_product' =>
'Product',
'ps.fk_entrepot' =>
"Warehouse");
548 $this->import_run_sql_after_array[$r] = array(
549 'UPDATE '.MAIN_DB_PREFIX.
'product as p SET stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.
'product_stock ps WHERE ps.fk_product = p.rowid);'