Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2020-04-05 00:44:59 +00:00
parent a8710c2109
commit 612bac6598
36 changed files with 3084 additions and 3084 deletions

File diff suppressed because it is too large Load Diff

View File

@ -39,165 +39,165 @@
*/
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = '', $addfieldentry = array(), $delfieldentry = '')
{
global $db, $langs;
global $db, $langs;
if (empty($objectname)) return -1;
if (empty($readdir)) $readdir = $destdir;
if (empty($objectname)) return -1;
if (empty($readdir)) $readdir = $destdir;
if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval']))
{
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
return -1;
}
if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval']))
{
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
return -1;
}
// Check parameters
if (count($addfieldentry) > 0)
{
if (empty($addfieldentry['name']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
return -2;
}
if (empty($addfieldentry['label']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
&& !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
{
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
return -2;
}
}
// Check parameters
if (count($addfieldentry) > 0)
{
if (empty($addfieldentry['name']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
return -2;
}
if (empty($addfieldentry['label']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
&& !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
{
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
return -2;
}
}
$pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
$pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
if (!dol_is_file($pathoffiletoeditsrc))
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -3;
}
$pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
$pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
if (!dol_is_file($pathoffiletoeditsrc))
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -3;
}
//$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp';
//dol_delete_file($pathoffiletoedittmp, 0, 1, 1);
//$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp';
//dol_delete_file($pathoffiletoedittmp, 0, 1, 1);
try
{
include_once $pathoffiletoeditsrc;
if (class_exists($objectname)) $object = new $objectname($db);
else return -4;
try
{
include_once $pathoffiletoeditsrc;
if (class_exists($objectname)) $object = new $objectname($db);
else return -4;
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
// Edit class files
$contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
// Edit class files
$contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
// Update ->fields (add or remove entries)
if (count($object->fields))
{
if (is_array($addfieldentry) && count($addfieldentry))
{
// Update ->fields (add or remove entries)
if (count($object->fields))
{
if (is_array($addfieldentry) && count($addfieldentry))
{
$name = $addfieldentry['name'];
unset($addfieldentry['name']);
unset($addfieldentry['name']);
$object->fields[$name] = $addfieldentry;
}
if (!empty($delfieldentry))
{
$name = $delfieldentry;
unset($object->fields[$name]);
}
}
$object->fields[$name] = $addfieldentry;
}
if (!empty($delfieldentry))
{
$name = $delfieldentry;
unset($object->fields[$name]);
}
}
dol_sort_array($object->fields, 'position');
dol_sort_array($object->fields, 'position');
$i = 0;
$texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
$texttoinsert .= "\t".'/**'."\n";
$texttoinsert .= "\t".' * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n";
$texttoinsert .= "\t".' */'."\n";
$texttoinsert .= "\t".'public $fields=array('."\n";
$i = 0;
$texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
$texttoinsert .= "\t".'/**'."\n";
$texttoinsert .= "\t".' * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n";
$texttoinsert .= "\t".' */'."\n";
$texttoinsert .= "\t".'public $fields=array('."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
$texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
$texttoinsert .= " 'enabled'=>".($val['enabled'] !== '' ? $val['enabled'] : 1).",";
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',";
if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',";
if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
if ($val['arrayofkeyval'])
{
$texttoinsert .= " 'arrayofkeyval'=>array(";
$i = 0;
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
if ($i) $texttoinsert .= ", ";
$texttoinsert .= "'".$key2."'=>'".$val2."'";
$i++;
}
$texttoinsert .= "),";
}
if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
$texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
$texttoinsert .= " 'enabled'=>".($val['enabled'] !== '' ? $val['enabled'] : 1).",";
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',";
if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',";
if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
if ($val['arrayofkeyval'])
{
$texttoinsert .= " 'arrayofkeyval'=>array(";
$i = 0;
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
if ($i) $texttoinsert .= ", ";
$texttoinsert .= "'".$key2."'=>'".$val2."'";
$i++;
}
$texttoinsert .= "),";
}
if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
$texttoinsert .= "),\n";
}
}
$texttoinsert .= "),\n";
}
}
$texttoinsert .= "\t".');'."\n";
$texttoinsert .= "\t".');'."\n";
//print ($texttoinsert);exit;
if (count($object->fields))
{
//$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
if (count($object->fields))
{
//$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
foreach ($object->fields as $key => $val)
{
$i++;
//$typephp=$typetotypephp[$val['type']];
$texttoinsert .= "\t".'public $'.$key.";";
//if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
//if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
//$texttoinsert.= ($val['notnull']?' NOT NULL':'');
//if ($i < count($object->fields)) $texttoinsert.=";";
$texttoinsert .= "\n";
}
}
foreach ($object->fields as $key => $val)
{
$i++;
//$typephp=$typetotypephp[$val['type']];
$texttoinsert .= "\t".'public $'.$key.";";
//if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
//if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
//$texttoinsert.= ($val['notnull']?' NOT NULL':'');
//if ($i < count($object->fields)) $texttoinsert.=";";
$texttoinsert .= "\n";
}
}
$texttoinsert .= "\t".'// END MODULEBUILDER PROPERTIES';
$texttoinsert .= "\t".'// END MODULEBUILDER PROPERTIES';
//print($texttoinsert);exit;
//print($texttoinsert);exit;
$contentclass = preg_replace('/\/\/ BEGIN MODULEBUILDER PROPERTIES.*END MODULEBUILDER PROPERTIES/ims', $texttoinsert, $contentclass);
$contentclass = preg_replace('/\/\/ BEGIN MODULEBUILDER PROPERTIES.*END MODULEBUILDER PROPERTIES/ims', $texttoinsert, $contentclass);
dol_mkdir(dirname($pathoffiletoedittarget));
dol_mkdir(dirname($pathoffiletoedittarget));
//file_put_contents($pathoffiletoedittmp, $contentclass);
file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass);
@chmod($pathoffiletoedittarget, octdec($newmask));
//file_put_contents($pathoffiletoedittmp, $contentclass);
file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass);
@chmod($pathoffiletoedittarget, octdec($newmask));
return $object;
}
catch (Exception $e)
{
print $e->getMessage();
return -5;
}
return $object;
}
catch (Exception $e)
{
print $e->getMessage();
return -5;
}
}
/**
@ -214,134 +214,134 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
*/
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '', $object = null)
{
global $db, $langs;
global $db, $langs;
$error = 0;
$error = 0;
if (empty($objectname)) return -1;
if (empty($readdir)) $readdir = $destdir;
if (empty($objectname)) return -1;
if (empty($readdir)) $readdir = $destdir;
$pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
$pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
// Edit .sql file
$pathoffiletoeditsrc = $readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
// Edit .sql file
$pathoffiletoeditsrc = $readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
if (!dol_is_file($pathoffiletoeditsrc))
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -1;
}
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -1;
}
// Load object from myobject.class.php
try
{
if (!is_object($object))
{
include_once $pathoffiletoclasssrc;
if (class_exists($objectname)) $object = new $objectname($db);
else return -1;
}
}
catch (Exception $e)
{
print $e->getMessage();
}
// Load object from myobject.class.php
try
{
if (!is_object($object))
{
include_once $pathoffiletoclasssrc;
if (class_exists($objectname)) $object = new $objectname($db);
else return -1;
}
}
catch (Exception $e)
{
print $e->getMessage();
}
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
$type = $val['type'];
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
$type = $val['type'];
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
$texttoinsert .= "\t".$key." ".$type;
if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert .= ' DEFAULT 1';
else
{
if ($val['default'] != '')
{
if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL";
elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
}
}
$texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
if ($i < count($object->fields)) $texttoinsert .= ", ";
$texttoinsert .= "\n";
}
}
$texttoinsert .= "\t".'-- END MODULEBUILDER FIELDS';
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
$texttoinsert .= "\t".$key." ".$type;
if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert .= ' DEFAULT 1';
else
{
if ($val['default'] != '')
{
if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL";
elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
}
}
$texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
if ($i < count($object->fields)) $texttoinsert .= ", ";
$texttoinsert .= "\n";
}
}
$texttoinsert .= "\t".'-- END MODULEBUILDER FIELDS';
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
$result = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
$result = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
// Edit .key.sql file
$pathoffiletoeditsrc = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql';
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
// Edit .key.sql file
$pathoffiletoeditsrc = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql';
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
if (!empty($val['index']))
{
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
$texttoinsert .= "\n";
}
if (!empty($val['foreignkey']))
{
$tmp = explode('.', $val['foreignkey']);
if (!empty($tmp[0]) && !empty($tmp[1]))
{
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".preg_replace('/^llx_/', '', $tmp[0])."(".$tmp[1].");";
$texttoinsert .= "\n";
}
}
}
}
$texttoinsert .= '-- END MODULEBUILDER INDEXES';
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
if (!empty($val['index']))
{
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
$texttoinsert .= "\n";
}
if (!empty($val['foreignkey']))
{
$tmp = explode('.', $val['foreignkey']);
if (!empty($tmp[0]) && !empty($tmp[1]))
{
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".preg_replace('/^llx_/', '', $tmp[0])."(".$tmp[1].");";
$texttoinsert .= "\n";
}
}
}
}
$texttoinsert .= '-- END MODULEBUILDER INDEXES';
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER INDEXES.*END MODULEBUILDER INDEXES/ims', $texttoinsert, $contentsql);
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER INDEXES.*END MODULEBUILDER INDEXES/ims', $texttoinsert, $contentsql);
dol_mkdir(dirname($pathoffiletoedittarget));
dol_mkdir(dirname($pathoffiletoedittarget));
$result2 = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
$result2 = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
return $error ? -1 : 1;
return $error ? -1 : 1;
}

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php';
class mod_bom_standard extends ModeleNumRefboms
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='BOM';
@ -48,16 +48,16 @@ class mod_bom_standard extends ModeleNumRefboms
public $name='standard';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -72,8 +72,8 @@ class mod_bom_standard extends ModeleNumRefboms
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -140,8 +140,8 @@ class mod_bom_standard extends ModeleNumRefboms
$date=$object->date_creation;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog("mod_bom_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -39,17 +39,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
abstract class ModelePDFBom extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'bom';
@ -110,7 +110,7 @@ abstract class ModeleNumRefBoms
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php
class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='CHK';
@ -45,16 +45,16 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
public $name='Mint';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -69,8 +69,8 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -137,15 +137,15 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
$date=$object->date_bordereau;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*
@ -155,7 +155,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
*/
public function chequereceipt_get_num($objsoc, $objforref)
{
// phpcs:enable
// phpcs:enable
return $this->getNextValue($objsoc, $objforref);
}
}

View File

@ -76,11 +76,11 @@ abstract class ModeleNumRefChequeReceipts
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
@ -128,17 +128,17 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type='chequereceipt';

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
class mod_commande_marbre extends ModeleNumRefCommandes
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='CO';
@ -48,16 +48,16 @@ class mod_commande_marbre extends ModeleNumRefCommandes
public $name='Marbre';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -72,8 +72,8 @@ class mod_commande_marbre extends ModeleNumRefCommandes
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -140,15 +140,15 @@ class mod_commande_marbre extends ModeleNumRefCommandes
$date=$object->date;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*
@ -158,7 +158,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
*/
public function commande_get_num($objsoc, $objforref)
{
// phpcs:enable
// phpcs:enable
return $this->getNextValue($objsoc, $objforref);
}
}

View File

@ -40,17 +40,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
abstract class ModelePDFCommandes extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'order';
@ -111,7 +111,7 @@ abstract class ModeleNumRefCommandes
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -34,32 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
*/
abstract class ModeleDon extends CommonDocGenerator
{
/**
/**
* @var string Error code (or message)
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
$type='donation';
$liste=array();
$type='donation';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
return $liste;
}
}
@ -68,81 +68,81 @@ abstract class ModeleDon extends CommonDocGenerator
*/
abstract class ModeleNumRefDons
{
/**
/**
* @var string Error code (or message)
*/
public $error='';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("bills");
return $langs->trans("NoDescription");
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("bills");
return $langs->trans("NoDescription");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
*/
public function getNextValue()
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
*/
public function getNextValue()
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
}

View File

@ -29,9 +29,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/expensereport/modules_expenserepo
class mod_expensereport_jade extends ModeleNumRefExpenseReport
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='ER';
@ -54,16 +54,16 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
public $name='Jade';
/**
* Return description of numbering model
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering model
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -71,19 +71,19 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
*
* @return string Example
*/
public function getExample()
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
public function canBeActivated()
{
global $conf,$langs,$db;
@ -117,7 +117,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($object)
public function getNextValue($object)
{
global $db,$conf;
@ -139,19 +139,19 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
$result = $db->query($sql);
if ($db->num_rows($result) > 0) {
$objp = $db->fetch_object($result);
$newref = $objp->max;
$newref++;
while (strlen($newref) < $num_car) {
$newref = "0".$newref;
}
} else {
$newref = 1;
while (strlen($newref) < $num_car) {
$newref = "0".$newref;
}
}
if ($db->num_rows($result) > 0) {
$objp = $db->fetch_object($result);
$newref = $objp->max;
$newref++;
while (strlen($newref) < $num_car) {
$newref = "0".$newref;
}
} else {
$newref = 1;
while (strlen($newref) < $num_car) {
$newref = "0".$newref;
}
}
$ref_number_int = ($newref+1)-1;
@ -202,8 +202,8 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -46,17 +46,17 @@ abstract class ModelePDFFactures extends CommonDocGenerator
public $atleastoneratenotnull = 0;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'invoice';
@ -114,8 +114,8 @@ abstract class ModeleNumRefFactures
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -40,17 +40,17 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type='ficheinter';
@ -109,8 +109,8 @@ abstract class ModeleNumRefFicheinter
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -164,7 +164,7 @@ abstract class ModeleNumRefFicheinter
*/
function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
// phpcs:enable
global $conf,$langs,$user;
$langs->load("ficheinter");
@ -187,11 +187,11 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0,
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp=explode(':', $modele, 2);
if (! empty($tmp[1]))
{
$modele=$tmp[0];
$srctemplatepath=$tmp[1];
}
if (! empty($tmp[1]))
{
$modele=$tmp[0];
$srctemplatepath=$tmp[1];
}
// Search template files
$file=''; $classname=''; $filefound=0;
@ -199,21 +199,21 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0,
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{
foreach(array('doc','pdf') as $prefix)
{
$file = $prefix."_".$modele.".modules.php";
foreach(array('doc','pdf') as $prefix)
{
$file = $prefix."_".$modele.".modules.php";
// On verifie l'emplacement du modele
$file=dol_buildpath($reldir."core/modules/fichinter/doc/".$file, 0);
if (file_exists($file))
{
$filefound=1;
$classname=$prefix.'_'.$modele;
break;
}
}
if ($filefound) break;
}
// On verifie l'emplacement du modele
$file=dol_buildpath($reldir."core/modules/fichinter/doc/".$file, 0);
if (file_exists($file))
{
$filefound=1;
$classname=$prefix.'_'.$modele;
break;
}
}
if ($filefound) break;
}
// Charge le modele
if ($filefound)

View File

@ -35,9 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php';
class mod_livraison_jade extends ModeleNumRefDeliveryOrder
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
@ -57,7 +57,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
*/
public $name = 'Jade';
public $prefix = 'BL';
public $prefix = 'BL';
/**
@ -74,103 +74,103 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $langs, $conf, $db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $langs, $conf, $db;
$langs->load("bills");
$langs->load("bills");
// Check invoice num
$fayymm = ''; $max = '';
// Check invoice num
$fayymm = ''; $max = '';
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; }
}
if ($fayymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm))
{
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
}
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; }
}
if ($fayymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm))
{
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
}
return true;
}
return true;
}
/**
/**
* Return next free value
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objsoc, $object)
{
global $db, $conf;
public function getNextValue($objsoc, $object)
{
global $db, $conf;
// D'abord on recupere la valeur max
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
// D'abord on recupere la valeur max
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max = 0;
}
else
{
return -1;
}
$resql = $db->query($sql);
dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max = 0;
}
else
{
return -1;
}
$date = $object->date_delivery;
if (empty($date)) $date = dol_now();
$yymm = strftime("%y%m", $date);
$date = $object->date_delivery;
if (empty($date)) $date = dol_now();
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free ref
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object livraison
* @return string Texte descriptif
*/
public function livraison_get_num($objsoc = 0, $object = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $object);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free ref
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object livraison
* @return string Texte descriptif
*/
public function livraison_get_num($objsoc = 0, $object = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $object);
}
}

View File

@ -36,32 +36,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
*/
abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
{
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string Error code (or message)
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
$type='delivery';
$liste=array();
$type='delivery';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
return $liste;
}
}
@ -72,83 +72,83 @@ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
*/
abstract class ModeleNumRefDeliveryOrder
{
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string Error code (or message)
*/
public $error='';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("deliveries");
return $langs->trans("NoDescription");
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("deliveries");
return $langs->trans("NoDescription");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("deliveries");
return $langs->trans("NoExample");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("deliveries");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Object $object Object delivery
* @return string Valeur
*/
public function getNextValue($objsoc, $object)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Object $object Object delivery
* @return string Valeur
*/
public function getNextValue($objsoc, $object)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("NotAvailable");
}
}

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php';
class mod_mo_standard extends ModeleNumRefMos
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix = 'MO';
@ -48,16 +48,16 @@ class mod_mo_standard extends ModeleNumRefMos
public $name = 'standard';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -72,8 +72,8 @@ class mod_mo_standard extends ModeleNumRefMos
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -140,8 +140,8 @@ class mod_mo_standard extends ModeleNumRefMos
$date = $object->date_creation;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
dol_syslog("mod_mo_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -39,17 +39,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
abstract class ModelePDFMo extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'mo';
@ -110,7 +110,7 @@ abstract class ModeleNumRefMos
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php';
class mod_payment_cicada extends ModeleNumRefPayments
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='PAY';
@ -55,16 +55,16 @@ class mod_payment_cicada extends ModeleNumRefPayments
public $name='Cicada';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -79,8 +79,8 @@ class mod_payment_cicada extends ModeleNumRefPayments
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -147,15 +147,15 @@ class mod_payment_cicada extends ModeleNumRefPayments
$date=$object->datepaye;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*
@ -165,7 +165,7 @@ class mod_payment_cicada extends ModeleNumRefPayments
*/
public function payment_get_num($objsoc, $objforref)
{
// phpcs:enable
// phpcs:enable
return $this->getNextValue($objsoc, $objforref);
}
}

View File

@ -63,11 +63,11 @@ abstract class ModeleNumRefPayments
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;

View File

@ -33,226 +33,226 @@
*/
abstract class ModelePDFProduct extends CommonDocGenerator
{
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string Error code (or message)
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
$type='product';
$liste=array();
$type='product';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
}
abstract class ModeleProductCode
{
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string Error code (or message)
*/
public $error='';
/** Renvoi la description par defaut du modele de numerotation
*
* @param Translate $langs Object langs
* @return string Texte descripif
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/** Renvoi la description par defaut du modele de numerotation
*
* @param Translate $langs Object langs
* @return string Texte descripif
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/** Renvoi nom module
*
* @param Translate $langs Object langs
* @return string Nom du module
*/
public function getNom($langs)
{
return empty($this->name)?$this->nom:$this->name;
}
/** Renvoi nom module
*
* @param Translate $langs Object langs
* @return string Nom du module
*/
public function getNom($langs)
{
return empty($this->name)?$this->nom:$this->name;
}
/** Return an example of numbering
*
* @param Translate $langs Object langs
* @return string Example
*/
public function getExample($langs)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/** Return an example of numbering
*
* @param Translate $langs Object langs
* @return string Example
*/
public function getExample($langs)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Return next value available
*
* @param Product $objproduct Object product
* @param int $type Type
* @return string Value
*/
public function getNextValue($objproduct = 0, $type = -1)
{
global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking");
}
/**
* Return next value available
*
* @param Product $objproduct Object product
* @param int $type Type
* @return string Value
*/
public function getNextValue($objproduct = 0, $type = -1)
{
global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking");
}
/** Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/** Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi la liste des modeles de numérotation
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
$liste=array();
$sql ="";
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi la liste des modeles de numérotation
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
$liste=array();
$sql ="";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Product $product Product object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $product, $type)
{
global $conf;
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Product $product Product object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $product, $type)
{
global $conf;
$langs->load("admin");
$langs->load("admin");
$s='';
if ($type == -1) {
$s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
$s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
}
if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>';
if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>';
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s.='<br>';
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0)
{
$s.=$langs->trans("RequiredIfProduct").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
elseif ($type == 1)
{
$s.=$langs->trans("RequiredIfService").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
elseif ($type == -1)
{
$s.=$langs->trans("Required").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
$s.=$langs->trans("CanBeModifiedIfOk").': ';
$s.=yn($this->code_modifiable, 1, 2);
$s.='<br>';
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$nextval=$this->getNextValue($product, 0);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$nextval=$this->getNextValue($product, 1);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
$s='';
if ($type == -1) {
$s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
$s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
}
if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>';
if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>';
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s.='<br>';
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0)
{
$s.=$langs->trans("RequiredIfProduct").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
elseif ($type == 1)
{
$s.=$langs->trans("RequiredIfService").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
elseif ($type == -1)
{
$s.=$langs->trans("Required").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
$s.=$langs->trans("CanBeModifiedIfOk").': ';
$s.=yn($this->code_modifiable, 1, 2);
$s.='<br>';
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$nextval=$this->getNextValue($product, 0);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$nextval=$this->getNextValue($product, 1);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Check if mask/numbering use prefix
*
* @return int 0=no, 1=yes
*/
public function verif_prefixIsUsed()
{
// phpcs:enable
return 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Check if mask/numbering use prefix
*
* @return int 0=no, 1=yes
*/
public function verif_prefixIsUsed()
{
// phpcs:enable
return 0;
}
}

View File

@ -32,14 +32,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php';
class mod_project_simple extends ModeleNumRefProjects
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='PJ';
/**
/**
* @var string Error code (or message)
*/
public $error='';
@ -57,74 +57,74 @@ class mod_project_simple extends ModeleNumRefProjects
public $name='Simple';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
$coyymm=''; $max='';
$coyymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."projet";
$sql.= " FROM ".MAIN_DB_PREFIX."projet";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel', $max);
return false;
}
}
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $project)
{
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $project)
{
global $db,$conf;
// D'abord on recupere la valeur max
@ -157,20 +157,20 @@ class mod_project_simple extends ModeleNumRefProjects
dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next reference not yet used as a reference
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Next not used reference
*/
public function project_get_num($objsoc = 0, $project = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $project);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next reference not yet used as a reference
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Next not used reference
*/
public function project_get_num($objsoc = 0, $project = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $project);
}
}

View File

@ -32,14 +32,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
class mod_task_simple extends ModeleNumRefTask
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='TK';
/**
/**
* @var string Error code (or message)
*/
public $error='';
@ -57,40 +57,40 @@ class mod_task_simple extends ModeleNumRefTask
public $name='Simple';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
$coyymm=''; $max='';
$coyymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
@ -98,34 +98,34 @@ class mod_task_simple extends ModeleNumRefTask
$sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
$sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
$sql .= " AND project.entity = " . $conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel', $max);
return false;
}
}
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Task $object Object Task
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $object)
{
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Task $object Object Task
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $object)
{
global $db,$conf;
// D'abord on recupere la valeur max
@ -157,19 +157,19 @@ class mod_task_simple extends ModeleNumRefTask
dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next reference not yet used as a reference
*
* @param Societe $objsoc Object third party
* @param Task $object Object task
* @return string Next not used reference
*/
public function task_get_num($objsoc = 0, $object = '')
{
return $this->getNextValue($objsoc, $object);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next reference not yet used as a reference
*
* @param Societe $objsoc Object third party
* @param Task $object Object task
* @return string Next not used reference
*/
public function task_get_num($objsoc = 0, $object = '')
{
return $this->getNextValue($objsoc, $object);
}
}

View File

@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php';
class mod_propale_marbre extends ModeleNumRefPropales
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='PR';
@ -57,16 +57,16 @@ class mod_propale_marbre extends ModeleNumRefPropales
public $name='Marbre';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -81,8 +81,8 @@ class mod_propale_marbre extends ModeleNumRefPropales
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -33,32 +33,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
*/
abstract class ModeleThirdPartyDoc extends CommonDocGenerator
{
/**
/**
* @var string Error code (or message)
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
$type='company';
$liste=array();
$type='company';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste = getListOfModels($db, $type, $maxfilenamelength);
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste = getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
return $liste;
}
}
/**
@ -67,197 +67,197 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator
*/
abstract class ModeleThirdPartyCode
{
/**
* @var string Error code (or message)
/**
* @var string Error code (or message)
*/
public $error='';
/** Renvoi la description par defaut du modele de numerotation
*
* @param Translate $langs Object langs
* @return string Texte descripif
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/** Renvoi la description par defaut du modele de numerotation
*
* @param Translate $langs Object langs
* @return string Texte descripif
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/** Return name of module
*
* @param Translate $langs Object langs
* @return string Nom du module
*/
public function getNom($langs)
{
return $this->name;
}
/** Return name of module
*
* @param Translate $langs Object langs
* @return string Nom du module
*/
public function getNom($langs)
{
return $this->name;
}
/** Return an example of numbering
*
* @param Translate $langs Object langs
* @return string Example
*/
public function getExample($langs)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/** Return an example of numbering
*
* @param Translate $langs Object langs
* @return string Example
*/
public function getExample($langs)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Return next value available
*
* @param Societe $objsoc Object thirdparty
* @param int $type Type
* @return string Value
*/
public function getNextValue($objsoc = 0, $type = -1)
{
global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking");
}
/**
* Return next value available
*
* @param Societe $objsoc Object thirdparty
* @param int $type Type
* @return string Value
*/
public function getNextValue($objsoc = 0, $type = -1)
{
global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking");
}
/**
* Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoie la liste des modeles de numérotation
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
$liste=array();
$sql ="";
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoie la liste des modeles de numérotation
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
$liste=array();
$sql ="";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $soc, $type)
{
global $conf;
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $soc, $type)
{
global $conf;
$langs->load("admin");
$langs->load("admin");
$s='';
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s.='<br>';
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0)
{
$s.=$langs->trans("RequiredIfCustomer").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
if ($type == 1)
{
$s.=$langs->trans("RequiredIfSupplier").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
if ($type == -1)
{
$s.=$langs->trans("Required").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
$s.=$langs->trans("CanBeModifiedIfOk").': ';
$s.=yn($this->code_modifiable, 1, 2);
$s.='<br>';
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$nextval=$this->getNextValue($soc, 0);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$nextval=$this->getNextValue($soc, 1);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
$s='';
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s.='<br>';
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0)
{
$s.=$langs->trans("RequiredIfCustomer").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
if ($type == 1)
{
$s.=$langs->trans("RequiredIfSupplier").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
if ($type == -1)
{
$s.=$langs->trans("Required").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
$s.=$langs->trans("CanBeModifiedIfOk").': ';
$s.=yn($this->code_modifiable, 1, 2);
$s.='<br>';
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$nextval=$this->getNextValue($soc, 0);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$nextval=$this->getNextValue($soc, 1);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Check if mask/numbering use prefix
*
* @return int 0=no, 1=yes
*/
public function verif_prefixIsUsed()
{
// phpcs:enable
return 0;
}
*/
public function verif_prefixIsUsed()
{
// phpcs:enable
return 0;
}
}
@ -266,119 +266,119 @@ abstract class ModeleThirdPartyCode
*/
abstract class ModeleAccountancyCode
{
/**
/**
* @var string Error code (or message)
*/
public $error='';
/**
* Return description of module
*
* @param Translate $langs Object langs
* @return string Description of module
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/**
* Return description of module
*
* @param Translate $langs Object langs
* @return string Description of module
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/**
* Return an example of result returned by getNextValue
*
* @param Translate $langs Object langs
* @param societe $objsoc Object thirdparty
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @return string Example
*/
public function getExample($langs, $objsoc = 0, $type = -1)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Return an example of result returned by getNextValue
*
* @param Translate $langs Object langs
* @param societe $objsoc Object thirdparty
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @return string Example
*/
public function getExample($langs, $objsoc = 0, $type = -1)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $soc, $type)
{
global $conf,$db;
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $soc, $type)
{
global $conf,$db;
$langs->load("admin");
$langs->load("admin");
$s='';
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
//$s.='<br>';
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$result=$this->get_code($db, $soc, 'customer');
$nextval=$this->code;
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$result=$this->get_code($db, $soc, 'supplier');
$nextval=$this->code;
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
$s='';
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
//$s.='<br>';
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$result=$this->get_code($db, $soc, 'customer');
$nextval=$this->code;
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$result=$this->get_code($db, $soc, 'supplier');
$nextval=$this->code;
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Set accountancy account code for a third party into this->code
*
* @param DoliDB $db Database handler
* @param Societe $societe Third party object
* @param int $type 'customer' or 'supplier'
* @return int >=0 if OK, <0 if KO
*/
public function get_code($db, $societe, $type = '')
{
// phpcs:enable
global $langs;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Set accountancy account code for a third party into this->code
*
* @param DoliDB $db Database handler
* @param Societe $societe Third party object
* @param int $type 'customer' or 'supplier'
* @return int >=0 if OK, <0 if KO
*/
public function get_code($db, $societe, $type = '')
{
// phpcs:enable
global $langs;
return $langs->trans("NotAvailable");
}
return $langs->trans("NotAvailable");
}
}
@ -399,7 +399,7 @@ abstract class ModeleAccountancyCode
*/
function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

View File

@ -32,15 +32,15 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_commandefo
class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
* @var string Error code (or message)
*/
public $error = '';
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string Nom du modele
@ -62,118 +62,118 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
*/
public function __construct()
{
global $conf;
global $conf;
if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order"
if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order"
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
$coyymm=''; $max='';
$coyymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel', $max);
return false;
}
}
return false;
}
}
/**
* Return next value
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Object $object Object
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc = 0, $object = '')
{
global $db,$conf;
*/
public function getNextValue($objsoc = 0, $object = '')
{
global $db,$conf;
// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max=0;
}
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max=0;
}
//$date=time();
$date=$object->date_commande; // Not always defined
if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders
$yymm = strftime("%y%m", $date);
$date=$object->date_commande; // Not always defined
if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
return $this->prefix.$yymm."-".$num;
}
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoie la reference de commande suivante non utilisee
*
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoie la reference de commande suivante non utilisee
*
* @param Societe $objsoc Object third party
* @param Object $object Object
* @return string Texte descripif
*/
public function commande_get_num($objsoc = 0, $object = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $object);
}
* @return string Texte descripif
*/
public function commande_get_num($objsoc = 0, $object = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $object);
}
}

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier
class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='SPAY';
@ -55,16 +55,16 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
public $name='Bronan';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -79,8 +79,8 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -147,15 +147,15 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
$date=$object->datepaye;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*
@ -165,7 +165,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
*/
public function payment_get_num($objsoc, $objforref)
{
// phpcs:enable
// phpcs:enable
return $this->getNextValue($objsoc, $objforref);
}
}

View File

@ -28,17 +28,17 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation models
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type='supplier_payment';
@ -98,11 +98,11 @@ abstract class ModeleNumRefSupplierPayments
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;

View File

@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_proposal/modules_supplie
class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='RQ'; // RQ = Request for quotation
@ -57,16 +57,16 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
public $name='Marbre';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -81,8 +81,8 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -47,21 +47,21 @@ abstract class ModeleNumRefTakepos
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("cashdesk@cashdesk");
return $langs->trans("NoDescription");
}
public function info()
{
global $langs;
$langs->load("cashdesk@cashdesk");
return $langs->trans("NoDescription");
}
/**
* Return an example of numbering
@ -69,11 +69,11 @@ abstract class ModeleNumRefTakepos
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load('cashdesk@cashdesk');
return $langs->trans('NoExample');
}
{
global $langs;
$langs->load('cashdesk@cashdesk');
return $langs->trans('NoExample');
}
/**
* Checks if the numbers already in the database do not
@ -82,20 +82,20 @@ abstract class ModeleNumRefTakepos
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
*/
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
*/
public function getNextValue()
{
global $langs;
return $langs->trans('NotAvailable');
}
{
global $langs;
return $langs->trans('NotAvailable');
}
/**
* Renvoi version du modele de numerotation
@ -103,14 +103,14 @@ abstract class ModeleNumRefTakepos
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans('VersionDevelopment');
if ($this->version == 'experimental') return $langs->trans('VersionExperimental');
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans('NotAvailable');
}
if ($this->version == 'development') return $langs->trans('VersionDevelopment');
if ($this->version == 'experimental') return $langs->trans('VersionExperimental');
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans('NotAvailable');
}
}

View File

@ -30,20 +30,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/ticket/modules_ticket.php';
*/
class mod_ticket_simple extends ModeleNumRefTicket
{
/**
* Dolibarr version of the loaded document
* @var string
*/
/**
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix = 'TS';
public $prefix = 'TS';
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string Error code (or message)
*/
public $error = '';
/**
/**
* @var string Nom du modele
* @deprecated
* @see $name
@ -55,108 +55,108 @@ class mod_ticket_simple extends ModeleNumRefTicket
*/
public $name='Simple';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix . "0501-0001";
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix . "0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf, $langs, $db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf, $langs, $db;
$coyymm = '';
$max = '';
$coyymm = '';
$max = '';
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
$search = $this->prefix . "____-%";
$sql .= " WHERE ref LIKE '" . $search ."'";
$sql .= " AND entity = " . $conf->entity;
$resql = $db->query($sql);
if ($resql) {
$row = $db->fetch_row($resql);
if ($row) {
$coyymm = substr($row[0], 0, 6);
$max = $row[0];
}
}
if (!$coyymm || preg_match('/' . $this->prefix . '[0-9][0-9][0-9][0-9]/i', $coyymm)) {
return true;
} else {
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
}
}
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
$search = $this->prefix . "____-%";
$sql .= " WHERE ref LIKE '" . $search ."'";
$sql .= " AND entity = " . $conf->entity;
$resql = $db->query($sql);
if ($resql) {
$row = $db->fetch_row($resql);
if ($row) {
$coyymm = substr($row[0], 0, 6);
$max = $row[0];
}
}
if (!$coyymm || preg_match('/' . $this->prefix . '[0-9][0-9][0-9][0-9]/i', $coyymm)) {
return true;
} else {
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Project $ticket Object ticket
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $ticket)
{
global $db, $conf;
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Project $ticket Object ticket
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $ticket)
{
global $db, $conf;
// D'abord on recupere la valeur max
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
$search = $this->prefix . "____-%";
$sql .= " WHERE ref LIKE '" . $search ."'";
$sql .= " AND entity = " . $conf->entity;
// D'abord on recupere la valeur max
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
$search = $this->prefix . "____-%";
$sql .= " WHERE ref LIKE '" . $search ."'";
$sql .= " AND entity = " . $conf->entity;
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
$max = intval($obj->max);
} else {
$max = 0;
}
} else {
dol_syslog("mod_ticket_simple::getNextValue", LOG_DEBUG);
return -1;
}
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
$max = intval($obj->max);
} else {
$max = 0;
}
} else {
dol_syslog("mod_ticket_simple::getNextValue", LOG_DEBUG);
return -1;
}
$date = empty($ticket->datec) ? dol_now() : $ticket->datec;
$date = empty($ticket->datec) ? dol_now() : $ticket->datec;
//$yymm = strftime("%y%m",time());
$yymm = strftime("%y%m", $date);
//$yymm = strftime("%y%m",time());
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1;
} // If counter > 9999, we do not format on 4 chars, we take number as it is
else {
$num = sprintf("%04s", $max + 1);
}
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1;
} // If counter > 9999, we do not format on 4 chars, we take number as it is
else {
$num = sprintf("%04s", $max + 1);
}
dol_syslog("mod_ticket_simple::getNextValue return " . $this->prefix . $yymm . "-" . $num);
return $this->prefix . $yymm . "-" . $num;
}
dol_syslog("mod_ticket_simple::getNextValue return " . $this->prefix . $yymm . "-" . $num);
return $this->prefix . $yymm . "-" . $num;
}
}

View File

@ -29,95 +29,95 @@
*/
abstract class ModeleNumRefTicket
{
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("ticket");
return $langs->trans("NoDescription");
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("ticket");
return $langs->trans("NoDescription");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("ticket");
return $langs->trans("NoExample");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("ticket");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Valeur
*/
public function getNextValue($objsoc, $project)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Valeur
*/
public function getNextValue($objsoc, $project)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') {
return $langs->trans("VersionDevelopment");
}
if ($this->version == 'development') {
return $langs->trans("VersionDevelopment");
}
if ($this->version == 'experimental') {
return $langs->trans("VersionExperimental");
}
if ($this->version == 'experimental') {
return $langs->trans("VersionExperimental");
}
if ($this->version == 'dolibarr') {
return DOL_VERSION;
}
if ($this->version == 'dolibarr') {
return DOL_VERSION;
}
if ($this->version) {
return $this->version;
}
if ($this->version) {
return $this->version;
}
return $langs->trans("NotAvailable");
}
return $langs->trans("NotAvailable");
}
}

View File

@ -28,8 +28,8 @@
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf)) {
print "Error, template page can't be called as URL";
exit;
print "Error, template page can't be called as URL";
exit;
}
@ -54,7 +54,7 @@ if ($action == 'presend')
}
else
{
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
}
$file = $fileparams['fullname'];
@ -102,11 +102,11 @@ if ($action == 'presend')
}
if ($object->element == 'invoice_supplier')
{
$fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+');
$fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+');
}
else
{
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
}
$file = $fileparams['fullname'];
@ -212,51 +212,51 @@ if ($action == 'presend')
complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
// Find the good contact address
$tmpobject = $object;
if (($object->element == 'shipping'|| $object->element == 'reception')) {
$origin = $object->origin;
$origin_id = $object->origin_id;
$tmpobject = $object;
if (($object->element == 'shipping'|| $object->element == 'reception')) {
$origin = $object->origin;
$origin_id = $object->origin_id;
if (!empty($origin) && !empty($origin_id)) {
$element = $subelement = $origin;
$regs = array();
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
$element = $regs[1];
$subelement = $regs[2];
}
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
}
if ($element == 'propal') {
$element = 'comm/propal';
$subelement = 'propal';
}
if ($element == 'contract') {
$element = $subelement = 'contrat';
}
if ($element == 'inter') {
$element = $subelement = 'ficheinter';
}
if ($element == 'shipping') {
$element = $subelement = 'expedition';
}
if ($element == 'order_supplier') {
$element = 'fourn';
$subelement = 'fournisseur.commande';
}
if ($element == 'project') {
$element = 'projet';
}
if (!empty($origin) && !empty($origin_id)) {
$element = $subelement = $origin;
$regs = array();
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
$element = $regs[1];
$subelement = $regs[2];
}
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
}
if ($element == 'propal') {
$element = 'comm/propal';
$subelement = 'propal';
}
if ($element == 'contract') {
$element = $subelement = 'contrat';
}
if ($element == 'inter') {
$element = $subelement = 'ficheinter';
}
if ($element == 'shipping') {
$element = $subelement = 'expedition';
}
if ($element == 'order_supplier') {
$element = 'fourn';
$subelement = 'fournisseur.commande';
}
if ($element == 'project') {
$element = 'projet';
}
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
$classname = ucfirst($origin);
$objectsrc = new $classname($db);
$objectsrc->fetch($origin_id);
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
$classname = ucfirst($origin);
$objectsrc = new $classname($db);
$objectsrc->fetch($origin_id);
$tmpobject = $objectsrc;
}
}
$tmpobject = $objectsrc;
}
}
$custcontact = '';
$contactarr = array();
@ -264,11 +264,11 @@ if ($action == 'presend')
if (is_array($contactarr) && count($contactarr) > 0) {
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
$contactstatic = new Contact($db);
$contactstatic = new Contact($db);
foreach ($contactarr as $contact) {
$contactstatic->fetch($contact['id']);
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
$contactstatic->fetch($contact['id']);
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
}
}

View File

@ -183,13 +183,13 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (empty($reshook))
{
$objectclass = 'Expedition';
$objectlabel = 'Sendings';
$permissiontoread = $user->rights->expedition->lire;
$permissiontoadd = $user->rights->expedition->creer;
$permissiontodelete = $user->rights->expedition->supprimer;
$uploaddir = $conf->expedition->dir_output.'/sending';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
$objectclass = 'Expedition';
$objectlabel = 'Sendings';
$permissiontoread = $user->rights->expedition->lire;
$permissiontoadd = $user->rights->expedition->creer;
$permissiontodelete = $user->rights->expedition->supprimer;
$uploaddir = $conf->expedition->dir_output.'/sending';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -313,7 +313,7 @@ if ($resql)
{
$num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array();
$arrayofselected = is_array($toselect) ? $toselect : array();
$expedition = new Expedition($db);
@ -341,18 +341,18 @@ if ($resql)
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
$arrayofmassactions = array(
'builddoc' => $langs->trans("PDFMerge"),
//'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged
'presend' => $langs->trans("SendByMail"),
);
if (in_array($massaction, array('presend'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$arrayofmassactions = array(
'builddoc' => $langs->trans("PDFMerge"),
//'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged
'presend' => $langs->trans("SendByMail"),
);
if (in_array($massaction, array('presend'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = '';
if ($user->rights->expedition->creer)
{
$newcardbutton .= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2');
$newcardbutton .= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2');
}
$i = 0;
@ -367,11 +367,11 @@ if ($resql)
print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
$topicmail = "SendShippingRef";
$modelmail = "shipping_send";
$objecttmp = new Expedition($db);
$trackid = 'shi'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
$topicmail = "SendShippingRef";
$modelmail = "shipping_send";
$objecttmp = new Expedition($db);
$trackid = 'shi'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall)
{
@ -583,7 +583,7 @@ if ($resql)
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
$typenArray = $formcompany->typent_array(1);
$typenArray = $formcompany->typent_array(1);
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
@ -736,48 +736,48 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
}
// Action column
print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
// Action column
print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;
}
$db->free($resql);
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>";
print "</div>";
print '</form>';
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
$filedir = $diroutputmassaction;
$genallowed = $user->rights->expedition->lire;
$delallowed = $user->rights->expedition->creer;
$title = '';
$filedir = $diroutputmassaction;
$genallowed = $user->rights->expedition->lire;
$delallowed = $user->rights->expedition->creer;
$title = '';
print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}
else
{
dol_print_error($db);
dol_print_error($db);
}
// End of page

File diff suppressed because it is too large Load Diff

View File

@ -35,9 +35,9 @@ dol_include_once('/mymodule/core/modules/mymodule/modules_myobject.php');
class mod_myobject_advanced extends ModeleNumRefMyObject
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
@ -51,14 +51,14 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
public $name = 'advanced';
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
*/
public function info()
{
global $conf, $langs, $db;
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
*/
public function info()
{
global $conf, $langs, $db;
$langs->load("bills");
@ -89,28 +89,28 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
$texte .= '</form>';
return $texte;
}
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $conf, $langs, $mysoc;
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $conf, $langs, $mysoc;
$object = new MyObject($this->db);
$object->initAsSpecimen();
$object = new MyObject($this->db);
$object->initAsSpecimen();
/*$old_code_client = $mysoc->code_client;
/*$old_code_client = $mysoc->code_client;
$old_code_type = $mysoc->typent_code;
$mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code = 'TTTTTTTTTT';*/
$numExample = $this->getNextValue($object);
$numExample = $this->getNextValue($object);
/*$mysoc->code_client = $old_code_client;
/*$mysoc->code_client = $old_code_client;
$mysoc->typent_code = $old_code_type;*/
if (!$numExample)
@ -118,7 +118,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
$numExample = $langs->trans('NotConfigured');
}
return $numExample;
}
}
/**
* Return next free value
@ -126,8 +126,8 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($object)
{
public function getNextValue($object)
{
global $db, $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

View File

@ -31,9 +31,9 @@ dol_include_once('/mymodule/core/modules/mymodule/modules_myobject.php');
class mod_myobject_standard extends ModeleNumRefMyObject
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix = 'MYOBJECT';
@ -49,16 +49,16 @@ class mod_myobject_standard extends ModeleNumRefMyObject
public $name = 'standard';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -73,8 +73,8 @@ class mod_myobject_standard extends ModeleNumRefMyObject
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @param Object $object Object we need next value for
* @return boolean false if conflict, true if ok
@ -151,8 +151,8 @@ class mod_myobject_standard extends ModeleNumRefMyObject
$date = $object->date_creation;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -38,17 +38,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
abstract class ModelePDFMyObject extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'mymodule_myobject';
@ -109,7 +109,7 @@ abstract class ModeleNumRefMyObject
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* cause conflicts that would prevent this numbering working.
*
* @param Object $object Object we need next value for
* @return boolean false if conflict, true if ok