51 $this->rights_class =
'mrp';
54 $this->family =
"products";
56 $this->module_position =
'66';
60 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
62 $this->
description =
"Module to Manage Manufacturing Orders (MO)";
64 $this->descriptionlong =
"Module to Manage Manufacturing Orders (MO)";
66 $this->version =
'dolibarr';
71 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
77 $this->module_parts = array(
111 'moduleforexternal' => 0,
115 $this->dirs = array(
"/mrp/temp");
117 $this->config_page_url = array(
"mrp.php");
120 $this->hidden =
false;
122 $this->depends = array(
'modBom');
123 $this->requiredby = array(
'modWorkstation');
124 $this->conflictwith = array();
125 $this->langfiles = array(
"mrp");
126 $this->phpmin = array(7, 0);
127 $this->need_dolibarr_version = array(8, 0);
128 $this->warnings_activation = array();
129 $this->warnings_activation_ext = array();
137 $this->
const = array(
139 2=>array(
'MRP_MO_ADDON',
'chaine',
'mod_mo_standard',
'Name of numbering rules of MO', 0),
140 3=>array(
'MRP_MO_ADDON_PDF_ODT_PATH',
'chaine',
'DOL_DATA_ROOT'.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/doctemplates/mrps',
'', 0)
149 if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) {
151 $conf->mrp->enabled = 0;
155 $this->tabs = array();
183 $this->dictionaries = array();
187 $this->boxes = array(
188 0 => array(
'file' =>
'box_mos.php',
'note' =>
'',
'enabledbydefaulton' =>
'Home')
193 $this->cronjobs = array(
215 $this->rights = array();
219 $this->rights[$r][0] = $this->numero + $r;
220 $this->rights[$r][1] =
'Read Manufacturing Order';
221 $this->rights[$r][4] =
'read';
222 $this->rights[$r][5] =
'';
224 $this->rights[$r][0] = $this->numero + $r;
225 $this->rights[$r][1] =
'Create/Update Manufacturing Order';
226 $this->rights[$r][4] =
'write';
227 $this->rights[$r][5] =
'';
229 $this->rights[$r][0] = $this->numero + $r;
230 $this->rights[$r][1] =
'Delete Manufacturing Order';
231 $this->rights[$r][4] =
'delete';
232 $this->rights[$r][5] =
'';
237 $this->menu = array();
243 $langs->loadLangs(array(
"mrp",
"stocks"));
248 $this->export_code[$r]=$this->rights_class.
'_'.$r;
249 $this->export_label[$r]=
'MOs';
250 $this->export_icon[$r]=
'mrp';
251 $this->export_fields_array[$r] = array(
255 'm.fk_project'=>
'Project',
257 'm.date_start_planned'=>
"DateStartPlanned",
258 'm.date_end_planned'=>
"DateEndPlanned",
259 'm.fk_product'=>
"Product",
260 'm.status'=>
'Status',
261 'm.model_pdf'=>
'Model',
262 'm.fk_user_valid'=>
'ValidatedById',
263 'm.fk_user_modif'=>
'ModifiedById',
264 'm.fk_user_creat'=>
'CreatedById',
265 'm.date_valid'=>
'DateValidation',
266 'm.note_private'=>
'NotePrivate',
267 'm.note_public'=>
'Note',
268 'm.fk_soc'=>
'ThirdParty:ID',
270 'm.date_creation'=>
'DateCreation',
271 'm.tms'=>
'DateModification',
272 'm.fk_warehouse'=>
'WarehouseForProduction:ID',
273 'e.ref'=>
'WarehouseForProduction:Ref'
275 $keyforselect =
'mrp_mo';
276 $keyforelement =
'mrp_mo';
277 $keyforaliasextra =
'extra';
278 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
279 $this->export_TypeFields_array[$r] = array(
282 'm.fk_project'=>
'Numeric',
283 'm.fk_bom'=>
"Numeric",
284 'm.date_end_planned'=>
"Date",
285 'm.date_start_planned'=>
"Date",
286 'm.fk_product'=>
"Numeric",
287 'm.status'=>
'Numeric',
288 'm.model_pdf'=>
'Text',
289 'm.fk_user_valid'=>
'Numeric',
290 'm.fk_user_modif'=>
'Numeric',
291 'm.fk_user_creat'=>
'Numeric',
292 'm.date_valid'=>
'Date',
293 'm.note_private'=>
'Text',
294 'm.note_public'=>
'Text',
295 'm.fk_soc'=>
'Numeric',
297 'm.date_creation'=>
'Date',
299 'm.fk_warehouse'=>
'Numeric',
302 $this->export_entities_array[$r] = array(
'm.fk_warehouse' =>
'warehouse',
'e.ref' =>
'warehouse');
303 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
304 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'mrp_mo as m';
305 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'mrp_mo_extrafields as extra ON m.rowid = extra.fk_object';
306 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as e ON e.rowid = m.fk_warehouse';
307 $this->export_sql_end[$r] .=
' WHERE m.entity IN ('.getEntity(
'mrp_mo').
')';
311 $this->export_code[$r]=$this->rights_class.
'_'.$r;
312 $this->export_label[$r]=
'ConsumptionAndProductionInMos';
313 $this->export_icon[$r]=
'mrp';
314 $this->export_fields_array[$r] = array(
318 'm.fk_project'=>
'ProjectId',
319 'm.fk_bom'=>
"Bom:ID",
320 'm.date_start_planned'=>
"DateStartPlanned",
321 'm.date_end_planned'=>
"DateEndPlanned",
322 'm.fk_product'=>
"Product",
323 'm.status'=>
'Status',
324 'm.model_pdf'=>
'Model',
325 'm.fk_user_valid'=>
'ValidatedById',
326 'm.fk_user_modif'=>
'ModifiedById',
327 'm.fk_user_creat'=>
'CreatedById',
328 'm.date_valid'=>
'DateValidation',
329 'm.note_private'=>
'NotePrivate',
330 'm.note_public'=>
'Note',
331 'm.fk_soc'=>
'ThirdParty',
333 'm.date_creation'=>
'DateCreation',
334 'm.tms'=>
'DateModification',
338 $keyforselect =
'mrp_mo';
339 $keyforelement =
'mrp_mo';
340 $keyforaliasextra =
'extra';
341 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
343 $this->export_fields_array[$r][
'mp.role'] =
'TypeOfMovement';
344 $this->export_fields_array[$r][
'mp.date_creation'] =
'DateCreation';
345 $this->export_fields_array[$r][
'mp.qty'] =
'Qty';
346 $this->export_fields_array[$r][
'mp.batch'] =
'Batch';
347 $this->export_fields_array[$r][
'mp.fk_product'] =
'ProductId';
348 $this->export_fields_array[$r][
'p.ref'] =
'ProductRef';
349 $this->export_fields_array[$r][
'mp.fk_warehouse'] =
'WarehouseId';
350 $this->export_fields_array[$r][
'e.ref'] =
'WarehouseRef';
351 $this->export_fields_array[$r][
'mp.fk_stock_movement'] =
'StockMovement:ID';
353 $keyforselect =
'mrp_production';
354 $keyforelement =
'mrp_production';
355 $keyforaliasextra =
'extramp';
356 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
358 $this->export_TypeFields_array[$r] = array(
361 'm.fk_project'=>
'Numeric',
362 'm.fk_bom'=>
"Numeric",
363 'm.date_end_planned'=>
"Date",
364 'm.date_start_planned'=>
"Date",
365 'm.fk_product'=>
"Numeric",
366 'm.status'=>
'Numeric',
367 'm.model_pdf'=>
'Text',
368 'm.fk_user_valid'=>
'Numeric',
369 'm.fk_user_modif'=>
'Numeric',
370 'm.fk_user_creat'=>
'Numeric',
371 'm.date_valid'=>
'Date',
372 'm.note_private'=>
'Text',
373 'm.note_public'=>
'Text',
374 'm.fk_soc'=>
'Numeric',
376 'm.date_creation'=>
'Date',
378 'e.fk_warehouse'=>
'Numeric',
380 'mp.qty' =>
'Numeric',
381 'mp.batch' =>
'Text',
382 'mp.fk_product' =>
'Numeric',
385 'mp.date_creation' =>
'Date',
386 'mp.fk_warehouse' =>
'Numeric',
387 'mp.fk_stock_movement' =>
'Numeric'
389 $this->export_entities_array[$r] = array(
390 'mp.qty' =>
'mrp_line',
391 'mp.batch' =>
'mrp_line',
392 'mp.role' =>
'mrp_line',
393 'mp.date_creation' =>
'mrp_line',
394 'mp.fk_product' =>
'product',
395 'p.ref' =>
'product',
396 'mp.fk_warehouse' =>
'warehouse',
397 'e.ref' =>
'warehouse',
398 'mp.fk_stock_movement' =>
'stock'
400 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
401 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'mrp_mo as m';
402 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'mrp_mo_extrafields as extra ON m.rowid = extra.fk_object';
403 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'mrp_production as mp ON m.rowid = mp.fk_mo';
404 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'mrp_production_extrafields as extramp ON mp.rowid = extramp.fk_object';
405 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as e ON e.rowid = mp.fk_warehouse';
406 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p ON p.rowid = mp.fk_product';
407 $this->export_sql_end[$r] .=
' WHERE m.entity IN ('.getEntity(
'mrp_mo').
')';
430 $this->import_code[$r]=$this->rights_class.
'_'.$r;
431 $this->import_label[$r]=
'MOs';
432 $this->import_icon[$r]=
'mrp';
433 $this->import_entities_array[$r] = array();
434 $this->import_tables_array[$r] = array(
'm'=>MAIN_DB_PREFIX.
'mrp_mo',
'extra'=>MAIN_DB_PREFIX.
'mrp_mo_extrafields');
435 $this->import_tables_creator_array[$r] = array(
'm'=>
'fk_user_creat');
436 $this->import_fields_array[$r] = array(
438 'm.label' =>
"Label*",
439 'm.fk_project'=>
'Project',
441 'm.date_start_planned'=>
"DateStartPlanned",
442 'm.date_end_planned'=>
"DateEndPlanned",
443 'm.fk_product'=>
"Product*",
444 'm.status'=>
'Status',
445 'm.model_pdf'=>
'Model',
446 'm.fk_user_valid'=>
'ValidatedById',
447 'm.fk_user_modif'=>
'ModifiedById',
448 'm.fk_user_creat'=>
'CreatedById',
449 'm.date_valid'=>
'DateValidation',
450 'm.note_private'=>
'NotePrivate',
451 'm.note_public'=>
'Note',
452 'm.fk_soc'=>
'ThirdParty',
453 'm.fk_warehouse'=>
'Warehouse',
455 'm.date_creation'=>
'DateCreation',
456 'm.tms'=>
'DateModification',
458 $import_sample = array();
461 $import_extrafield_sample = array();
462 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'mrp_mo' AND entity IN (0, ".$conf->entity.
")";
463 $resql = $this->db->query($sql);
466 while ($obj = $this->db->fetch_object($resql)) {
467 $fieldname =
'extra.'.$obj->name;
468 $fieldlabel = ucfirst($obj->label);
469 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
470 $import_extrafield_sample[$fieldname] = $fieldlabel;
475 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'mrp_mo');
480 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
481 $this->import_updatekeys_array[$r] = array(
'm.ref' =>
'Ref');
482 $this->import_convertvalue_array[$r] = array(
483 'm.fk_product' => array(
484 'rule' =>
'fetchidfromref',
485 'file' =>
'/product/class/product.class.php',
486 'class' =>
'Product',
488 'element' =>
'Product'
490 'm.fk_warehouse' => array(
491 'rule' =>
'fetchidfromref',
492 'file' =>
'/product/stock/class/entrepot.class.php',
493 'class' =>
'Entrepot',
495 'element' =>
'Warehouse'
497 'm.fk_user_valid' => array(
498 'rule' =>
'fetchidfromref',
499 'file' =>
'/user/class/user.class.php',
504 'm.fk_user_modif' => array(
505 'rule' =>
'fetchidfromref',
506 'file' =>
'/user/class/user.class.php',