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 = array();
74 $this->phpmin = array(7, 0);
75 $this->langfiles = array(
"stocks");
80 'STOCK_DISALLOW_NEGATIVE_TRANSFER',
90 'Name of PDF model of stock',
94 "MOUVEMENT_ADDON_PDF",
96 "standard_movement_stock",
97 'Name of PDF model of stock movement',
101 "STOCK_ADDON_PDF_ODT_PATH",
103 "DOL_DATA_ROOT".($conf->entity > 1 ?
'/'.$conf->entity :
'').
"/doctemplates/stocks",
108 "MOUVEMENT_ADDON_PDF_ODT_PATH",
110 "DOL_DATA_ROOT".($conf->entity > 1 ?
'/'.$conf->entity :
'').
"/doctemplates/stocks/movements",
118 $this->boxes = array();
121 $this->rights = array();
122 $this->rights_class =
'stock';
126 $this->rights[$r][0] = 1001;
127 $this->rights[$r][1] =
'Read stocks';
128 $this->rights[$r][2] =
'r';
129 $this->rights[$r][3] = 0;
130 $this->rights[$r][4] =
'lire';
131 $this->rights[$r][5] =
'';
134 $this->rights[$r][0] = 1002;
135 $this->rights[$r][1] =
'Create/Modify stocks';
136 $this->rights[$r][2] =
'w';
137 $this->rights[$r][3] = 0;
138 $this->rights[$r][4] =
'creer';
139 $this->rights[$r][5] =
'';
142 $this->rights[$r][0] = 1003;
143 $this->rights[$r][1] =
'Delete stock';
144 $this->rights[$r][2] =
'd';
145 $this->rights[$r][3] = 0;
146 $this->rights[$r][4] =
'supprimer';
147 $this->rights[$r][5] =
'';
150 $this->rights[$r][0] = 1004;
151 $this->rights[$r][1] =
'Read stock movements';
152 $this->rights[$r][2] =
'r';
153 $this->rights[$r][3] = 0;
154 $this->rights[$r][4] =
'mouvement';
155 $this->rights[$r][5] =
'lire';
158 $this->rights[$r][0] = 1005;
159 $this->rights[$r][1] =
'Create/modify stock movements';
160 $this->rights[$r][2] =
'w';
161 $this->rights[$r][3] = 0;
162 $this->rights[$r][4] =
'mouvement';
163 $this->rights[$r][5] =
'creer';
168 $this->rights[$r][0] = 1008;
169 $this->rights[$r][1] =
'Read stock value';
170 $this->rights[$r][2] =
'w';
171 $this->rights[$r][3] = 0;
172 $this->rights[$r][4] =
'value_advance';
173 $this->rights[$r][5] =
'read';
177 $this->rights[$r][0] = 1011;
178 $this->rights[$r][1] =
'inventoryReadPermission';
179 $this->rights[$r][3] = 0;
180 $this->rights[$r][4] =
'inventory_advance';
181 $this->rights[$r][5] =
'read';
184 $this->rights[$r][0] = 1012;
185 $this->rights[$r][1] =
'inventoryCreatePermission';
186 $this->rights[$r][3] = 0;
187 $this->rights[$r][4] =
'inventory_advance';
188 $this->rights[$r][5] =
'write';
191 $this->rights[$r][0] = 1013;
192 $this->rights[$r][1] =
'inventoryDeletePermission';
193 $this->rights[$r][3] = 0;
194 $this->rights[$r][4] =
'inventory_advance';
195 $this->rights[$r][5] =
'delete';
199 $this->rights[$r][0] = 1014;
200 $this->rights[$r][1] =
'inventoryValidatePermission';
201 $this->rights[$r][3] = 0;
202 $this->rights[$r][4] =
'inventory_advance';
203 $this->rights[$r][5] =
'validate';
206 $this->rights[$r][0] = 1015;
207 $this->rights[$r][1] =
'inventoryChangePMPPermission';
208 $this->rights[$r][3] = 0;
209 $this->rights[$r][4] =
'inventory_advance';
210 $this->rights[$r][5] =
'changePMP';
214 $this->menu = array();
228 $this->export_code[$r] = $this->rights_class.
'_emplacement';
229 $this->export_label[$r] =
"Warehouses";
230 $this->export_icon[$r] =
"warehouse";
231 $this->export_permission[$r] = array(array(
"stock",
"lire"));
232 $this->export_fields_array[$r] = array(
233 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
234 'd.code_departement' =>
'Departement',
'c.code' =>
'CountryCode',
235 'e.phone' =>
'Phone',
'e.fax' =>
'Fax',
'e.statut' =>
'Status',
'pe.rowid' =>
'ParentWarehouse',
'pe.ref' =>
'LocationSummary'
237 $this->export_TypeFields_array[$r] = array(
238 'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
239 'd.code_departement' =>
'List:c_departements:code_departement:code_departement:',
'c.code' =>
'List:c_country:code:code:',
240 'e.phone' =>
'Text',
'e.fax' =>
'Text',
'e.statut' =>
'Text',
'pe.rowid' =>
'List:entrepot:ref:rowid:stock',
'pe.ref' =>
'Text'
242 $this->export_entities_array[$r] = array();
243 $this->export_aggregate_array[$r] = array();
244 $keyforselect =
'entrepot';
245 $keyforelement =
'entrepot';
246 $keyforaliasextra =
'extra';
247 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
249 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
250 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'entrepot as e';
251 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON d.rowid = e.fk_departement';
252 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON c.rowid = e.fk_pays';
253 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as pe ON pe.rowid = e.fk_parent';
254 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot_extrafields as extra ON extra.fk_object = e.rowid';
255 $this->export_sql_end[$r] .=
' WHERE e.entity IN ('.getEntity(
'stock').
')';
259 $this->export_code[$r] = $this->rights_class.
'_emplacement_product';
260 $this->export_label[$r] =
"Stocks";
261 $this->export_icon[$r] =
"warehouse";
262 $this->export_permission[$r] = array(array(
"stock",
"lire"));
263 $this->export_fields_array[$r] = array(
264 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
265 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
266 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
267 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
268 'p.seuil_stock_alerte' =>
'StockLimit',
'p.barcode' =>
'BarCode',
'bt.libelle' =>
'BarcodeType',
271 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
273 $this->export_TypeFields_array[$r] = array(
274 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
275 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
276 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
277 'p.datec' =>
'Date',
'p.tms' =>
'Date',
'p.pmp' =>
'Numeric',
'p.cost_price' =>
'Numeric',
278 'ps.reel' =>
'Numeric',
279 'p.seuil_stock_alerte' =>
'Numeric',
'p.barcode' =>
'Text',
'bt.libelle' =>
'List:c_barcode_type:libelle',
282 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
284 $this->export_entities_array[$r] = array(
285 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
286 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
287 'p.datec' =>
'product',
'p.tms' =>
'product',
'p.pmp' =>
'product',
'p.cost_price' =>
'product',
288 'ps.reel' =>
'stock',
289 'p.seuil_stock_alerte' =>
'product',
'p.barcode' =>
'product',
'bt.libelle' =>
'product',
292 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
294 $this->export_aggregate_array[$r] = array(
'ps.reel' =>
'SUM');
295 $this->export_dependencies_array[$r] = array(
'stock' => array(
'p.rowid',
'e.rowid'));
296 $keyforselect =
'product';
297 $keyforelement =
'product';
298 $keyforaliasextra =
'extra';
299 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
300 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'ps.reel' =>
'Stock'));
302 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
303 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
304 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON extra.fk_object = p.rowid';
305 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_barcode_type as bt ON bt.rowid = p.fk_barcode_type';
306 $this->export_sql_end[$r] .=
', '.MAIN_DB_PREFIX.
'product_stock as ps, '.MAIN_DB_PREFIX.
'entrepot as e';
307 $this->export_sql_end[$r] .=
' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
308 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
312 $langs->load(
"productbatch");
317 $this->export_code[$r] = $this->rights_class.
'_emplacement_product_lot';
318 $this->export_label[$r] =
"StocksWithBatch";
319 $this->export_icon[$r] =
"warehouse";
320 $this->export_permission[$r] = array(array(
"stock",
"lire"));
321 $this->export_fields_array[$r] = array(
322 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
323 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
324 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
325 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
'lcpn.label'=>
'Nature',
326 'pb.rowid' =>
'Id',
'pb.batch' =>
'Batch',
'pb.qty' =>
'Qty',
327 'pl.eatby' =>
'EatByDate',
'pl.sellby' =>
'SellByDate',
'none.dateLastMovement' =>
'LastMovement'
330 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
332 $this->export_TypeFields_array[$r] = array(
333 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.lieu' =>
'Text',
'e.description' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
334 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
335 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
336 'p.datec' =>
'Date',
'p.tms' =>
'Date',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
'lcpn.label'=>
'Text',
337 'pb.batch' =>
'Text',
'pb.qty' =>
'Numeric',
338 'pl.eatby' =>
'Date',
'pl.sellby' =>
'Date',
'none.dateLastMovement' =>
'Date'
341 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
343 $this->export_entities_array[$r] = array(
344 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
345 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
346 'p.datec' =>
'product',
'p.tms' =>
'product',
'p.pmp' =>
'product',
'p.cost_price' =>
'product',
'lcpn.label'=>
'product',
347 'pb.rowid' =>
'batch',
'pb.batch' =>
'batch',
'pb.qty' =>
'batch',
'none.dateLastMovement' =>
'movement',
348 'pl.eatby' =>
'batch',
'pl.sellby' =>
'batch'
350 $this->export_special_array[$r] = array(
351 'none.dateLastMovement'=>array(
'rule'=>
'compute',
'classfile'=>
'/product/stock/class/mouvementstock.class.php',
'class'=>
'MouvementStock',
'method'=>
'getDateLastMovementProductBatch',
'method_params'=>[
'e_rowid',
'p_rowid',
'pb_batch']),
354 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
356 $this->export_aggregate_array[$r] = array(
'ps.reel' =>
'SUM');
358 $this->export_dependencies_array[$r] = array(
'stockbatch' => array(
'pb.rowid'),
'batch' => array(
'pb.rowid'),
'movement' => array(
'e.rowid',
'p.rowid',
'pb.batch'));
359 $keyforselect =
'product_lot';
360 $keyforelement =
'batch';
361 $keyforaliasextra =
'extra';
362 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
364 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
365 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product_batch as pb';
366 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product_stock as ps ON ps.rowid = pb.fk_product_stock';
367 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product as p ON p.rowid = ps.fk_product';
368 $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';
369 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lot_extrafields as extra ON extra.fk_object = pl.rowid';
370 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_product_nature as lcpn on lcpn.code = p.finished,';
371 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'entrepot as e';
372 $this->export_sql_end[$r] .=
' WHERE ps.fk_entrepot = e.rowid';
373 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
378 $this->export_code[$r] = $this->rights_class.
'_movement';
379 $this->export_label[$r] =
"StockMovements";
380 $this->export_icon[$r] =
"movement";
381 $this->export_permission[$r] = array(array(
"stock",
"lire"));
382 $this->export_fields_array[$r] = array(
383 'sm.rowid' =>
'MovementId',
'sm.value' =>
'Qty',
'sm.datem' =>
'DateMovement',
'sm.label' =>
'MovementLabel',
'sm.inventorycode' =>
'InventoryCode',
384 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
385 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
386 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification'
389 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
391 $this->export_TypeFields_array[$r] = array(
392 'sm.rowid' =>
'Numeric',
'sm.value' =>
'Numeric',
'sm.datem' =>
'Date',
'sm.batch' =>
'Text',
'sm.label' =>
'Text',
'sm.inventorycode' =>
'Text',
393 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
394 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
395 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
'p.datec' =>
'Date',
'p.tms' =>
'Date'
398 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
400 $this->export_entities_array[$r] = array(
401 'e.rowid' =>
'warehouse',
'e.ref' =>
'warehouse',
'e.description' =>
'warehouse',
'e.lieu' =>
'warehouse',
'e.address' =>
'warehouse',
'e.zip' =>
'warehouse',
'e.town' =>
'warehouse',
402 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
403 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
'p.datec' =>
'product',
'p.tms' =>
'product'
406 $this->export_fields_array[$r][
'sm.batch'] =
'Batch';
407 $this->export_TypeFields_array[$r][
'sm.batch'] =
'Text';
408 $this->export_entities_array[$r][
'sm.batch'] =
'movement';
411 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
413 $this->export_aggregate_array[$r] = array(
'sm.value' =>
'SUM');
414 $this->export_dependencies_array[$r] = array(
'movement' => array(
'sm.rowid'));
416 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
417 $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';
418 $this->export_sql_end[$r] .=
' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid';
419 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
424 $this->export_code[$r] = $this->rights_class.
'_inventory';
425 $this->export_label[$r] =
"Inventories";
426 $this->export_icon[$r] =
"inventory";
427 $this->export_permission[$r] = array(array(
"stock",
"lire"));
428 $this->export_fields_array[$r] = array(
429 'i.rowid' =>
'InventoryId',
'i.ref' =>
'InventoryRef',
'i.date_inventory' =>
'DateInventory',
'i.status' =>
'InventoryStatus',
'i.title' =>
'InventoryTitle',
430 'id.rowid' =>
'InventoryLineId',
'id.qty_view' =>
'QtyViewed',
'id.qty_stock' =>
'QtyStock',
'id.qty_regulated' =>
'QtyRegulated',
431 'id.batch' =>
'Lotserial',
432 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
433 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
434 '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'
437 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
439 $this->export_TypeFields_array[$r] = array(
440 'id.rowid' =>
'Numeric',
441 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
442 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
443 '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',
444 'i.rowid' =>
'Numeric',
'i.ref' =>
'Text',
'i.date_inventory' =>
'Date',
'i.status' =>
'Numeric',
'i.title' =>
'Text',
445 'id.qty_view' =>
'Numeric',
'id.qty_stock' =>
'Numeric',
'id.batch' =>
'Text',
446 'id.qty_regulated' =>
'Numeric',
'id.fk_warehouse' =>
'Numeric',
449 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
451 $this->export_entities_array[$r] = array(
452 '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',
453 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
454 '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'
457 $this->export_fields_array[$r][
'id.batch'] =
'Batch';
458 $this->export_TypeFields_array[$r][
'id.batch'] =
'Text';
459 $this->export_entities_array[$r][
'id.batch'] =
'inventory_line';
462 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
464 $this->export_aggregate_array[$r] = array(
'sm.value' =>
'SUM');
465 $this->export_dependencies_array[$r] = array(
'movement' => array(
'sm.rowid'));
467 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
468 $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';
469 $this->export_sql_end[$r] .=
' WHERE p.rowid = id.fk_product AND id.fk_inventory = i.rowid AND id.fk_warehouse = e.rowid';
470 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
480 $this->import_code[$r] = $this->rights_class.
'_'.$r;
481 $this->import_label[$r] =
"Warehouses";
482 $this->import_icon[$r] =
"warehouse";
483 $this->import_entities_array[$r] = array();
484 $this->import_tables_array[$r] = array(
'e' => MAIN_DB_PREFIX.
'entrepot',
'extra' => MAIN_DB_PREFIX.
'entrepot_extrafields');
485 $this->import_tables_creator_array[$r] = array(
'e' =>
'fk_user_author');
486 $this->import_fields_array[$r] = array(
'e.ref' =>
"LocationSummary*",
487 'e.description' =>
"DescWareHouse",
488 'e.lieu' =>
"LieuWareHouse",
489 'e.address' =>
"Address",
491 'e.fk_departement' =>
'StateCode',
492 'e.fk_pays' =>
'CountryCode',
493 'e.phone' =>
'Phone',
495 'e.statut' =>
'Status',
496 'e.fk_parent' =>
'ParentWarehouse'
499 $this->import_convertvalue_array[$r] = array(
500 'e.fk_departement' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/cstate.class.php',
'class' =>
'Cstate',
'method' =>
'fetch',
'dict' =>
'DictionaryStateCode'),
501 'e.fk_pays' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/ccountry.class.php',
'class' =>
'Ccountry',
'method' =>
'fetch',
'dict' =>
'DictionaryCountry'),
502 'e.fk_parent' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/stock/class/entrepot.class.php',
'class' =>
'Entrepot',
'method' =>
'fetch',
'element' =>
'ref')
504 $this->import_regex_array[$r] = array(
'e.statut' =>
'^[0|1]');
506 $import_extrafield_sample = array();
507 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'entrepot' AND entity IN (0, ".$conf->entity.
")";
508 $resql = $this->db->query($sql);
510 while ($obj = $this->db->fetch_object($resql)) {
511 $fieldname =
'extra.'.$obj->name;
512 $fieldlabel = ucfirst($obj->label);
513 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
514 $import_extrafield_sample[$fieldname] = $fieldlabel;
518 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'entrepot');
520 $this->import_examplevalues_array[$r] = array_merge(array(
'e.ref' =>
"ALM001",
521 'e.description' =>
"Central Warehouse",
522 'e.lieu' =>
"Central",
523 'e.address' =>
"Route 66",
525 'e.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
526 'e.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
527 'e.phone' =>
'(+33)(0)123456789',
528 'e.fax' =>
'(+33)(0)123456790',
530 'e.fk_parent' =>
'id or ref of warehouse'
531 ), $import_extrafield_sample);
532 $this->import_updatekeys_array[$r] = array(
'p.ref' =>
'Ref');
536 $this->import_code[$r] = $this->rights_class.
'_'.$r;
537 $this->import_label[$r] =
"Stocks";
538 $this->import_icon[$r] =
"stock";
539 $this->import_entities_array[$r] = array();
540 $this->import_tables_array[$r] = array(
'ps' => MAIN_DB_PREFIX.
'product_stock');
541 $this->import_fields_array[$r] = array(
'ps.fk_product' =>
"Product*",
'ps.fk_entrepot' =>
"Warehouse*",
'ps.reel' =>
"Stock*");
543 $this->import_convertvalue_array[$r] = array(
544 'ps.fk_product' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/class/product.class.php',
'class' =>
'Product',
'method' =>
'fetch',
'element' =>
'product'),
545 'ps.fk_entrepot' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/stock/class/entrepot.class.php',
'class' =>
'Entrepot',
'method' =>
'fetch',
'element' =>
'ref')
547 $this->import_examplevalues_array[$r] = array(
548 'ps.fk_product' =>
"id or ref of product",
'ps.fk_entrepot' =>
"id or ref of warehouse",
'ps.reel' =>
"10"
550 $this->import_updatekeys_array[$r] = array(
'ps.fk_product' =>
'Product',
'ps.fk_entrepot' =>
"Warehouse");
551 $this->import_run_sql_after_array[$r] = array(
552 '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);'