50 $this->rights_class =
'mrp';
53 $this->family =
"products";
55 $this->module_position =
'66';
59 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
61 $this->
description =
"Module to Manage Manufacturing Orders (MO)";
63 $this->descriptionlong =
"Module to Manage Manufacturing Orders (MO)";
65 $this->version =
'dolibarr';
70 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
76 $this->module_parts = array(
110 'moduleforexternal' => 0,
114 $this->dirs = array(
"/mrp/temp");
116 $this->config_page_url = array(
"mrp.php");
119 $this->hidden =
false;
121 $this->depends = array(
'modBom');
122 $this->requiredby = array(
'modWorkstation');
123 $this->conflictwith = array();
124 $this->langfiles = array(
"mrp");
125 $this->phpmin = array(7, 0);
126 $this->need_dolibarr_version = array(8, 0);
127 $this->warnings_activation = array();
128 $this->warnings_activation_ext = array();
137 $this->
const = array(
138 1=>array(
'MRP_MO_ADDON_PDF',
'chaine',
'alpha',
'Name of PDF model of MO', 0),
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/doctemplates/mrps',
'', 0)
149 if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) {
150 $conf->mrp =
new stdClass();
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',
269 'e.rowid'=>
'WarehouseId',
270 'e.ref'=>
'WarehouseRef',
272 'm.date_creation'=>
'DateCreation',
273 'm.tms'=>
'DateModification'
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',
296 'e.fk_warehouse'=>
'Numeric',
299 'm.date_creation'=>
'Date',
303 $this->export_entities_array[$r] = array();
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').
')';
330 $this->import_code[$r]=$this->rights_class.
'_'.$r;
331 $this->import_label[$r]=
'MOs';
332 $this->import_icon[$r]=
'mrp';
333 $this->import_entities_array[$r] = array();
334 $this->import_tables_array[$r] = array(
'm'=>MAIN_DB_PREFIX.
'mrp_mo',
'extra'=>MAIN_DB_PREFIX.
'mrp_mo_extrafields');
335 $this->import_tables_creator_array[$r] = array(
'm'=>
'fk_user_creat');
336 $this->import_fields_array[$r] = array(
338 'm.label' =>
"Label*",
339 'm.fk_project'=>
'Project',
341 'm.date_start_planned'=>
"DateStartPlanned",
342 'm.date_end_planned'=>
"DateEndPlanned",
343 'm.fk_product'=>
"Product*",
344 'm.status'=>
'Status',
345 'm.model_pdf'=>
'Model',
346 'm.fk_user_valid'=>
'ValidatedById',
347 'm.fk_user_modif'=>
'ModifiedById',
348 'm.fk_user_creat'=>
'CreatedById',
349 'm.date_valid'=>
'DateValid',
350 'm.note_private'=>
'NotePrivate',
351 'm.note_public'=>
'Note',
353 'm.fk_warehouse'=>
'Warehouse',
355 'm.date_creation'=>
'DateCreation',
356 'm.tms'=>
'DateModification',
358 $import_sample = array();
361 $import_extrafield_sample = array();
362 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'mrp_mo' AND entity IN (0, ".$conf->entity.
")";
363 $resql = $this->db->query($sql);
366 while ($obj = $this->db->fetch_object($resql)) {
367 $fieldname =
'extra.'.$obj->name;
368 $fieldlabel = ucfirst($obj->label);
369 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
370 $import_extrafield_sample[$fieldname] = $fieldlabel;
375 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'mrp_mo');
380 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
381 $this->import_updatekeys_array[$r] = array(
'm.ref' =>
'Ref');
382 $this->import_convertvalue_array[$r] = array(
383 'm.fk_product' => array(
384 'rule' =>
'fetchidfromref',
385 'file' =>
'/product/class/product.class.php',
386 'class' =>
'Product',
388 'element' =>
'Product'
390 'm.fk_warehouse' => array(
391 'rule' =>
'fetchidfromref',
392 'file' =>
'/product/stock/class/entrepot.class.php',
393 'class' =>
'Entrepot',
395 'element' =>
'Warehouse'
397 'm.fk_user_valid' => array(
398 'rule' =>
'fetchidfromref',
399 'file' =>
'/user/class/user.class.php',
404 'm.fk_user_modif' => array(
405 'rule' =>
'fetchidfromref',
406 'file' =>
'/user/class/user.class.php',