normalize and simplify code
This commit is contained in:
parent
29b8ce1c2d
commit
294b4865d1
@ -53,10 +53,10 @@ $specimenthirdparty->initAsSpecimen();
|
|||||||
|
|
||||||
if ($action == 'updateMask')
|
if ($action == 'updateMask')
|
||||||
{
|
{
|
||||||
$maskconstorder=GETPOST('maskconstorder','alpha');
|
$maskconstinvoice=GETPOST('maskconstinvoice','alpha');
|
||||||
$maskorder=GETPOST('maskorder','alpha');
|
$maskvalue=GETPOST('maskvalue','alpha');
|
||||||
|
|
||||||
if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
|
if ($maskconstinvoice) $res = dolibarr_set_const($db,$maskconstinvoice,$maskvalue,'chaine',0,'',$conf->entity);
|
||||||
|
|
||||||
if (! $res > 0) $error++;
|
if (! $res > 0) $error++;
|
||||||
|
|
||||||
@ -116,71 +116,37 @@ if ($action == 'specimen') // For invoices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'set')
|
// Activate a model
|
||||||
|
else if ($action == 'set')
|
||||||
{
|
{
|
||||||
$label = GETPOST('label','alpha');
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
$scandir = GETPOST('scandir','alpha');
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
|
|
||||||
$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
|
|
||||||
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
|
|
||||||
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
|
|
||||||
$sql.= ")";
|
|
||||||
$res=$db->query($sql);
|
|
||||||
if ($res)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
// else dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'del')
|
else if ($action == 'del')
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
|
$ret = delDocumentModel($value, $type);
|
||||||
$sql.= " WHERE nom = '".$value."'";
|
if ($ret > 0)
|
||||||
$sql.= " AND type = '".$type."'";
|
{
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'INVOICE_SUPPLIER_ADDON_PDF',$conf->entity);
|
||||||
$db->query($sql);
|
}
|
||||||
if ($res)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
// else dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setdoc')
|
// Set default model
|
||||||
|
else if ($action == 'setdoc')
|
||||||
{
|
{
|
||||||
$label = GETPOST('label','alpha');
|
if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
|
||||||
$scandir = GETPOST('scandir','alpha');
|
{
|
||||||
|
// La constante qui a ete lue en avant du nouveau set
|
||||||
|
// on passe donc par une variable pour avoir un affichage coherent
|
||||||
|
$conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$db->begin();
|
// On active le modele
|
||||||
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($type == 'order_supplier' && dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
|
if ($ret > 0)
|
||||||
{
|
{
|
||||||
$conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// On active le modele
|
|
||||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
|
|
||||||
$sql_del.= " WHERE nom = '".$db->escape($value)."'";
|
|
||||||
$sql_del.= " AND type = '".$type."'";
|
|
||||||
$sql_del.= " AND entity = ".$conf->entity;
|
|
||||||
$result1=$db->query($sql_del);
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
|
|
||||||
$sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
|
|
||||||
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
|
|
||||||
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
|
|
||||||
$sql.= ")";
|
|
||||||
$result2=$db->query($sql);
|
|
||||||
if ($result1 && $result2)
|
|
||||||
{
|
|
||||||
$db->commit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$db->rollback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setmod')
|
if ($action == 'setmod')
|
||||||
@ -294,7 +260,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
print $module->info();
|
print $module->info();
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Show example of numbering module
|
// Show example of numbering model
|
||||||
print '<td nowrap="nowrap">';
|
print '<td nowrap="nowrap">';
|
||||||
$tmp=$module->getExample();
|
$tmp=$module->getExample();
|
||||||
if (preg_match('/^Error/',$tmp)) {
|
if (preg_match('/^Error/',$tmp)) {
|
||||||
@ -447,7 +413,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
print "</td>";
|
print "</td>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defaut
|
// Default
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name")
|
if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name")
|
||||||
{
|
{
|
||||||
@ -484,6 +450,12 @@ foreach ($dirmodels as $reldir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '</table><br/>';
|
print '</table><br/>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Other options
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
print_titre($langs->trans("OtherOptions"));
|
print_titre($langs->trans("OtherOptions"));
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user