* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/admin/const.php * \ingroup setup * \brief Admin page to define miscellaneous constants * \version $Id: const.php,v 1.70 2011/07/31 22:23:21 eldy Exp $ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); $langs->load("admin"); if (!$user->admin) accessforbidden(); //var_dump($_POST); $typeconst=array('yesno','texte','chaine'); /* * Actions */ if ($_POST["action"] == 'add') { $error=0; if (empty($_POST["constname"])) { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Name")).'
'; $error++; } if ($_POST["constvalue"]=='') { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Value")).'
'; $error++; } if (! $error) { if (dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],1,isset($_POST["constnote"])?$_POST["constnote"]:'',$_POST["entity"]) < 0) { dolibarr_print_error($db); } } } if (($_POST["const"] && isset($_POST["update"]) && $_POST["update"] == $langs->trans("Modify"))) { foreach($_POST["const"] as $const) { if ($const["check"]) { if (dolibarr_set_const($db, $const["name"],$const["value"],$const["type"],1,$const["note"],$const["entity"]) < 0) { dolibarr_print_error($db); } } } } // Delete several lines at once if ($_POST["const"] && $_POST["delete"] && $_POST["delete"] == $langs->trans("Delete")) { foreach($_POST["const"] as $const) { if ($const["check"]) // Is checkbox checked { if (dolibarr_del_const($db, $const["rowid"], -1) < 0) { dolibarr_print_error($db); } } } } // Delete line from delete picto if ($_GET["action"] == 'delete') { if (dolibarr_del_const($db, $_GET["rowid"],$_GET["entity"]) < 0) { dolibarr_print_error($db); } } /* * View */ llxHeader('',$langs->trans("OtherSetup")); // Add logic to show/hide buttons if ($conf->use_javascript_ajax) { ?> trans("OtherSetup"),'','setup'); print $langs->trans("ConstDesc")."
\n"; print "
\n"; if ($mesg) print $mesg; print ''; print ''; print ''; print ''; print ''; if ($conf->multicompany->enabled && !$user->entity) print ''; print ''; print "\n"; $form = new Form($db); // Line to add new record $var=false; print "\n"; print ''; print ''; print ''; print ''."\n"; print ''; // Limit to superadmin if ($conf->multicompany->enabled && !$user->entity) { print ''; } else { print ''; } print '\n"; print ''; print ''; print "\n"; print ''; print ''; # Affiche lignes des constantes $sql = "SELECT"; $sql.= " rowid"; $sql.= ", ".$db->decrypt('name')." as name"; $sql.= ", ".$db->decrypt('value')." as value"; $sql.= ", type"; $sql.= ", note"; $sql.= ", entity"; $sql.= " FROM ".MAIN_DB_PREFIX."const"; $sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; if ($user->entity || empty($conf->multicompany->enabled)) $sql.= " AND visible = 1"; $sql.= " ORDER BY entity, name ASC"; dol_syslog("Const::listConstant sql=".$sql); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $var=false; while ($i < $num) { $obj = $db->fetch_object($result); $var=!$var; print "\n"; print ''; print ''; print ''; print ''."\n"; // Value print ''; // Entity limit to superadmin if ($conf->multicompany->enabled && !$user->entity) { print ''; } else { print ''; } print '\n"; print "\n"; $i++; } } print '
'.$langs->trans("Name").''.$langs->trans("Value").''.$langs->trans("Comment").''.$langs->trans("Entity").''.$langs->trans("Action").'
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "
'.$obj->name.''; print ''; print ''; // Note print ''; print ''; print ''; print ''; if ($conf->use_javascript_ajax) { print ''; print '   '; } else { print ''.img_delete().''; } print "
'; if ($conf->use_javascript_ajax) { print '
'; print '
'; print ''; print '
'; print '
'; print ''; print '
'; } print "\n"; $db->close(); llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.70 $'); ?>