Uniformize code

This commit is contained in:
Juanjo Menent 2011-08-31 08:10:39 +00:00
parent 63c25787b1
commit 7b5469007c
4 changed files with 60 additions and 37 deletions

View File

@ -33,9 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php');
$langs->load("admin"); $langs->load("admin");
$langs->load("bills"); $langs->load("errors");
$langs->load("other");
$langs->load("orders");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
@ -49,8 +47,9 @@ $value = GETPOST("value");
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstorder=$_POST['maskconstorder']; $maskconstorder=GETPOST("maskconstorder");
$maskorder=$_POST['maskorder']; $maskorder=GETPOST("maskorder");
if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity); if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
@ -67,7 +66,7 @@ if ($action == 'updateMask')
if ($action == 'specimen') if ($action == 'specimen')
{ {
$modele=$_GET["module"]; $modele=GETPOST("module");
$commande = new Commande($db); $commande = new Commande($db);
$commande->initAsSpecimen(); $commande->initAsSpecimen();

View File

@ -26,13 +26,14 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'); require_once(DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php');
$langs->load("admin"); $langs->load("admin");
$langs->load("bills"); $langs->load("errors");
$langs->load("other");
$langs->load("contracts");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$action = GETPOST("action");
$value = GETPOST("value");
if (empty($conf->global->CONTRACT_ADDON)) if (empty($conf->global->CONTRACT_ADDON))
{ {
$conf->global->CONTRACT_ADDON='mod_contract_serpis'; $conf->global->CONTRACT_ADDON='mod_contract_serpis';
@ -43,24 +44,36 @@ if (empty($conf->global->CONTRACT_ADDON))
* Actions * Actions
*/ */
if ($_POST["action"] == 'updateMask') if ($action == 'updateMask')
{ {
$maskconst=$_POST['maskconstcontract']; $maskconst=$_POST['maskconstcontract'];
$maskvalue=$_POST['maskcontract']; $maskvalue=$_POST['maskcontract'];
if ($maskconst) dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
if ($_GET["action"] == 'setmod') if ($action == 'setmod')
{ {
dolibarr_set_const($db, "CONTRACT_ADDON",$_GET["value"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "CONTRACT_ADDON",$value,'chaine',0,'',$conf->entity);
} }
/*
// constants of magre model // constants of magre model
if ($_POST["action"] == 'updateMatrice') dolibarr_set_const($db, "CONTRACT_NUM_MATRICE",$_POST["matrice"],'chaine',0,'',$conf->entity); if ($action == 'updateMatrice') dolibarr_set_const($db, "CONTRACT_NUM_MATRICE",$_POST["matrice"],'chaine',0,'',$conf->entity);
if ($_POST["action"] == 'updatePrefix') dolibarr_set_const($db, "CONTRACT_NUM_PREFIX",$_POST["prefix"],'chaine',0,'',$conf->entity); if ($action == 'updatePrefix') dolibarr_set_const($db, "CONTRACT_NUM_PREFIX",$_POST["prefix"],'chaine',0,'',$conf->entity);
if ($_POST["action"] == 'setOffset') dolibarr_set_const($db, "CONTRACT_NUM_DELTA",$_POST["offset"],'chaine',0,'',$conf->entity); if ($action == 'setOffset') dolibarr_set_const($db, "CONTRACT_NUM_DELTA",$_POST["offset"],'chaine',0,'',$conf->entity);
if ($_POST["action"] == 'setNumRestart') dolibarr_set_const($db, "CONTRACT_NUM_RESTART_BEGIN_YEAR",$_POST["numrestart"],'chaine',0,'',$conf->entity); if ($action == 'setNumRestart') dolibarr_set_const($db, "CONTRACT_NUM_RESTART_BEGIN_YEAR",$_POST["numrestart"],'chaine',0,'',$conf->entity);
*/
/* /*
* View * View
@ -127,12 +140,12 @@ if (is_resource($handle))
print '<td align="center">'; print '<td align="center">';
if ($conf->global->CONTRACT_ADDON == "$file") if ($conf->global->CONTRACT_ADDON == "$file")
{ {
print img_picto($langs->trans("Activated"),'on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Disabled"),'off'); print img_picto($langs->trans("Disabled"),'switch_off');
print '</a>'; print '</a>';
} }
print '</td>'; print '</td>';
@ -170,6 +183,9 @@ if (is_resource($handle))
} }
print '</table><br>'; print '</table><br>';
dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();

View File

@ -33,9 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
$langs->load("admin"); $langs->load("admin");
$langs->load("bills"); $langs->load("errors");
$langs->load("propal");
$langs->load("other");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();

View File

@ -35,6 +35,7 @@ if (!$user->admin)
accessforbidden(); accessforbidden();
$action=GETPOST("action"); $action=GETPOST("action");
$value = GETPOST("value");
/* /*
@ -42,7 +43,7 @@ $action=GETPOST("action");
*/ */
if ($action == 'setcodeclient') if ($action == 'setcodeclient')
{ {
if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$_GET["value"],'chaine',0,'',$conf->entity) > 0) if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$value,'chaine',0,'',$conf->entity) > 0)
{ {
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
@ -55,7 +56,7 @@ if ($action == 'setcodeclient')
if ($action == 'setcodecompta') if ($action == 'setcodecompta')
{ {
if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON",$_GET["value"],'chaine',0,'',$conf->entity) > 0) if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON",$value,'chaine',0,'',$conf->entity) > 0)
{ {
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
@ -68,7 +69,8 @@ if ($action == 'setcodecompta')
if ($action == 'COMPANY_USE_SEARCH_TO_SELECT') if ($action == 'COMPANY_USE_SEARCH_TO_SELECT')
{ {
$res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $_POST["activate_COMPANY_USE_SEARCH_TO_SELECT"],'chaine',0,'',$conf->entity); $companysearch = GETPOST("activate_COMPANY_USE_SEARCH_TO_SELECT");
$res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
if (! $error) if (! $error)
{ {
@ -114,11 +116,14 @@ if ($action == 'setModuleOptions')
// Activate a document generator module // Activate a document generator module
if ($action == 'set') if ($action == 'set')
{ {
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$type='company'; $type='company';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($_GET["value"])."','".$type."',".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")"; $sql.= ")";
if ($db->query($sql)) if ($db->query($sql))
{ {
@ -132,7 +137,7 @@ if ($action== 'del')
{ {
$type='company'; $type='company';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom='".$db->escape($_GET["value"])."' AND type='".$type."' AND entity=".$conf->entity; $sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity;
if ($db->query($sql)) if ($db->query($sql))
{ {
@ -143,11 +148,14 @@ if ($action== 'del')
// Define default generator // Define default generator
if ($action == 'setdoc') if ($action == 'setdoc')
{ {
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$db->begin(); $db->begin();
if (dolibarr_set_const($db, "COMPANY_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) if (dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{ {
$conf->global->COMPANY_ADDON_PDF = $_GET["value"]; $conf->global->COMPANY_ADDON_PDF = $value;
} }
// On active le modele // On active le modele
@ -160,9 +168,9 @@ if ($action == 'setdoc')
$result1=$db->query($sql_del); $result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($_GET["value"])."', '".$type."', ".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")"; $sql.= ")";
dol_syslog("societe.php ".$sql); dol_syslog("societe.php ".$sql);
$result2=$db->query($sql); $result2=$db->query($sql);
@ -180,8 +188,10 @@ if ($action == 'setdoc')
//Activate ProfId //Activate ProfId
if ($action == 'setprofid') if ($action == 'setprofid')
{ {
$idprof="SOCIETE_IDPROF".$_GET["value"]."_UNIQUE"; $status = GETPOST("status");
if (dolibarr_set_const($db, $idprof,$_GET["status"],'chaine',0,'',$conf->entity) > 0)
$idprof="SOCIETE_IDPROF".$value."_UNIQUE";
if (dolibarr_set_const($db, $idprof,$status,'chaine',0,'',$conf->entity) > 0)
{ {
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;