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");
78 $this->
const = array();
81 $this->
const[$r] = array(
'STOCK_ALLOW_NEGATIVE_TRANSFER',
'chaine',
'1',
'', 1);
84 $this->
const[$r][0] =
"STOCK_ADDON_PDF";
85 $this->
const[$r][1] =
"chaine";
86 $this->
const[$r][2] =
"standard_stock";
87 $this->
const[$r][3] =
'Name of PDF model of stock';
88 $this->
const[$r][4] = 0;
91 $this->
const[$r][0] =
"MOUVEMENT_ADDON_PDF";
92 $this->
const[$r][1] =
"chaine";
93 $this->
const[$r][2] =
"standard_movement_stock";
94 $this->
const[$r][3] =
'Name of PDF model of stock movement';
95 $this->
const[$r][4] = 0;
98 $this->
const[$r][0] =
"STOCK_ADDON_PDF_ODT_PATH";
99 $this->
const[$r][1] =
"chaine";
100 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/stocks";
101 $this->
const[$r][3] =
"";
102 $this->
const[$r][4] = 0;
105 $this->
const[$r][0] =
"MOUVEMENT_ADDON_PDF_ODT_PATH";
106 $this->
const[$r][1] =
"chaine";
107 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/stocks/movements";
108 $this->
const[$r][3] =
"";
109 $this->
const[$r][4] = 0;
112 $this->boxes = array();
115 $this->rights = array();
116 $this->rights_class =
'stock';
120 $this->rights[$r][0] = 1001;
121 $this->rights[$r][1] =
'Read stocks';
122 $this->rights[$r][2] =
'r';
123 $this->rights[$r][3] = 0;
124 $this->rights[$r][4] =
'lire';
125 $this->rights[$r][5] =
'';
128 $this->rights[$r][0] = 1002;
129 $this->rights[$r][1] =
'Create/Modify stocks';
130 $this->rights[$r][2] =
'w';
131 $this->rights[$r][3] = 0;
132 $this->rights[$r][4] =
'creer';
133 $this->rights[$r][5] =
'';
136 $this->rights[$r][0] = 1003;
137 $this->rights[$r][1] =
'Delete stock';
138 $this->rights[$r][2] =
'd';
139 $this->rights[$r][3] = 0;
140 $this->rights[$r][4] =
'supprimer';
141 $this->rights[$r][5] =
'';
144 $this->rights[$r][0] = 1004;
145 $this->rights[$r][1] =
'Read stock movements';
146 $this->rights[$r][2] =
'r';
147 $this->rights[$r][3] = 0;
148 $this->rights[$r][4] =
'mouvement';
149 $this->rights[$r][5] =
'lire';
152 $this->rights[$r][0] = 1005;
153 $this->rights[$r][1] =
'Create/modify stock movements';
154 $this->rights[$r][2] =
'w';
155 $this->rights[$r][3] = 0;
156 $this->rights[$r][4] =
'mouvement';
157 $this->rights[$r][5] =
'creer';
162 $this->rights[$r][0] = 1008;
163 $this->rights[$r][1] =
'Read stock value';
164 $this->rights[$r][2] =
'w';
165 $this->rights[$r][3] = 0;
166 $this->rights[$r][4] =
'value_advance';
167 $this->rights[$r][5] =
'read';
171 $this->rights[$r][0] = 1011;
172 $this->rights[$r][1] =
'inventoryReadPermission';
173 $this->rights[$r][3] = 0;
174 $this->rights[$r][4] =
'inventory_advance';
175 $this->rights[$r][5] =
'read';
178 $this->rights[$r][0] = 1012;
179 $this->rights[$r][1] =
'inventoryCreatePermission';
180 $this->rights[$r][3] = 0;
181 $this->rights[$r][4] =
'inventory_advance';
182 $this->rights[$r][5] =
'write';
185 $this->rights[$r][0] = 1013;
186 $this->rights[$r][1] =
'inventoryDeletePermission';
187 $this->rights[$r][3] = 0;
188 $this->rights[$r][4] =
'inventory_advance';
189 $this->rights[$r][5] =
'delete';
193 $this->rights[$r][0] = 1014;
194 $this->rights[$r][1] =
'inventoryValidatePermission';
195 $this->rights[$r][3] = 0;
196 $this->rights[$r][4] =
'inventory_advance';
197 $this->rights[$r][5] =
'validate';
200 $this->rights[$r][0] = 1015;
201 $this->rights[$r][1] =
'inventoryChangePMPPermission';
202 $this->rights[$r][3] = 0;
203 $this->rights[$r][4] =
'inventory_advance';
204 $this->rights[$r][5] =
'changePMP';
208 $this->menu = array();
222 $this->export_code[$r] = $this->rights_class.
'_emplacement';
223 $this->export_label[$r] =
"Warehouses";
224 $this->export_icon[$r] =
"warehouse";
225 $this->export_permission[$r] = array(array(
"stock",
"lire"));
226 $this->export_fields_array[$r] = array(
227 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
228 'd.code_departement' =>
'Departement',
'c.code' =>
'CountryCode',
229 'e.phone' =>
'Phone',
'e.fax' =>
'Fax',
'e.statut' =>
'Status',
'pe.rowid' =>
'ParentWarehouse',
'pe.ref' =>
'LocationSummary'
231 $this->export_TypeFields_array[$r] = array(
232 'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
233 'd.code_departement' =>
'List:c_departements:code_departement:code_departement:',
'c.code' =>
'List:c_country:code:code:',
234 'e.phone' =>
'Text',
'e.fax' =>
'Text',
'e.statut' =>
'Text',
'pe.rowid' =>
'List:entrepot:ref:rowid:stock',
'pe.ref' =>
'Text'
236 $this->export_entities_array[$r] = array();
237 $this->export_aggregate_array[$r] = array();
238 $keyforselect =
'warehouse';
239 $keyforelement =
'warehouse';
240 $keyforaliasextra =
'extra';
241 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
243 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
244 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'entrepot as e';
245 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON d.rowid = e.fk_departement';
246 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON c.rowid = e.fk_pays';
247 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as pe ON pe.rowid = e.fk_parent';
248 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot_extrafields as extra ON extra.fk_object = e.rowid';
249 $this->export_sql_end[$r] .=
' WHERE e.entity IN ('.getEntity(
'stock').
')';
253 $this->export_code[$r] = $this->rights_class.
'_emplacement_product';
254 $this->export_label[$r] =
"Stocks";
255 $this->export_icon[$r] =
"warehouse";
256 $this->export_permission[$r] = array(array(
"stock",
"lire"));
257 $this->export_fields_array[$r] = array(
258 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
259 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
260 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
261 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
262 'p.seuil_stock_alerte' =>
'StockLimit',
'p.barcode' =>
'BarCode',
'bt.libelle' =>
'BarcodeType',
264 if (isModEnabled(
'barcode')) {
265 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
267 $this->export_TypeFields_array[$r] = array(
268 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
269 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
270 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
271 'p.datec' =>
'Date',
'p.tms' =>
'Date',
'p.pmp' =>
'Numeric',
'p.cost_price' =>
'Numeric',
272 'ps.reel' =>
'Numeric',
273 'p.seuil_stock_alerte' =>
'Numeric',
'p.barcode' =>
'Text',
'bt.libelle' =>
'List:c_barcode_type:libelle',
275 if (isModEnabled(
'barcode')) {
276 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
278 $this->export_entities_array[$r] = array(
279 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
280 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
281 'p.datec' =>
'product',
'p.tms' =>
'product',
'p.pmp' =>
'product',
'p.cost_price' =>
'product',
282 'ps.reel' =>
'stock',
283 'p.seuil_stock_alerte' =>
'product',
'p.barcode' =>
'product',
'bt.libelle' =>
'product',
285 if (isModEnabled(
'barcode')) {
286 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
288 $this->export_aggregate_array[$r] = array(
'ps.reel' =>
'SUM');
289 $this->export_dependencies_array[$r] = array(
'stock' => array(
'p.rowid',
'e.rowid'));
290 $keyforselect =
'product';
291 $keyforelement =
'product';
292 $keyforaliasextra =
'extra';
293 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
294 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'ps.reel' =>
'Stock'));
296 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
297 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
298 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON extra.fk_object = p.rowid';
299 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_barcode_type as bt ON bt.rowid = p.fk_barcode_type';
300 $this->export_sql_end[$r] .=
', '.MAIN_DB_PREFIX.
'product_stock as ps, '.MAIN_DB_PREFIX.
'entrepot as e';
301 $this->export_sql_end[$r] .=
' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
302 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
305 if (isModEnabled(
'productbatch')) {
306 $langs->load(
"productbatch");
311 $this->export_code[$r] = $this->rights_class.
'_emplacement_product_lot';
312 $this->export_label[$r] =
"StocksWithBatch";
313 $this->export_icon[$r] =
"warehouse";
314 $this->export_permission[$r] = array(array(
"stock",
"lire"));
315 $this->export_fields_array[$r] = array(
316 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
317 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
318 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
319 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
'lcpn.label'=>
'Nature',
320 'pb.rowid' =>
'Id',
'pb.batch' =>
'Batch',
'pb.qty' =>
'Qty',
321 'pl.eatby' =>
'EatByDate',
'pl.sellby' =>
'SellByDate',
'none.dateLastMovement' =>
'LastMovement'
323 if (isModEnabled(
'barcode')) {
324 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
326 $this->export_TypeFields_array[$r] = array(
327 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.lieu' =>
'Text',
'e.description' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
328 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
329 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
330 'p.datec' =>
'Date',
'p.tms' =>
'Date',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
'lcpn.label'=>
'Text',
331 'pb.batch' =>
'Text',
'pb.qty' =>
'Numeric',
332 'pl.eatby' =>
'Date',
'pl.sellby' =>
'Date',
'none.dateLastMovement' =>
'Date'
334 if (isModEnabled(
'barcode')) {
335 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
337 $this->export_entities_array[$r] = array(
338 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
339 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
340 'p.datec' =>
'product',
'p.tms' =>
'product',
'p.pmp' =>
'product',
'p.cost_price' =>
'product',
'lcpn.label'=>
'product',
341 'pb.rowid' =>
'batch',
'pb.batch' =>
'batch',
'pb.qty' =>
'batch',
'none.dateLastMovement' =>
'movement',
342 'pl.eatby' =>
'batch',
'pl.sellby' =>
'batch'
344 $this->export_special_array[$r] = array(
345 'none.dateLastMovement'=>array(
'rule'=>
'compute',
'classfile'=>
'/product/stock/class/mouvementstock.class.php',
'class'=>
'MouvementStock',
'method'=>
'getDateLastMovementProductBatch',
'method_params'=>[
'e_rowid',
'p_rowid',
'pb_batch']),
347 if (isModEnabled(
'barcode')) {
348 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
350 $this->export_aggregate_array[$r] = array(
'ps.reel' =>
'SUM');
351 $this->export_dependencies_array[$r] = array(
'stockbatch' => array(
'pb.rowid'),
'batch' => array(
'pb.rowid'));
352 $keyforselect =
'product_lot';
353 $keyforelement =
'batch';
354 $keyforaliasextra =
'extra';
355 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
357 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
358 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product_batch as pb';
359 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product_stock as ps ON ps.rowid = pb.fk_product_stock';
360 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product as p ON p.rowid = ps.fk_product';
361 $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';
362 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lot_extrafields as extra ON extra.fk_object = pl.rowid';
363 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_product_nature as lcpn on lcpn.code = p.finished,';
364 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'entrepot as e';
365 $this->export_sql_end[$r] .=
' WHERE ps.fk_entrepot = e.rowid';
366 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
371 $this->export_code[$r] = $this->rights_class.
'_movement';
372 $this->export_label[$r] =
"StockMovements";
373 $this->export_icon[$r] =
"movement";
374 $this->export_permission[$r] = array(array(
"stock",
"lire"));
375 $this->export_fields_array[$r] = array(
376 'sm.rowid' =>
'MovementId',
'sm.value' =>
'Qty',
'sm.datem' =>
'DateMovement',
'sm.label' =>
'MovementLabel',
'sm.inventorycode' =>
'InventoryCode',
377 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
378 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
379 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification'
381 if (isModEnabled(
'barcode')) {
382 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
384 $this->export_TypeFields_array[$r] = array(
385 'sm.rowid' =>
'Numeric',
'sm.value' =>
'Numeric',
'sm.datem' =>
'Date',
'sm.batch' =>
'Text',
'sm.label' =>
'Text',
'sm.inventorycode' =>
'Text',
386 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
387 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
388 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
'p.datec' =>
'Date',
'p.tms' =>
'Date'
390 if (isModEnabled(
'barcode')) {
391 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
393 $this->export_entities_array[$r] = array(
394 'e.rowid' =>
'warehouse',
'e.ref' =>
'warehouse',
'e.description' =>
'warehouse',
'e.lieu' =>
'warehouse',
'e.address' =>
'warehouse',
'e.zip' =>
'warehouse',
'e.town' =>
'warehouse',
395 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
396 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
'p.datec' =>
'product',
'p.tms' =>
'product'
398 if (isModEnabled(
'productbatch')) {
399 $this->export_fields_array[$r][
'sm.batch'] =
'Batch';
400 $this->export_TypeFields_array[$r][
'sm.batch'] =
'Text';
401 $this->export_entities_array[$r][
'sm.batch'] =
'movement';
403 if (isModEnabled(
'barcode')) {
404 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
406 $this->export_aggregate_array[$r] = array(
'sm.value' =>
'SUM');
407 $this->export_dependencies_array[$r] = array(
'movement' => array(
'sm.rowid'));
409 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
410 $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';
411 $this->export_sql_end[$r] .=
' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid';
412 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
417 $this->export_code[$r] = $this->rights_class.
'_inventory';
418 $this->export_label[$r] =
"Inventories";
419 $this->export_icon[$r] =
"inventory";
420 $this->export_permission[$r] = array(array(
"stock",
"lire"));
421 $this->export_fields_array[$r] = array(
422 'i.rowid' =>
'InventoryId',
'i.ref' =>
'InventoryRef',
'i.date_inventory' =>
'DateInventory',
'i.status' =>
'InventoryStatus',
'i.title' =>
'InventoryTitle',
423 'id.rowid' =>
'InventoryLineId',
'id.qty_view' =>
'QtyViewed',
'id.qty_stock' =>
'QtyStock',
'id.qty_regulated' =>
'QtyRegulated',
424 'id.batch' =>
'Lotserial',
425 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
426 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
427 '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'
429 if (isModEnabled(
'barcode')) {
430 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
432 $this->export_TypeFields_array[$r] = array(
433 'id.rowid' =>
'Numeric',
434 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
435 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
436 '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',
437 'i.rowid' =>
'Numeric',
'i.ref' =>
'Text',
'i.date_inventory' =>
'Date',
'i.status' =>
'Numeric',
'i.title' =>
'Text',
438 'id.qty_view' =>
'Numeric',
'id.qty_stock' =>
'Numeric',
'id.batch' =>
'Text',
439 'id.qty_regulated' =>
'Numeric',
'id.fk_warehouse' =>
'Numeric',
441 if (isModEnabled(
'barcode')) {
442 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
444 $this->export_entities_array[$r] = array(
445 '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',
446 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
447 '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'
449 if (isModEnabled(
'productbatch')) {
450 $this->export_fields_array[$r][
'id.batch'] =
'Batch';
451 $this->export_TypeFields_array[$r][
'id.batch'] =
'Text';
452 $this->export_entities_array[$r][
'id.batch'] =
'inventory_line';
454 if (isModEnabled(
'barcode')) {
455 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
457 $this->export_aggregate_array[$r] = array(
'sm.value' =>
'SUM');
458 $this->export_dependencies_array[$r] = array(
'movement' => array(
'sm.rowid'));
460 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
461 $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';
462 $this->export_sql_end[$r] .=
' WHERE p.rowid = id.fk_product AND id.fk_inventory = i.rowid AND id.fk_warehouse = e.rowid';
463 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
473 $this->import_code[$r] = $this->rights_class.
'_'.$r;
474 $this->import_label[$r] =
"Warehouses";
475 $this->import_icon[$r] =
"warehouse";
476 $this->import_entities_array[$r] = array();
477 $this->import_tables_array[$r] = array(
'e' => MAIN_DB_PREFIX.
'entrepot');
478 $this->import_tables_creator_array[$r] = array(
'e' =>
'fk_user_author');
479 $this->import_fields_array[$r] = array(
'e.ref' =>
"LocationSummary*",
480 'e.description' =>
"DescWareHouse",
481 'e.lieu' =>
"LieuWareHouse",
482 'e.address' =>
"Address",
484 'e.fk_departement' =>
'StateCode',
485 'e.fk_pays' =>
'CountryCode',
486 'e.phone' =>
'Phone',
488 'e.statut' =>
'Status',
489 'e.fk_parent' =>
'ParentWarehouse'
492 $this->import_convertvalue_array[$r] = array(
493 'e.fk_departement' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/cstate.class.php',
'class' =>
'Cstate',
'method' =>
'fetch',
'dict' =>
'DictionaryStateCode'),
494 'e.fk_pays' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/ccountry.class.php',
'class' =>
'Ccountry',
'method' =>
'fetch',
'dict' =>
'DictionaryCountry'),
495 'e.fk_parent' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/stock/class/entrepot.class.php',
'class' =>
'Entrepot',
'method' =>
'fetch',
'element' =>
'ref')
497 $this->import_regex_array[$r] = array(
'e.statut' =>
'^[0|1]');
498 $this->import_examplevalues_array[$r] = array(
'e.ref' =>
"ALM001",
499 'e.description' =>
"Central Warehouse",
500 'e.lieu' =>
"Central",
501 'e.address' =>
"Route 66",
503 'e.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
504 'e.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
505 'e.phone' =>
'(+33)(0)123456789',
506 'e.fax' =>
'(+33)(0)123456790',
508 'e.fk_parent' =>
'id or ref of warehouse'
510 $this->import_updatekeys_array[$r] = array(
'p.ref' =>
'Ref');
514 $this->import_code[$r] = $this->rights_class.
'_'.$r;
515 $this->import_label[$r] =
"Stocks";
516 $this->import_icon[$r] =
"stock";
517 $this->import_entities_array[$r] = array();
518 $this->import_tables_array[$r] = array(
'ps' => MAIN_DB_PREFIX.
'product_stock');
519 $this->import_fields_array[$r] = array(
'ps.fk_product' =>
"Product*",
'ps.fk_entrepot' =>
"Warehouse*",
'ps.reel' =>
"Stock*");
521 $this->import_convertvalue_array[$r] = array(
522 'ps.fk_product' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/class/product.class.php',
'class' =>
'Product',
'method' =>
'fetch',
'element' =>
'product'),
523 'ps.fk_entrepot' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/stock/class/entrepot.class.php',
'class' =>
'Entrepot',
'method' =>
'fetch',
'element' =>
'ref')
525 $this->import_examplevalues_array[$r] = array(
526 'ps.fk_product' =>
"id or ref of product",
'ps.fk_entrepot' =>
"id or ref of warehouse",
'ps.reel' =>
"10"
528 $this->import_updatekeys_array[$r] = array(
'ps.fk_product' =>
'Product',
'ps.fk_entrepot' =>
"Warehouse");
529 $this->import_run_sql_after_array[$r] = array(
530 'UPDATE '.MAIN_DB_PREFIX.
'product as p SET p.stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.
'product_stock ps WHERE ps.fk_product = p.rowid);'