Work of BOM module

This commit is contained in:
Laurent Destailleur 2019-03-04 12:46:07 +01:00
parent dd9a4a8cbc
commit 1c775b7b68
9 changed files with 40 additions and 38 deletions

View File

@ -44,7 +44,7 @@ require_once '../lib/bom.lib.php';
//require_once "../class/myclass.class.php";
// Translations
$langs->loadLangs(array("admin", "bom@bom"));
$langs->loadLangs(array("admin", "mrp"));
// Access control
if (! $user->admin) accessforbidden();
@ -78,11 +78,11 @@ llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom@bom');
print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom');
// Configuration header
$head = bomAdminPrepareHead();
dol_fiche_head($head, 'settings', '', -1, "bom@bom");
dol_fiche_head($head, 'settings', '', -1, "bom");
// Setup page goes here
echo $langs->trans("BomSetupPage").'<br><br>';

View File

@ -63,7 +63,7 @@ dol_include_once('/bom/class/bom.class.php');
dol_include_once('/bom/lib/bom_bom.lib.php');
// Load translation files required by the page
$langs->loadLangs(array("bom@bom","other"));
$langs->loadLangs(array("mrp","other"));
// Get parameters
$id = GETPOST('id', 'int');
@ -154,7 +154,7 @@ if (empty($reshook))
$form=new Form($db);
$formfile=new FormFile($db);
llxHeader('', 'BillOfMaterials', '');
llxHeader('', 'NewBOM', '');
// Example : Adding jquery code
print '<script type="text/javascript" language="javascript">
@ -175,7 +175,7 @@ jQuery(document).ready(function() {
// Part to create
if ($action == 'create')
{
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("BillOfMaterials")));
print load_fiche_titre($langs->trans("NewBOM"));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -243,7 +243,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$res = $object->fetch_optionals();
$head = bomPrepareHead($object);
dol_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom@bom');
dol_fiche_head($head, 'card', $langs->trans("NewBOM"), -1, 'bom');
$formconfirm = '';

View File

@ -45,7 +45,7 @@ dol_include_once('/bom/class/bom.class.php');
dol_include_once('/bom/lib/bom_bom.lib.php');
// Load translation files required by the page
$langs->loadLangs(array("bom@bom","companies","other","mails"));
$langs->loadLangs(array("mrp","companies","other","mails"));
$action=GETPOST('action', 'aZ09');
@ -110,7 +110,7 @@ if ($object->id)
*/
$head = bomPrepareHead($object);
dol_fiche_head($head, 'document', $langs->trans("BillOfMaterials"), -1, 'bom@bom');
dol_fiche_head($head, 'document', $langs->trans("BillOfMaterials"), -1, 'bom');
// Build file list

View File

@ -62,7 +62,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
dol_include_once('/bom/class/bom.class.php');
// Load translation files required by the page
$langs->loadLangs(array("bom@bom", "other"));
$langs->loadLangs(array("mrp", "other"));
$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
@ -199,7 +199,7 @@ $now=dol_now();
//$help_url="EN:Module_BillOfMaterials|FR:Module_BillOfMaterials_FR|ES:Módulo_BillOfMaterials";
$help_url='';
$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("BillOfMaterialss"));
$title = $langs->trans('ListOfBOMs');
// Build and execute select

View File

@ -41,7 +41,7 @@ dol_include_once('/bom/class/bom.class.php');
dol_include_once('/bom/lib/bom_bom.lib.php');
// Load translation files required by the page
$langs->loadLangs(array("bom@bom","companies"));
$langs->loadLangs(array("mrp","companies"));
// Get parameters
$id = GETPOST('id', 'int');
@ -95,7 +95,7 @@ if ($id > 0 || ! empty($ref))
$head = bomPrepareHead($object);
dol_fiche_head($head, 'note', $langs->trans("BillOfMaterials"), -1, 'bom@bom');
dol_fiche_head($head, 'note', $langs->trans("BillOfMaterials"), -1, 'bom');
// Object card
// ------------------------------------------------------------

View File

@ -55,7 +55,7 @@ class BillOfMaterials extends CommonObject
/**
* @var string String with name of icon for bom. Must be the part after the 'object_' into object_bom.png
*/
public $picto = 'bom@bom';
public $picto = 'bom';
/**
@ -83,8 +83,8 @@ class BillOfMaterials extends CommonObject
*/
public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text", 'showoncombobox'=>'1',),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>61, 'notnull'=>-1,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>62, 'notnull'=>-1,),
@ -93,9 +93,9 @@ class BillOfMaterials extends CommonObject
'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',),
'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Actif', '-1'=>'Inactif')),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1,),
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'isameasure'=>'1',),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'ProductBOMHelp'),
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>-1, 'isameasure'=>'1',),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Enabled', '-1'=>'Disabled')),
);
public $rowid;
public $ref;
@ -487,7 +487,7 @@ class BillOfMaterials extends CommonObject
if (empty($this->labelstatus))
{
global $langs;
//$langs->load("bom");
//$langs->load("mrp");
$this->labelstatus[1] = $langs->trans('Enabled');
$this->labelstatus[0] = $langs->trans('Disabled');
}
@ -1070,7 +1070,7 @@ class BillOfMaterialsLine extends CommonObject
if (empty($this->labelstatus))
{
global $langs;
//$langs->load("bom");
//$langs->load("mrp");
$this->labelstatus[1] = $langs->trans('Enabled');
$this->labelstatus[0] = $langs->trans('Disabled');
}

View File

@ -30,7 +30,7 @@ function bomAdminPrepareHead()
{
global $langs, $conf;
$langs->load("bom@bom");
$langs->load("mrp");
$h = 0;
$head = array();
@ -72,7 +72,7 @@ function bomPrepareHead($object)
{
global $db, $langs, $conf;
$langs->load("bom@bom");
$langs->load("mrp");
$h = 0;
$head = array();
@ -118,7 +118,7 @@ function bomPrepareHead($object)
//$this->tabs = array(
// 'entity:-tabname:Title:@bom:/bom/mypage.php?id=__ID__'
//); // to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom@bom');
complete_head_from_modules($conf, $langs, $object, $head, $h, 'bom');
return $head;
}

View File

@ -1471,8 +1471,10 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// BOM
if (! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled))
{
$langs->load("mrp");
$newmenu->add("", $langs->trans("BOM"), 0, $user->rights->service->lire, '', $mainmenu, 'service');
$newmenu->add("/bom/bom_card.php?leftmenu=bom&amp;action=create", $langs->trans("NewBom"), 1, $user->rights->bom->write);
$newmenu->add("/bom/bom_card.php?leftmenu=bom&amp;action=create", $langs->trans("NewBOM"), 1, $user->rights->bom->write);
$newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read);
}
}

View File

@ -107,7 +107,7 @@ class modBom extends DolibarrModules
$this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
$this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
$this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
$this->langfiles = array("bom@bom");
$this->langfiles = array("mrp");
//$this->phpmin = array(5,4); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(9,0); // Minimum version of Dolibarr required by module
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
@ -241,7 +241,7 @@ class modBom extends DolibarrModules
'mainmenu'=>'bom',
'leftmenu'=>'',
'url'=>'/bom/bom_list.php',
'langs'=>'bom@bom', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r,
'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->enabled' if entry must be visible if module is enabled.
'perms'=>'1', // Use 'perms'=>'$user->rights->bom->level1->level2' if you want your menu with a permission rules
@ -257,7 +257,7 @@ class modBom extends DolibarrModules
'mainmenu'=>'bom',
'leftmenu'=>'bom_bom_list',
'url'=>'/bom/bom_list.php',
'langs'=>'bom@bom', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r,
'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->bom->level1->level2' if you want your menu with a permission rules
@ -269,7 +269,7 @@ class modBom extends DolibarrModules
'mainmenu'=>'bom',
'leftmenu'=>'bom_bom_new',
'url'=>'/bom/bom_page.php?action=create',
'langs'=>'bom@bom', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r,
'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->bom->level1->level2' if you want your menu with a permission rules
@ -284,7 +284,7 @@ class modBom extends DolibarrModules
'mainmenu'=>'bom',
'leftmenu'=>'bom_bom',
'url'=>'/bom/bom_list.php',
'langs'=>'bom@bom', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1100+$r,
'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->bom->level1->level2' if you want your menu with a permission rules
@ -297,7 +297,7 @@ class modBom extends DolibarrModules
'mainmenu'=>'bom',
'leftmenu'=>'bom_bom',
'url'=>'/bom/bom_card.php?action=create',
'langs'=>'bom@bom', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'mrp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1100+$r,
'enabled'=>'$conf->bom->enabled', // Define condition to show or hide menu entry. Use '$conf->bom->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->bom->level1->level2' if you want your menu with a permission rules
@ -312,10 +312,10 @@ class modBom extends DolibarrModules
/* BEGIN MODULEBUILDER EXPORT BILLOFMATERIALS */
/*
$langs->load("bom@bom");
$langs->load("mrp@mrp");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='BomLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='bom@bom';
$this->export_icon[$r]='bom';
$keyforclass = 'Bom'; $keyforclassfile='/mymobule/class/bom.class.php'; $keyforelement='bom';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='bom'; $keyforaliasextra='extra'; $keyforelement='bom';
@ -346,11 +346,11 @@ class modBom extends DolibarrModules
include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'bom@bom', '$conf->bom->enabled');
//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'bom@bom', '$conf->bom->enabled');
//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'bom@bom', '$conf->bom->enabled');
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'bom@bom', '$conf->bom->enabled');
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'bom@bom', '$conf->bom->enabled');
//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
$sql = array();