[ 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: presel_active_view.php,v 1.6 2005/12/08 10:48:45 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/presel_active_view.php,v $ 20 * 21 * Visualisation de l'etat des lignes preselectionnées 22 * 23 */ 24 require ("../../master.inc.php"); 25 require_once DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"; 26 require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php"; 27 28 $host = CMD_PRESEL_WEB_HOST; 29 $user_login = CMD_PRESEL_WEB_USER; 30 $user_passwd = CMD_PRESEL_WEB_PASS; 31 32 $user = new User($db); 33 $user->id = 1; 34 35 $ids = array(); 36 37 if ($argv[1]) 38 { 39 $debug = 0; 40 array_push($ids, $argv[1]); 41 } 42 else 43 { 44 $sql = "SELECT rowid,ligne"; 45 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne"; 46 $sql .= " WHERE fk_fournisseur = 4"; 47 $sql .= " AND statut = 3"; 48 if ($debug) 49 { 50 $sql .= " LIMIT 1"; 51 } 52 $resql = $db->query($sql); 53 54 if ($resql) 55 { 56 while ($row = $db->fetch_row($resql)) 57 { 58 array_push($ids, $row[1]); 59 } 60 } 61 else 62 { 63 print $db->error(); 64 exit(1); 65 } 66 } 67 68 GetPreselection_byRef($db, $host, $user_login, $user_passwd, $ids, $debug, $user); 69 70 /* 71 * Fonctions 72 * 73 */ 74 75 function GetPreselection_byRef($db, $host, $user_login, $user_passwd, $ids, $debug, $user) 76 { 77 $numcli = sizeof($ids); 78 $i = 0; 79 print "Nombre de lignes $numcli\n"; 80 foreach($ids as $cli) 81 { 82 $i++; 83 $fp = @fsockopen($host, 80, $errno, $errstr, 30); 84 if (!$fp) 85 { 86 print "Impossible de se connecter au server $errstr ($errno)"; 87 } 88 else 89 { 90 $ligne_numero = ""; 91 $ligne_service = ""; 92 $ligne_presel = ""; 93 94 //GetPreselection_byRef 95 $url = "/AzurApp_websvc_b3gdb/account.asmx/GetPreselection_byRef?"; 96 97 $url .= "user_login=". $user_login; 98 $url .= "&user_passwd=".$user_passwd; 99 $url .= "&telnum=".$cli; 100 101 $out = "GET $url HTTP/1.1\r\n"; 102 $out .= "Host: $host\r\n"; 103 $out .= "Connection: Close\r\n\r\n"; 104 105 fwrite($fp, $out); 106 107 while (!feof($fp)) 108 { 109 $line = fgets($fp, 1024); 110 if ($debug) 111 { 112 print $line; 113 } 114 if (preg_match("/<Preselection .* \/>/",$line)) 115 { 116 $results = split(" ",trim($line)); 117 //print_r($results); 118 119 $array = array(); 120 preg_match('/telnum="([0123456789]*)"/', $line, $array); 121 $ligne_numero = $array[1]; 122 123 $array = array(); 124 preg_match('/ServiceActive="([\S]*)"/i', $line, $array); 125 $service_active = $array[1]; 126 127 $array = array(); 128 preg_match('/PreSelectionActive="([\S]*)"/i', $line, $array); 129 $presel_active = $array[1]; 130 131 $array = array(); 132 preg_match('/Service_Statut="([\S]*)"/i', $line, $array); 133 $ligne_service = $array[1]; 134 135 $array = array(); 136 preg_match('/PreSelection_Statut="([\S]*)"/i', $line, $array); 137 $ligne_presel = $array[1]; 138 139 if ($ligne_service.$ligne_presel <> 'TRAITE_OKTRAITE_OK') 140 { 141 print "$i/$numcli "; 142 print $ligne_numero." "; 143 print "$service_active/$presel_active "; 144 print substr($ligne_service.str_repeat(" ",20),0,20); 145 print substr($ligne_presel.str_repeat(" ",20),0,20); 146 print "\n"; 147 } 148 149 $situation_key = $ligne_service.' / '.$ligne_presel; 150 151 if ($situation_key == 'TRAITE_OK / ATTENTE') 152 { 153 $ligne = new LigneTel($db); 154 155 if ($ligne->fetch($ligne_numero) == 1) 156 { 157 if ($ligne->statut == 3) 158 { 159 $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_commande_retour"; 160 $sql .= " (cli,mode,date_traitement,situation,fk_fournisseur,traite)"; 161 $sql .= " VALUES ('$ligne_numero','PRESELECTION',now(),'$situation_key',4,1);"; 162 163 $resql = $db->query($sql); 164 165 $statut = 6; 166 $date_resiliation = time(); 167 $datea = $db->idate($date_resiliation); 168 169 if ($ligne->set_statut($user, $statut, $datea,'',4) <> 0) 170 { 171 $error++; 172 print "ERROR\n"; 173 } 174 } 175 } 176 else 177 { 178 print "Erreur de lecture\n"; 179 } 180 } 181 182 183 } 184 185 if (preg_match("/<Error .* \/>/",$line)) 186 { 187 $array = array(); 188 preg_match('/libelle="(.*)" xmlns:d4p1/', $line, $array); 189 190 print "$i/$numcli "; 191 print "$cli ErreurAPI ".$array[1]."\n"; 192 } 193 } 194 fclose($fp); 195 } 196 } 197 } 198 199 ?>
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 |
![]() |