[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2004-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: tarifs.php,v 1.10 2005/09/06 21:56:20 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/client/tarifs.php,v $ 20 * 21 */ 22 23 require ("./pre.inc.php"); 24 25 $message_erreur = ''; 26 27 28 if ($_POST["action"] == 'addtarif' && $user->rights->telephonie->tarif->client_modifier) 29 { 30 $error = 0; 31 $saisieok = 1; 32 33 if (strlen(trim($_POST["temporel"])) == 0 OR strlen(trim($_POST["fixe"])) == 0) 34 { 35 $saisieok = 0; 36 } 37 else 38 { 39 $temporel = ereg_replace(",",".",trim($_POST["temporel"])); 40 $fixe = ereg_replace(",",".",trim($_POST["fixe"])); 41 } 42 43 if(! is_numeric($temporel)) 44 { 45 $saisieok = 0; 46 } 47 48 if(! is_numeric($fixe)) 49 { 50 $saisieok = 0; 51 } 52 53 if ($temporel < 0 OR $fixe < 0) 54 { 55 $saisieok = 0; 56 } 57 58 if ($saisieok) 59 { 60 61 $db->begin(); 62 63 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client"; 64 $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES "; 65 $sql .= " (".$_POST["tarifid"].",".$_GET["id"].",'".$temporel."','".$fixe."',".$user->id.")"; 66 67 if (! $db->query($sql) ) 68 { 69 $error++; 70 } 71 72 $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log"; 73 $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES "; 74 $sql .= " (".$_POST["tarifid"].",".$_GET["id"].",'".$temporel."','".$fixe."',".$user->id.",now())"; 75 76 if (! $db->query($sql) ) 77 { 78 $error++; 79 } 80 81 if ( $error == 0 ) 82 { 83 $db->commit(); 84 Header("Location: tarifs.php?id=".$_GET["id"]); 85 } 86 else 87 { 88 $db->rollback(); 89 print $db->error(); 90 } 91 } 92 else 93 { 94 $message_erreur = " Saisie invalide"; 95 } 96 } 97 98 99 /* 100 if ($_GET["special"] == 'done') 101 { 102 103 $sql = "SELECT DISTINCT(fk_tarif), fixe, temporel FROM llx_telephonie_prefix as p, llx_telephonie_tarif_vente as v where p.prefix=v.prefix and fixe= 0.14; "; 104 105 if ( $db->query( $sql) ) 106 { 107 $tt = array(); 108 109 $num = $db->num_rows(); 110 if ( $num > 0 ) 111 { 112 $i = 0; 113 114 while ($i < $num) 115 { 116 $row = $db->fetch_row(); 117 118 $tt[$row[0]] = $row[2]; 119 120 $i++; 121 } 122 } 123 124 $db->free(); 125 126 foreach($tt as $key=>$value) 127 { 128 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client"; 129 $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES "; 130 $sql .= " (".$key.",".$_GET["id"].",'".$value."','0.07',".$user->id.")"; 131 } 132 133 } 134 } 135 */ 136 137 if ($_GET["action"] == 'delete' && $user->rights->telephonie->tarif->client_modifier) 138 { 139 140 if (strlen(trim($_GET["tid"])) > 0) 141 { 142 $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_tarif_client"; 143 $sql .= " WHERE rowid = ".$_GET["tid"]; 144 145 if ( $db->query($sql) ) 146 { 147 Header("Location: tarifs.php?id=".$_GET["id"]); 148 } 149 else 150 { 151 print $db->error(); 152 } 153 } 154 } 155 156 llxHeader("","Téléphonie - Fiche Tarif client"); 157 158 if ($cancel == $langs->trans("Cancel")) 159 { 160 $action = ''; 161 } 162 163 /* 164 * 165 * 166 */ 167 168 if ($_GET["id"]) 169 { 170 $soc = new Societe($db); 171 $result = $soc->fetch($_GET["id"], $user); 172 173 if (!$soc->perm_read) 174 { 175 print "Lecture non authorisée"; 176 } 177 178 if ( $result == 1 && $soc->perm_read) 179 { 180 if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') 181 { 182 $h=0; 183 184 $head[$h][0] = DOL_URL_ROOT."/telephonie/client/fiche.php?id=".$soc->id; 185 $head[$h][1] = $langs->trans("Contrats"); 186 $h++; 187 188 $head[$h][0] = DOL_URL_ROOT."/telephonie/client/lignes.php?id=".$soc->id; 189 $head[$h][1] = $langs->trans("Lignes"); 190 $h++; 191 192 $head[$h][0] = DOL_URL_ROOT."/telephonie/client/factures.php?id=".$soc->id; 193 $head[$h][1] = $langs->trans("Factures"); 194 $h++; 195 196 $head[$h][0] = DOL_URL_ROOT."/telephonie/client/stats.php?id=".$soc->id; 197 $head[$h][1] = $langs->trans("Stats"); 198 $h++; 199 200 $head[$h][0] = DOL_URL_ROOT."/telephonie/client/tarifs.php?id=".$soc->id; 201 $head[$h][1] = $langs->trans("Tarifs"); 202 $hselected = $h; 203 $h++; 204 205 dolibarr_fiche_head($head, $hselected, 'Client : '.$soc->nom); 206 207 print '<table class="border" cellpadding="3" cellspacing="0" width="100%">'; 208 print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>'.$soc->nom.'</td><td>'.$langs->trans('Code client').'</td><td>'.$soc->code_client.'</td></tr>'; 209 210 print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>"; 211 212 print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dolibarr_print_phone($soc->tel).'</td>'; 213 print '<td>'.$langs->trans('Fax').'</td><td>'.dolibarr_print_phone($soc->fax).'</td></tr>'; 214 215 print "</table>\n<br />\n"; 216 217 print '<form action="tarifs.php?id='.$soc->id.'" method="POST">'; 218 print '<input type="hidden" name="action" value="addtarif">'; 219 220 print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; 221 222 print '<tr class="liste_titre"><td width="15%" valign="center">Tarif (coût en euros par minutes)'; 223 print '</td><td align="center">Temporel</td><td align="center">Fixe</td>'; 224 if ($user->rights->telephonie->tarif->client_modifier) 225 { 226 print '<td> </td>'; 227 } 228 print '<td> </td>'; 229 print "</tr>\n"; 230 231 if($message_erreur) 232 { 233 print '<tr class="liste_titre"><td align="center" bgcolor="red" colspan="5">'.$message_erreur.'</td></tr>'; 234 } 235 236 if ($user->rights->telephonie->tarif->client_modifier) 237 { 238 print "<tr><td>\n"; 239 print '<select name="tarifid">'; 240 241 $sql = "SELECT t.rowid , t.libelle"; 242 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif as t"; 243 $sql .= " ORDER BY t.libelle"; 244 $resql = $db->query($sql) ; 245 if ($resql) 246 { 247 $num = $db->num_rows($resql); 248 if ( $num > 0 ) 249 { 250 $i = 0; 251 252 while ($i < $num) 253 { 254 $obj = $db->fetch_object($resql); 255 print '<option value="'.$obj->rowid.'">'.$obj->libelle; 256 $i++; 257 } 258 } 259 } 260 print "</select></td>\n"; 261 262 print '<td align="center"><input name="temporel" type="text" value="'.$_POST["temporel"].'" "size="5"></td>'; 263 print '<td align="center"><input name="fixe" value="'.$_POST["fixe"].'" type="text" size="5"></td>'; 264 print '<td align="center"><input type="submit"></td><td> </td>'; 265 print "</tr>\n"; 266 } 267 268 /* Tarifs */ 269 270 $sql = "SELECT t.rowid , t.libelle, tc.temporel, tc.fixe, u.code, tc.rowid, u.code"; 271 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif as t"; 272 $sql .= "," . MAIN_DB_PREFIX."telephonie_tarif_client as tc"; 273 $sql .= "," . MAIN_DB_PREFIX."societe as s"; 274 $sql .= "," . MAIN_DB_PREFIX."user as u"; 275 276 $sql .= " WHERE t.rowid = tc.fk_tarif AND tc.fk_client = s.idp"; 277 $sql .= " AND u.rowid = tc.fk_user"; 278 $sql .= " AND s.idp = ".$soc->id; 279 $sql .= " ORDER BY t.libelle ASC"; 280 281 if ( $db->query( $sql) ) 282 { 283 $num = $db->num_rows(); 284 if ( $num > 0 ) 285 { 286 $i = 0; 287 288 $ligne = new LigneTel($db); 289 290 while ($i < $num) 291 { 292 $obj = $db->fetch_object($i); 293 $var=!$var; 294 295 print "<tr $bc[$var]><td>\n"; 296 297 print $obj->libelle."</td>\n"; 298 299 print '<td align="center">'.$obj->temporel."</td>\n"; 300 print '<td align="center">'.$obj->fixe."</td>\n"; 301 302 if ($user->rights->telephonie->tarif->client_modifier) 303 { 304 print '<td align="center"><a href="'.DOL_URL_ROOT.'/telephonie/client/tarifs.php?action=delete&tid='.$obj->rowid.'&id='.$soc->id.'">'; 305 print img_delete()."</a></td>\n"; 306 } 307 print '<td align="center">'.$obj->code."</td>\n"; 308 print '</tr>'; 309 310 $i++; 311 } 312 } 313 $db->free(); 314 315 } 316 else 317 { 318 print $sql; 319 } 320 321 print "</table>\n</form>\n"; 322 } 323 } 324 } 325 else 326 { 327 print "Error"; 328 } 329 330 331 print '</div>'; 332 333 /* ************************************************************************** */ 334 /* */ 335 /* Barre d'action */ 336 /* */ 337 /* ************************************************************************** */ 338 339 $db->close(); 340 341 llxFooter("<em>Dernière modification $Date: 2005/09/06 21:56:20 $ révision $Revision: 1.10 $</em>"); 342 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |