diff --git a/htdocs/admin/project.php b/htdocs/admin/project.php index dc58d8c77f6..26c95ece302 100644 --- a/htdocs/admin/project.php +++ b/htdocs/admin/project.php @@ -1,6 +1,7 @@ * Copyright (C) 2011 Laurent Destailleur + * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,16 +43,27 @@ $action=GETPOST('action'); * Actions */ -if ($_POST["action"] == 'updateMask') +if ($action == 'updateMask') { - $maskconstproject=$_POST['maskconstproject']; - $maskproject=$_POST['maskproject']; - if ($maskconstproject) dolibarr_set_const($db,$maskconstproject,$maskproject,'chaine',0,'',$conf->entity); + $maskconstproject=GETPOST("maskconstproject"); + $maskproject=GETPOST("maskproject"); + if ($maskconstproject) $res = dolibarr_set_const($db,$maskconstproject,$maskproject,'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"); $project = new Project($db); $project->initAsSpecimen(); @@ -84,13 +96,16 @@ if ($_GET["action"] == 'specimen') } } -if ($_GET["action"] == 'set') +if ($action == 'set') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $type='project'; $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)) { @@ -98,7 +113,7 @@ if ($_GET["action"] == 'set') } } -if ($_GET["action"] == 'del') +if ($action == 'del') { $type='project'; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; @@ -111,27 +126,30 @@ if ($_GET["action"] == 'del') } } -if ($_GET["action"] == 'setdoc') +if ($action == 'setdoc') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $db->begin(); - if (dolibarr_set_const($db, "PROJECT_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) + if (dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { - $conf->global->PROJECT_ADDON_PDF = $_GET["value"]; + $conf->global->PROJECT_ADDON_PDF = $value; } // On active le modele $type='project'; $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; $result1=$db->query($sql_del); $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.= ")"; $result2=$db->query($sql); if ($result1 && $result2) @@ -144,7 +162,7 @@ if ($_GET["action"] == 'setdoc') } } -if ($_GET["action"] == 'setmod') +if ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated @@ -380,5 +398,9 @@ if (is_resource($handle)) print '
'; +dol_htmloutput_mesg($mesg); + +$db->close(); + llxFooter(); ?>