diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index 285f2ec3584..11027a0ccda 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -30,9 +30,9 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php');
$langs->load("admin");
-$langs->load("companies");
-$langs->load("bills");
-$langs->load("other");
+//$langs->load("companies");
+//$langs->load("bills");
+//$langs->load("other");
$langs->load("errors");
if (!$user->admin)
@@ -41,26 +41,37 @@ accessforbidden();
$action = GETPOST("action");
$value = GETPOST("value");
-$typeconst=array('yesno','texte','chaine');
+//$typeconst=array('yesno','texte','chaine');
/*
* Actions
*/
-if ($_POST["action"] == 'updateMask')
+if ($action == 'updateMask')
{
- $maskconstinvoice=$_POST['maskconstinvoice'];
- $maskconstcredit=$_POST['maskconstcredit'];
- $maskinvoice=$_POST['maskinvoice'];
- $maskcredit=$_POST['maskcredit'];
- if ($maskconstinvoice) dolibarr_set_const($db,$maskconstinvoice,$maskinvoice,'chaine',0,'',$conf->entity);
- if ($maskconstcredit) dolibarr_set_const($db,$maskconstcredit,$maskcredit,'chaine',0,'',$conf->entity);
+ $maskconstinvoice=GETPOST("maskconstinvoice");
+ $maskconstcredit=GETPOST("maskconstcredit");
+ $maskinvoice=GETPOST("maskinvoice");
+ $maskcredit=GETPOST("maskcredit");
+ if ($maskconstinvoice) $res = dolibarr_set_const($db,$maskconstinvoice,$maskinvoice,'chaine',0,'',$conf->entity);
+ if ($maskconstcredit) $res = dolibarr_set_const($db,$maskconstcredit,$maskcredit,'chaine',0,'',$conf->entity);
+
+ if (! $res > 0) $error++;
+
+ if (! $error)
+ {
+ $mesg = "".$langs->trans("SetupSaved")."";
+ }
+ else
+ {
+ $mesg = "".$langs->trans("Error")."";
+ }
}
-if ($_GET["action"] == 'specimen')
+if ($action == 'specimen')
{
- $modele=$_GET["module"];
+ $modele=GETPOST("module");
$facture = new Facture($db);
$facture->initAsSpecimen();
@@ -82,19 +93,19 @@ if ($_GET["action"] == 'specimen')
}
else
{
- $mesg='
'.$obj->error.'
';
+ $mesg=''.$obj->error.'';
dol_syslog($obj->error, LOG_ERR);
}
}
else
{
- $mesg=''.$langs->trans("ErrorModuleNotFound").'
';
+ $mesg=''.$langs->trans("ErrorModuleNotFound").'';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
// define constants for models generator that need parameters
-if ($_POST["action"] == 'setModuleOptions')
+if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
for($i=0;$i < $post_size;$i++)
@@ -103,18 +114,31 @@ if ($_POST["action"] == 'setModuleOptions')
{
$param=$_POST["param".$i];
$value=$_POST["value".$i];
- if ($param) dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
+ if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
}
}
+ if (! $res > 0) $error++;
+
+ if (! $error)
+ {
+ $mesg = "".$langs->trans("SetupSaved")."";
+ }
+ else
+ {
+ $mesg = "".$langs->trans("Error")."";
+ }
}
-if ($_GET["action"] == 'set')
+if ($action == 'set')
{
+ $label = GETPOST("label");
+ $scandir = GETPOST("scandir");
+
$type='invoice';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
- $sql.= " VALUES ('".$db->escape($_GET["value"])."','".$type."',".$conf->entity.", ";
- $sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", ";
- $sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null");
+ $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))
{
@@ -122,7 +146,7 @@ if ($_GET["action"] == 'set')
}
}
-if ($_GET["action"] == 'del')
+if ($action == 'del')
{
$type='invoice';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
@@ -136,29 +160,32 @@ if ($_GET["action"] == 'del')
}
}
-if ($_GET["action"] == 'setdoc')
+if ($action == 'setdoc')
{
+ $label = GETPOST("label");
+ $scandir = GETPOST("scandir");
+
$db->begin();
- if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity))
+ if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{
- $conf->global->FACTURE_ADDON_PDF = $_GET["value"];
+ $conf->global->FACTURE_ADDON_PDF = $value;
}
// On active le modele
$type='invoice';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
- $sql_del.= " WHERE nom = '".$db->escape($_GET["value"])."'";
+ $sql_del.= " WHERE nom = '".$db->escape($value)."'";
$sql_del.= " AND type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity;
dol_syslog("facture.php ".$sql_del);
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
- $sql.= " VALUES ('".$_GET["value"]."', '".$type."', ".$conf->entity.", ";
- $sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", ";
- $sql.= (! empty($_GET["scandir"])?"'".$_GET["scandir"]."'":"null");
+ $sql.= " VALUES ('".$value."', '".$type."', ".$conf->entity.", ";
+ $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+ $sql.= (! empty($scandir)?"'".$scandir."'":"null");
$sql.= ")";
dol_syslog("facture.php ".$sql);
$result2=$db->query($sql);
@@ -173,36 +200,89 @@ if ($_GET["action"] == 'setdoc')
}
}
-if ($_GET["action"] == 'setmod')
+if ($action == 'setmod')
{
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
- dolibarr_set_const($db, "FACTURE_ADDON",$_GET["value"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "FACTURE_ADDON",$value,'chaine',0,'',$conf->entity);
}
-if ($_POST["action"] == 'setribchq')
+if ($action == 'setribchq')
{
- dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$_POST["rib"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$_POST["chq"],'chaine',0,'',$conf->entity);
+ $rib = GETPOST("rib");
+ $chq = GETPOST("chq");
+
+ $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$rib,'chaine',0,'',$conf->entity);
+ $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$chq,'chaine',0,'',$conf->entity);
+
+ if (! $res > 0) $error++;
+
+ if (! $error)
+ {
+ $mesg = "".$langs->trans("SetupSaved")."";
+ }
+ else
+ {
+ $mesg = "".$langs->trans("Error")."";
+ }
}
-if ($_POST["action"] == 'set_FACTURE_DRAFT_WATERMARK')
+if ($action == 'set_FACTURE_DRAFT_WATERMARK')
{
- dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK",trim($_POST["FACTURE_DRAFT_WATERMARK"]),'chaine',0,'',$conf->entity);
+ $draft = GETPOST("FACTURE_DRAFT_WATERMARK");
+
+ $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
+
+ if (! $res > 0) $error++;
+
+ if (! $error)
+ {
+ $mesg = "".$langs->trans("SetupSaved")."";
+ }
+ else
+ {
+ $mesg = "".$langs->trans("Error")."";
+ }
}
-if ($_POST["action"] == 'set_FACTURE_FREE_TEXT')
+if ($action == 'set_FACTURE_FREE_TEXT')
{
- dolibarr_set_const($db, "FACTURE_FREE_TEXT",$_POST["FACTURE_FREE_TEXT"],'chaine',0,'',$conf->entity);
+ $free = GETPOST("FACTURE_FREE_TEXT");
+
+ $res = dolibarr_set_const($db, "FACTURE_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
+
+ if (! $res > 0) $error++;
+
+ if (! $error)
+ {
+ $mesg = "".$langs->trans("SetupSaved")."";
+ }
+ else
+ {
+ $mesg = "".$langs->trans("Error")."";
+ }
}
-if ($_POST["action"] == 'setforcedate')
+if ($action == 'setforcedate')
{
- dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION",$_POST["forcedate"],'chaine',0,'',$conf->entity);
+ $forcedate = GETPOST("forcedate");
+
+ $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION",$forcedate,'chaine',0,'',$conf->entity);
+
+ if (! $res > 0) $error++;
+
+ if (! $error)
+ {
+ $mesg = "".$langs->trans("SetupSaved")."";
+ }
+ else
+ {
+ $mesg = "".$langs->trans("Error")."";
+ }
}
-if ($_POST["action"] == 'update' || $_POST["action"] == 'add')
+/*if ($action == 'update' || $action == 'add')
{
if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],0,isset($_POST["constnote"])?$_POST["constnote"]:'',$conf->entity));
{
@@ -210,13 +290,14 @@ if ($_POST["action"] == 'update' || $_POST["action"] == 'add')
}
}
-if ($_GET["action"] == 'delete')
+if ($action == 'delete')
{
- if (! dolibarr_del_const($db, $_GET["rowid"],$conf->entity));
+ $rowid = GETPOST("rowid");
+ if (! dolibarr_del_const($db, $rowid,$conf->entity));
{
dol_print_error($db);
}
-}
+}*/
/*
@@ -717,6 +798,7 @@ print "\n";
//dol_fiche_end();
+dol_htmloutput_mesg($mesg);
$db->close();