--- /tmp/dsg/dolibarr/htdocs/core/modules/supplier_invoice/github_19.0.3_mod_facture_fournisseur_cactus.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/supplier_invoice/client_mod_facture_fournisseur_cactus.php @@ -36,10 +36,10 @@ - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var string Error code (or message) + */ + public $error = ''; @@ -66,2 +66,26 @@ - /** - * Return description of numbering model + /** + * Return description of numbering model + * + * @return string Text with description + */ + public function info() + { + global $langs; + $langs->load("bills"); + return $langs->trans("CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit); + } + + + /** + * Returns a numbering example + * + * @return string Example + */ + public function getExample() + { + return $this->prefixinvoice."1301-0001"; + } + + + /** + * Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. @@ -69,2 +93 @@ - * @param Translate $langs Lang object to use for output - * @return string Descriptive text + * @return boolean false if conflict, true if ok @@ -72,26 +95 @@ - public function info($langs) - { - global $langs; - $langs->load("bills"); - return $langs->trans("CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit); - } - - - /** - * Returns a numbering example - * - * @return string Example - */ - public function getExample() - { - return $this->prefixinvoice."1301-0001"; - } - - - /** - * Tests if the numbers already in the database do not cause conflicts that would prevent this numbering. - * - * @param Object $object Object we need next value for - * @return boolean false if KO (there is a conflict), true if OK - */ - public function canBeActivated($object) + public function canBeActivated() @@ -104,2 +102 @@ - $siyymm = ''; - $max = ''; + $siyymm = ''; $max = ''; @@ -113 +110,2 @@ - if ($resql) { + if ($resql) + { @@ -115,6 +113,4 @@ - if ($row) { - $siyymm = substr($row[0], 0, 6); - $max = $row[0]; - } - } - if ($siyymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $siyymm)) { + if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; } + } + if ($siyymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $siyymm)) + { @@ -136 +132,2 @@ - if ($resql) { + if ($resql) + { @@ -138,6 +135,4 @@ - if ($row) { - $siyymm = substr($row[0], 0, 6); - $max = $row[0]; - } - } - if ($siyymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $siyymm)) { + if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; } + } + if ($siyymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $siyymm)) + { @@ -158 +153,2 @@ - if ($resql) { + if ($resql) + { @@ -160,6 +156,4 @@ - if ($row) { - $siyymm = substr($row[0], 0, 6); - $max = $row[0]; - } - } - if ($siyymm && !preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i', $siyymm)) { + if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; } + } + if ($siyymm && !preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i', $siyymm)) + { @@ -169,95 +163,83 @@ - - return true; - } - - /** - * Return next value - * - * @param Societe $objsoc Object third party - * @param Object $object Object invoice - * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, <=0 if KO - */ - public function getNextValue($objsoc, $object, $mode = 'next') - { - global $db, $conf; - - $prefix = $this->prefixinvoice; - if ($object->type == 2) { - $prefix = $this->prefixcreditnote; - } elseif ($object->type == 3) { - $prefix = $this->prefixdeposit; - } - - // First, we get the max value - $posindice = strlen($prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; - $sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-%'"; - $sql .= " AND entity = ".$conf->entity; - - $resql = $db->query($sql); - dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj) { - $max = intval($obj->max); - } else { - $max = 0; - } - } else { - return -1; - } - - if ($mode == 'last') { - if ($max >= (pow(10, 4) - 1)) { - $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is - } else { - $num = sprintf("%04s", $max); - } - - $ref = ''; - $sql = "SELECT ref as ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; - $sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-".$num."'"; - $sql .= " AND entity = ".$conf->entity; - - dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj) { - $ref = $obj->ref; - } - } else { - dol_print_error($db); - } - - return $ref; - } elseif ($mode == 'next') { - $date = $object->date; // This is invoice date (not creation date) - $yymm = dol_print_date($date, "%y%m"); - - 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(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); - return $prefix.$yymm."-".$num; - } else { - dol_print_error('', 'Bad parameter for getNextValue'); - return -1; - } - } - - - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value - */ + } + + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Object $object Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string Value if OK, 0 if KO + */ + public function getNextValue($objsoc, $object, $mode = 'next') + { + global $db, $conf; + + $prefix = $this->prefixinvoice; + if ($object->type == 2) $prefix = $this->prefixcreditnote; + elseif ($object->type == 3) $prefix = $this->prefixdeposit; + + // First, we get the max value + $posindice = strlen($prefix) + 6; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql .= " WHERE ref LIKE '".$prefix."____-%'"; + $sql .= " AND entity = ".$conf->entity; + + $resql = $db->query($sql); + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max = 0; + } + else + { + return -1; + } + + if ($mode == 'last') + { + if ($max >= (pow(10, 4) - 1)) $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max); + + $ref = ''; + $sql = "SELECT ref as ref"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql .= " WHERE ref LIKE '".$prefix."____-".$num."'"; + $sql .= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $ref = $obj->ref; + } + else dol_print_error($db); + + return $ref; + } + elseif ($mode == 'next') + { + $date = $object->date; // This is invoice date (not creation 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(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); + return $prefix.$yymm."-".$num; + } + else dol_print_error('', 'Bad parameter for getNextValue'); + } + + + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value + */ --- /tmp/dsg/dolibarr/htdocs/core/modules/supplier_invoice/github_19.0.3_mod_facture_fournisseur_tulip.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/supplier_invoice/client_mod_facture_fournisseur_tulip.php @@ -2,6 +2,6 @@ -/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> - * Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com> - * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2016-2021 Alexandre Spangaro <aspangaro@open-dsi.fr> +/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> + * Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com> + * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2016 Alexandre Spangaro <aspangaro@open-dsi.fr> @@ -26 +26 @@ - * \ingroup Supplier invoice + * \ingroup commande @@ -40,3 +40,3 @@ - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ @@ -46,3 +46,3 @@ - * @var string Error code (or message) - */ - public $error = ''; + * @var string Error code (or message) + */ + public $error = ''; @@ -63,9 +63,8 @@ - /** - * Returns the description of the model numbering - * - * @param Translate $langs Lang object to use for output - * @return string Descriptive text - */ - public function info($langs) - { - global $langs, $db; + /** + * Returns the description of the model numbering + * + * @return string Description Text + */ + public function info() + { + global $conf, $langs; @@ -74 +73 @@ - $langs->loadLangs(array("bills", "admin")); + $langs->loadLangs(array("bills", "admin")); @@ -76 +75 @@ - $form = new Form($db); + $form = new Form($this->db); @@ -83,2 +82,2 @@ - $texte .= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">'; - $texte .= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">'; + $texte .= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">'; + $texte .= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">'; @@ -94 +93 @@ - // Setting the prefix + // Parametrage du prefix @@ -97 +96 @@ - $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskinvoice" value="'.getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK").'">', $tooltip, 1, 1).'</td>'; + $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; @@ -99 +98 @@ - $texte .= '<td class="left" rowspan="2"> <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>'; + $texte .= '<td class="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; @@ -103 +102 @@ - // Prefix setting of credit note + // Parametrage du prefix des avoirs @@ -105 +104 @@ - $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskcredit" value="'.getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>'; + $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; @@ -108,5 +107,12 @@ - if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { - // Parametrage du prefix des replacement - $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; - $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskreplacement" value="'.getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>'; - $texte .= '</tr>'; + if ($conf->global->MAIN_FEATURE_LEVEL >= 2) + { + // Parametrage du prefix des replacement + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; + $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; + $texte .= '</tr>'; + + + // Parametrage du prefix des acomptes + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; + $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; + $texte .= '</tr>'; @@ -114,5 +119,0 @@ - - // Prefix setting of deposit - $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; - $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskdeposit" value="'.getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK").'">', $tooltip, 1, 1).'</td>'; - $texte .= '</tr>'; @@ -124 +125 @@ - } + } @@ -126,8 +127,8 @@ - /** - * Returns a numbering example - * - * @return string Example - */ - public function getExample() - { - global $conf, $langs, $mysoc; + /** + * Returns a numbering example + * + * @return string Example + */ + public function getExample() + { + global $conf, $langs, $mysoc; @@ -135,3 +136,3 @@ - $old_code_client = $mysoc->code_client; - $mysoc->code_client = 'CCCCCCCCCC'; - $numExample = $this->getNextValue($mysoc, ''); + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; + $numExample = $this->getNextValue($mysoc, ''); @@ -140 +141,2 @@ - if (!$numExample) { + if (!$numExample) + { @@ -144 +146 @@ - } + } @@ -151,2 +153,2 @@ - * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, 0 if KO + * @param string $mode 'next' for next value or 'last' for last value + * @return string Value if OK, 0 if KO @@ -154,2 +156,2 @@ - public function getNextValue($objsoc, $object, $mode = 'next') - { + public function getNextValue($objsoc, $object, $mode = 'next') + { @@ -162,4 +164,6 @@ - if (is_object($object) && $object->type == 1) { - $mask = getDolGlobalString("SUPPLIER_REPLACEMENT_TULIP_MASK"); - if (!$mask) { - $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK"); + if (is_object($object) && $object->type == 1) + { + $mask = $conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; + if (!$mask) + { + $mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK; @@ -167,6 +170,0 @@ - } elseif (is_object($object) && $object->type == 2) { - $mask = getDolGlobalString("SUPPLIER_CREDIT_TULIP_MASK"); - } elseif (is_object($object) && $object->type == 3) { - $mask = getDolGlobalString("SUPPLIER_DEPOSIT_TULIP_MASK"); - } else { - $mask = getDolGlobalString("SUPPLIER_INVOICE_TULIP_MASK"); @@ -174 +172,5 @@ - if (!$mask) { + elseif (is_object($object) && $object->type == 2) $mask = $conf->global->SUPPLIER_CREDIT_TULIP_MASK; + elseif (is_object($object) && $object->type == 3) $mask = $conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; + else $mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK; + if (!$mask) + { @@ -183 +185 @@ - } + } @@ -185,12 +187,12 @@ - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value - */ - public function getNumRef($objsoc, $objforref, $mode = 'next') - { - return $this->getNextValue($objsoc, $objforref, $mode); - } + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value + */ + public function getNumRef($objsoc, $objforref, $mode = 'next') + { + return $this->getNextValue($objsoc, $objforref, $mode); + } --- /tmp/dsg/dolibarr/htdocs/core/modules/supplier_invoice/github_19.0.3_modules_facturefournisseur.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/supplier_invoice/client_modules_facturefournisseur.php @@ -29 +28,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; @@ -38 +37,7 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * @var string Error code (or message) + */ + public $error = ''; + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -42,3 +47,3 @@ - * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of numbers + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of numbers @@ -48 +53,3 @@ - // phpcs:enable + // phpcs:enable + global $conf; + @@ -62 +69 @@ -abstract class ModeleNumRefSuppliersInvoices extends CommonNumRefGenerator +abstract class ModeleNumRefSuppliersInvoices @@ -64 +71,73 @@ - // No overload code + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** Return if a model can be used or not + * + * @return boolean true if model can be used + */ + public function isEnabled() + { + return true; + } + + /** Returns the default description of the model numbering + * + * @return string Description Text + */ + public function info() + { + global $langs; + $langs->load("invoices"); + return $langs->trans("NoDescription"); + } + + /** Returns a numbering example + * + * @return string Example + */ + public function getExample() + { + global $langs; + $langs->load("invoices"); + return $langs->trans("NoExample"); + } + + /** Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + return true; + } + + /** Returns next value assigned + * + * @param Societe $objsoc Object third party + * @param Object $object Object + * @param string $mode 'next' for next value or 'last' for last value + * @return string Value if OK, 0 if KO + */ + public function getNextValue($objsoc, $object, $mode) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** Returns version of the model numbering + * + * @return string Value + */ + 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"); + }