30 require_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
41 public $name =
'Elephant';
46 public $code_modifiable;
51 public $code_modifiable_invalide;
56 public $code_modifiable_null;
67 public $version =
'dolibarr';
82 public $numbitcounter;
87 public $prefixIsRequired;
96 $this->code_modifiable = 1;
97 $this->code_modifiable_invalide = 1;
98 $this->code_modifiable_null = 1;
100 $this->prefixIsRequired = 0;
115 $langs->load(
"companies");
117 $disabled = ((!empty($mc->sharings[
'referent']) && $mc->sharings[
'referent'] != $conf->entity) ?
' disabled' :
'');
119 $texte = $langs->trans(
'GenericNumRefModelDesc').
"<br>\n";
120 $texte .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
121 $texte .=
'<input type="hidden" name="token" value="'.newToken().
'">';
122 $texte .=
'<input type="hidden" name="action" value="setModuleOptions">';
123 $texte .=
'<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">';
124 $texte .=
'<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">';
125 $texte .=
'<table class="nobordernopadding" width="100%">';
127 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"ThirdParty"), $langs->transnoentities(
"ThirdParty"));
129 $tooltip .= $langs->trans(
"GenericMaskCodes3");
130 $tooltip .= $langs->trans(
"GenericMaskCodes4b");
131 $tooltip .= $langs->trans(
"GenericMaskCodes5");
134 $texte .=
'<tr><td>'.$langs->trans(
"Mask").
' ('.$langs->trans(
"CustomerCodeModel").
'):</td>';
135 $texte .=
'<td class="right">'.$form->textwithpicto(
'<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.
'"'.$disabled.
'>', $tooltip, 1, 1).
'</td>';
137 $texte .=
'<td class="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans(
"Modify").
'" name="Button"'.$disabled.
'></td>';
142 $texte .=
'<tr><td>'.$langs->trans(
"Mask").
' ('.$langs->trans(
"SupplierCodeModel").
'):</td>';
143 $texte .=
'<td class="right">'.$form->textwithpicto(
'<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.
'"'.$disabled.
'>', $tooltip, 1, 1).
'</td>';
146 $texte .=
'</table>';
167 "ErrorCantUseRazIfNoYearInMask",
168 "ErrorCantUseRazInStartedYearIfNoYearMonthInMask",
173 $examplecust = $langs->trans(
'NotConfigured');
175 if (in_array($examplecust, $errmsg)) {
176 $langs->load(
"errors");
177 $examplecust = $langs->trans($examplecust);
183 $examplesup = $langs->trans(
'NotConfigured');
185 if (in_array($examplesup, $errmsg)) {
186 $langs->load(
"errors");
187 $examplesup = $langs->trans($examplesup);
193 } elseif ($type == 1) {
196 return $examplecust.
'<br>'.$examplesup;
211 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
215 if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ?
'' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
216 if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ?
'' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
219 $this->error =
'NotConfigured';
223 $field =
''; $where =
'';
226 $field =
'code_client';
228 } elseif ($type == 1)
230 $field =
'code_fournisseur';
236 $numFinal =
get_next_value($db, $mask,
'societe', $field, $where,
'', $now);
253 $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
254 if (preg_match(
'/\{pre\}/i', $mask))
return 1;
256 $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
257 if (preg_match(
'/\{pre\}/i', $mask))
return 1;
278 public function verif($db, &$code, $soc, $type)
282 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
285 $code = strtoupper(trim($code));
287 if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
290 } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
296 if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ?
'' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
297 if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ?
'' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
300 $this->error =
'NotConfigured';
304 if (is_string($result))
306 $this->error = $result;
311 dol_syslog(
"mod_codeclient_elephant::verif type=".$type.
" result=".$result);
329 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe";
330 if ($type == 1) $sql .=
" WHERE code_fournisseur = '".$db->escape($code).
"'";
331 else $sql .=
" WHERE code_client = '".$db->escape($code).
"'";
332 if ($soc->id > 0) $sql .=
" AND rowid <> ".$soc->id;
334 $resql = $db->query($sql);
337 if ($db->num_rows(
$resql) == 0)
Class to manage third party code with elephant rule.
verif($db, &$code, $soc, $type)
Check validity of code according to its rules.
dol_now($mode= 'auto')
Return date for now.
verif_dispo($db, $code, $soc, $type=0)
Renvoi si un code est pris ou non (par autre tiers)
get_next_value($db, $mask, $table, $field, $where= '', $objsoc= '', $date= '', $mode= 'next', $bentityon=true, $objuser=null, $forceentity=null)
Return last or next value for a mask (according to area we should not reset)
verif_prefixIsUsed()
Check if mask/numbering use prefix.
check_value($mask, $value)
Check value.
Parent class for third parties code generators.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
__construct()
Constructor.
info($langs)
Return description of module.
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.
getNextValue($objsoc=0, $type=-1)
Return next value.
getExample($langs, $objsoc=0, $type=-1)
Return an example of result returned by getNextValue.