diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index 1ce01df4cec..b858ea6c96b 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) + * 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 @@ -39,21 +40,34 @@ $langs->load("other"); if (!$user->admin) accessforbidden(); +$action =GETPOST("action"); +$value = GETPOST("value"); /* * Actions */ -if ($_POST["action"] == 'updateMask') +if ($action == 'updateMask') { - $maskconstpropal=$_POST['maskconstpropal']; - $maskpropal=$_POST['maskpropal']; - if ($maskconstpropal) dolibarr_set_const($db,$maskconstpropal,$maskpropal,'chaine',0,'',$conf->entity); + $maskconstpropal=GETPOST("maskconstpropal"); + $maskpropal=GETPOST("maskpropal"); + if ($maskconstpropal) $res = dolibarr_set_const($db,$maskconstpropal,$maskpropal,'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"); $propal = new Propal($db); $propal->initAsSpecimen(); @@ -76,63 +90,112 @@ if ($_GET["action"] == 'specimen') } else { - $mesg='
'.$module->error.'
'; + $mesg=''.$module->error.''; dol_syslog($module->error, LOG_ERR); } } else { - $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + $mesg=''.$langs->trans("ErrorModuleNotFound").''; dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } -if ($_POST["action"] == 'set_PROPALE_DRAFT_WATERMARK') +if ($action == 'set_PROPALE_DRAFT_WATERMARK') { - dolibarr_set_const($db, "PROPALE_DRAFT_WATERMARK",trim($_POST["PROPALE_DRAFT_WATERMARK"]),'chaine',0,'',$conf->entity); + $draft = GETPOST("PROPALE_DRAFT_WATERMARK"); + + $res = dolibarr_set_const($db, "PROPALE_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_PROPALE_FREE_TEXT') +if ($action == 'set_PROPALE_FREE_TEXT') { - dolibarr_set_const($db, "PROPALE_FREE_TEXT",$_POST["PROPALE_FREE_TEXT"],'chaine',0,'',$conf->entity); + $freetext = GETPOST("PROPALE_FREE_TEXT"); + + $res = dolibarr_set_const($db, "PROPALE_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -if ($_POST["action"] == 'setdefaultduration') +if ($action == 'setdefaultduration') { - dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION",$_POST["value"],'chaine',0,'',$conf->entity); + $res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION",$value,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -if ($_POST["action"] == 'setclassifiedinvoiced') +if ($action == 'setclassifiedinvoiced') { - dolibarr_set_const($db, "PROPALE_CLASSIFIED_INVOICED_WITH_ORDER",$_POST["value"],'chaine',0,'',$conf->entity); + $res = dolibarr_set_const($db, "PROPALE_CLASSIFIED_INVOICED_WITH_ORDER",$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -if ($_POST["action"] == 'setusecustomercontactasrecipient') +/*if ($action == 'setusecustomercontactasrecipient') { dolibarr_set_const($db, "PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT",$_POST["value"],'chaine',0,'',$conf->entity); -} +}*/ -if ($_GET["action"] == 'set') +if ($action == 'set') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $type='propal'; $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)) { } } -if ($_GET["action"] == 'del') +if ($action == 'del') { $type='propal'; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql.= " WHERE nom = '".$_GET["value"]."'"; + $sql.= " WHERE nom = '".$value."'"; $sql.= " AND type = '".$type."'"; $sql.= " AND entity = ".$conf->entity; if ($db->query($sql)) @@ -141,27 +204,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, "PROPALE_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) + if (dolibarr_set_const($db, "PROPALE_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { - $conf->global->PROPALE_ADDON_PDF = $_GET["value"]; + $conf->global->PROPALE_ADDON_PDF = $value; } // On active le modele $type='propal'; $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.= ($value?"'".$db->escape($label)."'":'null').", "; + $sql.= (! empty($value)?"'".$db->escape($scandir)."'":"null"); $sql.= ")"; $result2=$db->query($sql); if ($result1 && $result2) @@ -174,12 +240,12 @@ 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, "PROPALE_ADDON",$_GET["value"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "PROPALE_ADDON",$value,'chaine',0,'',$conf->entity); } @@ -191,7 +257,7 @@ llxHeader('',$langs->trans("PropalSetup")); $html=new Form($db); -if ($mesg) print $mesg; +//if ($mesg) print $mesg; $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup'); @@ -255,12 +321,12 @@ foreach ($conf->file->dol_document_root as $dirroot) print ''; if ($conf->global->PROPALE_ADDON == "$file") { - print img_picto($langs->trans("Activated"),'on'); + print img_picto($langs->trans("Activated"),'switch_on'); } else { print ''; - print img_picto($langs->trans("Disabled"),'off'); + print img_picto($langs->trans("Disabled"),'switch_off'); print ''; } print ''; @@ -377,18 +443,18 @@ foreach ($conf->file->dol_document_root as $dirroot) if ($conf->global->PROPALE_ADDON_PDF != "$name") { print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Activated"),'on'); + print img_picto($langs->trans("Activated"),'switch_on'); print ''; } else { - print img_picto($langs->trans("Activated"),'on'); + print img_picto($langs->trans("Activated"),'switch_on'); } } else { print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Disabled"),'off'); + print img_picto($langs->trans("Disabled"),'switch_off'); print ''; } print ""; @@ -397,12 +463,12 @@ foreach ($conf->file->dol_document_root as $dirroot) print ''; if ($conf->global->PROPALE_ADDON_PDF == "$name") { - print img_picto($langs->trans("Yes"),'on'); + print img_picto($langs->trans("Yes"),'switch_on'); } else { print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("No"),'off'); + print img_picto($langs->trans("No"),'switch_off'); print ''; } print ''; @@ -538,7 +604,7 @@ print "\n"; print "\n ".$langs->trans("PathDirectory")."\n ".$conf->propale->dir_output."\n\n"; print "\n
"; - +dol_htmloutput_mesg($mesg); $db->close();