[ 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: simulation.php,v 1.2 2005/03/18 23:56:44 eldy Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/simulation.php,v $ 20 * 21 * 22 */ 23 24 require ("../../master.inc.php"); 25 26 $error = 0; 27 28 $datetime = time(); 29 30 $date = strftime("%d %h %Y %Hh %Mm %S",$datetime); 31 32 33 $sql = " INSERT INTO ".MAIN_DB_PREFIX."telephonie_simul"; 34 $sql .= " (description) VALUES ("; 35 $sql .= " 'Simulation du $date')"; 36 37 if ( $db->query($sql) ) 38 { 39 $simid = $db->last_insert_id(MAIN_DB_PREFIX."telephonie_simul"); 40 } 41 print "Simulation : $simid\n"; 42 /******************************************************************************* 43 * 44 * 45 */ 46 $sql = "SELECT ligne, date, numero, duree "; 47 $sql .= " ,fourn_montant"; 48 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; 49 50 if ( $db->query($sql) ) 51 { 52 $row = array(); 53 $nums = $db->num_rows(); 54 $i = 0; 55 56 while($i < $nums) 57 { 58 $row[$i] = $db->fetch_row(); 59 60 print "."; 61 $i++; 62 } 63 $db->free(); 64 } 65 print "\n"; 66 67 for ($i = 0 ; $i < sizeof($row) ; $i++) 68 { 69 $numero = $row[$i][2]; 70 $duree = $row[$i][3]; 71 $cout_achat = $row[$i][4]; 72 73 if (substr($numero,0,2) == '00') /* International */ 74 { 75 $cout_vente = $cout_achat * 2; 76 } 77 elseif (substr($numero,0,2) == '06') /* Telephones Mobiles */ 78 { 79 $cout_vente = ereg_replace(",",".",$cout_achat + 0.04); 80 } 81 else 82 { 83 $cout_vente = ereg_replace(",",".",($duree * 0.01)/60 + 0.09); 84 } 85 86 $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_simul_comm"; 87 $sql .= "(fk_simulation, ligne, date, numero, duree, cout_achat, cout_vente)"; 88 $sql .=" VALUES ('$simid','".$row[$i][0]."'"; 89 $sql .=" ,'".$row[$i][1]."'"; 90 $sql .=" ,'".$row[$i][2]."'"; 91 $sql .=" ,'".$row[$i][3]."'"; 92 $sql .=" ,'".$row[$i][4]."'"; 93 $sql .=" ,'".$cout_vente."'"; 94 $sql .= " )"; 95 96 if (! $db->query($sql) ) 97 { 98 print "Error"; 99 exit ; 100 } 101 } 102 103 /* 104 * 105 * 106 */ 107 108 $sql = "SELECT fk_simulation, sum(cout_achat), sum(cout_vente),count(*)"; 109 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_simul_comm"; 110 $sql .= " GROUP BY fk_simulation"; 111 if ( $db->query($sql) ) 112 { 113 $nums = $db->num_rows(); 114 $i = 0; 115 116 while($i < $nums) 117 { 118 $row = $db->fetch_row(); 119 120 print $row[0]." ".round($row[1],2); 121 print "\t".round($row[2],2); 122 print "\t".round(($row[2]-$row[1])/$row[1]*100,2)." %"; 123 print "\t".round($row[3],2); 124 print "\t".round($row[1]/$row[3],2); 125 print "\t".round($row[2]/$row[3],2)."\n"; 126 127 $i++; 128 } 129 $db->free(); 130 } 131 print "\n"; 132 133 134 ?>
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 |
![]() |