27 require_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
38 public $name =
'Monkey';
40 public $code_modifiable;
42 public $code_modifiable_invalide;
44 public $code_modifiable_null;
52 public $version =
'dolibarr';
59 public $prefixcustomer =
'CU';
61 public $prefixsupplier =
'SU';
63 public $prefixIsRequired;
71 $this->nom =
"Monkey";
72 $this->
name =
"Monkey";
73 $this->version =
"dolibarr";
75 $this->code_modifiable = 1;
76 $this->code_modifiable_invalide = 1;
77 $this->code_modifiable_null = 1;
79 $this->prefixIsRequired = 0;
89 public function info($langs)
91 return $langs->trans(
"MonkeyNumRefModelDesc", $this->prefixcustomer, $this->prefixsupplier);
105 return $this->prefixcustomer.
'0901-00001<br>'.$this->prefixsupplier.
'0901-00001';
118 global $db, $conf, $mc;
123 $field =
'code_client';
124 $prefix = $this->prefixcustomer;
125 } elseif ($type == 1) {
126 $field =
'code_fournisseur';
127 $prefix = $this->prefixsupplier;
133 $posindice = strlen($prefix) + 6;
134 $sql =
"SELECT MAX(CAST(SUBSTRING(".$field.
" FROM ".$posindice.
") AS SIGNED)) as max";
135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe";
136 $sql .=
" WHERE ".$field.
" LIKE '".$db->escape($prefix).
"____-%'";
137 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
139 dol_syslog(get_class($this).
"::getNextValue", LOG_DEBUG);
141 $resql = $db->query($sql);
143 $obj = $db->fetch_object(
$resql);
145 $max = intval($obj->max);
156 if ($max >= (pow(10, 5) - 1)) {
159 $num = sprintf(
"%05s", $max + 1);
162 dol_syslog(get_class($this).
"::getNextValue return ".$prefix.$yymm.
"-".$num);
163 return $prefix.$yymm.
"-".$num;
180 public function verif($db, &$code, $soc, $type)
185 $code = strtoupper(trim($code));
187 if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) {
189 } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) {
193 $is_dispo = $this->
verif_dispo($db, $code, $soc, $type);
194 if ($is_dispo <> 0) {
208 dol_syslog(get_class($this).
"::verif code=".$code.
" type=".$type.
" result=".$result);
228 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe";
230 $sql .=
" WHERE code_fournisseur = '".$db->escape($code).
"'";
232 $sql .=
" WHERE code_client = '".$db->escape($code).
"'";
234 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
236 $sql .=
" AND rowid <> ".$soc->id;
239 dol_syslog(get_class($this).
"::verif_dispo", LOG_DEBUG);
240 $resql = $db->query($sql);
242 if ($db->num_rows(
$resql) == 0) {
Parent class for third parties code generators.
Classe permettant la gestion monkey des codes tiers.
verif_syntax($code)
Renvoi si un code respecte la syntaxe.
getExample($langs, $objsoc=0, $type=-1)
Return an example of result returned by getNextValue.
info($langs)
Return description of module.
__construct()
Constructor.
verif_dispo($db, $code, $soc, $type=0)
Renvoi si un code est pris ou non (par autre tiers)
verif($db, &$code, $soc, $type)
Check validity of code according to its rules.
getNextValue($objsoc=0, $type=-1)
Return next value.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db name
Only used if Module[ID]Name translation string is not found.