Fix: add ajax constant on/off

This commit is contained in:
Regis Houssin 2012-02-13 09:45:38 +01:00
parent fdb2122070
commit c80646671f

View File

@ -1,8 +1,8 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -30,13 +30,14 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
$langs->load("admin"); $langs->load("admin");
$langs->load("workflow"); $langs->load("workflow");
if (!$user->admin) if (! $user->admin) accessforbidden();
accessforbidden();
$action = GETPOST('action', 'alpha');
/* /*
* Actions * Actions
*/ */
if (preg_match('/set(.*)/',$_GET["action"],$reg)) if (preg_match('/set(.*)/',$action,$reg))
{ {
$code=$reg[1]; $code=$reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
@ -50,7 +51,7 @@ if (preg_match('/set(.*)/',$_GET["action"],$reg))
} }
} }
if (preg_match('/del(.*)/',$_GET["action"],$reg)) if (preg_match('/del(.*)/',$action,$reg))
{ {
$code=$reg[1]; $code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0)
@ -82,8 +83,8 @@ print "<br>";
// Choix du module de gestion des codes clients / fournisseurs // Choix du module de gestion des codes clients / fournisseurs
print "<table class=\"noborder\" width=\"100%\">\n"; print '<table class="noborder" width="100%">'."\n";
print "<tr class=\"liste_titre\">\n"; print '<tr class="liste_titre">'."\n";
print ' <td>'.$langs->trans("Description").'</td>'; print ' <td>'.$langs->trans("Description").'</td>';
print ' <td align="center">'.$langs->trans("Status").'</td>'; print ' <td align="center">'.$langs->trans("Status").'</td>';
//print ' <td align="center" width="80">'.$langs->trans("Infos").'</td>'; //print ' <td align="center" width="80">'.$langs->trans("Infos").'</td>';
@ -104,18 +105,27 @@ if (count($workflowcodes) > 0)
$var = !$var; $var = !$var;
print "<tr ".$bc[$var].">\n"; print "<tr ".$bc[$var].">\n";
print "<td>".$langs->trans('desc'.$code)."</td>\n"; print "<td>".$langs->trans('desc'.$code)."</td>\n";
if (! empty($conf->global->$code)) print '<td align="center">';
if ($conf->use_javascript_ajax)
{ {
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=del'.$code.'">'; print ajax_constantonoff($code);
print img_picto($langs->trans("Activated"),'switch_on');
print '</a></td>';
} }
else else
{ {
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=set'.$code.'">'; if (! empty($conf->global->$code))
print img_picto($langs->trans("Disabled"),'switch_off'); {
print '</a></td>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del'.$code.'">';
print img_picto($langs->trans("Activated"),'switch_on');
print '</a>';
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set'.$code.'">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a>';
}
} }
print '</td>';
//print '<td align="center">'; //print '<td align="center">';
//$s=$modCodeTiers->getToolTip($langs,$soc,-1); //$s=$modCodeTiers->getToolTip($langs,$soc,-1);
@ -131,8 +141,8 @@ else
} }
print '</table>'; print '</table>';
llxFooter();
$db->close(); $db->close();
llxFooter();
?> ?>