51 $this->family =
"products";
52 $this->module_position =
'39';
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 =
'stock';
64 $this->dirs = array(
"/stock/temp");
66 $this->config_page_url = array(
"stock.php");
69 $this->hidden =
false;
70 $this->depends = array(
"modProduct");
71 $this->requiredby = array(
"modProductBatch");
72 $this->conflictwith = array();
73 $this->phpmin = array(7, 0);
74 $this->langfiles = array(
"stocks");
77 $this->
const = array();
80 $this->
const[$r] = array(
'STOCK_ALLOW_NEGATIVE_TRANSFER',
'chaine',
'1',
'', 1);
83 $this->
const[$r][0] =
"STOCK_ADDON_PDF";
84 $this->
const[$r][1] =
"chaine";
85 $this->
const[$r][2] =
"standard";
86 $this->
const[$r][3] =
'Name of PDF model of stock';
87 $this->
const[$r][4] = 0;
90 $this->
const[$r][0] =
"MOUVEMENT_ADDON_PDF";
91 $this->
const[$r][1] =
"chaine";
92 $this->
const[$r][2] =
"stdmovement";
93 $this->
const[$r][3] =
'Name of PDF model of stock movement';
94 $this->
const[$r][4] = 0;
97 $this->
const[$r][0] =
"STOCK_ADDON_PDF_ODT_PATH";
98 $this->
const[$r][1] =
"chaine";
99 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/stocks";
100 $this->
const[$r][3] =
"";
101 $this->
const[$r][4] = 0;
104 $this->
const[$r][0] =
"MOUVEMENT_ADDON_PDF_ODT_PATH";
105 $this->
const[$r][1] =
"chaine";
106 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/stocks/movements";
107 $this->
const[$r][3] =
"";
108 $this->
const[$r][4] = 0;
111 $this->boxes = array();
114 $this->rights = array();
115 $this->rights_class =
'stock';
119 $this->rights[$r][0] = 1001;
120 $this->rights[$r][1] =
'Read stocks';
121 $this->rights[$r][2] =
'r';
122 $this->rights[$r][3] = 0;
123 $this->rights[$r][4] =
'lire';
124 $this->rights[$r][5] =
'';
127 $this->rights[$r][0] = 1002;
128 $this->rights[$r][1] =
'Create/Modify stocks';
129 $this->rights[$r][2] =
'w';
130 $this->rights[$r][3] = 0;
131 $this->rights[$r][4] =
'creer';
132 $this->rights[$r][5] =
'';
135 $this->rights[$r][0] = 1003;
136 $this->rights[$r][1] =
'Delete stock';
137 $this->rights[$r][2] =
'd';
138 $this->rights[$r][3] = 0;
139 $this->rights[$r][4] =
'supprimer';
140 $this->rights[$r][5] =
'';
143 $this->rights[$r][0] = 1004;
144 $this->rights[$r][1] =
'Read stock movements';
145 $this->rights[$r][2] =
'r';
146 $this->rights[$r][3] = 0;
147 $this->rights[$r][4] =
'mouvement';
148 $this->rights[$r][5] =
'lire';
151 $this->rights[$r][0] = 1005;
152 $this->rights[$r][1] =
'Create/modify stock movements';
153 $this->rights[$r][2] =
'w';
154 $this->rights[$r][3] = 0;
155 $this->rights[$r][4] =
'mouvement';
156 $this->rights[$r][5] =
'creer';
159 $this->rights[$r][0] = 1011;
160 $this->rights[$r][1] =
'inventoryReadPermission';
161 $this->rights[$r][3] = 0;
162 $this->rights[$r][4] =
'inventory_advance';
163 $this->rights[$r][5] =
'read';
166 $this->rights[$r][0] = 1012;
167 $this->rights[$r][1] =
'inventoryCreatePermission';
168 $this->rights[$r][3] = 0;
169 $this->rights[$r][4] =
'inventory_advance';
170 $this->rights[$r][5] =
'write';
173 $this->rights[$r][0] = 1013;
174 $this->rights[$r][1] =
'inventoryDeletePermission';
175 $this->rights[$r][3] = 0;
176 $this->rights[$r][4] =
'inventory_advance';
177 $this->rights[$r][5] =
'delete';
181 $this->rights[$r][0] = 1014;
182 $this->rights[$r][1] =
'inventoryValidatePermission';
183 $this->rights[$r][3] = 0;
184 $this->rights[$r][4] =
'inventory_advance';
185 $this->rights[$r][5] =
'validate';
188 $this->rights[$r][0] = 1015;
189 $this->rights[$r][1] =
'inventoryChangePMPPermission';
190 $this->rights[$r][3] = 0;
191 $this->rights[$r][4] =
'inventory_advance';
192 $this->rights[$r][5] =
'changePMP';
196 $this->menu = array();
210 $this->export_code[$r] = $this->rights_class.
'_emplacement';
211 $this->export_label[$r] =
"Warehouses";
212 $this->export_icon[$r] =
"warehouse";
213 $this->export_permission[$r] = array(array(
"stock",
"lire"));
214 $this->export_fields_array[$r] = array(
215 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
216 'd.code_departement' =>
'Departement',
'c.code' =>
'CountryCode',
217 'e.phone' =>
'Phone',
'e.fax' =>
'Fax',
'e.statut' =>
'Status',
'pe.rowid' =>
'ParentWarehouse',
'pe.ref' =>
'LocationSummary'
219 $this->export_TypeFields_array[$r] = array(
220 'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
221 'd.code_departement' =>
'List:c_departements:code_departement:code_departement:',
'c.code' =>
'List:c_country:code:code:',
222 'e.phone' =>
'Text',
'e.fax' =>
'Text',
'e.statut' =>
'Text',
'pe.rowid' =>
'List:entrepot:ref:rowid:stock',
'pe.ref' =>
'Text'
224 $this->export_entities_array[$r] = array();
225 $this->export_aggregate_array[$r] = array();
226 $keyforselect =
'warehouse';
227 $keyforelement =
'warehouse';
228 $keyforaliasextra =
'extra';
229 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
231 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
232 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'entrepot as e';
233 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON d.rowid = e.fk_departement';
234 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON c.rowid = e.fk_pays';
235 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as pe ON pe.rowid = e.fk_parent';
236 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot_extrafields as extra ON extra.fk_object = e.rowid';
237 $this->export_sql_end[$r] .=
' WHERE e.entity IN ('.getEntity(
'stock').
')';
241 $this->export_code[$r] = $this->rights_class.
'_emplacement_product';
242 $this->export_label[$r] =
"Stocks";
243 $this->export_icon[$r] =
"warehouse";
244 $this->export_permission[$r] = array(array(
"stock",
"lire"));
245 $this->export_fields_array[$r] = array(
246 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
247 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
248 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
249 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
250 'p.seuil_stock_alerte' =>
'StockLimit',
'p.barcode' =>
'BarCode',
'bt.libelle' =>
'BarcodeType',
252 if (isModEnabled(
'barcode')) {
253 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
255 $this->export_TypeFields_array[$r] = array(
256 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
257 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
258 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
259 'p.datec' =>
'Date',
'p.tms' =>
'Date',
'p.pmp' =>
'Numeric',
'p.cost_price' =>
'Numeric',
260 'ps.reel' =>
'Numeric',
261 'p.seuil_stock_alerte' =>
'Numeric',
'p.barcode' =>
'Text',
'bt.libelle' =>
'List:c_barcode_type:libelle',
263 if (isModEnabled(
'barcode')) {
264 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
266 $this->export_entities_array[$r] = array(
267 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
268 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
269 'p.datec' =>
'product',
'p.tms' =>
'product',
'p.pmp' =>
'product',
'p.cost_price' =>
'product',
270 'ps.reel' =>
'stock',
271 'p.seuil_stock_alerte' =>
'product',
'p.barcode' =>
'product',
'bt.libelle' =>
'product',
273 if (isModEnabled(
'barcode')) {
274 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
276 $this->export_aggregate_array[$r] = array(
'ps.reel' =>
'SUM');
277 $this->export_dependencies_array[$r] = array(
'stock' => array(
'p.rowid',
'e.rowid'));
278 $keyforselect =
'product';
279 $keyforelement =
'product';
280 $keyforaliasextra =
'extra';
281 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
282 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'ps.reel' =>
'Stock'));
284 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
285 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p';
286 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON extra.fk_object = p.rowid';
287 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_barcode_type as bt ON bt.rowid = p.fk_barcode_type';
288 $this->export_sql_end[$r] .=
', '.MAIN_DB_PREFIX.
'product_stock as ps, '.MAIN_DB_PREFIX.
'entrepot as e';
289 $this->export_sql_end[$r] .=
' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
290 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
293 if (isModEnabled(
'productbatch')) {
294 $langs->load(
"productbatch");
299 $this->export_code[$r] = $this->rights_class.
'_emplacement_product_lot';
300 $this->export_label[$r] =
"StocksWithBatch";
301 $this->export_icon[$r] =
"warehouse";
302 $this->export_permission[$r] = array(array(
"stock",
"lire"));
303 $this->export_fields_array[$r] = array(
304 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
305 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
306 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
307 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
308 'pb.rowid' =>
'Id',
'pb.batch' =>
'Batch',
'pb.qty' =>
'Qty',
309 'pl.eatby' =>
'EatByDate',
'pl.sellby' =>
'SellByDate'
311 if (isModEnabled(
'barcode')) {
312 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
314 $this->export_TypeFields_array[$r] = array(
315 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.lieu' =>
'Text',
'e.description' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
316 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
317 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
318 'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification',
'p.pmp' =>
'PMPValue',
'p.cost_price' =>
'CostPrice',
319 'pb.batch' =>
'Text',
'pb.qty' =>
'Numeric',
320 'pl.eatby' =>
'Date',
'pl.sellby' =>
'Date'
322 if (isModEnabled(
'barcode')) {
323 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
325 $this->export_entities_array[$r] = array(
326 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
327 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
328 'p.datec' =>
'product',
'p.tms' =>
'product',
'p.pmp' =>
'product',
'p.cost_price' =>
'product',
329 'pb.rowid' =>
'batch',
'pb.batch' =>
'batch',
'pb.qty' =>
'batch',
330 'pl.eatby' =>
'batch',
'pl.sellby' =>
'batch'
332 if (isModEnabled(
'barcode')) {
333 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
335 $this->export_aggregate_array[$r] = array(
'ps.reel' =>
'SUM');
336 $this->export_dependencies_array[$r] = array(
'stockbatch' => array(
'pb.rowid'),
'batch' => array(
'pb.rowid'));
337 $keyforselect =
'product_lot';
338 $keyforelement =
'batch';
339 $keyforaliasextra =
'extra';
340 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
342 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
343 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product_batch as pb';
344 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product_stock as ps ON ps.rowid = pb.fk_product_stock';
345 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product as p ON p.rowid = ps.fk_product';
346 $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';
347 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lot_extrafields as extra ON extra.fk_object = pl.rowid,';
348 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'entrepot as e';
349 $this->export_sql_end[$r] .=
' WHERE ps.fk_entrepot = e.rowid';
350 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
355 $this->export_code[$r] = $this->rights_class.
'_movement';
356 $this->export_label[$r] =
"StockMovements";
357 $this->export_icon[$r] =
"movement";
358 $this->export_permission[$r] = array(array(
"stock",
"lire"));
359 $this->export_fields_array[$r] = array(
360 'sm.rowid' =>
'MovementId',
'sm.value' =>
'Qty',
'sm.datem' =>
'DateMovement',
'sm.label' =>
'MovementLabel',
'sm.inventorycode' =>
'InventoryCode',
361 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
362 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
363 'p.price' =>
"Price",
'p.tva_tx' =>
'VAT',
'p.tosell' =>
"OnSell",
'p.tobuy' =>
'OnBuy',
'p.duration' =>
"Duration",
'p.datec' =>
'DateCreation',
'p.tms' =>
'DateModification'
365 if (isModEnabled(
'barcode')) {
366 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
368 $this->export_TypeFields_array[$r] = array(
369 'sm.rowid' =>
'Numeric',
'sm.value' =>
'Numeric',
'sm.datem' =>
'Date',
'sm.batch' =>
'Text',
'sm.label' =>
'Text',
'sm.inventorycode' =>
'Text',
370 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
371 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
372 'p.price' =>
"Numeric",
'p.tva_tx' =>
'Numeric',
'p.tosell' =>
"Boolean",
'p.tobuy' =>
"Boolean",
'p.duration' =>
"Duree",
'p.datec' =>
'Date',
'p.tms' =>
'Date'
374 if (isModEnabled(
'barcode')) {
375 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
377 $this->export_entities_array[$r] = array(
378 'e.rowid' =>
'warehouse',
'e.ref' =>
'warehouse',
'e.description' =>
'warehouse',
'e.lieu' =>
'warehouse',
'e.address' =>
'warehouse',
'e.zip' =>
'warehouse',
'e.town' =>
'warehouse',
379 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
380 'p.price' =>
"product",
'p.tva_tx' =>
'product',
'p.tosell' =>
"product",
'p.tobuy' =>
"product",
'p.duration' =>
"product",
'p.datec' =>
'product',
'p.tms' =>
'product'
382 if (isModEnabled(
'productbatch')) {
383 $this->export_fields_array[$r][
'sm.batch'] =
'Batch';
384 $this->export_TypeFields_array[$r][
'sm.batch'] =
'Text';
385 $this->export_entities_array[$r][
'sm.batch'] =
'movement';
387 if (isModEnabled(
'barcode')) {
388 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
390 $this->export_aggregate_array[$r] = array(
'sm.value' =>
'SUM');
391 $this->export_dependencies_array[$r] = array(
'movement' => array(
'sm.rowid'));
393 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
394 $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';
395 $this->export_sql_end[$r] .=
' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid';
396 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
401 $this->export_code[$r] = $this->rights_class.
'_inventory';
402 $this->export_label[$r] =
"Inventories";
403 $this->export_icon[$r] =
"inventory";
404 $this->export_permission[$r] = array(array(
"stock",
"lire"));
405 $this->export_fields_array[$r] = array(
406 'i.rowid' =>
'InventoryId',
'i.ref' =>
'InventoryRef',
'i.date_inventory' =>
'DateInventory',
'i.status' =>
'InventoryStatus',
'i.title' =>
'InventoryTitle',
407 'id.rowid' =>
'InventoryLineId',
'id.qty_view' =>
'QtyViewed',
'id.qty_stock' =>
'QtyStock',
'id.qty_regulated' =>
'QtyRegulated',
408 'id.batch' =>
'Lotserial',
409 'e.rowid' =>
'IdWarehouse',
'e.ref' =>
'LocationSummary',
'e.description' =>
'DescWareHouse',
'e.lieu' =>
'LieuWareHouse',
'e.address' =>
'Address',
'e.zip' =>
'Zip',
'e.town' =>
'Town',
410 'p.rowid' =>
"ProductId",
'p.ref' =>
"Ref",
'p.fk_product_type' =>
"Type",
'p.label' =>
"Label",
'p.description' =>
"Description",
'p.note' =>
"Note",
411 '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'
413 if (isModEnabled(
'barcode')) {
414 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'p.barcode' =>
'BarCode'));
416 $this->export_TypeFields_array[$r] = array(
417 'id.rowid' =>
'Numeric',
418 'e.rowid' =>
'List:entrepot:ref::stock',
'e.ref' =>
'Text',
'e.description' =>
'Text',
'e.lieu' =>
'Text',
'e.address' =>
'Text',
'e.zip' =>
'Text',
'e.town' =>
'Text',
419 'p.rowid' =>
"Numeric",
'p.ref' =>
"Text",
'p.fk_product_type' =>
"Text",
'p.label' =>
"Text",
'p.description' =>
"Text",
'p.note' =>
"Text",
420 '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',
421 'i.rowid' =>
'Numeric',
'i.ref' =>
'Text',
'i.date_inventory' =>
'Date',
'i.status' =>
'Numeric',
'i.title' =>
'Text',
422 'id.qty_view' =>
'Numeric',
'id.qty_stock' =>
'Numeric',
'id.batch' =>
'Text',
423 'id.qty_regulated' =>
'Numeric',
'id.fk_warehouse' =>
'Numeric',
425 if (isModEnabled(
'barcode')) {
426 $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array(
'p.barcode' =>
'Text'));
428 $this->export_entities_array[$r] = array(
429 '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',
430 'p.rowid' =>
"product",
'p.ref' =>
"product",
'p.fk_product_type' =>
"product",
'p.label' =>
"product",
'p.description' =>
"product",
'p.note' =>
"product",
431 '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'
433 if (isModEnabled(
'productbatch')) {
434 $this->export_fields_array[$r][
'id.batch'] =
'Batch';
435 $this->export_TypeFields_array[$r][
'id.batch'] =
'Text';
436 $this->export_entities_array[$r][
'id.batch'] =
'inventory_line';
438 if (isModEnabled(
'barcode')) {
439 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'p.barcode' =>
'product'));
441 $this->export_aggregate_array[$r] = array(
'sm.value' =>
'SUM');
442 $this->export_dependencies_array[$r] = array(
'movement' => array(
'sm.rowid'));
444 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
445 $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';
446 $this->export_sql_end[$r] .=
' WHERE p.rowid = id.fk_product AND id.fk_inventory = i.rowid AND id.fk_warehouse = e.rowid';
447 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
457 $this->import_code[$r] = $this->rights_class.
'_'.$r;
458 $this->import_label[$r] =
"Warehouses";
459 $this->import_icon[$r] =
"warehouse";
460 $this->import_entities_array[$r] = array();
461 $this->import_tables_array[$r] = array(
'e' => MAIN_DB_PREFIX.
'entrepot');
462 $this->import_tables_creator_array[$r] = array(
'e' =>
'fk_user_author');
463 $this->import_fields_array[$r] = array(
'e.ref' =>
"LocationSummary*",
464 'e.description' =>
"DescWareHouse",
465 'e.lieu' =>
"LieuWareHouse",
466 'e.address' =>
"Address",
468 'e.fk_departement' =>
'StateCode',
469 'e.fk_pays' =>
'CountryCode',
470 'e.phone' =>
'Phone',
472 'e.statut' =>
'Status',
473 'e.fk_parent' =>
'ParentWarehouse'
476 $this->import_convertvalue_array[$r] = array(
477 'e.fk_departement' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/cstate.class.php',
'class' =>
'Cstate',
'method' =>
'fetch',
'dict' =>
'DictionaryStateCode'),
478 'e.fk_pays' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/ccountry.class.php',
'class' =>
'Ccountry',
'method' =>
'fetch',
'dict' =>
'DictionaryCountry'),
479 'e.fk_parent' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/stock/class/entrepot.class.php',
'class' =>
'Entrepot',
'method' =>
'fetch',
'element' =>
'ref')
481 $this->import_regex_array[$r] = array(
'e.statut' =>
'^[0|1]');
482 $this->import_examplevalues_array[$r] = array(
'e.ref' =>
"ALM001",
483 'e.description' =>
"Central Warehouse",
484 'e.lieu' =>
"Central",
485 'e.address' =>
"Route 66",
487 'e.fk_departement' =>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
488 'e.fk_pays' =>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
489 'e.phone' =>
'(+33)(0)123456789',
490 'e.fax' =>
'(+33)(0)123456790',
492 'e.fk_parent' =>
'id or ref of warehouse'
494 $this->import_updatekeys_array[$r] = array(
'p.ref' =>
'Ref');
498 $this->import_code[$r] = $this->rights_class.
'_'.$r;
499 $this->import_label[$r] =
"Stocks";
500 $this->import_icon[$r] =
"stock";
501 $this->import_entities_array[$r] = array();
502 $this->import_tables_array[$r] = array(
'ps' => MAIN_DB_PREFIX.
'product_stock');
503 $this->import_fields_array[$r] = array(
'ps.fk_product' =>
"Product*",
'ps.fk_entrepot' =>
"Warehouse*",
'ps.reel' =>
"Stock*");
505 $this->import_convertvalue_array[$r] = array(
506 'ps.fk_product' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/class/product.class.php',
'class' =>
'Product',
'method' =>
'fetch',
'element' =>
'product'),
507 'ps.fk_entrepot' => array(
'rule' =>
'fetchidfromref',
'classfile' =>
'/product/stock/class/entrepot.class.php',
'class' =>
'Entrepot',
'method' =>
'fetch',
'element' =>
'ref')
509 $this->import_examplevalues_array[$r] = array(
510 'ps.fk_product' =>
"id or ref of product",
'ps.fk_entrepot' =>
"id or ref of warehouse",
'ps.reel' =>
"10"
512 $this->import_updatekeys_array[$r] = array(
'ps.fk_product' =>
'Product',
'ps.fk_entrepot' =>
"Warehouse");
513 $this->import_run_sql_after_array[$r] = array(
514 '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);'