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',
270 'e.rowid'=>
'WarehouseId',
271 'e.ref'=>
'WarehouseRef',
273 'm.date_creation'=>
'DateCreation',
274 'm.tms'=>
'DateModification'
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',
297 'e.fk_warehouse'=>
'Numeric',
300 'm.date_creation'=>
'Date',
304 $this->export_entities_array[$r] = array();
305 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
306 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'mrp_mo as m';
307 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'mrp_mo_extrafields as extra ON m.rowid = extra.fk_object';
308 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as e ON e.rowid = m.fk_warehouse';
309 $this->export_sql_end[$r] .=
' WHERE m.entity IN ('.getEntity(
'mrp_mo').
')';
331 $this->import_code[$r]=$this->rights_class.
'_'.$r;
332 $this->import_label[$r]=
'MOs';
333 $this->import_icon[$r]=
'mrp';
334 $this->import_entities_array[$r] = array();
335 $this->import_tables_array[$r] = array(
'm'=>MAIN_DB_PREFIX.
'mrp_mo',
'extra'=>MAIN_DB_PREFIX.
'mrp_mo_extrafields');
336 $this->import_tables_creator_array[$r] = array(
'm'=>
'fk_user_creat');
337 $this->import_fields_array[$r] = array(
339 'm.label' =>
"Label*",
340 'm.fk_project'=>
'Project',
342 'm.date_start_planned'=>
"DateStartPlanned",
343 'm.date_end_planned'=>
"DateEndPlanned",
344 'm.fk_product'=>
"Product*",
345 'm.status'=>
'Status',
346 'm.model_pdf'=>
'Model',
347 'm.fk_user_valid'=>
'ValidatedById',
348 'm.fk_user_modif'=>
'ModifiedById',
349 'm.fk_user_creat'=>
'CreatedById',
350 'm.date_valid'=>
'DateValidation',
351 'm.note_private'=>
'NotePrivate',
352 'm.note_public'=>
'Note',
354 'm.fk_warehouse'=>
'Warehouse',
356 'm.date_creation'=>
'DateCreation',
357 'm.tms'=>
'DateModification',
359 $import_sample = array();
362 $import_extrafield_sample = array();
363 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'mrp_mo' AND entity IN (0, ".$conf->entity.
")";
364 $resql = $this->db->query($sql);
367 while ($obj = $this->db->fetch_object($resql)) {
368 $fieldname =
'extra.'.$obj->name;
369 $fieldlabel = ucfirst($obj->label);
370 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
371 $import_extrafield_sample[$fieldname] = $fieldlabel;
376 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'mrp_mo');
381 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
382 $this->import_updatekeys_array[$r] = array(
'm.ref' =>
'Ref');
383 $this->import_convertvalue_array[$r] = array(
384 'm.fk_product' => array(
385 'rule' =>
'fetchidfromref',
386 'file' =>
'/product/class/product.class.php',
387 'class' =>
'Product',
389 'element' =>
'Product'
391 'm.fk_warehouse' => array(
392 'rule' =>
'fetchidfromref',
393 'file' =>
'/product/stock/class/entrepot.class.php',
394 'class' =>
'Entrepot',
396 'element' =>
'Warehouse'
398 'm.fk_user_valid' => array(
399 'rule' =>
'fetchidfromref',
400 'file' =>
'/user/class/user.class.php',
405 'm.fk_user_modif' => array(
406 'rule' =>
'fetchidfromref',
407 'file' =>
'/user/class/user.class.php',