Skip to content
Snippets Groups Projects
Commit 294b4865 authored by Philippe Grand's avatar Philippe Grand
Browse files

normalize and simplify code

parent 29b8ce1c
No related branches found
No related tags found
No related merge requests found
......@@ -53,10 +53,10 @@ $specimenthirdparty->initAsSpecimen();
if ($action == 'updateMask')
{
$maskconstorder=GETPOST('maskconstorder','alpha');
$maskorder=GETPOST('maskorder','alpha');
$maskconstinvoice=GETPOST('maskconstinvoice','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++;
......@@ -116,71 +116,37 @@ if ($action == 'specimen') // For invoices
}
}
if ($action == 'set')
// Activate a model
else if ($action == 'set')
{
$label = GETPOST('label','alpha');
$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);
$ret = addDocumentModel($value, $type, $label, $scandir);
}
if ($action == 'del')
else if ($action == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$value."'";
$sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$db->query($sql);
if ($res)
{
}
// else dol_print_error($db);
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'INVOICE_SUPPLIER_ADDON_PDF',$conf->entity);
}
}
if ($action == 'setdoc')
// Set default model
else if ($action == 'setdoc')
{
$label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$db->begin();
if ($type == 'order_supplier' && dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{
$conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
}
// 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 (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{
// 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;
}
// On active le modele
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
}
if ($action == 'setmod')
......@@ -294,7 +260,7 @@ foreach ($dirmodels as $reldir)
print $module->info();
print '</td>';
// Show example of numbering module
// Show example of numbering model
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) {
......@@ -447,7 +413,7 @@ foreach ($dirmodels as $reldir)
print "</td>";
}
// Defaut
// Default
print '<td align="center">';
if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name")
{
......@@ -484,6 +450,12 @@ foreach ($dirmodels as $reldir)
}
print '</table><br/>';
print '<br>';
/*
* Other options
*
*/
print_titre($langs->trans("OtherOptions"));
print '<table class="noborder" width="100%">';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment