';
+*/
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php
index 1f3e23e05d6..455175220a8 100644
--- a/htdocs/admin/commande.php
+++ b/htdocs/admin/commande.php
@@ -300,7 +300,7 @@ foreach ($dirmodels as $reldir)
if ($module->isEnabled())
{
- print '
'.$module->nom."
\n";
+ print '
'.$module->name."
\n";
print $module->info();
print '
';
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index f327be2db1c..0c1e887dd17 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -1,6 +1,5 @@
- * Copyright (C) ---Put here your own copyright and developer email---
+/* Copyright (C) 2019 Laurent Destailleur
*
* 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
@@ -19,7 +18,7 @@
/**
* \file class/bom.class.php
* \ingroup bom
- * \brief This file is a CRUD class file for BillOfMaterials (Create/Read/Update/Delete)
+ * \brief This file is a CRUD class file for BOM (Create/Read/Update/Delete)
*/
// Put here all includes required by your class file
@@ -28,9 +27,9 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
/**
- * Class for BillOfMaterials
+ * Class for BOM
*/
-class BillOfMaterials extends CommonObject
+class BOM extends CommonObject
{
/**
* @var string ID to identify managed object
diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php
index ac7af246f78..0085d06b69c 100644
--- a/htdocs/bom/lib/bom.lib.php
+++ b/htdocs/bom/lib/bom.lib.php
@@ -35,7 +35,7 @@ function bomAdminPrepareHead()
$h = 0;
$head = array();
- $head[$h][0] = dol_buildpath("/bom/admin/setup.php", 1);
+ $head[$h][0] = DOL_URL_ROOT."/admin/bom.php";
$head[$h][1] = $langs->trans("Settings");
$head[$h][2] = 'settings';
$h++;
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index 2e9af363d08..8544cdb2416 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -977,7 +977,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
*
* @return int Error count (0 if OK)
*/
- private function _active()
+ protected function _active()
{
global $conf, $user;
@@ -1018,7 +1018,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
*
* @return int Error count (0 if OK)
*/
- private function _unactive()
+ protected function _unactive()
{
global $conf;
@@ -1048,7 +1048,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
* @param string $reldir Relative directory where to scan files
* @return int <=0 if KO, >0 if OK
*/
- private function _load_tables($reldir)
+ protected function _load_tables($reldir)
{
// phpcs:enable
global $conf;
diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php
new file mode 100644
index 00000000000..50cafb276ca
--- /dev/null
+++ b/htdocs/core/modules/bom/mod_bom_advanced.php
@@ -0,0 +1,160 @@
+
+ * Copyright (C) 2004-2007 Laurent Destailleur
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2008 Raphael Bertrand (Resultic)
+ *
+ * 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 .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/bom/mod_bom_advanced.php
+ * \ingroup bom
+ * \brief Fichier contenant la classe du modele de numerotation de reference de bom advanced
+ */
+
+require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php';
+
+
+/**
+ * Class to manage customer Bom numbering rules advanced
+ */
+class mod_bom_advanced extends ModeleNumRefboms
+{
+ /**
+ * Dolibarr version of the loaded document
+ * @public string
+ */
+ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
+
+ /**
+ * @var string Error message
+ */
+ public $error = '';
+
+ /**
+ * @var string name
+ */
+ public $name='advanced';
+
+
+ /**
+ * Renvoi la description du modele de numerotation
+ *
+ * @return string Texte descripif
+ */
+ public function info()
+ {
+ global $conf, $langs;
+
+ $langs->load("bills");
+
+ $form = new Form($this->db);
+
+ $texte = $langs->trans('GenericNumRefModelDesc')." \n";
+ $texte.= '';
+
+ return $texte;
+ }
+
+ /**
+ * Renvoi un exemple de numerotation
+ *
+ * @return string Example
+ */
+ public function getExample()
+ {
+ global $conf,$langs,$mysoc;
+
+ $old_code_client=$mysoc->code_client;
+ $old_code_type=$mysoc->typent_code;
+ $mysoc->code_client='CCCCCCCCCC';
+ $mysoc->typent_code='TTTTTTTTTT';
+ $numExample = $this->getNextValue($mysoc, '');
+ $mysoc->code_client=$old_code_client;
+ $mysoc->typent_code=$old_code_type;
+
+ if (! $numExample)
+ {
+ $numExample = $langs->trans('NotConfigured');
+ }
+ return $numExample;
+ }
+
+ /**
+ * Return next free value
+ *
+ * @param Societe $objsoc Object thirdparty
+ * @param Object $object Object we need next value for
+ * @return string Value if KO, <0 if KO
+ */
+ public function getNextValue($objsoc, $object)
+ {
+ global $db,$conf;
+
+ require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
+
+ // We get cursor rule
+ $mask=$conf->global->BOM_ADVANCED_MASK;
+
+ if (! $mask)
+ {
+ $this->error='NotConfigured';
+ return 0;
+ }
+
+ $date = ($object->date_bom ? $object->date_bom : $object->date);
+
+ $numFinal=get_next_value($db, $mask, 'bom', 'ref', '', $objsoc, $date);
+
+ return $numFinal;
+ }
+
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Return next free value
+ *
+ * @param Societe $objsoc Object third party
+ * @param string $objforref Object for number to search
+ * @return string Next free value
+ */
+ public function bom_get_num($objsoc, $objforref)
+ {
+ // phpcs:enable
+ return $this->getNextValue($objsoc, $objforref);
+ }
+}
diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php
new file mode 100644
index 00000000000..4bfa3173fd4
--- /dev/null
+++ b/htdocs/core/modules/bom/mod_bom_standard.php
@@ -0,0 +1,164 @@
+
+ * Copyright (C) 2005-2009 Regis Houssin
+ *
+ * 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 .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/bom/mod_bom_standard.php
+ * \ingroup bom
+ * \brief File of class to manage customer order numbering rules standard
+ */
+require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php';
+
+/**
+ * Class to manage customer order numbering rules standard
+ */
+class mod_bom_standard extends ModeleNumRefboms
+{
+ /**
+ * Dolibarr version of the loaded document
+ * @public string
+ */
+ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
+
+ public $prefix='BOM';
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string name
+ */
+ public $name='standard';
+
+
+ /**
+ * Return description of numbering module
+ *
+ * @return string Text with description
+ */
+ public function info()
+ {
+ global $langs;
+ return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
+ }
+
+
+ /**
+ * Renvoi un exemple de numerotation
+ *
+ * @return string Example
+ */
+ public function getExample()
+ {
+ return $this->prefix."0501-0001";
+ }
+
+
+ /**
+ * Test si les numeros deje en vigueur dans la base ne provoquent pas de
+ * de conflits qui empechera cette numerotation de fonctionner.
+ *
+ * @return boolean false si conflit, true si ok
+ */
+ public function canBeActivated()
+ {
+ global $conf,$langs,$db;
+
+ $coyymm=''; $max='';
+
+ $posindice=8;
+ $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
+ $sql.= " FROM ".MAIN_DB_PREFIX."bom";
+ $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
+ $sql.= " AND entity = ".$conf->entity;
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $row = $db->fetch_row($resql);
+ if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
+ }
+ if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
+ {
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorNumRefModel', $max);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return next free value
+ *
+ * @param Societe $objsoc Object thirdparty
+ * @param Object $object Object we need next value for
+ * @return string Value if KO, <0 if KO
+ */
+ public function getNextValue($objsoc, $object)
+ {
+ global $db,$conf;
+
+ // D'abord on recupere la valeur max
+ $posindice=8;
+ $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
+ $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom";
+ $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
+ $sql.= " AND entity = ".$conf->entity;
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj) $max = intval($obj->max);
+ else $max=0;
+ }
+ else
+ {
+ dol_syslog("mod_bom_standard::getNextValue", LOG_DEBUG);
+ return -1;
+ }
+
+ //$date=time();
+ $date=$object->date;
+ $yymm = strftime("%y%m", $date);
+
+ if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
+ else $num = sprintf("%04s", $max+1);
+
+ dol_syslog("mod_bom_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
+ return $this->prefix.$yymm."-".$num;
+ }
+
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Return next free value
+ *
+ * @param Societe $objsoc Object third party
+ * @param string $objforref Object for number to search
+ * @return string Next free value
+ */
+ public function bom_get_num($objsoc, $objforref)
+ {
+ // phpcs:enable
+ return $this->getNextValue($objsoc, $objforref);
+ }
+}
diff --git a/htdocs/core/modules/bom/modules_bom.php b/htdocs/core/modules/bom/modules_bom.php
new file mode 100644
index 00000000000..fc4d2167980
--- /dev/null
+++ b/htdocs/core/modules/bom/modules_bom.php
@@ -0,0 +1,150 @@
+
+ * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2006 Andre Cianfarani
+ * Copyright (C) 2012 Juanjo Menent
+ * Copyright (C) 2014 Marcos GarcĂa
+ *
+ * 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 .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/bom/modules_bom.php
+ * \ingroup bom
+ * \brief File that contains parent class for boms models
+ * and parent class for boms numbering models
+ */
+
+require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
+
+
+/**
+ * Parent class for boms models
+ */
+abstract class ModelePDFBoms extends CommonDocGenerator
+{
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Return list of active generation modules
+ *
+ * @param DoliDB $db Database handler
+ * @param integer $maxfilenamelength Max length of value to show
+ * @return array List of templates
+ */
+ public static function liste_modeles($db, $maxfilenamelength = 0)
+ {
+ // phpcs:enable
+ global $conf;
+
+ $type = 'order';
+ $list = array();
+
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ $list = getListOfModels($db, $type, $maxfilenamelength);
+
+ return $list;
+ }
+}
+
+
+
+/**
+ * Parent class to manage numbering of BOMs
+ */
+abstract class ModeleNumRefBoms
+{
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * Return if a module can be used or not
+ *
+ * @return boolean true if module can be used
+ */
+ public function isEnabled()
+ {
+ return true;
+ }
+
+ /**
+ * Renvoie la description par defaut du modele de numerotation
+ *
+ * @return string Texte descripif
+ */
+ public function info()
+ {
+ global $langs;
+ $langs->load("mrp");
+ return $langs->trans("NoDescription");
+ }
+
+ /**
+ * Renvoie un exemple de numerotation
+ *
+ * @return string Example
+ */
+ public function getExample()
+ {
+ global $langs;
+ $langs->load("mrp");
+ return $langs->trans("NoExample");
+ }
+
+ /**
+ * Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner.
+ *
+ * @return boolean false si conflit, true si ok
+ */
+ public function canBeActivated()
+ {
+ return true;
+ }
+
+ /**
+ * Renvoie prochaine valeur attribuee
+ *
+ * @param Societe $objsoc Object thirdparty
+ * @param Object $object Object we need next value for
+ * @return string Valeur
+ */
+ public function getNextValue($objsoc, $object)
+ {
+ global $langs;
+ return $langs->trans("NotAvailable");
+ }
+
+ /**
+ * Renvoie version du module numerotation
+ *
+ * @return string Valeur
+ */
+ public function getVersion()
+ {
+ global $langs;
+ $langs->load("admin");
+
+ if ($this->version == 'development') return $langs->trans("VersionDevelopment");
+ if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
+ if ($this->version == 'dolibarr') return DOL_VERSION;
+ if ($this->version) return $this->version;
+ return $langs->trans("NotAvailable");
+ }
+}
diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php
index b0b462e96dc..620ab210f31 100644
--- a/htdocs/core/modules/commande/mod_commande_marbre.php
+++ b/htdocs/core/modules/commande/mod_commande_marbre.php
@@ -42,13 +42,6 @@ class mod_commande_marbre extends ModeleNumRefCommandes
*/
public $error='';
- /**
- * @var string
- * @deprecated
- * @see name
- */
- public $nom='Marbre';
-
/**
* @var string name
*/
diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php
index 373f1e01200..40ca0e2e222 100644
--- a/htdocs/core/modules/commande/mod_commande_saphir.php
+++ b/htdocs/core/modules/commande/mod_commande_saphir.php
@@ -44,13 +44,6 @@ class mod_commande_saphir extends ModeleNumRefCommandes
*/
public $error = '';
- /**
- * @var string nom
- * @deprecated
- * @see name
- */
- public $nom='Saphir';
-
/**
* @var string name
*/
diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php
index e0a0e454861..47fb20a56b4 100644
--- a/htdocs/core/modules/commande/modules_commande.php
+++ b/htdocs/core/modules/commande/modules_commande.php
@@ -66,10 +66,8 @@ abstract class ModelePDFCommandes extends CommonDocGenerator
/**
- * \class ModeleNumRefCommandes
- * \brief Classe mere des modeles de numerotation des references de commandes
+ * Parent class to manage numbering of Sale Orders
*/
-
abstract class ModeleNumRefCommandes
{
/**
diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php
index 6578320ed92..6cfac4e2050 100644
--- a/htdocs/core/modules/modBom.class.php
+++ b/htdocs/core/modules/modBom.class.php
@@ -46,7 +46,7 @@ class modBom extends DolibarrModules
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
- $this->numero = 650; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
+ $this->numero = 650;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'bom';
@@ -100,7 +100,7 @@ class modBom extends DolibarrModules
$this->dirs = array("/bom/temp");
// Config pages. Put here list of php page, stored into bom/admin directory, to use to setup module.
- $this->config_page_url = array("setup.php@bom");
+ $this->config_page_url = array("bom.php");
// Dependencies
$this->hidden = false; // A condition to hide module
@@ -121,7 +121,9 @@ class modBom extends DolibarrModules
// 1=>array('BILLOFMATERIALS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
// );
$this->const = array(
- //1=>array('BILLOFMATERIALS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
+ 1=>array('BOM_ADDON_PDF', 'chaine', 'avalue', 'Name of PDF model of BOM', 0),
+ 2=>array('BOM_ADDON', 'chaine', 'mod_bom_standard', 'Name of numbering rules of BOM', 0),
+ 3=>array('BOM_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/boms', '', 0)
);
// Some keys to add into the overwriting translation tables
diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang
index 88682c56cd3..68e84aee8e3 100644
--- a/htdocs/langs/en_US/mrp.lang
+++ b/htdocs/langs/en_US/mrp.lang
@@ -1,3 +1,8 @@
+BOMsSetup=Setup of module BOM
ListOfBOMs=List of BOMs
NewBOM=New BOM
ProductBOMHelp=Product to create with this BOM
+BOMsNumberingModules=BOMs numbering templates
+BOMsModelModule=BOMS document templates
+FreeLegalTextOnBOMs=Free text on document of BOMs
+WatermarkOnDraftBOMs=Watermark on draft BOMs