diff --git a/htdocs/telephonie/tarifs/grille.php b/htdocs/telephonie/tarifs/grille.php new file mode 100644 index 00000000000..8dcfe5ad527 --- /dev/null +++ b/htdocs/telephonie/tarifs/grille.php @@ -0,0 +1,279 @@ + + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ +require("./pre.inc.php"); + +$page = $_GET["page"]; +$sortorder = $_GET["sortorder"]; +$sortfield = $_GET["sortfield"]; + +$sql = "SELECT pwrite "; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights "; +$sql .= " WHERE fk_grille = '".$_GET["id"]."'"; +$sql .= " AND fk_user = ".$user->id; + +$auth_write = 0; + +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows(); + $i = 0; + + if ($num > 0) + { + $row = $db->fetch_row($resql); + $auth_write = $row[0]; + } + $db->free($resql); +} + +/* + * + * + */ +if ($_POST["action"] == 'modif' && $auth_write) +{ + $sortorder = "DESC"; + $sortfield = "m.tms"; + + if ($_POST["temporel"] > 0) + { + require_once DOL_DOCUMENT_ROOT."/telephonie/telephonie.tarif.grille.class.php"; + + $obgrille = new TelephonieTarifGrille($db); + + $obgrille->UpdateTarif($_GET["id"], $_POST["tarif"], $_POST["temporel"], $_POST["fixe"], $user); + + + Header("Location: grille.php?id=".$_GET["id"]); + } +} + +llxHeader(); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + + + + +/* + * Mode Liste + * + * + * + */ +print '
| ';
+
+$sql = "SELECT d.libelle as tarif_desc, d.type_tarif";
+$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille as d";
+$sql .= " WHERE d.rowid = '".$_GET["id"]."'";
+
+$resql = $db->query($sql);
+if ($resql)
+{
+ $num = $db->num_rows();
+ $i = 0;
+
+ if ($num > 0)
+ {
+ $grille = $db->fetch_row($resql);
+ }
+}
+
+print "Grille : ".$grille[0]." "; + +print 'Export tableur '; + +if ($auth_write) +{ + + print ''; + +} + + +print '
| ';
+
+
+
+if ($sortorder == "") $sortorder="ASC";
+if ($sortfield == "") $sortfield="t.libelle ASC, d.rowid ";
+
+$offset = $conf->liste_limit * $page ;
+
+
+$sql = "SELECT d.libelle as tarif_desc, d.type_tarif";
+$sql .= " , t.libelle as tarif";
+$sql .= " , m.temporel, m.fixe, t.rowid";
+$sql .= " , u.code";
+$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille as d";
+$sql .= "," . MAIN_DB_PREFIX."telephonie_tarif_montant as m";
+$sql .= "," . MAIN_DB_PREFIX."telephonie_tarif as t";
+$sql .= "," . MAIN_DB_PREFIX."user as u";
+
+$sqlc .= " WHERE d.rowid = m.fk_tarif_desc";
+$sqlc .= " AND m.fk_tarif = t.rowid";
+$sqlc .= " AND m.fk_user = u.rowid";
+
+$sqlc .= " AND d.rowid = '".$_GET["id"]."'";
+
+
+if ($_GET["search_libelle"])
+{
+ $sqlc .=" AND t.libelle LIKE '%".$_GET["search_libelle"]."%'";
+}
+
+if ($_GET["search_prefix"])
+{
+ $sqlc .=" AND tf.prefix LIKE '%".$_GET["search_prefix"]."%'";
+}
+
+if ($_GET["type"])
+{
+ $sqlc .= " AND d.type_tarif = '".$_GET["type"]."'";
+}
+
+
+$sql = $sql . $sqlc . " ORDER BY $sortfield $sortorder";
+
+$result = $db->query($sql);
+if ($result)
+{
+ $num = $db->num_rows();
+ $i = 0;
+
+ print '
|