28 require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
42 public $nom =
'Elephant';
47 public $name =
'Elephant';
49 public $code_modifiable;
51 public $code_modifiable_invalide;
53 public $code_modifiable_null;
61 public $version =
'dolibarr';
70 public $numbitcounter;
72 public $prefixIsRequired;
81 $this->code_modifiable = 1;
82 $this->code_modifiable_invalide = 1;
83 $this->code_modifiable_null = 1;
85 $this->prefixIsRequired = 0;
95 public function info($langs)
100 $langs->load(
"products");
102 $disabled = ((!empty($mc->sharings[
'referent']) && $mc->sharings[
'referent'] != $conf->entity) ?
' disabled' :
'');
104 $texte = $langs->trans(
'GenericNumRefModelDesc').
"<br>\n";
105 $texte .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
106 $texte .=
'<input type="hidden" name="token" value="'.newToken().
'">';
107 $texte .=
'<input type="hidden" name="action" value="setModuleOptions">';
108 $texte .=
'<input type="hidden" name="param1" value="PRODUCT_ELEPHANT_MASK_PRODUCT">';
109 $texte .=
'<input type="hidden" name="param2" value="PRODUCT_ELEPHANT_MASK_SERVICE">';
110 $texte .=
'<table class="nobordernopadding" width="100%">';
112 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Product"), $langs->transnoentities(
"Product"));
113 $tooltip .= $langs->trans(
"GenericMaskCodes3");
114 $tooltip .= $langs->trans(
"GenericMaskCodes4c");
115 $tooltip .= $langs->trans(
"GenericMaskCodes5");
118 $texte .=
'<tr><td>'.$langs->trans(
"Mask").
' ('.$langs->trans(
"ProductCodeModel").
'):</td>';
119 $texte .=
'<td class="right">'.$form->textwithpicto(
'<input type="text" class="flat" size="24" name="value1" value="'.(!empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ? $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT :
'').
'"'.$disabled.
'>', $tooltip, 1, 1).
'</td>';
121 $texte .=
'<td class="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans(
"Modify").
'" name="Button"'.$disabled.
'></td>';
126 $texte .=
'<tr><td>'.$langs->trans(
"Mask").
' ('.$langs->trans(
"ServiceCodeModel").
'):</td>';
127 $texte .=
'<td class="right">'.$form->textwithpicto(
'<input type="text" class="flat" size="24" name="value2" value="'.(!empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE) ? $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE :
'').
'"'.$disabled.
'>', $tooltip, 1, 1).
'</td>';
130 $texte .=
'</table>';
145 public function getExample($langs, $objproduct = 0, $type = -1)
147 if ($type == 0 || $type == -1)
150 if (!$exampleproduct)
152 $exampleproduct = $langs->trans(
'NotConfigured');
154 if ($exampleproduct ==
"ErrorBadMask")
156 $langs->load(
"errors");
157 $exampleproduct = $langs->trans($exampleproduct);
160 if ($type == 1 || $type == -1)
163 if (!$exampleservice)
165 $exampleservice = $langs->trans(
'NotConfigured');
167 if ($exampleservice ==
"ErrorBadMask")
169 $langs->load(
"errors");
170 $exampleservice = $langs->trans($exampleservice);
174 if ($type == 0)
return $exampleproduct;
175 if ($type == 1)
return $exampleservice;
176 return $exampleproduct.
'<br>'.$exampleservice;
190 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
194 if ($type == 0 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT))
195 $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
196 elseif ($type == 1 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE))
197 $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
201 $this->error =
'NotConfigured';
205 $field =
''; $where =
'';
210 } elseif ($type == 1)
218 if (!empty($conf->global->PRODUCT_ELEPHANT_ADD_WHERE))
220 $where =
' AND ('.dol_string_nospecial(
dol_string_unaccent($conf->global->PRODUCT_ELEPHANT_ADD_WHERE),
'_', array(
',',
'@',
'"',
"|",
";",
":")).
')';
223 $numFinal =
get_next_value($db, $mask,
'product', $field, $where,
'', $now);
240 $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
241 if (preg_match(
'/\{pre\}/i', $mask))
return 1;
243 $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
244 if (preg_match(
'/\{pre\}/i', $mask))
return 1;
264 public function verif($db, &$code, $product, $type)
268 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
271 $code = strtoupper(trim($code));
273 if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
276 } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
282 if ($type == 0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ?
'' : $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
283 if ($type == 1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE) ?
'' : $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
286 $this->error =
'NotConfigured';
291 if (is_string($result))
293 $this->error = $result;
298 dol_syslog(
"mod_codeclient_elephant::verif type=".$type.
" result=".$result);
315 $sql =
"SELECT ref FROM ".MAIN_DB_PREFIX.
"product";
316 $sql .=
" WHERE ref = '".$db->escape($code).
"'";
317 if ($product->id > 0) $sql .=
" AND rowid <> ".$product->id;
319 $resql = $db->query($sql);
322 if ($db->num_rows(
$resql) == 0)
getExample($langs, $objproduct=0, $type=-1)
Return an example of result returned by getNextValue.
verif($db, &$code, $product, $type)
Check validity of code according to its rules.
dol_now($mode= 'auto')
Return date for now.
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)
__construct()
Constructor.
check_value($mask, $value)
Check value.
info($langs)
Return description of module.
getNextValue($objproduct=0, $type=-1)
Return next value.
verif_prefixIsUsed()
Check if mask/numbering use prefix.
verif_dispo($db, $code, $product)
Renvoi si un code est pris ou non (par autre tiers)
Class to manage product code with elephant rule.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
Class template for classes of numbering product.
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.