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