52 $this->rights_class =
'bom';
56 $this->family =
"products";
58 $this->module_position =
'65';
63 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
65 $this->
description =
"Module to define your Bills Of Materials (BOM). Can be used for Manufacturing Resource Planning by the module Manufacturing Orders (MO)";
67 $this->descriptionlong =
"Bill of Materials definitions. They can be used to make Manufacturing Resource Planning";
70 $this->version =
'dolibarr';
75 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
82 $this->module_parts = array(
101 $this->dirs = array(
"/bom/temp");
104 $this->config_page_url = array(
"bom.php");
107 $this->hidden =
false;
109 $this->depends = array(
'modProduct');
110 $this->requiredby = array(
'modMrp');
111 $this->conflictwith = array();
112 $this->langfiles = array(
"mrp");
114 $this->need_dolibarr_version = array(9, 0);
115 $this->warnings_activation = array();
116 $this->warnings_activation_ext = array();
125 $this->
const = array(
126 1=>array(
'BOM_ADDON_PDF',
'chaine',
'generic_bom_odt',
'Name of PDF model of BOM', 0),
127 2=>array(
'BOM_ADDON',
'chaine',
'mod_bom_standard',
'Name of numbering rules of BOM', 0),
128 3=>array(
'BOM_ADDON_PDF_ODT_PATH',
'chaine',
'DOL_DATA_ROOT/doctemplates/boms',
'', 0)
137 if (!isset($conf->bom) || !isset($conf->bom->enabled)) {
139 $conf->bom->enabled = 0;
144 $this->tabs = array();
173 $this->dictionaries = array();
178 $this->boxes = array(
179 0=>array(
'file' =>
'box_boms.php',
'note' =>
'',
'enabledbydefaulton' =>
'Home')
185 $this->cronjobs = array(
194 $this->rights = array();
197 $this->rights[$r][0] = $this->numero + $r;
198 $this->rights[$r][1] =
'Read bom of Bom';
199 $this->rights[$r][3] = 0;
200 $this->rights[$r][4] =
'read';
201 $this->rights[$r][5] =
'';
204 $this->rights[$r][0] = $this->numero + $r;
205 $this->rights[$r][1] =
'Create/Update bom of Bom';
206 $this->rights[$r][3] = 0;
207 $this->rights[$r][4] =
'write';
208 $this->rights[$r][5] =
'';
211 $this->rights[$r][0] = $this->numero + $r;
212 $this->rights[$r][1] =
'Delete bom of Bom';
213 $this->rights[$r][3] = 0;
214 $this->rights[$r][4] =
'delete';
215 $this->rights[$r][5] =
'';
219 $this->menu = array();
275 $this->export_code[$r] = $this->rights_class.
'_'.$r;
276 $this->export_label[$r] =
'BomAndBomLines';
277 $this->export_permission[$r] = array(array(
"bom",
"read"));
278 $this->export_icon[$r] =
'bom';
279 $keyforclass =
'BOM';
280 $keyforclassfile =
'/bom/class/bom.class.php';
281 $keyforelement =
'bom';
282 include DOL_DOCUMENT_ROOT.
'/core/commonfieldsinexport.inc.php';
283 $keyforclass =
'BOMLine';
284 $keyforclassfile =
'/bom/class/bom.class.php';
285 $keyforelement =
'bomline';
287 include DOL_DOCUMENT_ROOT.
'/core/commonfieldsinexport.inc.php';
288 unset($this->export_fields_array[$r][
'tl.fk_bom']);
289 $keyforselect =
'bom_bom';
290 $keyforaliasextra =
'extra';
291 $keyforelement =
'bom';
292 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
293 $keyforselect =
'bom_bomline';
294 $keyforaliasextra =
'extraline';
295 $keyforelement =
'bomline';
296 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
297 $this->export_dependencies_array[$r] = array(
'bomline'=>
'tl.rowid');
298 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
299 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'bom_bom as t';
300 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bom_bom_extrafields as extra on (t.rowid = extra.fk_object)';
301 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bom_bomline as tl ON tl.fk_bom = t.rowid';
302 $this->export_sql_end[$r] .=
' WHERE 1 = 1';
303 $this->export_sql_end[$r] .=
' AND t.entity IN ('.getEntity(
'bom').
')';
313 $this->import_code[$r] =
'bom_'.$r;
314 $this->import_label[$r] =
'BillOfMaterials';
315 $this->import_icon[$r] = $this->picto;
316 $this->import_entities_array[$r] = array();
317 $this->import_tables_array[$r] = array(
'b' => MAIN_DB_PREFIX.
'bom_bom',
'extra' => MAIN_DB_PREFIX.
'bom_bom_extrafields');
318 $this->import_tables_creator_array[$r] = array(
'b' =>
'fk_user_creat');
319 $this->import_fields_array[$r] = array(
321 'b.label' =>
'Label*',
322 'b.fk_product' =>
'ProductRef*',
323 'b.description' =>
'Description',
324 'b.note_public' =>
'Note',
325 'b.note_private' =>
'NotePrivate',
326 'b.fk_warehouse' =>
'WarehouseRef',
328 'b.efficiency' =>
'Efficiency',
329 'b.duration' =>
'Duration',
330 'b.date_creation' =>
'DateCreation',
331 'b.date_valid' =>
'DateValid',
332 'b.fk_user_modif' =>
'ModifiedById',
333 'b.fk_user_valid' =>
'ValidatedById',
334 'b.model_pdf' =>
'Model',
335 'b.status' =>
'Status*',
336 'b.bomtype' =>
'Type*'
338 $import_sample = array();
341 $import_extrafield_sample = array();
342 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'bom_bom' AND entity IN (0, ".$conf->entity.
")";
343 $resql = $this->db->query($sql);
346 while ($obj = $this->db->fetch_object($resql)) {
347 $fieldname =
'extra.'.$obj->name;
348 $fieldlabel = ucfirst($obj->label);
349 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
350 $import_extrafield_sample[$fieldname] = $fieldlabel;
355 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
356 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'bom_bom');
357 $this->import_regex_array[$r] = array(
361 $this->import_updatekeys_array[$r] = array(
'b.ref' =>
'Ref');
362 $this->import_convertvalue_array[$r] = array(
363 'b.fk_product' => array(
364 'rule' =>
'fetchidfromref',
365 'file' =>
'/product/class/product.class.php',
366 'class' =>
'Product',
368 'element' =>
'Product'
370 'b.fk_warehouse' => array(
371 'rule' =>
'fetchidfromref',
372 'file' =>
'/product/stock/class/entrepot.class.php',
373 'class' =>
'Entrepot',
375 'element' =>
'Warehouse'
377 'b.fk_user_valid' => array(
378 'rule' =>
'fetchidfromref',
379 'file' =>
'/user/class/user.class.php',
384 'b.fk_user_modif' => array(
385 'rule' =>
'fetchidfromref',
386 'file' =>
'/user/class/user.class.php',
395 $this->import_code[$r] =
'bom_lines_'.$r;
396 $this->import_label[$r] =
'BillOfMaterialsLines';
397 $this->import_icon[$r] = $this->picto;
398 $this->import_entities_array[$r] = array();
399 $this->import_tables_array[$r] = array(
'bd' => MAIN_DB_PREFIX.
'bom_bomline',
'extra' => MAIN_DB_PREFIX.
'bom_bomline_extrafields');
400 $this->import_fields_array[$r] = array(
401 'bd.fk_bom' =>
'BOM*',
402 'bd.fk_product' =>
'ProductRef',
403 'bd.fk_bom_child' =>
'BOMChild',
404 'bd.description' =>
'Description',
405 'bd.qty' =>
'LineQty',
406 'bd.qty_frozen' =>
'LineIsFrozen',
407 'bd.disable_stock_change' =>
'Disable Stock Change',
408 'bd.efficiency' =>
'Efficiency',
409 'bd.position' =>
'LinePosition'
413 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'bom_bomline' AND entity IN (0, ".$conf->entity.
")";
414 $resql = $this->db->query($sql);
416 while ($obj = $this->db->fetch_object($resql)) {
417 $fieldname =
'extra.'.$obj->name;
418 $fieldlabel = ucfirst($obj->label);
419 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
424 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'bom_bomline');
425 $this->import_regex_array[$r] = array();
426 $this->import_updatekeys_array[$r] = array(
'bd.fk_bom' =>
'BOM Id',
'bd.fk_product' =>
'ProductRef');
427 $this->import_convertvalue_array[$r] = array(
428 'bd.fk_bom' => array(
429 'rule' =>
'fetchidfromref',
430 'file' =>
'/bom/class/bom.class.php',
435 'bd.fk_product' => array(
436 'rule' =>
'fetchidfromref',
437 'file' =>
'/product/class/product.class.php',
438 'class' =>
'Product',
440 'element' =>
'Product'