[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/admin/ -> const.php (source)

   1  <?php
   2  /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: const.php,v 1.27 2005/10/14 21:05:13 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/admin/const.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/admin/const.php
  25          \ingroup    setup
  26          \brief      Page d'administration/configuration des constantes autres
  27          \version    $Revision: 1.27 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  
  32  $langs->load("admin");
  33  
  34  if (!$user->admin)
  35    accessforbidden();
  36  
  37  
  38  
  39  $typeconst=array('yesno','texte','chaine');
  40  
  41  if ($_POST["action"] == 'update' || $_POST["action"] == 'add')
  42  {
  43      if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],1,isset($_POST["constnote"])?$_POST["constnote"]:''));
  44      {
  45            print $db->error();
  46      }
  47  }
  48  
  49  if ($_GET["action"] == 'delete')
  50  {
  51      if (! dolibarr_del_const($db, $_GET["rowid"]));
  52      {
  53            print $db->error();
  54      }
  55  }
  56  
  57  
  58  llxHeader();
  59  
  60  print_fiche_titre($langs->trans("OtherSetup"));
  61  
  62  print '<table class="noborder" width="100%">';
  63  print '<tr class="liste_titre">';
  64  print '<td>'.$langs->trans("Name").'</td>';
  65  print '<td>'.$langs->trans("Value").'</td>';
  66  print '<td>'.$langs->trans("Type").'</td>';
  67  print '<td>'.$langs->trans("Note").'</td>';
  68  print '<td>'.$langs->trans("Action").'</td>';
  69  print "</tr>\n";
  70  
  71  
  72  $form = new Form($db);
  73  
  74  
  75  # Affiche ligne d'ajout
  76  $var=false;
  77  print '<form action="const.php" method="POST">';
  78  print '<input type="hidden" name="action" value="add">';
  79  
  80  print "<tr $bc[$var] class=value><td><input type=\"text\" class=\"flat\" size=\"24\" name=\"constname\" value=\"\"></td>\n";
  81  
  82  print '<td>';
  83  print '<input type="text" class="flat" size="30" name="constvalue" value="">';
  84  print '</td><td>';
  85  
  86  $form->select_array('consttype',array('yesno','texte','chaine'),2);
  87  print '</td><td>';
  88  
  89  print '<input type="text" class="flat" size="15" name="constnote" value="">';
  90  print '</td><td>';
  91  
  92  print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="Button"><br>';
  93  print "</td>\n";
  94      
  95  print '</tr>';
  96  print '</form>';
  97  
  98  
  99  # Affiche lignes des constantes
 100  if ($all==1){
 101    $sql = "SELECT rowid, name, value, type, note FROM llx_const ORDER BY name ASC";
 102  }else{
 103    $sql = "SELECT rowid, name, value, type, note FROM llx_const WHERE visible = 1 ORDER BY name ASC";
 104  }
 105  $result = $db->query($sql);
 106  if ($result) 
 107  {
 108    $num = $db->num_rows($result);
 109    $i = 0;
 110    $var=false;
 111  
 112    while ($i < $num)
 113      {
 114        $obj = $db->fetch_object($result);
 115        $var=!$var;
 116  
 117        print '<form action="const.php" method="POST">';
 118        print '<input type="hidden" name="action" value="update">';
 119        print '<input type="hidden" name="rowid" value="'.$rowid.'">';
 120        print '<input type="hidden" name="constname" value="'.$obj->name.'">';
 121  
 122        print "<tr $bc[$var] class=value><td>$obj->name</td>\n";
 123  
 124        // Type
 125        print '<td>';
 126        if ($obj->type == 'yesno')
 127      {
 128        $form->selectyesnonum('constvalue',$obj->value);
 129        print '</td><td>';
 130        $form->select_array('consttype',array('yesno','texte','chaine'),0);
 131      }
 132        elseif ($obj->type == 'texte')
 133      {
 134        print '<textarea name="constvalue" cols="32" rows="3" wrap="soft">';
 135        print $obj->value;
 136        print "</textarea>\n";
 137        print '</td><td>';
 138        $form->select_array('consttype',array('yesno','texte','chaine'),1);
 139      }
 140        else
 141      {
 142        print '<input type="text" class="flat" size="30" name="constvalue" value="'.stripslashes($obj->value).'">';
 143        print '</td><td>';
 144        $form->select_array('consttype',array('yesno','texte','chaine'),2);
 145      }
 146        print '</td><td>';
 147  
 148        // Note
 149        print '<input type="text" class="flat" size="15" name="constnote" value="'.stripslashes(nl2br($obj->note)).'">';
 150        print '</td><td>';
 151        print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="button"> &nbsp; ';
 152        print '<a href="const.php?rowid='.$obj->rowid.'&action=delete">'.img_delete().'</a>';
 153        print "</td></tr>\n";
 154  
 155        print '</form>';
 156        $i++;
 157      }
 158  }
 159  
 160  
 161  print '</table>';
 162  
 163  $db->close();
 164  
 165  llxFooter();
 166  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics