30 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
50 $this->family =
"products";
51 $this->module_position =
'39';
53 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
57 $this->version =
'dolibarr';
59 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
60 $this->picto =
'stock';
63 $this->dirs = array(
"/stock/temp");
65 $this->config_page_url = array(
"stock.php");
68 $this->hidden =
false;
69 $this->depends = array(
"modProduct");
70 $this->requiredby = array(
"modProductBatch");
71 $this->conflictwith = array();
72 $this->phpmin = array(7, 0);
73 $this->langfiles = array(
"stocks");
76 $this->
const = array();
79 $this->
const[$r] = array(
'STOCK_ALLOW_NEGATIVE_TRANSFER',
'chaine',
'1',
'', 1);
82 $this->
const[$r][0] =
"STOCK_ADDON_PDF";
83 $this->
const[$r][1] =
"chaine";
84 $this->
const[$r][2] =
"standard";
85 $this->
const[$r][3] =
'Name of PDF model of stock';
86 $this->
const[$r][4] = 0;
89 $this->
const[$r][0] =
"MOUVEMENT_ADDON_PDF";
90 $this->
const[$r][1] =
"chaine";
91 $this->
const[$r][2] =
"stdmovement";
92 $this->
const[$r][3] =
'Name of PDF model of stock mouvement';
93 $this->
const[$r][4] = 0;
96 $this->
const[$r][0] =
"STOCK_ADDON_PDF_ODT_PATH";
97 $this->
const[$r][1] =
"chaine";
98 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/stocks";
99 $this->
const[$r][3] =
"";
100 $this->
const[$r][4] = 0;
103 $this->
const[$r][0] =
"MOUVEMENT_ADDON_PDF_ODT_PATH";
104 $this->
const[$r][1] =
"chaine";
105 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/stocks/mouvements";
106 $this->
const[$r][3] =
"";
107 $this->
const[$r][4] = 0;
110 $this->boxes = array();
113 $this->rights = array();
114 $this->rights_class =
'stock';
116 $this->rights[0][0] = 1001;
117 $this->rights[0][1] =
'Lire les stocks';
118 $this->rights[0][2] =
'r';
119 $this->rights[0][3] = 0;
120 $this->rights[0][4] =
'lire';
121 $this->rights[0][5] =
'';
123 $this->rights[1][0] = 1002;
124 $this->rights[1][1] =
'Creer/Modifier les stocks';
125 $this->rights[1][2] =
'w';
126 $this->rights[1][3] = 0;
127 $this->rights[1][4] =
'creer';
128 $this->rights[1][5] =
'';
130 $this->rights[2][0] = 1003;
131 $this->rights[2][1] =
'Supprimer les stocks';
132 $this->rights[2][2] =
'd';
133 $this->rights[2][3] = 0;
134 $this->rights[2][4] =
'supprimer';
135 $this->rights[2][5] =
'';
137 $this->rights[3][0] = 1004;
138 $this->rights[3][1] =
'Lire mouvements de stocks';
139 $this->rights[3][2] =
'r';
140 $this->rights[3][3] = 0;
141 $this->rights[3][4] =
'mouvement';
142 $this->rights[3][5] =
'lire';
144 $this->rights[4][0] = 1005;
145 $this->rights[4][1] =
'Creer/modifier mouvements de stocks';
146 $this->rights[4][2] =
'w';
147 $this->rights[4][3] = 0;
148 $this->rights[4][4] =
'mouvement';
149 $this->rights[4][5] =
'creer';
151 $this->rights[5][0] = 1011;
152 $this->rights[5][1] =
'inventoryReadPermission';
153 $this->rights[5][3] = 0;
154 $this->rights[5][4] =
'inventory_advance';
155 $this->rights[5][5] =
'read';
157 $this->rights[6][0] = 1012;
158 $this->rights[6][1] =
'inventoryCreatePermission';
159 $this->rights[6][3] = 0;
160 $this->rights[6][4] =
'inventory_advance';
161 $this->rights[6][5] =
'write';
163 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
164 $this->rights[8][0] = 1014;
165 $this->rights[8][1] =
'inventoryValidatePermission';
166 $this->rights[8][3] = 0;
167 $this->rights[8][4] =
'inventory_advance';
168 $this->rights[8][5] =
'validate';
170 $this->rights[9][0] = 1015;
171 $this->rights[9][1] =
'inventoryChangePMPPermission';
172 $this->rights[9][3] = 0;
173 $this->rights[9][4] =
'inventory_advance';
174 $this->rights[9][5] =
'changePMP';
176 $this->rights[10][0] = 1016;
177 $this->rights[10][1] =
'inventoryDeletePermission';
178 $this->rights[10][3] = 0;
179 $this->rights[10][4] =
'inventory_advance';
180 $this->rights[10][5] =
'delete';
184 $this->menu = array();
198 $this->export_code[$r] = $this->rights_class.
'_emplacement';
199 $this->export_label[$r] =
"Warehouses";
200 $this->export_icon[$r] =
"warehouse";
201 $this->export_permission[$r] = array(array(
"stock",
"lire"));
202 $this->export_fields_array[$r] = array(
203 'e.rowid'=>
'IdWarehouse',
'e.ref'=>
'LocationSummary',
'e.description'=>
'DescWareHouse',
'e.lieu'=>
'LieuWareHouse',
'e.address'=>
'Address',
'e.zip'=>
'Zip',
'e.town'=>
'Town',
204 'd.code_departement'=>
'Departement',
'c.code'=>
'CountryCode',
205 'e.phone'=>
'Phone',
'e.fax'=>
'Fax',
'e.statut'=>
'Status',
'pe.rowid'=>
'ParentWarehouse',
'pe.ref'=>
'LocationSummary'
207 $this->export_TypeFields_array[$r] = array(
208 'e.ref'=>
'Text',
'e.description'=>
'Text',
'e.lieu'=>
'Text',
'e.address'=>
'Text',
'e.zip'=>
'Text',
'e.town'=>
'Text',
209 'd.code_departement'=>
'List:c_departements:code_departement:code_departement:',
'c.code'=>
'List:c_country:code:code:',
210 'e.phone'=>
'Text',
'e.fax'=>
'Text',
'e.statut'=>
'Text',
'pe.rowid'=>
'List:entrepot:ref:rowid:stock',
'pe.ref'=>
'Text'
212 $this->export_entities_array[$r] = array();
213 $this->export_aggregate_array[$r] = array();
214 $keyforselect =
'warehouse';
215 $keyforelement =
'warehouse';
216 $keyforaliasextra =
'extra';
217 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
219 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
220 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'entrepot as e';
221 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON d.rowid = e.fk_departement';
222 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c ON c.rowid = e.fk_pays';
223 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as pe ON pe.rowid = e.fk_parent';
224 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot_extrafields as extra ON extra.fk_object = e.rowid';
225 $this->export_sql_end[$r] .=
' WHERE e.entity IN ('.getEntity(
'stock').
')';
229 $this->export_code[$r] = $this->rights_class.
'_emplacement_product';
230 $this->export_label[$r] =
"Stocks";
231 $this->export_icon[$r] =
"warehouse";
232 $this->export_permission[$r] = array(array(
"stock",
"lire"));
233 $this->export_fields_array[$r] = array(
234 'e.rowid'=>
'IdWarehouse',
'e.ref'=>
'LocationSummary',
'e.description'=>
'DescWareHouse',
'e.lieu'=>
'LieuWareHouse',
'e.address'=>
'Address',
'e.zip'=>
'Zip',
'e.town'=>
'Town',
235 'p.rowid'=>
"ProductId",
'p.ref'=>
"Ref",
'p.fk_product_type'=>
"Type",
'p.label'=>
"Label",
'p.description'=>
"Description",
'p.note'=>
"Note",
236 'p.price'=>
"Price",
'p.tva_tx'=>
'VAT',
'p.tosell'=>
"OnSell",
'p.tobuy'=>
'OnBuy',
'p.duration'=>
"Duration",
237 'p.datec'=>
'DateCreation',
'p.tms'=>
'DateModification',
'p.pmp'=>
'PMPValue',
'p.cost_price'=>
'CostPrice',
238 'p.seuil_stock_alerte'=>
'StockLimit',
240 $this->export_TypeFields_array[$r] = array(
241 'e.rowid'=>
'List:entrepot:ref::stock',
'e.ref'=>
'Text',
'e.lieu'=>
'Text',
'e.address'=>
'Text',
'e.zip'=>
'Text',
'e.town'=>
'Text',
242 'p.rowid'=>
"Numeric",
'p.ref'=>
"Text",
'p.fk_product_type'=>
"Text",
'p.label'=>
"Text",
'p.description'=>
"Text",
'p.note'=>
"Text",
243 'p.price'=>
"Numeric",
'p.tva_tx'=>
'Numeric',
'p.tosell'=>
"Boolean",
'p.tobuy'=>
"Boolean",
'p.duration'=>
"Duree",
244 'p.datec'=>
'Date',
'p.tms'=>
'Date',
'p.pmp'=>
'Numeric',
'p.cost_price'=>
'Numeric',
245 'ps.reel'=>
'Numeric',
246 'p.seuil_stock_alerte'=>
'Numeric',
248 $this->export_entities_array[$r] = array(
249 'p.rowid'=>
"product",
'p.ref'=>
"product",
'p.fk_product_type'=>
"product",
'p.label'=>
"product",
'p.description'=>
"product",
'p.note'=>
"product",
250 'p.price'=>
"product",
'p.tva_tx'=>
'product',
'p.tosell'=>
"product",
'p.tobuy'=>
"product",
'p.duration'=>
"product",
251 'p.datec'=>
'product',
'p.tms'=>
'product',
'p.pmp'=>
'product',
'p.cost_price'=>
'product',
253 'p.seuil_stock_alerte'=>
'product',
255 $this->export_aggregate_array[$r] = array(
'ps.reel'=>
'SUM');
256 $this->export_dependencies_array[$r] = array(
'stock'=>array(
'p.rowid',
'e.rowid'));
257 $keyforselect =
'product';
258 $keyforelement =
'product';
259 $keyforaliasextra =
'extra';
260 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
261 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'ps.reel'=>
'Stock'));
263 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
264 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product as p LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra ON extra.fk_object = p.rowid, '.MAIN_DB_PREFIX.
'product_stock as ps, '.MAIN_DB_PREFIX.
'entrepot as e';
265 $this->export_sql_end[$r] .=
' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
266 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
270 $langs->load(
"productbatch");
275 $this->export_code[$r] = $this->rights_class.
'_emplacement_product_lot';
276 $this->export_label[$r] =
"StocksWithBatch";
277 $this->export_icon[$r] =
"warehouse";
278 $this->export_permission[$r] = array(array(
"stock",
"lire"));
279 $this->export_fields_array[$r] = array(
280 'e.rowid'=>
'IdWarehouse',
'e.ref'=>
'LocationSummary',
'e.description'=>
'DescWareHouse',
'e.lieu'=>
'LieuWareHouse',
'e.address'=>
'Address',
'e.zip'=>
'Zip',
'e.town'=>
'Town',
281 'p.rowid'=>
"ProductId",
'p.ref'=>
"Ref",
'p.fk_product_type'=>
"Type",
'p.label'=>
"Label",
'p.description'=>
"Description",
'p.note'=>
"Note",
282 'p.price'=>
"Price",
'p.tva_tx'=>
'VAT',
'p.tosell'=>
"OnSell",
'p.tobuy'=>
'OnBuy',
'p.duration'=>
"Duration",
283 'p.datec'=>
'DateCreation',
'p.tms'=>
'DateModification',
'p.pmp'=>
'PMPValue',
'p.cost_price'=>
'CostPrice',
284 'pb.rowid'=>
'Id',
'pb.batch'=>
'Batch',
'pb.qty'=>
'Qty',
285 'pl.eatby'=>
'EatByDate',
'pl.sellby'=>
'SellByDate'
287 $this->export_TypeFields_array[$r] = array(
288 'e.rowid'=>
'List:entrepot:ref::stock',
'e.ref'=>
'Text',
'e.lieu'=>
'Text',
'e.description'=>
'Text',
'e.address'=>
'Text',
'e.zip'=>
'Text',
'e.town'=>
'Text',
289 'p.rowid'=>
"Numeric",
'p.ref'=>
"Text",
'p.fk_product_type'=>
"Text",
'p.label'=>
"Text",
'p.description'=>
"Text",
'p.note'=>
"Text",
290 'p.price'=>
"Numeric",
'p.tva_tx'=>
'Numeric',
'p.tosell'=>
"Boolean",
'p.tobuy'=>
"Boolean",
'p.duration'=>
"Duree",
291 'p.datec'=>
'DateCreation',
'p.tms'=>
'DateModification',
'p.pmp'=>
'PMPValue',
'p.cost_price'=>
'CostPrice',
292 'pb.batch'=>
'Text',
'pb.qty'=>
'Numeric',
293 'pl.eatby'=>
'Date',
'pl.sellby'=>
'Date'
295 $this->export_entities_array[$r] = array(
296 'p.rowid'=>
"product",
'p.ref'=>
"product",
'p.fk_product_type'=>
"product",
'p.label'=>
"product",
'p.description'=>
"product",
'p.note'=>
"product",
297 'p.price'=>
"product",
'p.tva_tx'=>
'product',
'p.tosell'=>
"product",
'p.tobuy'=>
"product",
'p.duration'=>
"product",
298 'p.datec'=>
'product',
'p.tms'=>
'product',
'p.pmp'=>
'product',
'p.cost_price'=>
'product',
299 'pb.rowid'=>
'batch',
'pb.batch'=>
'batch',
'pb.qty'=>
'batch',
300 'pl.eatby'=>
'batch',
'pl.sellby'=>
'batch'
302 $this->export_aggregate_array[$r] = array(
'ps.reel'=>
'SUM');
303 $this->export_dependencies_array[$r] = array(
'stockbatch'=>array(
'pb.rowid'),
'batch'=>array(
'pb.rowid'));
304 $keyforselect =
'product_lot';
305 $keyforelement =
'batch';
306 $keyforaliasextra =
'extra';
307 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
309 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
310 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'product_batch as pb';
311 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product_stock as ps ON ps.rowid = pb.fk_product_stock';
312 $this->export_sql_end[$r] .=
' INNER JOIN '.MAIN_DB_PREFIX.
'product as p ON p.rowid = ps.fk_product';
313 $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';
314 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lot_extrafields as extra ON extra.fk_object = pl.rowid,';
315 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'entrepot as e';
316 $this->export_sql_end[$r] .=
' WHERE ps.fk_entrepot = e.rowid';
317 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
322 $this->export_code[$r] = $this->rights_class.
'_movement';
323 $this->export_label[$r] =
"StockMovements";
324 $this->export_icon[$r] =
"movement";
325 $this->export_permission[$r] = array(array(
"stock",
"lire"));
326 $this->export_fields_array[$r] = array(
327 'sm.rowid'=>
'MovementId',
'sm.value'=>
'Qty',
'sm.datem'=>
'DateMovement',
'sm.label'=>
'MovementLabel',
'sm.inventorycode'=>
'InventoryCode',
328 'e.rowid'=>
'IdWarehouse',
'e.ref'=>
'LocationSummary',
'e.description'=>
'DescWareHouse',
'e.lieu'=>
'LieuWareHouse',
'e.address'=>
'Address',
'e.zip'=>
'Zip',
'e.town'=>
'Town',
329 'p.rowid'=>
"ProductId",
'p.ref'=>
"Ref",
'p.fk_product_type'=>
"Type",
'p.label'=>
"Label",
'p.description'=>
"Description",
'p.note'=>
"Note",
330 'p.price'=>
"Price",
'p.tva_tx'=>
'VAT',
'p.tosell'=>
"OnSell",
'p.tobuy'=>
'OnBuy',
'p.duration'=>
"Duration",
'p.datec'=>
'DateCreation',
'p.tms'=>
'DateModification'
332 $this->export_TypeFields_array[$r] = array(
333 'sm.rowid'=>
'Numeric',
'sm.value'=>
'Numeric',
'sm.datem'=>
'Date',
'sm.batch'=>
'Text',
'sm.label'=>
'Text',
'sm.inventorycode'=>
'Text',
334 'e.rowid'=>
'List:entrepot:ref::stock',
'e.ref'=>
'Text',
'e.description'=>
'Text',
'e.lieu'=>
'Text',
'e.address'=>
'Text',
'e.zip'=>
'Text',
'e.town'=>
'Text',
335 'p.rowid'=>
"Numeric",
'p.ref'=>
"Text",
'p.fk_product_type'=>
"Text",
'p.label'=>
"Text",
'p.description'=>
"Text",
'p.note'=>
"Text",
336 'p.price'=>
"Numeric",
'p.tva_tx'=>
'Numeric',
'p.tosell'=>
"Boolean",
'p.tobuy'=>
"Boolean",
'p.duration'=>
"Duree",
'p.datec'=>
'Date',
'p.tms'=>
'Date'
338 $this->export_entities_array[$r] = array(
339 'e.rowid'=>
'warehouse',
'e.ref'=>
'warehouse',
'e.description'=>
'warehouse',
'e.lieu'=>
'warehouse',
'e.address'=>
'warehouse',
'e.zip'=>
'warehouse',
'e.town'=>
'warehouse',
340 'p.rowid'=>
"product",
'p.ref'=>
"product",
'p.fk_product_type'=>
"product",
'p.label'=>
"product",
'p.description'=>
"product",
'p.note'=>
"product",
341 'p.price'=>
"product",
'p.tva_tx'=>
'product',
'p.tosell'=>
"product",
'p.tobuy'=>
"product",
'p.duration'=>
"product",
'p.datec'=>
'product',
'p.tms'=>
'product'
344 $this->export_fields_array[$r][
'sm.batch'] =
'Batch';
345 $this->export_TypeFields_array[$r][
'sm.batch'] =
'Text';
346 $this->export_entities_array[$r][
'sm.batch'] =
'movement';
348 $this->export_aggregate_array[$r] = array(
'sm.value'=>
'SUM');
349 $this->export_dependencies_array[$r] = array(
'movement'=>array(
'sm.rowid'));
351 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
352 $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';
353 $this->export_sql_end[$r] .=
' WHERE p.rowid = sm.fk_product AND sm.fk_entrepot = e.rowid';
354 $this->export_sql_end[$r] .=
' AND e.entity IN ('.getEntity(
'stock').
')';
363 $this->import_code[$r] = $this->rights_class.
'_'.$r;
364 $this->import_label[$r] =
"Warehouses";
365 $this->import_icon[$r] =
"warehouse";
366 $this->import_entities_array[$r] = array();
367 $this->import_tables_array[$r] = array(
'e'=>MAIN_DB_PREFIX.
'entrepot');
368 $this->import_tables_creator_array[$r] = array(
'e'=>
'fk_user_author');
369 $this->import_fields_array[$r] = array(
'e.ref'=>
"LocationSummary*",
370 'e.description'=>
"DescWareHouse",
371 'e.lieu'=>
"LieuWareHouse",
372 'e.address'=>
"Address",
374 'e.fk_departement'=>
'StateCode',
375 'e.fk_pays'=>
'CountryCode',
378 'e.statut'=>
'Status',
379 'e.fk_parent'=>
'ParentWarehouse'
382 $this->import_convertvalue_array[$r] = array(
383 'e.fk_departement'=>array(
'rule'=>
'fetchidfromcodeid',
'classfile'=>
'/core/class/cstate.class.php',
'class'=>
'Cstate',
'method'=>
'fetch',
'dict'=>
'DictionaryStateCode'),
384 'e.fk_pays'=>array(
'rule'=>
'fetchidfromcodeid',
'classfile'=>
'/core/class/ccountry.class.php',
'class'=>
'Ccountry',
'method'=>
'fetch',
'dict'=>
'DictionaryCountry'),
385 'e.fk_parent'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/product/stock/class/entrepot.class.php',
'class'=>
'Entrepot',
'method'=>
'fetch',
'element'=>
'ref')
387 $this->import_regex_array[$r] = array(
'e.statut'=>
'^[0|1]');
388 $this->import_examplevalues_array[$r] = array(
'e.ref'=>
"ALM001",
389 'e.description'=>
"Central Warehouse",
391 'e.address'=>
"Route 66",
393 'e.fk_departement'=>
'matches field "code_departement" in table "'.MAIN_DB_PREFIX.
'c_departements"',
394 'e.fk_pays'=>
'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.
'c_country"',
395 'e.phone'=>
'(+33)(0)123456789',
396 'e.fax'=>
'(+33)(0)123456790',
398 'e.fk_parent'=>
'id or ref of warehouse'
400 $this->import_updatekeys_array[$r] = array(
'p.ref'=>
'Ref');
404 $this->import_code[$r] = $this->rights_class.
'_'.$r;
405 $this->import_label[$r] =
"Stocks";
406 $this->import_icon[$r] =
"stock";
407 $this->import_entities_array[$r] = array();
408 $this->import_tables_array[$r] = array(
'ps'=>MAIN_DB_PREFIX.
'product_stock');
409 $this->import_fields_array[$r] = array(
'ps.fk_product'=>
"Product*",
'ps.fk_entrepot'=>
"Warehouse*",
'ps.reel'=>
"Stock*");
411 $this->import_convertvalue_array[$r] = array(
412 'ps.fk_product'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/product/class/product.class.php',
'class'=>
'Product',
'method'=>
'fetch',
'element'=>
'product'),
413 'ps.fk_entrepot'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/product/stock/class/entrepot.class.php',
'class'=>
'Entrepot',
'method'=>
'fetch',
'element'=>
'ref')
415 $this->import_examplevalues_array[$r] = array(
416 'ps.fk_product'=>
"id or ref of product",
'ps.fk_entrepot'=>
"id or ref of warehouse",
'ps.reel'=>
"10"
418 $this->import_updatekeys_array[$r] = array(
'ps.fk_product'=>
'Product',
'ps.fk_entrepot'=>
"Warehouse");
419 $this->import_run_sql_after_array[$r] = array(
420 '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);'
433 public function init($options =
'')
435 global $conf, $langs;
437 $result = $this->
_load_tables(
'/install/mysql/',
'stock');
443 $this->
remove($options);
446 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/stocks/template_warehouse.odt';
447 $dirodt = DOL_DATA_ROOT.
'/doctemplates/stocks';
448 $dest = $dirodt.
'/template_warehouse.odt';
450 if (file_exists($src) && !file_exists($dest)) {
451 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
453 $result =
dol_copy($src, $dest, 0, 0);
455 $langs->load(
"errors");
456 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
464 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = '".$this->db->escape($this->const[1][2]).
"' AND type = 'stock' AND entity = ".((
int) $conf->entity),
465 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2]).
"','stock',".((
int) $conf->entity).
")",
466 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = '".$this->db->escape($this->const[2][2]).
"' AND type = 'mouvement' AND entity = ".((
int) $conf->entity),
467 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2]).
"','mouvement',".((
int) $conf->entity).
")",
470 return $this->
_init($sql, $options);
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Class to describe and enable module Stock.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
isModEnabled($module)
Is Dolibarr module enabled.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.