[ Index ] |
|
Code source de Dolibarr 2.0.1 |
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: telephonie.service.class.php,v 1.3 2005/04/07 15:55:50 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/telephonie.service.class.php,v $ 20 * 21 */ 22 23 class TelephonieService { 24 var $db; 25 26 var $id; 27 var $ligne; 28 29 function TelephonieService($DB) 30 { 31 global $config; 32 33 $this->db = $DB; 34 $this->error_message = ''; 35 $this->statuts[0] = "Inactif"; 36 $this->statuts[1] = "Actif"; 37 38 return 0; 39 } 40 /* 41 * 42 * 43 */ 44 function update($user) 45 { 46 $this->montant = ereg_replace(",",".",$this->montant); 47 48 $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_service"; 49 $sql .= " SET "; 50 $sql .= " libelle = '$this->libelle' "; 51 $sql .= ", libelle_facture = '$this->libelle' "; 52 $sql .= ", montant = '$this->montant' "; 53 $sql .= ", fk_user_modif = $user->id "; 54 $sql .= ", date_modif = now() "; 55 56 $sql .= " WHERE rowid = $this->id"; 57 58 $resql = $this->db->query($sql); 59 60 if ( $resql ) 61 { 62 return 0; 63 } 64 else 65 { 66 print $this->db->error(); 67 print $sql ; 68 return -1; 69 } 70 } 71 /* 72 * 73 * 74 */ 75 function active($user) 76 { 77 78 $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_service"; 79 $sql .= " SET "; 80 $sql .= " statut = 1"; 81 $sql .= ", fk_user_modif = $user->id "; 82 $sql .= ", date_modif = now() "; 83 84 $sql .= " WHERE rowid = $this->id AND statut = 0"; 85 86 $resql = $this->db->query($sql); 87 88 if ( $resql ) 89 { 90 return 0; 91 } 92 else 93 { 94 print $this->db->error(); 95 print $sql ; 96 return -1; 97 } 98 } 99 100 /* 101 * 102 * 103 */ 104 function create($user) 105 { 106 107 $this->montant = ereg_replace(",",".",$this->montant); 108 109 $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_service"; 110 $sql .= " (ref, libelle, libelle_facture, montant, fk_user_creat, date_creat)"; 111 $sql .= " VALUES ("; 112 $sql .= " '$this->ref','$this->libelle','$this->libelle_facture','$this->montant',$user->id, now())"; 113 114 if ( $this->db->query($sql) ) 115 { 116 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."telephonie_service"); 117 return 0; 118 } 119 else 120 { 121 122 $this->error_message = "Echec de la création du service !"; 123 dolibarr_syslog("TelephonieService::Create Error -1"); 124 return -1; 125 } 126 } 127 /* 128 * 129 * 130 */ 131 132 function fetch($id) 133 { 134 $sql = "SELECT s.rowid, s.libelle, s.libelle_facture, s.montant, s.statut"; 135 $sql .= " , s.ref"; 136 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_service as s"; 137 $sql .= " WHERE s.rowid = ".$id; 138 139 $resql = $this->db->query($sql); 140 141 if ($resql) 142 { 143 if ($this->db->num_rows($resql)) 144 { 145 $obj = $this->db->fetch_object($resql); 146 147 $this->id = $obj->rowid; 148 $this->ref = $obj->ref; 149 $this->libelle = stripslashes($obj->libelle); 150 $this->libelle_facture = stripslashes($obj->libelle_facture); 151 $this->montant = $obj->montant; 152 $this->statut = $obj->statut; 153 154 $result = 0; 155 } 156 else 157 { 158 $result = -2; 159 } 160 161 $this->db->free($resql); 162 } 163 else 164 { 165 /* Erreur select SQL */ 166 print $this->db->error(); 167 $result = -1; 168 } 169 170 return $result; 171 } 172 } 173 ?>
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 |
![]() |