[ 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/telephonie/tarifs/ -> grille.php (source)

   1  <?PHP
   2  /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: grille.php,v 1.4 2005/09/06 15:42:48 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/tarifs/grille.php,v $
  20   *
  21   */
  22  require ("./pre.inc.php");
  23  
  24  $page = $_GET["page"];
  25  $sortorder = $_GET["sortorder"];
  26  $sortfield = $_GET["sortfield"];
  27  
  28  $sql = "SELECT pwrite, pread ";
  29  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights ";
  30  $sql .= " WHERE fk_grille = '".$_GET["id"]."'";
  31  $sql .= " AND fk_user = ".$user->id;
  32  
  33  $auth_write = 0;
  34  
  35  $resql = $db->query($sql);
  36  if ($resql)
  37  {
  38    $num = $db->num_rows();
  39    $i = 0;
  40  
  41    if ($num > 0)
  42      {
  43        $row = $db->fetch_row($resql);
  44        $auth_write = $row[0];
  45        $auth_read = $row[1];
  46      }
  47    $db->free($resql);
  48  }
  49  
  50  if ($auth_read == 0)
  51    accessforbidden();
  52  
  53  /*
  54   *
  55   *
  56   */
  57  if ($_POST["action"] == 'modif' && $auth_write)
  58  {
  59    $sortorder = "DESC";
  60    $sortfield = "m.tms";
  61  
  62    $temporel = ereg_replace(",",".",$_POST["temporel"]);
  63  
  64    if ($temporel > 0)
  65      {
  66        require_once DOL_DOCUMENT_ROOT."/telephonie/telephonie.tarif.grille.class.php";
  67  
  68        $obgrille = new TelephonieTarifGrille($db);
  69  
  70        $obgrille->UpdateTarif($_GET["id"], $_POST["tarif"], $temporel, $_POST["fixe"], $user);
  71  
  72        Header("Location: grille.php?id=".$_GET["id"]);
  73      }
  74  }
  75  
  76  llxHeader();
  77  
  78  /*
  79   * Sécurité accés client
  80   */
  81  if ($user->societe_id > 0) 
  82  {
  83    $action = '';
  84    $socidp = $user->societe_id;
  85  }
  86  
  87  
  88  
  89  
  90  /*
  91   * Mode Liste
  92   *
  93   *
  94   *
  95   */
  96  print '<table width="100%" class="noborder">';
  97  print '<tr><td valign="top" width="30%">';
  98  
  99  $sql = "SELECT d.libelle as tarif_desc, d.type_tarif";
 100  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille as d";
 101  $sql .= " WHERE d.rowid = '".$_GET["id"]."'";
 102  
 103  $resql = $db->query($sql);
 104  if ($resql)
 105  {
 106    $num = $db->num_rows();
 107    $i = 0;
 108  
 109    if ($num > 0)
 110      {
 111        $grille = $db->fetch_row($resql);
 112      }
 113  }
 114  
 115  print "Grille : ".$grille[0]."<br>";
 116  
 117  //print '<a href="grille-export.php?id='.$_GET["id"].'">Export tableur</a><br><br>';
 118  
 119  if ($auth_write)
 120  {
 121  
 122    print '<form method="POST" action="grille.php?id='.$_GET["id"].'">';
 123    print '<input type="hidden" name="action" value="modif">';
 124    print '<table width="100%" class="border">';
 125    print '<tr><td colspan="2">Modification</td></tr>';
 126    print '<tr><td>Tarif</td>';
 127    print '<td><select name="tarif">';
 128    
 129    $sql = "SELECT rowid, libelle";
 130    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif";
 131    $sql .= " WHERE tlink = 0";
 132    $sql .= " ORDER BY libelle ASC";
 133    
 134    $resql = $db->query($sql);
 135    if ($resql)
 136      {
 137        $num = $db->num_rows();
 138        $i = 0;
 139        
 140        while ($i < $num)
 141      {
 142        $row = $db->fetch_row($resql);
 143        print '<option value="'.$row[0].'">'.$row[1]."\n";
 144        $i++;
 145      }
 146      }
 147    print '</select></td></tr>';
 148    
 149  
 150    print '<tr><td>Cout minute</td>';
 151    print '<td><input type="text" name="temporel" value="0"></td></tr>';
 152    
 153    print '<tr><td>Cout connexion</td>';
 154    print '<td><input type="text" name="fixe" value="0"></td></tr>';
 155    
 156    print '<tr><td colspan="2"><input type="submit"></td></tr>';
 157    print '</table></form>';
 158    
 159  }
 160  
 161  
 162  print '<br><table width="100%" class="border">';
 163  print '<tr><td>Personnes pouvant modifier cette grille</td></tr>';
 164  
 165  $sql = "SELECT u.name, u.firstname";
 166  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights as r";
 167  $sql .= " , ".MAIN_DB_PREFIX."user  as u";
 168  $sql .= " WHERE r.fk_grille = '".$_GET["id"]."'";
 169  $sql .= " AND r.fk_user = u.rowid ";
 170  $sql .= " AND r.pwrite = 1";
 171  
 172  $resql = $db->query($sql);
 173  if ($resql)
 174  {
 175    $num = $db->num_rows();
 176    $i = 0;
 177    while ($i < $num )
 178      {
 179        $row = $db->fetch_row($resql);
 180        print '<tr><td>'.$row[1] . ' '.$row[0].'</td></tr>';
 181        $i++;
 182      }
 183  }
 184  print '</table>';
 185  
 186  
 187  
 188  print '</td><td valign="top" width="70%">';
 189  
 190  
 191  
 192  if ($sortorder == "") $sortorder="ASC";
 193  if ($sortfield == "") $sortfield="t.libelle ASC, d.rowid ";
 194  
 195  $offset = $conf->liste_limit * $page ;
 196  
 197  
 198  $sql = "SELECT d.libelle as tarif_desc, d.type_tarif";
 199  $sql .= " , t.libelle as tarif";
 200  $sql .= " , m.temporel, m.fixe, t.rowid";
 201  $sql .= " , u.code";
 202  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille as d";
 203  $sql .= "," . MAIN_DB_PREFIX."telephonie_tarif_montant as m";
 204  $sql .= "," . MAIN_DB_PREFIX."telephonie_tarif as t";
 205  $sql .= "," . MAIN_DB_PREFIX."user as u";
 206  
 207  $sqlc .= " WHERE d.rowid = m.fk_tarif_desc";
 208  $sqlc .= " AND m.fk_tarif = t.rowid";
 209  $sqlc .= " AND m.fk_user = u.rowid";
 210  
 211  $sqlc .= " AND d.rowid = '".$_GET["id"]."'";
 212  
 213  
 214  if ($_GET["search_libelle"])
 215  {
 216    $sqlc .=" AND t.libelle LIKE '%".$_GET["search_libelle"]."%'";
 217  }
 218  
 219  if ($_GET["search_prefix"])
 220  {
 221    $sqlc .=" AND tf.prefix LIKE '%".$_GET["search_prefix"]."%'";
 222  }
 223  
 224  if ($_GET["type"])
 225  {
 226    $sqlc .= " AND d.type_tarif = '".$_GET["type"]."'";
 227  }
 228  
 229  
 230  $sql = $sql . $sqlc . " ORDER BY $sortfield $sortorder";
 231  
 232  $result = $db->query($sql);
 233  if ($result)
 234  {
 235    $num = $db->num_rows();
 236    $i = 0;
 237    
 238    print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
 239    print '<tr class="liste_titre">';
 240  
 241    print_liste_field_titre("Tarif","grille.php","d.libelle");
 242    print_liste_field_titre("Destination","grille.php","t.libelle", "&type=".$_GET["type"]);
 243    print_liste_field_titre("Cout / min","grille.php","temporel", "&type=".$_GET["type"]);
 244    print "</td>";
 245    print "<td>Cout fixe</td>";
 246    print "<td>Type</td><td>User</td>";
 247    print "</tr>\n";
 248  
 249    $var=True;
 250  
 251    while ($i < $num)
 252      {
 253        $obj = $db->fetch_object($i);    
 254        $var=!$var;
 255  
 256        print "<tr $bc[$var]>";
 257  
 258        print "<td>".$obj->tarif_desc."</td>\n";
 259        print '<td><a href="tarif.php?id='.$obj->rowid.'">'.$obj->tarif."</a></td>\n";
 260        print "<td>".sprintf("%01.4f",$obj->temporel)."</td>\n";
 261        print "<td>".sprintf("%01.4f",$obj->fixe)."</td>\n";
 262        print "<td>".$obj->type_tarif."</td>\n";
 263        print "<td>".$obj->code."</td>\n";
 264        print "</tr>\n";
 265        $i++;
 266      }
 267    print "</table>";
 268    $db->free();
 269  }
 270  else 
 271  {
 272    print $db->error() . ' ' . $sql;
 273  }
 274  
 275  print '</td></tr></table>';
 276  
 277  
 278  
 279  
 280  
 281  $db->close();
 282  
 283  llxFooter("<em>Derni&egrave;re modification $Date: 2005/09/06 15:42:48 $ r&eacute;vision $Revision: 1.4 $</em>");
 284  ?>


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