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();
138 $this->
const = array(
140 2=>array(
'MRP_MO_ADDON',
'chaine',
'mod_mo_standard',
'Name of numbering rules of MO', 0),
141 3=>array(
'MRP_MO_ADDON_PDF_ODT_PATH',
'chaine',
'DOL_DATA_ROOT/doctemplates/mrps',
'', 0)
150 if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) {
152 $conf->mrp->enabled = 0;
156 $this->tabs = array();
184 $this->dictionaries = array();
188 $this->boxes = array(
189 0 => array(
'file' =>
'box_mos.php',
'note' =>
'',
'enabledbydefaulton' =>
'Home')
194 $this->cronjobs = array(
216 $this->rights = array();
220 $this->rights[$r][0] = $this->numero + $r;
221 $this->rights[$r][1] =
'Read Manufacturing Order';
222 $this->rights[$r][4] =
'read';
223 $this->rights[$r][5] =
'';
225 $this->rights[$r][0] = $this->numero + $r;
226 $this->rights[$r][1] =
'Create/Update Manufacturing Order';
227 $this->rights[$r][4] =
'write';
228 $this->rights[$r][5] =
'';
230 $this->rights[$r][0] = $this->numero + $r;
231 $this->rights[$r][1] =
'Delete Manufacturing Order';
232 $this->rights[$r][4] =
'delete';
233 $this->rights[$r][5] =
'';
238 $this->menu = array();
244 $langs->loadLangs(array(
"mrp",
"stocks"));
249 $this->export_code[$r]=$this->rights_class.
'_'.$r;
250 $this->export_label[$r]=
'MOs';
251 $this->export_icon[$r]=
'mrp';
252 $this->export_fields_array[$r] = array(
256 'm.fk_project'=>
'Project',
258 'm.date_start_planned'=>
"DateStartPlanned",
259 'm.date_end_planned'=>
"DateEndPlanned",
260 'm.fk_product'=>
"Product",
261 'm.status'=>
'Status',
262 'm.model_pdf'=>
'Model',
263 'm.fk_user_valid'=>
'ValidatedById',
264 'm.fk_user_modif'=>
'ModifiedById',
265 'm.fk_user_creat'=>
'CreatedById',
266 'm.date_valid'=>
'DateValidation',
267 'm.note_private'=>
'NotePrivate',
268 'm.note_public'=>
'Note',
269 'm.fk_soc'=>
'ThirdParty:ID',
271 'm.date_creation'=>
'DateCreation',
272 'm.tms'=>
'DateModification',
273 'm.fk_warehouse'=>
'WarehouseForProduction:ID',
274 'e.ref'=>
'WarehouseForProduction:Ref'
276 $keyforselect =
'mrp_mo';
277 $keyforelement =
'mrp_mo';
278 $keyforaliasextra =
'extra';
279 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
280 $this->export_TypeFields_array[$r] = array(
283 'm.fk_project'=>
'Numeric',
284 'm.fk_bom'=>
"Numeric",
285 'm.date_end_planned'=>
"Date",
286 'm.date_start_planned'=>
"Date",
287 'm.fk_product'=>
"Numeric",
288 'm.status'=>
'Numeric',
289 'm.model_pdf'=>
'Text',
290 'm.fk_user_valid'=>
'Numeric',
291 'm.fk_user_modif'=>
'Numeric',
292 'm.fk_user_creat'=>
'Numeric',
293 'm.date_valid'=>
'Date',
294 'm.note_private'=>
'Text',
295 'm.note_public'=>
'Text',
296 'm.fk_soc'=>
'Numeric',
298 'm.date_creation'=>
'Date',
300 'm.fk_warehouse'=>
'Numeric',
303 $this->export_entities_array[$r] = array(
'm.fk_warehouse' =>
'warehouse',
'e.ref' =>
'warehouse');
304 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
305 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'mrp_mo as m';
306 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'mrp_mo_extrafields as extra ON m.rowid = extra.fk_object';
307 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as e ON e.rowid = m.fk_warehouse';
308 $this->export_sql_end[$r] .=
' WHERE m.entity IN ('.getEntity(
'mrp_mo').
')';
312 $this->export_code[$r]=$this->rights_class.
'_'.$r;
313 $this->export_label[$r]=
'ConsumptionAndProductionInMos';
314 $this->export_icon[$r]=
'mrp';
315 $this->export_fields_array[$r] = array(
319 'm.fk_project'=>
'ProjectId',
320 'm.fk_bom'=>
"Bom:ID",
321 'm.date_start_planned'=>
"DateStartPlanned",
322 'm.date_end_planned'=>
"DateEndPlanned",
323 'm.fk_product'=>
"Product",
324 'm.status'=>
'Status',
325 'm.model_pdf'=>
'Model',
326 'm.fk_user_valid'=>
'ValidatedById',
327 'm.fk_user_modif'=>
'ModifiedById',
328 'm.fk_user_creat'=>
'CreatedById',
329 'm.date_valid'=>
'DateValidation',
330 'm.note_private'=>
'NotePrivate',
331 'm.note_public'=>
'Note',
334 'm.date_creation'=>
'DateCreation',
335 'm.tms'=>
'DateModification',
339 $keyforselect =
'mrp_mo';
340 $keyforelement =
'mrp_mo';
341 $keyforaliasextra =
'extra';
342 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
344 $this->export_fields_array[$r][
'mp.role'] =
'TypeOfMovement';
345 $this->export_fields_array[$r][
'mp.date_creation'] =
'DateCreation';
346 $this->export_fields_array[$r][
'mp.qty'] =
'Qty';
347 $this->export_fields_array[$r][
'mp.batch'] =
'Batch';
348 $this->export_fields_array[$r][
'mp.fk_product'] =
'ProductId';
349 $this->export_fields_array[$r][
'p.ref'] =
'ProductRef';
350 $this->export_fields_array[$r][
'mp.fk_warehouse'] =
'WarehouseId';
351 $this->export_fields_array[$r][
'e.ref'] =
'WarehouseRef';
352 $this->export_fields_array[$r][
'mp.fk_stock_movement'] =
'StockMovement:ID';
354 $keyforselect =
'mrp_production';
355 $keyforelement =
'mrp_production';
356 $keyforaliasextra =
'extramp';
357 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
359 $this->export_TypeFields_array[$r] = array(
362 'm.fk_project'=>
'Numeric',
363 'm.fk_bom'=>
"Numeric",
364 'm.date_end_planned'=>
"Date",
365 'm.date_start_planned'=>
"Date",
366 'm.fk_product'=>
"Numeric",
367 'm.status'=>
'Numeric',
368 'm.model_pdf'=>
'Text',
369 'm.fk_user_valid'=>
'Numeric',
370 'm.fk_user_modif'=>
'Numeric',
371 'm.fk_user_creat'=>
'Numeric',
372 'm.date_valid'=>
'Date',
373 'm.note_private'=>
'Text',
374 'm.note_public'=>
'Text',
375 'm.fk_soc'=>
'Numeric',
377 'm.date_creation'=>
'Date',
379 'e.fk_warehouse'=>
'Numeric',
381 'mp.qty' =>
'Numeric',
382 'mp.batch' =>
'Text',
383 'mp.fk_product' =>
'Numeric',
386 'mp.date_creation' =>
'Date',
387 'mp.fk_warehouse' =>
'Numeric',
388 'mp.fk_stock_movement' =>
'Numeric'
390 $this->export_entities_array[$r] = array(
391 'mp.qty' =>
'mrp_line',
392 'mp.batch' =>
'mrp_line',
393 'mp.role' =>
'mrp_line',
394 'mp.date_creation' =>
'mrp_line',
395 'mp.fk_product' =>
'product',
396 'p.ref' =>
'product',
397 'mp.fk_warehouse' =>
'warehouse',
398 'e.ref' =>
'warehouse',
399 'mp.fk_stock_movement' =>
'stock'
401 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
402 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'mrp_mo as m';
403 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'mrp_mo_extrafields as extra ON m.rowid = extra.fk_object';
404 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'mrp_production as mp ON m.rowid = mp.fk_mo';
405 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'mrp_production_extrafields as extramp ON mp.rowid = extramp.fk_object';
406 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as e ON e.rowid = mp.fk_warehouse';
407 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p ON p.rowid = mp.fk_product';
408 $this->export_sql_end[$r] .=
' WHERE m.entity IN ('.getEntity(
'mrp_mo').
')';
431 $this->import_code[$r]=$this->rights_class.
'_'.$r;
432 $this->import_label[$r]=
'MOs';
433 $this->import_icon[$r]=
'mrp';
434 $this->import_entities_array[$r] = array();
435 $this->import_tables_array[$r] = array(
'm'=>MAIN_DB_PREFIX.
'mrp_mo',
'extra'=>MAIN_DB_PREFIX.
'mrp_mo_extrafields');
436 $this->import_tables_creator_array[$r] = array(
'm'=>
'fk_user_creat');
437 $this->import_fields_array[$r] = array(
439 'm.label' =>
"Label*",
440 'm.fk_project'=>
'Project',
442 'm.date_start_planned'=>
"DateStartPlanned",
443 'm.date_end_planned'=>
"DateEndPlanned",
444 'm.fk_product'=>
"Product*",
445 'm.status'=>
'Status',
446 'm.model_pdf'=>
'Model',
447 'm.fk_user_valid'=>
'ValidatedById',
448 'm.fk_user_modif'=>
'ModifiedById',
449 'm.fk_user_creat'=>
'CreatedById',
450 'm.date_valid'=>
'DateValidation',
451 'm.note_private'=>
'NotePrivate',
452 'm.note_public'=>
'Note',
454 'm.fk_warehouse'=>
'Warehouse',
456 'm.date_creation'=>
'DateCreation',
457 'm.tms'=>
'DateModification',
459 $import_sample = array();
462 $import_extrafield_sample = array();
463 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'mrp_mo' AND entity IN (0, ".$conf->entity.
")";
464 $resql = $this->db->query($sql);
467 while ($obj = $this->db->fetch_object($resql)) {
468 $fieldname =
'extra.'.$obj->name;
469 $fieldlabel = ucfirst($obj->label);
470 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
471 $import_extrafield_sample[$fieldname] = $fieldlabel;
476 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'mrp_mo');
481 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
482 $this->import_updatekeys_array[$r] = array(
'm.ref' =>
'Ref');
483 $this->import_convertvalue_array[$r] = array(
484 'm.fk_product' => array(
485 'rule' =>
'fetchidfromref',
486 'file' =>
'/product/class/product.class.php',
487 'class' =>
'Product',
489 'element' =>
'Product'
491 'm.fk_warehouse' => array(
492 'rule' =>
'fetchidfromref',
493 'file' =>
'/product/stock/class/entrepot.class.php',
494 'class' =>
'Entrepot',
496 'element' =>
'Warehouse'
498 'm.fk_user_valid' => array(
499 'rule' =>
'fetchidfromref',
500 'file' =>
'/user/class/user.class.php',
505 'm.fk_user_modif' => array(
506 'rule' =>
'fetchidfromref',
507 'file' =>
'/user/class/user.class.php',