[ 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: communication.class.php,v 1.8 2005/12/02 13:26:19 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/communication.class.php,v $ 20 * 21 */ 22 23 class CommunicationTelephonique { 24 25 var $index; 26 var $ligne; 27 var $date; 28 var $duree; 29 var $dest; 30 var $numero; 31 var $montant; 32 33 /** 34 * Constructeur 35 * 36 */ 37 function CommunicationTelephonique() 38 { 39 return 1; 40 } 41 42 /** 43 * Calcul le coût de la communication 44 * 45 */ 46 function cout($tarif_achat, $tarif_vente, $ligne, $_db) 47 { 48 $error = 0; 49 50 if (substr($this->numero,0,2) == '00') /* International */ 51 { 52 $nbinter++; 53 $duree_international += $objp->duree; 54 55 $num = $this->numero; 56 57 $this->remise = 0; 58 } 59 60 elseif (substr($this->numero,0,2) == '06') /* Telephones Mobiles */ 61 { 62 $dureemob += $objp->duree; 63 $nbmob++; 64 65 $num = "0033".substr($this->numero,1); 66 67 $this->remise = $ligne->remise; 68 } 69 /* Tarif Local */ 70 /* 71 elseif (substr($this->numero,0,4) == substr($objp->client,0,4) ) 72 { 73 $dureenat += $objp->duree; 74 $nbnat++; 75 $num = "0033999".substr($this->numero, 1); 76 $this->remise = $ligne->remise; 77 }*/ 78 else 79 { 80 $dureenat += $objp->duree; 81 $nbnat++; 82 83 $num = "0033".substr($this->numero, 1); 84 85 $this->remise = $ligne->remise; 86 } 87 88 /* 89 * 90 * 91 */ 92 /* Numéros spéciaux */ 93 if (substr($num,4,1) == 8) 94 { 95 $this->remise = 0; 96 $this->cout_temp_vente = 0; 97 $this->tarif_libelle_vente = "Numéros spéciaux"; 98 $this->cout_fixe_vente = ereg_replace(",",".", $this->montant); 99 } 100 else 101 { 102 /* Fin Numéros spéciaux */ 103 if (! $tarif_achat->cout($num, $this->cout_temp_achat, $this->cout_fixe_achat, $tarif_libelle_achat)) 104 { 105 print "3- Tarif achat manquant pour $num\n"; 106 dolibarr_syslog("CommunicationTelephonique::Cout Tarif achat manquant pour $num"); 107 $error++; 108 } 109 110 if (! $tarif_vente->cout($num, $this->cout_temp_vente, $this->cout_fixe_vente, $this->tarif_libelle_vente)) 111 { 112 print "3- Tarif vente manquant pour $num\n"; 113 dolibarr_syslog("CommunicationTelephonique::Cout Tarif vente manquant pour $num"); 114 $error++; 115 } 116 } 117 /* Specification VoIP */ 118 if ($ligne->techno == 'voip') 119 { 120 if (substr($num,4,1) < 6) 121 { 122 $lignedest = new LigneTel($_db); 123 124 if ($lignedest->fetch("0".substr($num, -9)) == 1) 125 { 126 if ($lignedest->techno == 'voip' && ($ligne->client_comm_id == $lignedest->client_comm_id)) 127 { 128 $this->remise = 0; 129 $this->cout_fixe_vente = 0; 130 $this->cout_temp_vente = 0; 131 $this->tarif_libelle_vente = "Appel Interne VoIP"; 132 } 133 } 134 } 135 } 136 /* Fin VoIP */ 137 138 $this->cout_achat = ( ($this->duree * $this->cout_temp_achat / 60) + $this->cout_fixe_achat); 139 140 if ($ligne->facturable == 1) 141 { 142 $this->cout_vente = ( ($this->duree * $this->cout_temp_vente / 60)); 143 144 $this->cout_vente = ( $this->cout_vente * ( 1 - ($this->remise / 100))); 145 /* Ajouté round le 2/12/05 */ 146 $this->cout_vente = round(($this->cout_vente + $this->cout_fixe_vente), 3); 147 } 148 else 149 { 150 $this->cout_vente = 0; 151 } 152 153 return $error; 154 } 155 156 /* 157 * Enregistre la ligne de communications dans 158 * llx_telephonie_communications_details 159 * 160 */ 161 162 function logsql($db) 163 { 164 165 $this->cout_achat = ereg_replace(",",".", $this->cout_achat); 166 $this->cout_vente = ereg_replace(",",".", $this->cout_vente); 167 $this->remise = ereg_replace(",",".", $this->remise); 168 $this->montant = ereg_replace(",",".", $this->montant); 169 170 $this->dateheure = mktime(substr($this->heure, 0,2), 171 substr($this->heure, 3,2), 172 substr($this->heure, 6,2), 173 substr($this->date, 3,2), 174 substr($this->date, 0,2), 175 substr($this->date, 6,4)); 176 177 178 $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_communications_details"; 179 $sql .= " (fk_ligne,ligne, date, numero, duree"; 180 $sql .= ", tarif_achat_temp, tarif_achat_fixe, tarif_vente_temp, tarif_vente_fixe"; 181 $sql .= ", cout_achat, cout_vente, remise,dest, fourn_montant"; 182 $sql .= " , fichier_cdr, fk_fournisseur, fk_telephonie_facture)"; 183 184 $sql .= " VALUES ("; 185 $sql .= $this->fk_ligne.","; 186 $sql .= "'$this->ligne','".$db->idate($this->dateheure)."','$this->numero','$this->duree'"; 187 188 $sql .= ", '$this->cout_temp_achat','$this->cout_fixe_achat','$this->cout_temp_vente','$this->cout_fixe_vente'"; 189 $sql .= ", '$this->cout_achat','$this->cout_vente', '$this->remise'"; 190 $sql .= ",'".addslashes($this->tarif_libelle_vente)."','$this->montant'"; 191 $sql .= ",'".$this->fichier_cdr."','".$this->fournisseur."'"; 192 $sql .= ",'".$this->facture_id."')"; 193 194 if (! $db->query($sql)) 195 { 196 dolibarr_syslog("CommunicationTelephonique::logsql Erreur"); 197 dolibarr_syslog("CommunicationTelephonique::logsql ".$db->error()); 198 return 1; 199 } 200 else 201 { 202 return 0; 203 } 204 } 205 206 /* 207 * 208 */ 209 210 function _log( $text) 211 { 212 if ($this->file_details) 213 { 214 fputs($this->file_details, $text); 215 } 216 } 217 218 /* 219 * 220 */ 221 222 function loghtml($file) 223 { 224 $this->file_details = $file; 225 226 $this->_log( '<tr>'); 227 $this->_log( "<td>$this->index"); 228 $this->_log( "<td>$this->ligne"); 229 $this->_log( "<td>".$this->dest); 230 $this->_log( "<td>".$this->duree); 231 $this->_log( "<td>".$this->montant); 232 $this->_log( "<td>".$cout_calcul); 233 234 if (round($cout_calcul,3) <> $objp->montant) 235 { 236 _log($file_details, "<td bgcolor=pink>".round($cout_calcul,3)); 237 $err++; 238 } 239 else 240 { 241 _log($file_details, "<td>".round($cout_calcul,3)); 242 } 243 _log($file_details, "<td>$err"); 244 245 } 246 } 247 ?>
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 |
![]() |