27require_once DOL_DOCUMENT_ROOT.
'/core/modules/asset/modules_asset.php';
 
   38  public $version = 
'dolibarr'; 
 
   40  public $prefix = 
'ASSET';
 
   50  public $name = 
'standard';
 
   59  public function info($langs)
 
   62    return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
 
 
   73    return $this->prefix.
"0501-0001";
 
 
   86    global $conf, $langs, $db;
 
   91    $posindice = strlen($this->prefix) + 6;
 
   92    $sql = 
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
 
   93    $sql .= 
" FROM ".MAIN_DB_PREFIX.
"asset_asset";
 
   94    $sql .= 
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
 
   95    if ($object->ismultientitymanaged == 1) {
 
   96      $sql .= 
" AND entity = ".$conf->entity;
 
   97    } elseif ($object->ismultientitymanaged == 2) {
 
  101    $resql = $db->query($sql);
 
  103      $row = $db->fetch_row($resql);
 
  105        $coyymm = substr($row[0], 0, 6);
 
  109    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.
"asset";
 
  132    $sql .= 
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
 
  133    if ($object->ismultientitymanaged == 1) {
 
  134      $sql .= 
" AND entity = ".$conf->entity;
 
  135    } elseif ($object->ismultientitymanaged == 2) {
 
  139    $resql = $db->query($sql);
 
  141      $obj = $db->fetch_object($resql);
 
  143        $max = intval($obj->max);
 
  148      dol_syslog(
"mod_asset_standard::getNextValue", LOG_DEBUG);
 
  153    $date = $object->date_creation;
 
  156    if ($max >= (pow(10, 4) - 1)) {
 
  159      $num = sprintf(
"%04s", $max + 1);
 
  162    dol_syslog(
"mod_asset_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
 
  163    return $this->prefix.$yymm.
"-".$num;
 
 
 
Parent class to manage numbering of Asset.
 
Class to manage the Standard numbering rule for Asset.
 
getNextValue($object)
Return next free value.
 
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
 
info($langs)
Return description of numbering module.
 
getExample()
Return an example of numbering.
 
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.