24 require_once DOL_DOCUMENT_ROOT.
'/core/modules/contract/modules_contract.php';
35 public $version =
'dolibarr';
37 public $prefix =
'CT';
49 public $nom =
'Serpis';
54 public $name =
'Serpis';
59 public $code_auto = 1;
70 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
81 return $this->prefix.
"0501-0001";
92 global $conf, $langs, $db;
94 $coyymm =
''; $max =
'';
96 $posindice = strlen($this->prefix) + 6;
97 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat";
99 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
100 $sql .=
" AND entity = ".$conf->entity;
102 $resql = $db->query($sql);
105 $row = $db->fetch_row(
$resql);
106 if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
108 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm))
110 $langs->load(
"errors");
111 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
129 $posindice = strlen($this->prefix) + 6;
130 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
131 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat";
132 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
133 $sql .=
" AND entity = ".$conf->entity;
135 $resql = $db->query($sql);
138 $obj = $db->fetch_object(
$resql);
139 if ($obj) $max = intval($obj->max);
142 dol_syslog(
"mod_contract_serpis::getNextValue", LOG_DEBUG);
146 $date = $contract->date_contrat;
147 $yymm = strftime(
"%y%m", $date);
149 if ($max >= (pow(10, 4) - 1)) $num = $max + 1;
150 else $num = sprintf(
"%04s", $max + 1);
152 dol_syslog(
"mod_contract_serpis::getNextValue return ".$this->prefix.$yymm.
"-".$num);
153 return $this->prefix.$yymm.
"-".$num;
canBeActivated()
Test if existing numbers make problems with numbering.
contract_get_num($objsoc, $objforref)
Return next value.
info()
Return default description of numbering model.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
getExample()
Return numbering example.
Class to manage contract numbering rules Serpis.
Parent class for all contract numbering modules.
getNextValue($objsoc, $contract)
Return next value.