';
+print ' ';
+
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php
index acbb2ae0b36..38358222282 100644
--- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php
+++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php
@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
/**
* Class to build documents using ODF templates generator
*/
-class doc_generic_bom_odt extends ModelePDFBOMs
+class doc_generic_bom_odt extends ModelePDFBoms
{
/**
* Issuer
diff --git a/htdocs/core/modules/bom/modules_bom.php b/htdocs/core/modules/bom/modules_bom.php
index 45bca8a38b3..f8f29fec2e6 100644
--- a/htdocs/core/modules/bom/modules_bom.php
+++ b/htdocs/core/modules/bom/modules_bom.php
@@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
/**
* Parent class for boms models
*/
-abstract class ModelePDFBom extends CommonDocGenerator
+abstract class ModelePDFBoms extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php
index 1700f15afd7..47daf430873 100644
--- a/htdocs/core/modules/modBom.class.php
+++ b/htdocs/core/modules/modBom.class.php
@@ -189,7 +189,7 @@ class modBom extends DolibarrModules
// Boxes/Widgets
// Add here list of php file(s) stored in bom/core/boxes that contains class to show a widget.
$this->boxes = array(
- 0=>array('file'=>'box_boms.php','note'=>'','enabledbydefaulton'=>'Home')
+ 0=>array('file' => 'box_boms.php', 'note' => '', 'enabledbydefaulton' => 'Home')
);
@@ -203,7 +203,7 @@ class modBom extends DolibarrModules
// );
- // Permissions
+ // Permissions provided by this module
$this->rights = array(); // Permission array used by this module
$r=0;
@@ -228,7 +228,7 @@ class modBom extends DolibarrModules
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->bom->level1->level2)
- // Main menu entries
+ // Main menu entries to add
$this->menu = array(); // List of menus to add
$r=0;
@@ -323,9 +323,8 @@ class modBom extends DolibarrModules
if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default')
// Create extrafields
- include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- $extrafields = new ExtraFields($this->db);
-
+ //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, '', '', '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');
@@ -357,8 +356,8 @@ class modBom extends DolibarrModules
}
$sql = array(
- "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('alpha')."' AND type = 'bom' AND entity = ".$conf->entity,
- "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('alpha')."', 'bom', ".$conf->entity.")"
+ "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'bom' AND entity = ".$conf->entity,
+ "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'bom', ".$conf->entity.")"
);
return $this->_init($sql, $options);
diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php
index 53f778d063f..248179b5447 100644
--- a/htdocs/core/modules/modMrp.class.php
+++ b/htdocs/core/modules/modMrp.class.php
@@ -58,7 +58,7 @@ class modMrp extends DolibarrModules
// Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module).
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module).
- $this->description = "MRPDescription";
+ $this->description = "Module to Manage Manufacturing Orders (MO)";
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "Module to Manage Manufacturing Orders (MO)";
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
@@ -113,7 +113,7 @@ class modMrp extends DolibarrModules
// Example: this->dirs = array("/mrp/temp","/mrp/subdir");
$this->dirs = array("/mrp/temp");
// Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module.
- $this->config_page_url = array("setup.php@mrp");
+ $this->config_page_url = array("mrp.php");
// Dependencies
// A condition to hide module
$this->hidden = false;
@@ -135,7 +135,9 @@ class modMrp extends DolibarrModules
// 2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
// );
$this->const = array(
- // 1 => array('MRP_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
+ 1=>array('MRP_MO_ADDON_PDF', 'chaine', 'alpha', 'Name of PDF model of BOM', 0),
+ 2=>array('MRP_MO_ADDON', 'chaine', 'mod_bom_standard', 'Name of numbering rules of BOM', 0),
+ 3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/boms', '', 0)
);
// Some keys to add into the overwriting translation tables
@@ -312,6 +314,8 @@ class modMrp extends DolibarrModules
*/
public function init($options = '')
{
+ global $conf, $langs;
+
$result=$this->_load_tables('/mrp/sql/');
if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
@@ -324,7 +328,34 @@ class modMrp extends DolibarrModules
//$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->mrp->enabled');
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');
+ // Permissions
+ $this->remove($options);
+
$sql = array();
+
+ // ODT template
+ $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt';
+ $dirodt=DOL_DATA_ROOT.'/doctemplates/mrps';
+ $dest=$dirodt.'/template_mo.odt';
+
+ if (file_exists($src) && ! file_exists($dest))
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ dol_mkdir($dirodt);
+ $result=dol_copy($src, $dest, 0, 0);
+ if ($result < 0)
+ {
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+ return 0;
+ }
+ }
+
+ $sql = array(
+ "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'mo' AND entity = ".$conf->entity,
+ "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'mo', ".$conf->entity.")"
+ );
+
return $this->_init($sql, $options);
}
diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php
index 9beb300ebb0..0447694465f 100644
--- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php
+++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php
@@ -27,7 +27,7 @@
* \brief File of class to build ODT documents for MOs
*/
-require_once DOL_DOCUMENT_ROOT.'/core/modules/bom/modules_bom.php';
+require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mrp.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
/**
* Class to build documents using ODF templates generator
*/
-class doc_generic_mo_odt extends ModelePDFMOs
+class doc_generic_mo_odt extends ModelePDFMos
{
/**
* Issuer
diff --git a/htdocs/install/doctemplates/boms/template_bom.odt b/htdocs/install/doctemplates/boms/template_bom.odt
index 344fcfa391a..9eea32e4197 100644
Binary files a/htdocs/install/doctemplates/boms/template_bom.odt and b/htdocs/install/doctemplates/boms/template_bom.odt differ
diff --git a/htdocs/install/doctemplates/mrps/template_mo.odt b/htdocs/install/doctemplates/mrps/template_mo.odt
new file mode 100644
index 00000000000..7545fe73a34
Binary files /dev/null and b/htdocs/install/doctemplates/mrps/template_mo.odt differ
diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang
index 6bf86dac102..4fc51f5a114 100644
--- a/htdocs/langs/en_US/mrp.lang
+++ b/htdocs/langs/en_US/mrp.lang
@@ -2,7 +2,7 @@ Mrp=Manufacturing Orders
MO=Manufacturing Order
MRPDescription=Module to manage Manufacturing Orders (MO).
MRPArea=MRP Area
-MrpSetupPage=Setup of module MO
+MrpSetupPage=Setup of module MRP
MenuBOM=Bills of material
LatestBOMModified=Latest %s Bills of materials modified
LatestMOModified=Latest %s Manufacturing Orders modified
@@ -14,9 +14,13 @@ ListOfManufacturingOrders=List of Manufacturing Orders
NewBOM=New bill of material
ProductBOMHelp=Product to create with this BOM
BOMsNumberingModules=BOM numbering templates
-BOMsModelModule=BOMS document templates
+BOMsModelModule=BOM document templates
+MOsNumberingModules=MO numbering templates
+MOsModelModule=MO document templates
FreeLegalTextOnBOMs=Free text on document of BOM
WatermarkOnDraftBOMs=Watermark on draft BOM
+FreeLegalTextOnMOs=Free text on document of MO
+WatermarkOnDraftMOs=Watermark on draft MO
ConfirmCloneBillOfMaterials=Are you sure you want to clone this bill of material ?
ManufacturingEfficiency=Manufacturing efficiency
ValueOfMeansLoss=Value of 0.95 means an average of 5%% of loss during the production
diff --git a/htdocs/mrp/admin/setup.php b/htdocs/mrp/admin/setup.php
deleted file mode 100644
index 8d7df29b383..00000000000
--- a/htdocs/mrp/admin/setup.php
+++ /dev/null
@@ -1,151 +0,0 @@
-
- * Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file mrp/admin/setup.php
- * \ingroup mrp
- * \brief Mrp setup page.
- */
-
-// Load Dolibarr environment
-$res=0;
-// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
-if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
-// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
-$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
-while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
-if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
-if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
-// Try main.inc.php using relative path
-if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
-if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
-if (! $res) die("Include of main fails");
-
-global $langs, $user;
-
-// Libraries
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
-require_once '../lib/mrp.lib.php';
-//require_once "../class/myclass.class.php";
-
-// Translations
-$langs->loadLangs(array("admin", "mrp"));
-
-// Access control
-if (! $user->admin) accessforbidden();
-
-// Parameters
-$action = GETPOST('action', 'alpha');
-$backtopage = GETPOST('backtopage', 'alpha');
-
-$arrayofparameters=array(
- 'MRP_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1),
- 'MRP_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1)
-);
-
-
-
-/*
- * Actions
- */
-
-if ((float) DOL_VERSION >= 6)
-{
- include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
-}
-
-
-
-/*
- * View
- */
-
-$page_name = "MrpSetup";
-llxHeader('', $langs->trans($page_name));
-
-// Subheader
-$linkback = ''.$langs->trans("BackToModuleList").'';
-
-print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mrp');
-
-// Configuration header
-$head = mrpAdminPrepareHead();
-dol_fiche_head($head, 'settings', '', -1, "mrp");
-
-// Setup page goes here
-echo ''.$langs->trans("MrpSetupPage").'