Qual: Mutualized and uniformize code
This commit is contained in:
parent
c4f90f8174
commit
3e1d2c3e63
@ -118,7 +118,7 @@ else if ($action == 'specimen')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Activate a model
|
// Activate a model
|
||||||
else if ($action == 'set')
|
if ($action == 'set')
|
||||||
{
|
{
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
@ -264,14 +264,14 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
require_once $dir.$file.'.php';
|
require_once $dir.$file.'.php';
|
||||||
|
|
||||||
$module = new $file;
|
$module = new $file($db);
|
||||||
|
|
||||||
|
// Show modules according to features level
|
||||||
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||||
|
|
||||||
if ($module->isEnabled())
|
if ($module->isEnabled())
|
||||||
{
|
{
|
||||||
// Show modules according to features level
|
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
|
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
|
||||||
print $module->info();
|
print $module->info();
|
||||||
@ -323,7 +323,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
print $form->textwithpicto('',$htmltooltip,1,0);
|
print $form->textwithpicto('',$htmltooltip,1,0);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '</tr>';
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,17 +331,16 @@ foreach ($dirmodels as $reldir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print "</table><br>\n";
|
||||||
print '</table><br>';
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document templates generators
|
* Document templates generators
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print_titre($langs->trans("OrdersModelModule"));
|
print_titre($langs->trans("OrdersModelModule"));
|
||||||
|
|
||||||
// Load array def with activated templates
|
// Load array def with activated templates
|
||||||
$type='order';
|
|
||||||
$def = array();
|
$def = array();
|
||||||
$sql = "SELECT nom";
|
$sql = "SELECT nom";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||||
|
|||||||
@ -40,6 +40,9 @@ if (! $user->admin) accessforbidden();
|
|||||||
|
|
||||||
$action = GETPOST('action','alpha');
|
$action = GETPOST('action','alpha');
|
||||||
$value = GETPOST('value','alpha');
|
$value = GETPOST('value','alpha');
|
||||||
|
$label = GETPOST('label','alpha');
|
||||||
|
$scandir = GETPOST('scandir','alpha');
|
||||||
|
$type='invoice';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -137,78 +140,40 @@ if ($action == 'setModuleOptions')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'set')
|
// Activate a model
|
||||||
|
else if ($action == 'set')
|
||||||
{
|
{
|
||||||
$label = GETPOST('label','alpha');
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
$scandir = GETPOST('scandir','alpha');
|
|
||||||
|
|
||||||
$type='invoice';
|
|
||||||
$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.= ")";
|
|
||||||
if ($db->query($sql))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'del')
|
else if ($action == 'del')
|
||||||
{
|
{
|
||||||
$type='invoice';
|
$ret = delDocumentModel($value, $type);
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
|
if ($ret > 0)
|
||||||
$sql.= " WHERE nom = '".$db->escape($value)."'";
|
{
|
||||||
$sql.= " AND type = '".$type."'";
|
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
|
||||||
|
|
||||||
if ($db->query($sql))
|
|
||||||
{
|
|
||||||
if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF',$conf->entity);
|
if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF',$conf->entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setdoc')
|
// Set default model
|
||||||
|
else if ($action == 'setdoc')
|
||||||
{
|
{
|
||||||
$label = GETPOST('label','alpha');
|
if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
|
||||||
$scandir = GETPOST('scandir','alpha');
|
{
|
||||||
|
// La constante qui a ete lue en avant du nouveau set
|
||||||
$db->begin();
|
// on passe donc par une variable pour avoir un affichage coherent
|
||||||
|
$conf->global->FACTURE_ADDON_PDF = $value;
|
||||||
if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
|
}
|
||||||
{
|
|
||||||
$conf->global->FACTURE_ADDON_PDF = $value;
|
// On active le modele
|
||||||
}
|
$ret = delDocumentModel($value, $type);
|
||||||
|
if ($ret > 0)
|
||||||
// On active le modele
|
{
|
||||||
$type='invoice';
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
|
}
|
||||||
$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;
|
|
||||||
dol_syslog("Delete from model table ".$sql_del);
|
|
||||||
$result1=$db->query($sql_del);
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
|
|
||||||
$sql.= " VALUES ('".$value."', '".$type."', ".$conf->entity.", ";
|
|
||||||
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
|
|
||||||
$sql.= (! empty($scandir)?"'".$scandir."'":"null");
|
|
||||||
$sql.= ")";
|
|
||||||
dol_syslog("Insert into model table ".$sql);
|
|
||||||
$result2=$db->query($sql);
|
|
||||||
if ($result1 && $result2)
|
|
||||||
{
|
|
||||||
$db->commit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_syslog("Error ".$db->lasterror(), LOG_ERR);
|
|
||||||
$db->rollback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setmod')
|
else if ($action == 'setmod')
|
||||||
{
|
{
|
||||||
// TODO Verifier si module numerotation choisi peut etre active
|
// TODO Verifier si module numerotation choisi peut etre active
|
||||||
// par appel methode canBeActivated
|
// par appel methode canBeActivated
|
||||||
|
|||||||
@ -193,8 +193,7 @@ if ($action == 'setModuleOptions')
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Activate a model
|
||||||
|
|
||||||
if ($action == 'set')
|
if ($action == 'set')
|
||||||
{
|
{
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
@ -359,16 +358,16 @@ print "</table><br>\n";
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modeles de documents
|
* Document templates generators
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print_titre($langs->trans("ProposalsPDFModules"));
|
print_titre($langs->trans("ProposalsPDFModules"));
|
||||||
|
|
||||||
// Defini tableau def de modele propal
|
// Load array def with activated templates
|
||||||
$def = array();
|
$def = array();
|
||||||
$sql = "SELECT nom";
|
$sql = "SELECT nom";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||||
$sql.= " WHERE type = 'propal'";
|
$sql.= " WHERE type = '".$type."'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -390,7 +389,7 @@ else
|
|||||||
|
|
||||||
print "<table class=\"noborder\" width=\"100%\">\n";
|
print "<table class=\"noborder\" width=\"100%\">\n";
|
||||||
print "<tr class=\"liste_titre\">\n";
|
print "<tr class=\"liste_titre\">\n";
|
||||||
print " <td width=\"140\">".$langs->trans("Name")."</td>\n";
|
print " <td>".$langs->trans("Name")."</td>\n";
|
||||||
print " <td>".$langs->trans("Description")."</td>\n";
|
print " <td>".$langs->trans("Description")."</td>\n";
|
||||||
print '<td align="center" width="40">'.$langs->trans("Status")."</td>\n";
|
print '<td align="center" width="40">'.$langs->trans("Status")."</td>\n";
|
||||||
print '<td align="center" width="40">'.$langs->trans("Default")."</td>\n";
|
print '<td align="center" width="40">'.$langs->trans("Default")."</td>\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user