29 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
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;
108 $this->depends = array(
'modProduct');
109 $this->requiredby = array(
'modMrp');
110 $this->conflictwith = array();
111 $this->langfiles = array(
"mrp");
113 $this->need_dolibarr_version = array(9, 0);
114 $this->warnings_activation = array();
115 $this->warnings_activation_ext = array();
124 $this->
const = array(
125 1=>array(
'BOM_ADDON_PDF',
'chaine',
'generic_bom_odt',
'Name of PDF model of BOM', 0),
126 2=>array(
'BOM_ADDON',
'chaine',
'mod_bom_standard',
'Name of numbering rules of BOM', 0),
127 3=>array(
'BOM_ADDON_PDF_ODT_PATH',
'chaine',
'DOL_DATA_ROOT/doctemplates/boms',
'', 0)
136 if (!isset($conf->bom) || !isset($conf->bom->enabled)) {
137 $conf->bom =
new stdClass();
138 $conf->bom->enabled = 0;
143 $this->tabs = array();
172 $this->dictionaries = array();
177 $this->boxes = array(
178 0=>array(
'file' =>
'box_boms.php',
'note' =>
'',
'enabledbydefaulton' =>
'Home')
184 $this->cronjobs = array(
193 $this->rights = array();
196 $this->rights[$r][0] = $this->numero + $r;
197 $this->rights[$r][1] =
'Read bom of Bom';
198 $this->rights[$r][3] = 0;
199 $this->rights[$r][4] =
'read';
200 $this->rights[$r][5] =
'';
203 $this->rights[$r][0] = $this->numero + $r;
204 $this->rights[$r][1] =
'Create/Update bom of Bom';
205 $this->rights[$r][3] = 0;
206 $this->rights[$r][4] =
'write';
207 $this->rights[$r][5] =
'';
210 $this->rights[$r][0] = $this->numero + $r;
211 $this->rights[$r][1] =
'Delete bom of Bom';
212 $this->rights[$r][3] = 0;
213 $this->rights[$r][4] =
'delete';
214 $this->rights[$r][5] =
'';
218 $this->menu = array();
274 $this->export_code[$r] = $this->rights_class.
'_'.$r;
275 $this->export_label[$r] =
'BomAndBomLines';
276 $this->export_permission[$r] = array(array(
"bom",
"read"));
277 $this->export_icon[$r] =
'bom';
278 $keyforclass =
'BOM';
279 $keyforclassfile =
'/bom/class/bom.class.php';
280 $keyforelement =
'bom';
281 include DOL_DOCUMENT_ROOT.
'/core/commonfieldsinexport.inc.php';
282 $keyforclass =
'BOMLine';
283 $keyforclassfile =
'/bom/class/bom.class.php';
284 $keyforelement =
'bomline';
286 include DOL_DOCUMENT_ROOT.
'/core/commonfieldsinexport.inc.php';
287 unset($this->export_fields_array[$r][
'tl.fk_bom']);
288 $keyforselect =
'bom_bom';
289 $keyforaliasextra =
'extra';
290 $keyforelement =
'bom';
291 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
292 $keyforselect =
'bom_bomline';
293 $keyforaliasextra =
'extraline';
294 $keyforelement =
'bomline';
295 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
296 $this->export_dependencies_array[$r] = array(
'bomline'=>
'tl.rowid');
297 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
298 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'bom_bom as t';
299 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bom_bom_extrafields as extra on (t.rowid = extra.fk_object)';
300 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bom_bomline as tl ON tl.fk_bom = t.rowid';
301 $this->export_sql_end[$r] .=
' WHERE 1 = 1';
302 $this->export_sql_end[$r] .=
' AND t.entity IN ('.getEntity(
'bom').
')';
312 $this->import_code[$r] =
'bom_'.$r;
313 $this->import_label[$r] =
'BillOfMaterials';
314 $this->import_icon[$r] = $this->picto;
315 $this->import_entities_array[$r] = array();
316 $this->import_tables_array[$r] = array(
'b' => MAIN_DB_PREFIX.
'bom_bom',
'extra' => MAIN_DB_PREFIX.
'bom_bom_extrafields');
317 $this->import_tables_creator_array[$r] = array(
'b' =>
'fk_user_creat');
318 $this->import_fields_array[$r] = array(
320 'b.label' =>
'Label*',
321 'b.fk_product' =>
'ProductRef*',
322 'b.description' =>
'Description',
323 'b.note_public' =>
'Note',
324 'b.note_private' =>
'NotePrivate',
325 'b.fk_warehouse' =>
'WarehouseRef',
327 'b.efficiency' =>
'Efficiency',
328 'b.duration' =>
'Duration',
329 'b.date_creation' =>
'DateCreation',
330 'b.date_valid' =>
'DateValid',
331 'b.fk_user_modif' =>
'ModifiedById',
332 'b.fk_user_valid' =>
'ValidatedById',
333 'b.model_pdf' =>
'Model',
334 'b.status' =>
'Status*',
335 'b.bomtype' =>
'Type*'
337 $import_sample = array();
340 $import_extrafield_sample = array();
341 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'bom_bom' AND entity IN (0, ".$conf->entity.
")";
345 while ($obj = $this->
db->fetch_object(
$resql)) {
346 $fieldname =
'extra.'.$obj->name;
347 $fieldlabel = ucfirst($obj->label);
348 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
349 $import_extrafield_sample[$fieldname] = $fieldlabel;
354 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
355 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'bom_bom');
356 $this->import_regex_array[$r] = array(
360 $this->import_updatekeys_array[$r] = array(
'b.ref' =>
'Ref');
361 $this->import_convertvalue_array[$r] = array(
362 'b.fk_product' => array(
363 'rule' =>
'fetchidfromref',
364 'file' =>
'/product/class/product.class.php',
365 'class' =>
'Product',
367 'element' =>
'Product'
369 'b.fk_warehouse' => array(
370 'rule' =>
'fetchidfromref',
371 'file' =>
'/product/stock/class/entrepot.class.php',
372 'class' =>
'Entrepot',
374 'element' =>
'Warehouse'
376 'b.fk_user_valid' => array(
377 'rule' =>
'fetchidfromref',
378 'file' =>
'/user/class/user.class.php',
383 'b.fk_user_modif' => array(
384 'rule' =>
'fetchidfromref',
385 'file' =>
'/user/class/user.class.php',
394 $this->import_code[$r] =
'bom_lines_'.$r;
395 $this->import_label[$r] =
'BillOfMaterialsLines';
396 $this->import_icon[$r] = $this->picto;
397 $this->import_entities_array[$r] = array();
398 $this->import_tables_array[$r] = array(
'bd' => MAIN_DB_PREFIX.
'bom_bomline',
'extra' => MAIN_DB_PREFIX.
'bom_bomline_extrafields');
399 $this->import_fields_array[$r] = array(
400 'bd.fk_bom' =>
'BOM*',
401 'bd.fk_product' =>
'ProductRef',
402 'bd.fk_bom_child' =>
'BOMChild',
403 'bd.description' =>
'Description',
404 'bd.qty' =>
'LineQty',
405 'bd.qty_frozen' =>
'LineIsFrozen',
406 'bd.disable_stock_change' =>
'Disable Stock Change',
407 'bd.efficiency' =>
'Efficiency',
408 'bd.position' =>
'LinePosition'
412 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'bom_bomline' AND entity IN (0, ".$conf->entity.
")";
415 while ($obj = $this->
db->fetch_object(
$resql)) {
416 $fieldname =
'extra.'.$obj->name;
417 $fieldlabel = ucfirst($obj->label);
418 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
423 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'bom_bomline');
424 $this->import_regex_array[$r] = array();
425 $this->import_updatekeys_array[$r] = array(
'bd.fk_bom' =>
'BOM Id');
426 $this->import_convertvalue_array[$r] = array(
427 'bd.fk_bom' => array(
428 'rule' =>
'fetchidfromref',
429 'file' =>
'/bom/class/bom.class.php',
434 'bd.fk_product' => array(
435 'rule' =>
'fetchidfromref',
436 'file' =>
'/product/class/product.class.php',
437 'class' =>
'Product',
439 'element' =>
'Product'
452 public function init($options =
'')
454 global $conf, $langs;
467 $this->
remove($options);
472 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/boms/template_bom.odt';
473 $dirodt = DOL_DATA_ROOT.
'/doctemplates/boms';
474 $dest = $dirodt.
'/template_bom.odt';
476 if (file_exists($src) && !file_exists($dest)) {
477 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
479 $result =
dol_copy($src, $dest, 0, 0);
481 $langs->load(
"errors");
482 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
492 return $this->
_init($sql, $options);
503 public function remove($options =
'')
507 return $this->
_remove($sql, $options);
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
Description and activation class for module Bom.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.