Merge pull request #13497 from Dolibarr/scrutinizer-patch-4
Scrutinizer Auto-Fixes
This commit is contained in:
commit
aba401e37e
File diff suppressed because it is too large
Load Diff
@ -39,165 +39,165 @@
|
|||||||
*/
|
*/
|
||||||
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = '', $addfieldentry = array(), $delfieldentry = '')
|
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = '', $addfieldentry = array(), $delfieldentry = '')
|
||||||
{
|
{
|
||||||
global $db, $langs;
|
global $db, $langs;
|
||||||
|
|
||||||
if (empty($objectname)) return -1;
|
if (empty($objectname)) return -1;
|
||||||
if (empty($readdir)) $readdir = $destdir;
|
if (empty($readdir)) $readdir = $destdir;
|
||||||
|
|
||||||
if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval']))
|
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.');
|
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (count($addfieldentry) > 0)
|
if (count($addfieldentry) > 0)
|
||||||
{
|
{
|
||||||
if (empty($addfieldentry['name']))
|
if (empty($addfieldentry['name']))
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
if (empty($addfieldentry['label']))
|
if (empty($addfieldentry['label']))
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
|
if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
|
||||||
&& !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
|
&& !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
|
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
|
$pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
|
||||||
$pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
|
$pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
|
||||||
if (!dol_is_file($pathoffiletoeditsrc))
|
if (!dol_is_file($pathoffiletoeditsrc))
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
|
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp';
|
//$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp';
|
||||||
//dol_delete_file($pathoffiletoedittmp, 0, 1, 1);
|
//dol_delete_file($pathoffiletoedittmp, 0, 1, 1);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
include_once $pathoffiletoeditsrc;
|
include_once $pathoffiletoeditsrc;
|
||||||
if (class_exists($objectname)) $object = new $objectname($db);
|
if (class_exists($objectname)) $object = new $objectname($db);
|
||||||
else return -4;
|
else return -4;
|
||||||
|
|
||||||
// Backup old file
|
// Backup old file
|
||||||
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
|
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
|
||||||
|
|
||||||
// Edit class files
|
// Edit class files
|
||||||
$contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
|
$contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
|
||||||
|
|
||||||
// Update ->fields (add or remove entries)
|
// Update ->fields (add or remove entries)
|
||||||
if (count($object->fields))
|
if (count($object->fields))
|
||||||
{
|
{
|
||||||
if (is_array($addfieldentry) && count($addfieldentry))
|
if (is_array($addfieldentry) && count($addfieldentry))
|
||||||
{
|
{
|
||||||
$name = $addfieldentry['name'];
|
$name = $addfieldentry['name'];
|
||||||
unset($addfieldentry['name']);
|
unset($addfieldentry['name']);
|
||||||
|
|
||||||
$object->fields[$name] = $addfieldentry;
|
$object->fields[$name] = $addfieldentry;
|
||||||
}
|
}
|
||||||
if (!empty($delfieldentry))
|
if (!empty($delfieldentry))
|
||||||
{
|
{
|
||||||
$name = $delfieldentry;
|
$name = $delfieldentry;
|
||||||
unset($object->fields[$name]);
|
unset($object->fields[$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_sort_array($object->fields, 'position');
|
dol_sort_array($object->fields, 'position');
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
|
$texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
|
||||||
$texttoinsert .= "\t".'/**'."\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".' * @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".' */'."\n";
|
||||||
$texttoinsert .= "\t".'public $fields=array('."\n";
|
$texttoinsert .= "\t".'public $fields=array('."\n";
|
||||||
|
|
||||||
if (count($object->fields))
|
if (count($object->fields))
|
||||||
{
|
{
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
$texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
|
$texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
|
||||||
$texttoinsert .= " 'enabled'=>".($val['enabled'] !== '' ? $val['enabled'] : 1).",";
|
$texttoinsert .= " 'enabled'=>".($val['enabled'] !== '' ? $val['enabled'] : 1).",";
|
||||||
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
|
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
|
||||||
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
|
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
|
||||||
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
|
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
|
||||||
if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
|
if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
|
||||||
if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',";
|
if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',";
|
||||||
if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
|
if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
|
||||||
if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
|
if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
|
||||||
if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
|
if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
|
||||||
if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
|
if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
|
||||||
if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',";
|
if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',";
|
||||||
if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
|
if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
|
||||||
if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
|
if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
|
||||||
if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
|
if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
|
||||||
if ($val['arrayofkeyval'])
|
if ($val['arrayofkeyval'])
|
||||||
{
|
{
|
||||||
$texttoinsert .= " 'arrayofkeyval'=>array(";
|
$texttoinsert .= " 'arrayofkeyval'=>array(";
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($val['arrayofkeyval'] as $key2 => $val2)
|
foreach ($val['arrayofkeyval'] as $key2 => $val2)
|
||||||
{
|
{
|
||||||
if ($i) $texttoinsert .= ", ";
|
if ($i) $texttoinsert .= ", ";
|
||||||
$texttoinsert .= "'".$key2."'=>'".$val2."'";
|
$texttoinsert .= "'".$key2."'=>'".$val2."'";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$texttoinsert .= "),";
|
$texttoinsert .= "),";
|
||||||
}
|
}
|
||||||
if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
|
if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
|
||||||
|
|
||||||
$texttoinsert .= "),\n";
|
$texttoinsert .= "),\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$texttoinsert .= "\t".');'."\n";
|
$texttoinsert .= "\t".');'."\n";
|
||||||
//print ($texttoinsert);exit;
|
//print ($texttoinsert);exit;
|
||||||
|
|
||||||
if (count($object->fields))
|
if (count($object->fields))
|
||||||
{
|
{
|
||||||
//$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
|
//$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
|
||||||
|
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
//$typephp=$typetotypephp[$val['type']];
|
//$typephp=$typetotypephp[$val['type']];
|
||||||
$texttoinsert .= "\t".'public $'.$key.";";
|
$texttoinsert .= "\t".'public $'.$key.";";
|
||||||
//if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
|
//if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
|
||||||
//if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
|
//if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
|
||||||
//$texttoinsert.= ($val['notnull']?' NOT NULL':'');
|
//$texttoinsert.= ($val['notnull']?' NOT NULL':'');
|
||||||
//if ($i < count($object->fields)) $texttoinsert.=";";
|
//if ($i < count($object->fields)) $texttoinsert.=";";
|
||||||
$texttoinsert .= "\n";
|
$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($pathoffiletoedittmp, $contentclass);
|
||||||
file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass);
|
file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass);
|
||||||
@chmod($pathoffiletoedittarget, octdec($newmask));
|
@chmod($pathoffiletoedittarget, octdec($newmask));
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
print $e->getMessage();
|
print $e->getMessage();
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -214,134 +214,134 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
|
|||||||
*/
|
*/
|
||||||
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '', $object = null)
|
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($objectname)) return -1;
|
||||||
if (empty($readdir)) $readdir = $destdir;
|
if (empty($readdir)) $readdir = $destdir;
|
||||||
|
|
||||||
$pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
|
$pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
|
||||||
|
|
||||||
// Edit .sql file
|
// Edit .sql file
|
||||||
$pathoffiletoeditsrc = $readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
|
$pathoffiletoeditsrc = $readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
|
||||||
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
|
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
|
||||||
if (!dol_is_file($pathoffiletoeditsrc))
|
if (!dol_is_file($pathoffiletoeditsrc))
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
|
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load object from myobject.class.php
|
// Load object from myobject.class.php
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!is_object($object))
|
if (!is_object($object))
|
||||||
{
|
{
|
||||||
include_once $pathoffiletoclasssrc;
|
include_once $pathoffiletoclasssrc;
|
||||||
if (class_exists($objectname)) $object = new $objectname($db);
|
if (class_exists($objectname)) $object = new $objectname($db);
|
||||||
else return -1;
|
else return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
print $e->getMessage();
|
print $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backup old file
|
// Backup old file
|
||||||
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
|
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;
|
$i = 0;
|
||||||
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
|
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
|
||||||
if (count($object->fields))
|
if (count($object->fields))
|
||||||
{
|
{
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
$type = $val['type'];
|
$type = $val['type'];
|
||||||
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
|
$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
|
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 ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
|
||||||
elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
|
elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
|
||||||
$texttoinsert .= "\t".$key." ".$type;
|
$texttoinsert .= "\t".$key." ".$type;
|
||||||
if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
|
if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
|
||||||
if ($key == 'entity') $texttoinsert .= ' DEFAULT 1';
|
if ($key == 'entity') $texttoinsert .= ' DEFAULT 1';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($val['default'] != '')
|
if ($val['default'] != '')
|
||||||
{
|
{
|
||||||
if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL";
|
if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL";
|
||||||
elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
|
elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
|
||||||
else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
|
else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
|
$texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
|
||||||
if ($i < count($object->fields)) $texttoinsert .= ", ";
|
if ($i < count($object->fields)) $texttoinsert .= ", ";
|
||||||
$texttoinsert .= "\n";
|
$texttoinsert .= "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$texttoinsert .= "\t".'-- END MODULEBUILDER FIELDS';
|
$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);
|
$result = file_put_contents($pathoffiletoedittarget, $contentsql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@chmod($pathoffiletoedittarget, octdec($newmask));
|
@chmod($pathoffiletoedittarget, octdec($newmask));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit .key.sql file
|
// Edit .key.sql file
|
||||||
$pathoffiletoeditsrc = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql';
|
$pathoffiletoeditsrc = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql';
|
||||||
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
|
$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;
|
$i = 0;
|
||||||
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
|
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
|
||||||
if (count($object->fields))
|
if (count($object->fields))
|
||||||
{
|
{
|
||||||
foreach ($object->fields as $key => $val)
|
foreach ($object->fields as $key => $val)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
if (!empty($val['index']))
|
if (!empty($val['index']))
|
||||||
{
|
{
|
||||||
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
|
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
|
||||||
$texttoinsert .= "\n";
|
$texttoinsert .= "\n";
|
||||||
}
|
}
|
||||||
if (!empty($val['foreignkey']))
|
if (!empty($val['foreignkey']))
|
||||||
{
|
{
|
||||||
$tmp = explode('.', $val['foreignkey']);
|
$tmp = explode('.', $val['foreignkey']);
|
||||||
if (!empty($tmp[0]) && !empty($tmp[1]))
|
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 .= "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 .= "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$texttoinsert .= '-- END MODULEBUILDER INDEXES';
|
$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);
|
$result2 = file_put_contents($pathoffiletoedittarget, $contentsql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@chmod($pathoffiletoedittarget, octdec($newmask));
|
@chmod($pathoffiletoedittarget, octdec($newmask));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error ? -1 : 1;
|
return $error ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php';
|
|||||||
class mod_bom_standard extends ModeleNumRefboms
|
class mod_bom_standard extends ModeleNumRefboms
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='BOM';
|
public $prefix='BOM';
|
||||||
@ -48,16 +48,16 @@ class mod_bom_standard extends ModeleNumRefboms
|
|||||||
public $name='standard';
|
public $name='standard';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
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
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
@ -140,8 +140,8 @@ class mod_bom_standard extends ModeleNumRefboms
|
|||||||
$date=$object->date_creation;
|
$date=$object->date_creation;
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max+1);
|
||||||
|
|
||||||
dol_syslog("mod_bom_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
|
dol_syslog("mod_bom_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
return $this->prefix.$yymm."-".$num;
|
return $this->prefix.$yymm."-".$num;
|
||||||
|
|||||||
@ -39,17 +39,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
|
|||||||
abstract class ModelePDFBom extends CommonDocGenerator
|
abstract class ModelePDFBom extends CommonDocGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type = 'bom';
|
$type = 'bom';
|
||||||
@ -110,7 +110,7 @@ abstract class ModeleNumRefBoms
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php
|
|||||||
class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
|
class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='CHK';
|
public $prefix='CHK';
|
||||||
@ -45,16 +45,16 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
|
|||||||
public $name='Mint';
|
public $name='Mint';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
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
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
@ -137,15 +137,15 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
|
|||||||
$date=$object->date_bordereau;
|
$date=$object->date_bordereau;
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max+1);
|
||||||
|
|
||||||
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
|
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
|
||||||
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
|
* Return next free value
|
||||||
*
|
*
|
||||||
@ -155,7 +155,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
|
|||||||
*/
|
*/
|
||||||
public function chequereceipt_get_num($objsoc, $objforref)
|
public function chequereceipt_get_num($objsoc, $objforref)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return $this->getNextValue($objsoc, $objforref);
|
return $this->getNextValue($objsoc, $objforref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,11 +76,11 @@ abstract class ModeleNumRefChequeReceipts
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -128,17 +128,17 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator
|
|||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type='chequereceipt';
|
$type='chequereceipt';
|
||||||
|
|||||||
@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
|
|||||||
class mod_commande_marbre extends ModeleNumRefCommandes
|
class mod_commande_marbre extends ModeleNumRefCommandes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='CO';
|
public $prefix='CO';
|
||||||
@ -48,16 +48,16 @@ class mod_commande_marbre extends ModeleNumRefCommandes
|
|||||||
public $name='Marbre';
|
public $name='Marbre';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
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
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
@ -140,15 +140,15 @@ class mod_commande_marbre extends ModeleNumRefCommandes
|
|||||||
$date=$object->date;
|
$date=$object->date;
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max+1);
|
||||||
|
|
||||||
dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
|
dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
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
|
* Return next free value
|
||||||
*
|
*
|
||||||
@ -158,7 +158,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
|
|||||||
*/
|
*/
|
||||||
public function commande_get_num($objsoc, $objforref)
|
public function commande_get_num($objsoc, $objforref)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return $this->getNextValue($objsoc, $objforref);
|
return $this->getNextValue($objsoc, $objforref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,17 +40,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
|
|||||||
abstract class ModelePDFCommandes extends CommonDocGenerator
|
abstract class ModelePDFCommandes extends CommonDocGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type = 'order';
|
$type = 'order';
|
||||||
@ -111,7 +111,7 @@ abstract class ModeleNumRefCommandes
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -34,32 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
|||||||
*/
|
*/
|
||||||
abstract class ModeleDon extends CommonDocGenerator
|
abstract class ModeleDon extends CommonDocGenerator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type='donation';
|
$type='donation';
|
||||||
$liste=array();
|
$liste=array();
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
$liste=getListOfModels($db, $type, $maxfilenamelength);
|
$liste=getListOfModels($db, $type, $maxfilenamelength);
|
||||||
|
|
||||||
return $liste;
|
return $liste;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,81 +68,81 @@ abstract class ModeleDon extends CommonDocGenerator
|
|||||||
*/
|
*/
|
||||||
abstract class ModeleNumRefDons
|
abstract class ModeleNumRefDons
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if a module can be used or not
|
* Return if a module can be used or not
|
||||||
*
|
*
|
||||||
* @return boolean true if module can be used
|
* @return boolean true if module can be used
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi la description par defaut du modele de numerotation
|
* Renvoi la description par defaut du modele de numerotation
|
||||||
*
|
*
|
||||||
* @return string Texte descripif
|
* @return string Texte descripif
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
return $langs->trans("NoDescription");
|
return $langs->trans("NoDescription");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of numbering
|
* Return an example of numbering
|
||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
return $langs->trans("NoExample");
|
return $langs->trans("NoExample");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi prochaine valeur attribuee
|
* Renvoi prochaine valeur attribuee
|
||||||
*
|
*
|
||||||
* @return string Valeur
|
* @return string Valeur
|
||||||
*/
|
*/
|
||||||
public function getNextValue()
|
public function getNextValue()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("NotAvailable");
|
return $langs->trans("NotAvailable");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi version du module numerotation
|
* Renvoi version du module numerotation
|
||||||
*
|
*
|
||||||
* @return string Valeur
|
* @return string Valeur
|
||||||
*/
|
*/
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,9 +29,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/expensereport/modules_expenserepo
|
|||||||
class mod_expensereport_jade extends ModeleNumRefExpenseReport
|
class mod_expensereport_jade extends ModeleNumRefExpenseReport
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='ER';
|
public $prefix='ER';
|
||||||
@ -54,16 +54,16 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
|
|||||||
public $name='Jade';
|
public $name='Jade';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering model
|
* Return description of numbering model
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,19 +71,19 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
|
|||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
return $this->prefix."0501-0001";
|
return $this->prefix."0501-0001";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
global $conf,$langs,$db;
|
global $conf,$langs,$db;
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
|
|||||||
* @param Object $object Object we need next value for
|
* @param Object $object Object we need next value for
|
||||||
* @return string Value if KO, <0 if KO
|
* @return string Value if KO, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function getNextValue($object)
|
public function getNextValue($object)
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
|
|
||||||
@ -139,19 +139,19 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
|
|||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if ($db->num_rows($result) > 0) {
|
if ($db->num_rows($result) > 0) {
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
$newref = $objp->max;
|
$newref = $objp->max;
|
||||||
$newref++;
|
$newref++;
|
||||||
while (strlen($newref) < $num_car) {
|
while (strlen($newref) < $num_car) {
|
||||||
$newref = "0".$newref;
|
$newref = "0".$newref;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$newref = 1;
|
$newref = 1;
|
||||||
while (strlen($newref) < $num_car) {
|
while (strlen($newref) < $num_car) {
|
||||||
$newref = "0".$newref;
|
$newref = "0".$newref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ref_number_int = ($newref+1)-1;
|
$ref_number_int = ($newref+1)-1;
|
||||||
|
|
||||||
@ -202,8 +202,8 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
|
|||||||
|
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max+1);
|
||||||
|
|
||||||
dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
|
dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
return $this->prefix.$yymm."-".$num;
|
return $this->prefix.$yymm."-".$num;
|
||||||
|
|||||||
@ -46,17 +46,17 @@ abstract class ModelePDFFactures extends CommonDocGenerator
|
|||||||
public $atleastoneratenotnull = 0;
|
public $atleastoneratenotnull = 0;
|
||||||
|
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type = 'invoice';
|
$type = 'invoice';
|
||||||
@ -114,8 +114,8 @@ abstract class ModeleNumRefFactures
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -40,17 +40,17 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator
|
|||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type='ficheinter';
|
$type='ficheinter';
|
||||||
@ -109,8 +109,8 @@ abstract class ModeleNumRefFicheinter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @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)
|
function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf,$langs,$user;
|
global $conf,$langs,$user;
|
||||||
$langs->load("ficheinter");
|
$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")
|
// If selected modele is a filename template (then $modele="modelname:filename")
|
||||||
$tmp=explode(':', $modele, 2);
|
$tmp=explode(':', $modele, 2);
|
||||||
if (! empty($tmp[1]))
|
if (! empty($tmp[1]))
|
||||||
{
|
{
|
||||||
$modele=$tmp[0];
|
$modele=$tmp[0];
|
||||||
$srctemplatepath=$tmp[1];
|
$srctemplatepath=$tmp[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search template files
|
// Search template files
|
||||||
$file=''; $classname=''; $filefound=0;
|
$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']);
|
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']);
|
||||||
foreach($dirmodels as $reldir)
|
foreach($dirmodels as $reldir)
|
||||||
{
|
{
|
||||||
foreach(array('doc','pdf') as $prefix)
|
foreach(array('doc','pdf') as $prefix)
|
||||||
{
|
{
|
||||||
$file = $prefix."_".$modele.".modules.php";
|
$file = $prefix."_".$modele.".modules.php";
|
||||||
|
|
||||||
// On verifie l'emplacement du modele
|
// On verifie l'emplacement du modele
|
||||||
$file=dol_buildpath($reldir."core/modules/fichinter/doc/".$file, 0);
|
$file=dol_buildpath($reldir."core/modules/fichinter/doc/".$file, 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound=1;
|
||||||
$classname=$prefix.'_'.$modele;
|
$classname=$prefix.'_'.$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($filefound) break;
|
if ($filefound) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Charge le modele
|
// Charge le modele
|
||||||
if ($filefound)
|
if ($filefound)
|
||||||
|
|||||||
@ -35,9 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php';
|
|||||||
class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +57,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
|||||||
*/
|
*/
|
||||||
public $name = 'Jade';
|
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 an example of numbering
|
||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
return $this->prefix."0501-0001";
|
return $this->prefix."0501-0001";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
global $langs, $conf, $db;
|
global $langs, $conf, $db;
|
||||||
|
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
// Check invoice num
|
// Check invoice num
|
||||||
$fayymm = ''; $max = '';
|
$fayymm = ''; $max = '';
|
||||||
|
|
||||||
$posindice = 8;
|
$posindice = 8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
|
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
|
||||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; }
|
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))
|
if ($fayymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm))
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->error = $langs->trans('ErrorNumRefModel', $max);
|
$this->error = $langs->trans('ErrorNumRefModel', $max);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next free value
|
* Return next free value
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object thirdparty
|
* @param Societe $objsoc Object thirdparty
|
||||||
* @param Object $object Object we need next value for
|
* @param Object $object Object we need next value for
|
||||||
* @return string Value if KO, <0 if KO
|
* @return string Value if KO, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objsoc, $object)
|
public function getNextValue($objsoc, $object)
|
||||||
{
|
{
|
||||||
global $db, $conf;
|
global $db, $conf;
|
||||||
|
|
||||||
// D'abord on recupere la valeur max
|
// D'abord on recupere la valeur max
|
||||||
$posindice = 8;
|
$posindice = 8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
|
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
|
||||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG);
|
dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
if ($obj) $max = intval($obj->max);
|
if ($obj) $max = intval($obj->max);
|
||||||
else $max = 0;
|
else $max = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = $object->date_delivery;
|
$date = $object->date_delivery;
|
||||||
if (empty($date)) $date = dol_now();
|
if (empty($date)) $date = dol_now();
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max + 1);
|
||||||
|
|
||||||
dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
|
dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
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 ref
|
* Return next free ref
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object thirdparty
|
* @param Societe $objsoc Object thirdparty
|
||||||
* @param Object $object Object livraison
|
* @param Object $object Object livraison
|
||||||
* @return string Texte descriptif
|
* @return string Texte descriptif
|
||||||
*/
|
*/
|
||||||
public function livraison_get_num($objsoc = 0, $object = '')
|
public function livraison_get_num($objsoc = 0, $object = '')
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return $this->getNextValue($objsoc, $object);
|
return $this->getNextValue($objsoc, $object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,32 +36,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
|
|||||||
*/
|
*/
|
||||||
abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
|
abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type='delivery';
|
$type='delivery';
|
||||||
$liste=array();
|
$liste=array();
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
$liste=getListOfModels($db, $type, $maxfilenamelength);
|
$liste=getListOfModels($db, $type, $maxfilenamelength);
|
||||||
|
|
||||||
return $liste;
|
return $liste;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -72,83 +72,83 @@ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
|
|||||||
*/
|
*/
|
||||||
abstract class ModeleNumRefDeliveryOrder
|
abstract class ModeleNumRefDeliveryOrder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if a module can be used or not
|
* Return if a module can be used or not
|
||||||
*
|
*
|
||||||
* @return boolean true if module can be used
|
* @return boolean true if module can be used
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi la description par defaut du modele de numerotation
|
* Renvoi la description par defaut du modele de numerotation
|
||||||
*
|
*
|
||||||
* @return string Texte descripif
|
* @return string Texte descripif
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("deliveries");
|
$langs->load("deliveries");
|
||||||
return $langs->trans("NoDescription");
|
return $langs->trans("NoDescription");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of numbering
|
* Return an example of numbering
|
||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("deliveries");
|
$langs->load("deliveries");
|
||||||
return $langs->trans("NoExample");
|
return $langs->trans("NoExample");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi prochaine valeur attribuee
|
* Renvoi prochaine valeur attribuee
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object third party
|
* @param Societe $objsoc Object third party
|
||||||
* @param Object $object Object delivery
|
* @param Object $object Object delivery
|
||||||
* @return string Valeur
|
* @return string Valeur
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objsoc, $object)
|
public function getNextValue($objsoc, $object)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("NotAvailable");
|
return $langs->trans("NotAvailable");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi version du module numerotation
|
* Renvoi version du module numerotation
|
||||||
*
|
*
|
||||||
* @return string Valeur
|
* @return string Valeur
|
||||||
*/
|
*/
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
|
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
|
||||||
elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental");
|
elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental");
|
||||||
elseif ($this->version == 'dolibarr') return DOL_VERSION;
|
elseif ($this->version == 'dolibarr') return DOL_VERSION;
|
||||||
elseif ($this->version) return $this->version;
|
elseif ($this->version) return $this->version;
|
||||||
else return $langs->trans("NotAvailable");
|
else return $langs->trans("NotAvailable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php';
|
|||||||
class mod_mo_standard extends ModeleNumRefMos
|
class mod_mo_standard extends ModeleNumRefMos
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix = 'MO';
|
public $prefix = 'MO';
|
||||||
@ -48,16 +48,16 @@ class mod_mo_standard extends ModeleNumRefMos
|
|||||||
public $name = 'standard';
|
public $name = 'standard';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
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
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
@ -140,8 +140,8 @@ class mod_mo_standard extends ModeleNumRefMos
|
|||||||
$date = $object->date_creation;
|
$date = $object->date_creation;
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max + 1);
|
||||||
|
|
||||||
dol_syslog("mod_mo_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
|
dol_syslog("mod_mo_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
return $this->prefix.$yymm."-".$num;
|
return $this->prefix.$yymm."-".$num;
|
||||||
|
|||||||
@ -39,17 +39,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
|
|||||||
abstract class ModelePDFMo extends CommonDocGenerator
|
abstract class ModelePDFMo extends CommonDocGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type = 'mo';
|
$type = 'mo';
|
||||||
@ -110,7 +110,7 @@ abstract class ModeleNumRefMos
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php';
|
|||||||
class mod_payment_cicada extends ModeleNumRefPayments
|
class mod_payment_cicada extends ModeleNumRefPayments
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='PAY';
|
public $prefix='PAY';
|
||||||
@ -55,16 +55,16 @@ class mod_payment_cicada extends ModeleNumRefPayments
|
|||||||
public $name='Cicada';
|
public $name='Cicada';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
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
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
@ -147,15 +147,15 @@ class mod_payment_cicada extends ModeleNumRefPayments
|
|||||||
$date=$object->datepaye;
|
$date=$object->datepaye;
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max+1);
|
||||||
|
|
||||||
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
|
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
|
||||||
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
|
* Return next free value
|
||||||
*
|
*
|
||||||
@ -165,7 +165,7 @@ class mod_payment_cicada extends ModeleNumRefPayments
|
|||||||
*/
|
*/
|
||||||
public function payment_get_num($objsoc, $objforref)
|
public function payment_get_num($objsoc, $objforref)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return $this->getNextValue($objsoc, $objforref);
|
return $this->getNextValue($objsoc, $objforref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,11 +63,11 @@ abstract class ModeleNumRefPayments
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -33,226 +33,226 @@
|
|||||||
*/
|
*/
|
||||||
abstract class ModelePDFProduct extends CommonDocGenerator
|
abstract class ModelePDFProduct extends CommonDocGenerator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type='product';
|
$type='product';
|
||||||
$liste=array();
|
$liste=array();
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
$liste=getListOfModels($db, $type, $maxfilenamelength);
|
$liste=getListOfModels($db, $type, $maxfilenamelength);
|
||||||
return $liste;
|
return $liste;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ModeleProductCode
|
abstract class ModeleProductCode
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
/** Renvoi la description par defaut du modele de numerotation
|
/** Renvoi la description par defaut du modele de numerotation
|
||||||
*
|
*
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @return string Texte descripif
|
* @return string Texte descripif
|
||||||
*/
|
*/
|
||||||
public function info($langs)
|
public function info($langs)
|
||||||
{
|
{
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
return $langs->trans("NoDescription");
|
return $langs->trans("NoDescription");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Renvoi nom module
|
/** Renvoi nom module
|
||||||
*
|
*
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @return string Nom du module
|
* @return string Nom du module
|
||||||
*/
|
*/
|
||||||
public function getNom($langs)
|
public function getNom($langs)
|
||||||
{
|
{
|
||||||
return empty($this->name)?$this->nom:$this->name;
|
return empty($this->name)?$this->nom:$this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Return an example of numbering
|
/** Return an example of numbering
|
||||||
*
|
*
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample($langs)
|
public function getExample($langs)
|
||||||
{
|
{
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
return $langs->trans("NoExample");
|
return $langs->trans("NoExample");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next value available
|
* Return next value available
|
||||||
*
|
*
|
||||||
* @param Product $objproduct Object product
|
* @param Product $objproduct Object product
|
||||||
* @param int $type Type
|
* @param int $type Type
|
||||||
* @return string Value
|
* @return string Value
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objproduct = 0, $type = -1)
|
public function getNextValue($objproduct = 0, $type = -1)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("Function_getNextValue_InModuleNotWorking");
|
return $langs->trans("Function_getNextValue_InModuleNotWorking");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Return version of module
|
/** Return version of module
|
||||||
*
|
*
|
||||||
* @return string Version
|
* @return string Version
|
||||||
*/
|
*/
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$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");
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Renvoi la liste des modeles de numérotation
|
* Renvoi la liste des modeles de numérotation
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of numbers
|
* @return array List of numbers
|
||||||
*/
|
*/
|
||||||
public static function liste_modeles($db, $maxfilenamelength = 0)
|
public static function liste_modeles($db, $maxfilenamelength = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
$liste=array();
|
$liste=array();
|
||||||
$sql ="";
|
$sql ="";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$liste[$row[0]]=$row[1];
|
$liste[$row[0]]=$row[1];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return $liste;
|
return $liste;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of module parameters
|
* Return description of module parameters
|
||||||
*
|
*
|
||||||
* @param Translate $langs Output language
|
* @param Translate $langs Output language
|
||||||
* @param Product $product Product object
|
* @param Product $product Product object
|
||||||
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
|
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
|
||||||
* @return string HTML translated description
|
* @return string HTML translated description
|
||||||
*/
|
*/
|
||||||
public function getToolTip($langs, $product, $type)
|
public function getToolTip($langs, $product, $type)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
$s='';
|
$s='';
|
||||||
if ($type == -1) {
|
if ($type == -1) {
|
||||||
$s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
|
$s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
|
||||||
$s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
$s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
||||||
}
|
}
|
||||||
if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>';
|
if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>';
|
||||||
if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>';
|
if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>';
|
||||||
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
|
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
|
||||||
$s.='<br>';
|
$s.='<br>';
|
||||||
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
||||||
if ($type == 0)
|
if ($type == 0)
|
||||||
{
|
{
|
||||||
$s.=$langs->trans("RequiredIfProduct").': ';
|
$s.=$langs->trans("RequiredIfProduct").': ';
|
||||||
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
||||||
$s.=yn(!$this->code_null, 1, 2);
|
$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")).')';
|
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.='<br>';
|
||||||
}
|
}
|
||||||
elseif ($type == 1)
|
elseif ($type == 1)
|
||||||
{
|
{
|
||||||
$s.=$langs->trans("RequiredIfService").': ';
|
$s.=$langs->trans("RequiredIfService").': ';
|
||||||
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
||||||
$s.=yn(!$this->code_null, 1, 2);
|
$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")).')';
|
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.='<br>';
|
||||||
}
|
}
|
||||||
elseif ($type == -1)
|
elseif ($type == -1)
|
||||||
{
|
{
|
||||||
$s.=$langs->trans("Required").': ';
|
$s.=$langs->trans("Required").': ';
|
||||||
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
||||||
$s.=yn(!$this->code_null, 1, 2);
|
$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")).')';
|
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.='<br>';
|
||||||
}
|
}
|
||||||
$s.=$langs->trans("CanBeModifiedIfOk").': ';
|
$s.=$langs->trans("CanBeModifiedIfOk").': ';
|
||||||
$s.=yn($this->code_modifiable, 1, 2);
|
$s.=yn($this->code_modifiable, 1, 2);
|
||||||
$s.='<br>';
|
$s.='<br>';
|
||||||
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<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.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
|
||||||
$s.='<br>';
|
$s.='<br>';
|
||||||
if ($type == 0 || $type == -1)
|
if ($type == 0 || $type == -1)
|
||||||
{
|
{
|
||||||
$nextval=$this->getNextValue($product, 0);
|
$nextval=$this->getNextValue($product, 0);
|
||||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
|
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
|
||||||
}
|
}
|
||||||
if ($type == 1 || $type == -1)
|
if ($type == 1 || $type == -1)
|
||||||
{
|
{
|
||||||
$nextval=$this->getNextValue($product, 1);
|
$nextval=$this->getNextValue($product, 1);
|
||||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
|
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
|
||||||
}
|
}
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Check if mask/numbering use prefix
|
* Check if mask/numbering use prefix
|
||||||
*
|
*
|
||||||
* @return int 0=no, 1=yes
|
* @return int 0=no, 1=yes
|
||||||
*/
|
*/
|
||||||
public function verif_prefixIsUsed()
|
public function verif_prefixIsUsed()
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,14 +32,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php';
|
|||||||
class mod_project_simple extends ModeleNumRefProjects
|
class mod_project_simple extends ModeleNumRefProjects
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='PJ';
|
public $prefix='PJ';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
@ -57,74 +57,74 @@ class mod_project_simple extends ModeleNumRefProjects
|
|||||||
public $name='Simple';
|
public $name='Simple';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of numbering module values
|
* Return an example of numbering module values
|
||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
return $this->prefix."0501-0001";
|
return $this->prefix."0501-0001";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
global $conf,$langs,$db;
|
global $conf,$langs,$db;
|
||||||
|
|
||||||
$coyymm=''; $max='';
|
$coyymm=''; $max='';
|
||||||
|
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
$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.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
|
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))
|
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->error=$langs->trans('ErrorNumRefModel', $max);
|
$this->error=$langs->trans('ErrorNumRefModel', $max);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next value
|
* Return next value
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object third party
|
* @param Societe $objsoc Object third party
|
||||||
* @param Project $project Object project
|
* @param Project $project Object project
|
||||||
* @return string Value if OK, 0 if KO
|
* @return string Value if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objsoc, $project)
|
public function getNextValue($objsoc, $project)
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
|
|
||||||
// D'abord on recupere la valeur max
|
// 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);
|
dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
return $this->prefix.$yymm."-".$num;
|
return $this->prefix.$yymm."-".$num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return next reference not yet used as a reference
|
* Return next reference not yet used as a reference
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object third party
|
* @param Societe $objsoc Object third party
|
||||||
* @param Project $project Object project
|
* @param Project $project Object project
|
||||||
* @return string Next not used reference
|
* @return string Next not used reference
|
||||||
*/
|
*/
|
||||||
public function project_get_num($objsoc = 0, $project = '')
|
public function project_get_num($objsoc = 0, $project = '')
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return $this->getNextValue($objsoc, $project);
|
return $this->getNextValue($objsoc, $project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,14 +32,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
|
|||||||
class mod_task_simple extends ModeleNumRefTask
|
class mod_task_simple extends ModeleNumRefTask
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='TK';
|
public $prefix='TK';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
@ -57,40 +57,40 @@ class mod_task_simple extends ModeleNumRefTask
|
|||||||
public $name='Simple';
|
public $name='Simple';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of numbering module values
|
* Return an example of numbering module values
|
||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
return $this->prefix."0501-0001";
|
return $this->prefix."0501-0001";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
global $conf,$langs,$db;
|
global $conf,$langs,$db;
|
||||||
|
|
||||||
$coyymm=''; $max='';
|
$coyymm=''; $max='';
|
||||||
|
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
|
$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 .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
|
||||||
$sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
|
$sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
|
||||||
$sql .= " AND project.entity = " . $conf->entity;
|
$sql .= " AND project.entity = " . $conf->entity;
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
|
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))
|
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->error=$langs->trans('ErrorNumRefModel', $max);
|
$this->error=$langs->trans('ErrorNumRefModel', $max);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next value
|
* Return next value
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object third party
|
* @param Societe $objsoc Object third party
|
||||||
* @param Task $object Object Task
|
* @param Task $object Object Task
|
||||||
* @return string Value if OK, 0 if KO
|
* @return string Value if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objsoc, $object)
|
public function getNextValue($objsoc, $object)
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
|
|
||||||
// D'abord on recupere la valeur max
|
// 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);
|
dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
return $this->prefix.$yymm."-".$num;
|
return $this->prefix.$yymm."-".$num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return next reference not yet used as a reference
|
* Return next reference not yet used as a reference
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object third party
|
* @param Societe $objsoc Object third party
|
||||||
* @param Task $object Object task
|
* @param Task $object Object task
|
||||||
* @return string Next not used reference
|
* @return string Next not used reference
|
||||||
*/
|
*/
|
||||||
public function task_get_num($objsoc = 0, $object = '')
|
public function task_get_num($objsoc = 0, $object = '')
|
||||||
{
|
{
|
||||||
return $this->getNextValue($objsoc, $object);
|
return $this->getNextValue($objsoc, $object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php';
|
|||||||
class mod_propale_marbre extends ModeleNumRefPropales
|
class mod_propale_marbre extends ModeleNumRefPropales
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='PR';
|
public $prefix='PR';
|
||||||
@ -57,16 +57,16 @@ class mod_propale_marbre extends ModeleNumRefPropales
|
|||||||
public $name='Marbre';
|
public $name='Marbre';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
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
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -33,32 +33,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
|
|||||||
*/
|
*/
|
||||||
abstract class ModeleThirdPartyDoc extends CommonDocGenerator
|
abstract class ModeleThirdPartyDoc extends CommonDocGenerator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type='company';
|
$type='company';
|
||||||
$liste=array();
|
$liste=array();
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
$liste = getListOfModels($db, $type, $maxfilenamelength);
|
$liste = getListOfModels($db, $type, $maxfilenamelength);
|
||||||
|
|
||||||
return $liste;
|
return $liste;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,197 +67,197 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator
|
|||||||
*/
|
*/
|
||||||
abstract class ModeleThirdPartyCode
|
abstract class ModeleThirdPartyCode
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
/** Renvoi la description par defaut du modele de numerotation
|
/** Renvoi la description par defaut du modele de numerotation
|
||||||
*
|
*
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @return string Texte descripif
|
* @return string Texte descripif
|
||||||
*/
|
*/
|
||||||
public function info($langs)
|
public function info($langs)
|
||||||
{
|
{
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
return $langs->trans("NoDescription");
|
return $langs->trans("NoDescription");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return name of module
|
/** Return name of module
|
||||||
*
|
*
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @return string Nom du module
|
* @return string Nom du module
|
||||||
*/
|
*/
|
||||||
public function getNom($langs)
|
public function getNom($langs)
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Return an example of numbering
|
/** Return an example of numbering
|
||||||
*
|
*
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample($langs)
|
public function getExample($langs)
|
||||||
{
|
{
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
return $langs->trans("NoExample");
|
return $langs->trans("NoExample");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next value available
|
* Return next value available
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object thirdparty
|
* @param Societe $objsoc Object thirdparty
|
||||||
* @param int $type Type
|
* @param int $type Type
|
||||||
* @return string Value
|
* @return string Value
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objsoc = 0, $type = -1)
|
public function getNextValue($objsoc = 0, $type = -1)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("Function_getNextValue_InModuleNotWorking");
|
return $langs->trans("Function_getNextValue_InModuleNotWorking");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return version of module
|
* Return version of module
|
||||||
*
|
*
|
||||||
* @return string Version
|
* @return string Version
|
||||||
*/
|
*/
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$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");
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Renvoie la liste des modeles de numérotation
|
* Renvoie la liste des modeles de numérotation
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of numbers
|
* @return array List of numbers
|
||||||
*/
|
*/
|
||||||
public static function liste_modeles($db, $maxfilenamelength = 0)
|
public static function liste_modeles($db, $maxfilenamelength = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
$liste=array();
|
$liste=array();
|
||||||
$sql ="";
|
$sql ="";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$liste[$row[0]]=$row[1];
|
$liste[$row[0]]=$row[1];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return $liste;
|
return $liste;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of module parameters
|
* Return description of module parameters
|
||||||
*
|
*
|
||||||
* @param Translate $langs Output language
|
* @param Translate $langs Output language
|
||||||
* @param Societe $soc Third party object
|
* @param Societe $soc Third party object
|
||||||
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
|
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
|
||||||
* @return string HTML translated description
|
* @return string HTML translated description
|
||||||
*/
|
*/
|
||||||
public function getToolTip($langs, $soc, $type)
|
public function getToolTip($langs, $soc, $type)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
$s='';
|
$s='';
|
||||||
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
|
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 == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
||||||
if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
|
if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
|
||||||
if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
|
if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
|
||||||
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
|
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
|
||||||
$s.='<br>';
|
$s.='<br>';
|
||||||
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
||||||
if ($type == 0)
|
if ($type == 0)
|
||||||
{
|
{
|
||||||
$s.=$langs->trans("RequiredIfCustomer").': ';
|
$s.=$langs->trans("RequiredIfCustomer").': ';
|
||||||
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
||||||
$s.=yn(!$this->code_null, 1, 2);
|
$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")).')';
|
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.='<br>';
|
||||||
}
|
}
|
||||||
if ($type == 1)
|
if ($type == 1)
|
||||||
{
|
{
|
||||||
$s.=$langs->trans("RequiredIfSupplier").': ';
|
$s.=$langs->trans("RequiredIfSupplier").': ';
|
||||||
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
||||||
$s.=yn(!$this->code_null, 1, 2);
|
$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")).')';
|
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.='<br>';
|
||||||
}
|
}
|
||||||
if ($type == -1)
|
if ($type == -1)
|
||||||
{
|
{
|
||||||
$s.=$langs->trans("Required").': ';
|
$s.=$langs->trans("Required").': ';
|
||||||
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
|
||||||
$s.=yn(!$this->code_null, 1, 2);
|
$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")).')';
|
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.='<br>';
|
||||||
}
|
}
|
||||||
$s.=$langs->trans("CanBeModifiedIfOk").': ';
|
$s.=$langs->trans("CanBeModifiedIfOk").': ';
|
||||||
$s.=yn($this->code_modifiable, 1, 2);
|
$s.=yn($this->code_modifiable, 1, 2);
|
||||||
$s.='<br>';
|
$s.='<br>';
|
||||||
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<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.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
|
||||||
$s.='<br>';
|
$s.='<br>';
|
||||||
if ($type == 0 || $type == -1)
|
if ($type == 0 || $type == -1)
|
||||||
{
|
{
|
||||||
$nextval=$this->getNextValue($soc, 0);
|
$nextval=$this->getNextValue($soc, 0);
|
||||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
|
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
|
||||||
}
|
}
|
||||||
if ($type == 1 || $type == -1)
|
if ($type == 1 || $type == -1)
|
||||||
{
|
{
|
||||||
$nextval=$this->getNextValue($soc, 1);
|
$nextval=$this->getNextValue($soc, 1);
|
||||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
|
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
|
||||||
}
|
}
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Check if mask/numbering use prefix
|
* Check if mask/numbering use prefix
|
||||||
*
|
*
|
||||||
* @return int 0=no, 1=yes
|
* @return int 0=no, 1=yes
|
||||||
*/
|
*/
|
||||||
public function verif_prefixIsUsed()
|
public function verif_prefixIsUsed()
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -266,119 +266,119 @@ abstract class ModeleThirdPartyCode
|
|||||||
*/
|
*/
|
||||||
abstract class ModeleAccountancyCode
|
abstract class ModeleAccountancyCode
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of module
|
* Return description of module
|
||||||
*
|
*
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @return string Description of module
|
* @return string Description of module
|
||||||
*/
|
*/
|
||||||
public function info($langs)
|
public function info($langs)
|
||||||
{
|
{
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
return $langs->trans("NoDescription");
|
return $langs->trans("NoDescription");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of result returned by getNextValue
|
* Return an example of result returned by getNextValue
|
||||||
*
|
*
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @param societe $objsoc Object thirdparty
|
* @param societe $objsoc Object thirdparty
|
||||||
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
|
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample($langs, $objsoc = 0, $type = -1)
|
public function getExample($langs, $objsoc = 0, $type = -1)
|
||||||
{
|
{
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
return $langs->trans("NoExample");
|
return $langs->trans("NoExample");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return version of module
|
* Return version of module
|
||||||
*
|
*
|
||||||
* @return string Version
|
* @return string Version
|
||||||
*/
|
*/
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of module parameters
|
* Return description of module parameters
|
||||||
*
|
*
|
||||||
* @param Translate $langs Output language
|
* @param Translate $langs Output language
|
||||||
* @param Societe $soc Third party object
|
* @param Societe $soc Third party object
|
||||||
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
|
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
|
||||||
* @return string HTML translated description
|
* @return string HTML translated description
|
||||||
*/
|
*/
|
||||||
public function getToolTip($langs, $soc, $type)
|
public function getToolTip($langs, $soc, $type)
|
||||||
{
|
{
|
||||||
global $conf,$db;
|
global $conf,$db;
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
$s='';
|
$s='';
|
||||||
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
|
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
|
||||||
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
||||||
//$s.='<br>';
|
//$s.='<br>';
|
||||||
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
||||||
$s.='<br>';
|
$s.='<br>';
|
||||||
if ($type == 0 || $type == -1)
|
if ($type == 0 || $type == -1)
|
||||||
{
|
{
|
||||||
$result=$this->get_code($db, $soc, 'customer');
|
$result=$this->get_code($db, $soc, 'customer');
|
||||||
$nextval=$this->code;
|
$nextval=$this->code;
|
||||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
|
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
|
||||||
}
|
}
|
||||||
if ($type == 1 || $type == -1)
|
if ($type == 1 || $type == -1)
|
||||||
{
|
{
|
||||||
$result=$this->get_code($db, $soc, 'supplier');
|
$result=$this->get_code($db, $soc, 'supplier');
|
||||||
$nextval=$this->code;
|
$nextval=$this->code;
|
||||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
|
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
|
||||||
}
|
}
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Set accountancy account code for a third party into this->code
|
* Set accountancy account code for a third party into this->code
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param Societe $societe Third party object
|
* @param Societe $societe Third party object
|
||||||
* @param int $type 'customer' or 'supplier'
|
* @param int $type 'customer' or 'supplier'
|
||||||
* @return int >=0 if OK, <0 if KO
|
* @return int >=0 if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function get_code($db, $societe, $type = '')
|
public function get_code($db, $societe, $type = '')
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs;
|
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)
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,15 +32,15 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_commandefo
|
|||||||
class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
|
class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error = '';
|
public $error = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Nom du modele
|
* @var string Nom du modele
|
||||||
@ -62,118 +62,118 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
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 description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of numbering
|
* Return an example of numbering
|
||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
return $this->prefix."0501-0001";
|
return $this->prefix."0501-0001";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
global $conf,$langs,$db;
|
global $conf,$langs,$db;
|
||||||
|
|
||||||
$coyymm=''; $max='';
|
$coyymm=''; $max='';
|
||||||
|
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
$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.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
|
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))
|
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->error=$langs->trans('ErrorNumRefModel', $max);
|
$this->error=$langs->trans('ErrorNumRefModel', $max);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next value
|
* Return next value
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object third party
|
* @param Societe $objsoc Object third party
|
||||||
* @param Object $object Object
|
* @param Object $object Object
|
||||||
* @return string Value if OK, 0 if KO
|
* @return string Value if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objsoc = 0, $object = '')
|
public function getNextValue($objsoc = 0, $object = '')
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
|
|
||||||
// D'abord on recupere la valeur max
|
// D'abord on recupere la valeur max
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
$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.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
if ($obj) $max = intval($obj->max);
|
if ($obj) $max = intval($obj->max);
|
||||||
else $max=0;
|
else $max=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$date=time();
|
//$date=time();
|
||||||
$date=$object->date_commande; // Not always defined
|
$date=$object->date_commande; // Not always defined
|
||||||
if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders
|
if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max+1);
|
||||||
|
|
||||||
return $this->prefix.$yymm."-".$num;
|
return $this->prefix.$yymm."-".$num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Renvoie la reference de commande suivante non utilisee
|
* Renvoie la reference de commande suivante non utilisee
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object third party
|
* @param Societe $objsoc Object third party
|
||||||
* @param Object $object Object
|
* @param Object $object Object
|
||||||
* @return string Texte descripif
|
* @return string Texte descripif
|
||||||
*/
|
*/
|
||||||
public function commande_get_num($objsoc = 0, $object = '')
|
public function commande_get_num($objsoc = 0, $object = '')
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return $this->getNextValue($objsoc, $object);
|
return $this->getNextValue($objsoc, $object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier
|
|||||||
class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
|
class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='SPAY';
|
public $prefix='SPAY';
|
||||||
@ -55,16 +55,16 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
|
|||||||
public $name='Bronan';
|
public $name='Bronan';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
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
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
@ -147,15 +147,15 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
|
|||||||
$date=$object->datepaye;
|
$date=$object->datepaye;
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max+1);
|
||||||
|
|
||||||
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
|
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
|
||||||
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
|
* Return next free value
|
||||||
*
|
*
|
||||||
@ -165,7 +165,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
|
|||||||
*/
|
*/
|
||||||
public function payment_get_num($objsoc, $objforref)
|
public function payment_get_num($objsoc, $objforref)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
return $this->getNextValue($objsoc, $objforref);
|
return $this->getNextValue($objsoc, $objforref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,17 +28,17 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator
|
|||||||
public $error='';
|
public $error='';
|
||||||
|
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation models
|
* Return list of active generation models
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of numbers
|
* @return array List of numbers
|
||||||
*/
|
*/
|
||||||
public static function liste_modeles($db, $maxfilenamelength = 0)
|
public static function liste_modeles($db, $maxfilenamelength = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$type='supplier_payment';
|
$type='supplier_payment';
|
||||||
@ -98,11 +98,11 @@ abstract class ModeleNumRefSupplierPayments
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_proposal/modules_supplie
|
|||||||
class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
|
class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix='RQ'; // RQ = Request for quotation
|
public $prefix='RQ'; // RQ = Request for quotation
|
||||||
@ -57,16 +57,16 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
|
|||||||
public $name='Marbre';
|
public $name='Marbre';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
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
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -47,21 +47,21 @@ abstract class ModeleNumRefTakepos
|
|||||||
* @return boolean true if module can be used
|
* @return boolean true if module can be used
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi la description par defaut du modele de numerotation
|
* Renvoi la description par defaut du modele de numerotation
|
||||||
*
|
*
|
||||||
* @return string Texte descripif
|
* @return string Texte descripif
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("cashdesk@cashdesk");
|
$langs->load("cashdesk@cashdesk");
|
||||||
return $langs->trans("NoDescription");
|
return $langs->trans("NoDescription");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of numbering
|
* Return an example of numbering
|
||||||
@ -69,11 +69,11 @@ abstract class ModeleNumRefTakepos
|
|||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load('cashdesk@cashdesk');
|
$langs->load('cashdesk@cashdesk');
|
||||||
return $langs->trans('NoExample');
|
return $langs->trans('NoExample');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi prochaine valeur attribuee
|
* Renvoi prochaine valeur attribuee
|
||||||
*
|
*
|
||||||
* @return string Valeur
|
* @return string Valeur
|
||||||
*/
|
*/
|
||||||
public function getNextValue()
|
public function getNextValue()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans('NotAvailable');
|
return $langs->trans('NotAvailable');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi version du modele de numerotation
|
* Renvoi version du modele de numerotation
|
||||||
@ -103,14 +103,14 @@ abstract class ModeleNumRefTakepos
|
|||||||
* @return string Valeur
|
* @return string Valeur
|
||||||
*/
|
*/
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,20 +30,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/ticket/modules_ticket.php';
|
|||||||
*/
|
*/
|
||||||
class mod_ticket_simple extends ModeleNumRefTicket
|
class mod_ticket_simple extends ModeleNumRefTicket
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix = 'TS';
|
public $prefix = 'TS';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error = '';
|
public $error = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Nom du modele
|
* @var string Nom du modele
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @see $name
|
* @see $name
|
||||||
@ -55,108 +55,108 @@ class mod_ticket_simple extends ModeleNumRefTicket
|
|||||||
*/
|
*/
|
||||||
public $name='Simple';
|
public $name='Simple';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of numbering module values
|
* Return an example of numbering module values
|
||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
return $this->prefix . "0501-0001";
|
return $this->prefix . "0501-0001";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
global $conf, $langs, $db;
|
global $conf, $langs, $db;
|
||||||
|
|
||||||
$coyymm = '';
|
$coyymm = '';
|
||||||
$max = '';
|
$max = '';
|
||||||
|
|
||||||
$posindice = 8;
|
$posindice = 8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
|
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
|
||||||
$search = $this->prefix . "____-%";
|
$search = $this->prefix . "____-%";
|
||||||
$sql .= " WHERE ref LIKE '" . $search ."'";
|
$sql .= " WHERE ref LIKE '" . $search ."'";
|
||||||
$sql .= " AND entity = " . $conf->entity;
|
$sql .= " AND entity = " . $conf->entity;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$coyymm = substr($row[0], 0, 6);
|
$coyymm = substr($row[0], 0, 6);
|
||||||
$max = $row[0];
|
$max = $row[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$coyymm || preg_match('/' . $this->prefix . '[0-9][0-9][0-9][0-9]/i', $coyymm)) {
|
if (!$coyymm || preg_match('/' . $this->prefix . '[0-9][0-9][0-9][0-9]/i', $coyymm)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->error = $langs->trans('ErrorNumRefModel', $max);
|
$this->error = $langs->trans('ErrorNumRefModel', $max);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next value
|
* Return next value
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object third party
|
* @param Societe $objsoc Object third party
|
||||||
* @param Project $ticket Object ticket
|
* @param Project $ticket Object ticket
|
||||||
* @return string Value if OK, 0 if KO
|
* @return string Value if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objsoc, $ticket)
|
public function getNextValue($objsoc, $ticket)
|
||||||
{
|
{
|
||||||
global $db, $conf;
|
global $db, $conf;
|
||||||
|
|
||||||
// D'abord on recupere la valeur max
|
// D'abord on recupere la valeur max
|
||||||
$posindice = 8;
|
$posindice = 8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
|
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
|
||||||
$search = $this->prefix . "____-%";
|
$search = $this->prefix . "____-%";
|
||||||
$sql .= " WHERE ref LIKE '" . $search ."'";
|
$sql .= " WHERE ref LIKE '" . $search ."'";
|
||||||
$sql .= " AND entity = " . $conf->entity;
|
$sql .= " AND entity = " . $conf->entity;
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
if ($obj) {
|
if ($obj) {
|
||||||
$max = intval($obj->max);
|
$max = intval($obj->max);
|
||||||
} else {
|
} else {
|
||||||
$max = 0;
|
$max = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_syslog("mod_ticket_simple::getNextValue", LOG_DEBUG);
|
dol_syslog("mod_ticket_simple::getNextValue", LOG_DEBUG);
|
||||||
return -1;
|
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",time());
|
||||||
$yymm = strftime("%y%m", $date);
|
$yymm = strftime("%y%m", $date);
|
||||||
|
|
||||||
if ($max >= (pow(10, 4) - 1)) {
|
if ($max >= (pow(10, 4) - 1)) {
|
||||||
$num = $max + 1;
|
$num = $max + 1;
|
||||||
} // If counter > 9999, we do not format on 4 chars, we take number as it is
|
} // If counter > 9999, we do not format on 4 chars, we take number as it is
|
||||||
else {
|
else {
|
||||||
$num = sprintf("%04s", $max + 1);
|
$num = sprintf("%04s", $max + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog("mod_ticket_simple::getNextValue return " . $this->prefix . $yymm . "-" . $num);
|
dol_syslog("mod_ticket_simple::getNextValue return " . $this->prefix . $yymm . "-" . $num);
|
||||||
return $this->prefix . $yymm . "-" . $num;
|
return $this->prefix . $yymm . "-" . $num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,95 +29,95 @@
|
|||||||
*/
|
*/
|
||||||
abstract class ModeleNumRefTicket
|
abstract class ModeleNumRefTicket
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error = '';
|
public $error = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if a module can be used or not
|
* Return if a module can be used or not
|
||||||
*
|
*
|
||||||
* @return boolean true if module can be used
|
* @return boolean true if module can be used
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi la description par defaut du modele de numerotation
|
* Renvoi la description par defaut du modele de numerotation
|
||||||
*
|
*
|
||||||
* @return string Texte descripif
|
* @return string Texte descripif
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("ticket");
|
$langs->load("ticket");
|
||||||
return $langs->trans("NoDescription");
|
return $langs->trans("NoDescription");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of numbering
|
* Return an example of numbering
|
||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("ticket");
|
$langs->load("ticket");
|
||||||
return $langs->trans("NoExample");
|
return $langs->trans("NoExample");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @return boolean false if conflict, true if ok
|
||||||
*/
|
*/
|
||||||
public function canBeActivated()
|
public function canBeActivated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi prochaine valeur attribuee
|
* Renvoi prochaine valeur attribuee
|
||||||
*
|
*
|
||||||
* @param Societe $objsoc Object third party
|
* @param Societe $objsoc Object third party
|
||||||
* @param Project $project Object project
|
* @param Project $project Object project
|
||||||
* @return string Valeur
|
* @return string Valeur
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objsoc, $project)
|
public function getNextValue($objsoc, $project)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("NotAvailable");
|
return $langs->trans("NotAvailable");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoi version du module numerotation
|
* Renvoi version du module numerotation
|
||||||
*
|
*
|
||||||
* @return string Valeur
|
* @return string Valeur
|
||||||
*/
|
*/
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if ($this->version == 'development') {
|
if ($this->version == 'development') {
|
||||||
return $langs->trans("VersionDevelopment");
|
return $langs->trans("VersionDevelopment");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->version == 'experimental') {
|
if ($this->version == 'experimental') {
|
||||||
return $langs->trans("VersionExperimental");
|
return $langs->trans("VersionExperimental");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->version == 'dolibarr') {
|
if ($this->version == 'dolibarr') {
|
||||||
return DOL_VERSION;
|
return DOL_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->version) {
|
if ($this->version) {
|
||||||
return $this->version;
|
return $this->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $langs->trans("NotAvailable");
|
return $langs->trans("NotAvailable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
// Protection to avoid direct call of template
|
// Protection to avoid direct call of template
|
||||||
if (empty($conf) || ! is_object($conf)) {
|
if (empty($conf) || ! is_object($conf)) {
|
||||||
print "Error, template page can't be called as URL";
|
print "Error, template page can't be called as URL";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ if ($action == 'presend')
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $fileparams['fullname'];
|
$file = $fileparams['fullname'];
|
||||||
@ -102,11 +102,11 @@ if ($action == 'presend')
|
|||||||
}
|
}
|
||||||
if ($object->element == 'invoice_supplier')
|
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
|
else
|
||||||
{
|
{
|
||||||
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $fileparams['fullname'];
|
$file = $fileparams['fullname'];
|
||||||
@ -212,51 +212,51 @@ if ($action == 'presend')
|
|||||||
complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
|
complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
|
||||||
|
|
||||||
// Find the good contact address
|
// Find the good contact address
|
||||||
$tmpobject = $object;
|
$tmpobject = $object;
|
||||||
if (($object->element == 'shipping'|| $object->element == 'reception')) {
|
if (($object->element == 'shipping'|| $object->element == 'reception')) {
|
||||||
$origin = $object->origin;
|
$origin = $object->origin;
|
||||||
$origin_id = $object->origin_id;
|
$origin_id = $object->origin_id;
|
||||||
|
|
||||||
if (!empty($origin) && !empty($origin_id)) {
|
if (!empty($origin) && !empty($origin_id)) {
|
||||||
$element = $subelement = $origin;
|
$element = $subelement = $origin;
|
||||||
$regs = array();
|
$regs = array();
|
||||||
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
|
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
|
||||||
$element = $regs[1];
|
$element = $regs[1];
|
||||||
$subelement = $regs[2];
|
$subelement = $regs[2];
|
||||||
}
|
}
|
||||||
// For compatibility
|
// For compatibility
|
||||||
if ($element == 'order') {
|
if ($element == 'order') {
|
||||||
$element = $subelement = 'commande';
|
$element = $subelement = 'commande';
|
||||||
}
|
}
|
||||||
if ($element == 'propal') {
|
if ($element == 'propal') {
|
||||||
$element = 'comm/propal';
|
$element = 'comm/propal';
|
||||||
$subelement = 'propal';
|
$subelement = 'propal';
|
||||||
}
|
}
|
||||||
if ($element == 'contract') {
|
if ($element == 'contract') {
|
||||||
$element = $subelement = 'contrat';
|
$element = $subelement = 'contrat';
|
||||||
}
|
}
|
||||||
if ($element == 'inter') {
|
if ($element == 'inter') {
|
||||||
$element = $subelement = 'ficheinter';
|
$element = $subelement = 'ficheinter';
|
||||||
}
|
}
|
||||||
if ($element == 'shipping') {
|
if ($element == 'shipping') {
|
||||||
$element = $subelement = 'expedition';
|
$element = $subelement = 'expedition';
|
||||||
}
|
}
|
||||||
if ($element == 'order_supplier') {
|
if ($element == 'order_supplier') {
|
||||||
$element = 'fourn';
|
$element = 'fourn';
|
||||||
$subelement = 'fournisseur.commande';
|
$subelement = 'fournisseur.commande';
|
||||||
}
|
}
|
||||||
if ($element == 'project') {
|
if ($element == 'project') {
|
||||||
$element = 'projet';
|
$element = 'projet';
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
|
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
|
||||||
$classname = ucfirst($origin);
|
$classname = ucfirst($origin);
|
||||||
$objectsrc = new $classname($db);
|
$objectsrc = new $classname($db);
|
||||||
$objectsrc->fetch($origin_id);
|
$objectsrc->fetch($origin_id);
|
||||||
|
|
||||||
$tmpobject = $objectsrc;
|
$tmpobject = $objectsrc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$custcontact = '';
|
$custcontact = '';
|
||||||
$contactarr = array();
|
$contactarr = array();
|
||||||
@ -264,11 +264,11 @@ if ($action == 'presend')
|
|||||||
|
|
||||||
if (is_array($contactarr) && count($contactarr) > 0) {
|
if (is_array($contactarr) && count($contactarr) > 0) {
|
||||||
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
|
||||||
$contactstatic = new Contact($db);
|
$contactstatic = new Contact($db);
|
||||||
|
|
||||||
foreach ($contactarr as $contact) {
|
foreach ($contactarr as $contact) {
|
||||||
$contactstatic->fetch($contact['id']);
|
$contactstatic->fetch($contact['id']);
|
||||||
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
|
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -183,13 +183,13 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
|||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$objectclass = 'Expedition';
|
$objectclass = 'Expedition';
|
||||||
$objectlabel = 'Sendings';
|
$objectlabel = 'Sendings';
|
||||||
$permissiontoread = $user->rights->expedition->lire;
|
$permissiontoread = $user->rights->expedition->lire;
|
||||||
$permissiontoadd = $user->rights->expedition->creer;
|
$permissiontoadd = $user->rights->expedition->creer;
|
||||||
$permissiontodelete = $user->rights->expedition->supprimer;
|
$permissiontodelete = $user->rights->expedition->supprimer;
|
||||||
$uploaddir = $conf->expedition->dir_output.'/sending';
|
$uploaddir = $conf->expedition->dir_output.'/sending';
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ if ($resql)
|
|||||||
{
|
{
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||||
|
|
||||||
$expedition = new Expedition($db);
|
$expedition = new Expedition($db);
|
||||||
|
|
||||||
@ -341,18 +341,18 @@ if ($resql)
|
|||||||
// Add $param from extra fields
|
// Add $param from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||||
|
|
||||||
$arrayofmassactions = array(
|
$arrayofmassactions = array(
|
||||||
'builddoc' => $langs->trans("PDFMerge"),
|
'builddoc' => $langs->trans("PDFMerge"),
|
||||||
//'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged
|
//'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged
|
||||||
'presend' => $langs->trans("SendByMail"),
|
'presend' => $langs->trans("SendByMail"),
|
||||||
);
|
);
|
||||||
if (in_array($massaction, array('presend'))) $arrayofmassactions = array();
|
if (in_array($massaction, array('presend'))) $arrayofmassactions = array();
|
||||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|
||||||
$newcardbutton = '';
|
$newcardbutton = '';
|
||||||
if ($user->rights->expedition->creer)
|
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;
|
$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);
|
print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
|
||||||
|
|
||||||
$topicmail = "SendShippingRef";
|
$topicmail = "SendShippingRef";
|
||||||
$modelmail = "shipping_send";
|
$modelmail = "shipping_send";
|
||||||
$objecttmp = new Expedition($db);
|
$objecttmp = new Expedition($db);
|
||||||
$trackid = 'shi'.$object->id;
|
$trackid = 'shi'.$object->id;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||||
|
|
||||||
if ($sall)
|
if ($sall)
|
||||||
{
|
{
|
||||||
@ -583,7 +583,7 @@ if ($resql)
|
|||||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$typenArray = $formcompany->typent_array(1);
|
$typenArray = $formcompany->typent_array(1);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$totalarray = array();
|
$totalarray = array();
|
||||||
while ($i < min($num, $limit))
|
while ($i < min($num, $limit))
|
||||||
@ -736,48 +736,48 @@ if ($resql)
|
|||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) $totalarray['nbfield']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action column
|
// Action column
|
||||||
print '<td class="nowrap" align="center">';
|
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
|
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;
|
$selected = 0;
|
||||||
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
|
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 '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!$i) $totalarray['nbfield']++;
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$db->free($resql);
|
$db->free($resql);
|
||||||
|
|
||||||
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
$hidegeneratedfilelistifempty = 1;
|
$hidegeneratedfilelistifempty = 1;
|
||||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
|
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
|
||||||
|
|
||||||
// Show list of available documents
|
// Show list of available documents
|
||||||
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||||
$urlsource .= str_replace('&', '&', $param);
|
$urlsource .= str_replace('&', '&', $param);
|
||||||
|
|
||||||
$filedir = $diroutputmassaction;
|
$filedir = $diroutputmassaction;
|
||||||
$genallowed = $user->rights->expedition->lire;
|
$genallowed = $user->rights->expedition->lire;
|
||||||
$delallowed = $user->rights->expedition->creer;
|
$delallowed = $user->rights->expedition->creer;
|
||||||
$title = '';
|
$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
|
else
|
||||||
{
|
{
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -35,9 +35,9 @@ dol_include_once('/mymodule/core/modules/mymodule/modules_myobject.php');
|
|||||||
class mod_myobject_advanced extends ModeleNumRefMyObject
|
class mod_myobject_advanced extends ModeleNumRefMyObject
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,14 +51,14 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
|||||||
public $name = 'advanced';
|
public $name = 'advanced';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the description of the numbering model
|
* Returns the description of the numbering model
|
||||||
*
|
*
|
||||||
* @return string Texte descripif
|
* @return string Texte descripif
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $conf, $langs, $db;
|
global $conf, $langs, $db;
|
||||||
|
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
@ -89,28 +89,28 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
|||||||
$texte .= '</form>';
|
$texte .= '</form>';
|
||||||
|
|
||||||
return $texte;
|
return $texte;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an example of numbering
|
* Return an example of numbering
|
||||||
*
|
*
|
||||||
* @return string Example
|
* @return string Example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
global $conf, $langs, $mysoc;
|
global $conf, $langs, $mysoc;
|
||||||
|
|
||||||
$object = new MyObject($this->db);
|
$object = new MyObject($this->db);
|
||||||
$object->initAsSpecimen();
|
$object->initAsSpecimen();
|
||||||
|
|
||||||
/*$old_code_client = $mysoc->code_client;
|
/*$old_code_client = $mysoc->code_client;
|
||||||
$old_code_type = $mysoc->typent_code;
|
$old_code_type = $mysoc->typent_code;
|
||||||
$mysoc->code_client = 'CCCCCCCCCC';
|
$mysoc->code_client = 'CCCCCCCCCC';
|
||||||
$mysoc->typent_code = 'TTTTTTTTTT';*/
|
$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;*/
|
$mysoc->typent_code = $old_code_type;*/
|
||||||
|
|
||||||
if (!$numExample)
|
if (!$numExample)
|
||||||
@ -118,7 +118,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
|||||||
$numExample = $langs->trans('NotConfigured');
|
$numExample = $langs->trans('NotConfigured');
|
||||||
}
|
}
|
||||||
return $numExample;
|
return $numExample;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next free value
|
* Return next free value
|
||||||
@ -126,8 +126,8 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
|||||||
* @param Object $object Object we need next value for
|
* @param Object $object Object we need next value for
|
||||||
* @return string Value if KO, <0 if KO
|
* @return string Value if KO, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function getNextValue($object)
|
public function getNextValue($object)
|
||||||
{
|
{
|
||||||
global $db, $conf;
|
global $db, $conf;
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
|||||||
@ -31,9 +31,9 @@ dol_include_once('/mymodule/core/modules/mymodule/modules_myobject.php');
|
|||||||
class mod_myobject_standard extends ModeleNumRefMyObject
|
class mod_myobject_standard extends ModeleNumRefMyObject
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Dolibarr version of the loaded document
|
* Dolibarr version of the loaded document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
|
|
||||||
public $prefix = 'MYOBJECT';
|
public $prefix = 'MYOBJECT';
|
||||||
@ -49,16 +49,16 @@ class mod_myobject_standard extends ModeleNumRefMyObject
|
|||||||
public $name = 'standard';
|
public $name = 'standard';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return description of numbering module
|
* Return description of numbering module
|
||||||
*
|
*
|
||||||
* @return string Text with description
|
* @return string Text with description
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
|
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
|
* 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
|
* @param Object $object Object we need next value for
|
||||||
* @return boolean false if conflict, true if ok
|
* @return boolean false if conflict, true if ok
|
||||||
@ -151,8 +151,8 @@ class mod_myobject_standard extends ModeleNumRefMyObject
|
|||||||
$date = $object->date_creation;
|
$date = $object->date_creation;
|
||||||
$yymm = strftime("%y%m", $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
|
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);
|
else $num = sprintf("%04s", $max + 1);
|
||||||
|
|
||||||
dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
|
dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||||
return $this->prefix.$yymm."-".$num;
|
return $this->prefix.$yymm."-".$num;
|
||||||
|
|||||||
@ -38,17 +38,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
|
|||||||
abstract class ModelePDFMyObject extends CommonDocGenerator
|
abstract class ModelePDFMyObject extends CommonDocGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* Return list of active generation modules
|
* Return list of active generation modules
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of templates
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
$type = 'mymodule_myobject';
|
$type = 'mymodule_myobject';
|
||||||
@ -109,7 +109,7 @@ abstract class ModeleNumRefMyObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the numbers already in the database do not
|
* 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
|
* @param Object $object Object we need next value for
|
||||||
* @return boolean false if conflict, true if ok
|
* @return boolean false if conflict, true if ok
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user