[ 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: delete_presel.php,v 1.1 2005/11/30 13:56:36 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/delete_presel.php,v $ 20 * 21 * 22 * Commandes des lignes par API 23 * 24 */ 25 require ("../../master.inc.php"); 26 require_once DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"; 27 28 $verbose = 0; 29 30 for ($i = 1 ; $i < sizeof($argv) ; $i++) 31 { 32 if ($argv[$i] == "-v") 33 { 34 $verbose = 1; 35 } 36 if ($argv[$i] == "-vv") 37 { 38 $verbose = 2; 39 } 40 if ($argv[$i] == "-vvv") 41 { 42 $verbose = 3; 43 } 44 } 45 46 47 $user = new User($db); 48 $user->id = 1; // C'est sale je sais ! 49 50 $host = CMD_PRESEL_WEB_HOST; 51 $user_login = CMD_PRESEL_WEB_USER; 52 $user_passwd = CMD_PRESEL_WEB_PASS; 53 $user_contract = CMD_PRESEL_WEB_CONTRACT; 54 55 /* 56 * Lecture des lignes a résilier 57 * 58 */ 59 $sql = "SELECT s.nom, s.idp as socid, s.address, s.cp, s.ville"; 60 $sql .= ", l.ligne, l.statut, l.rowid"; 61 62 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; 63 $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; 64 $sql .= " , ".MAIN_DB_PREFIX."telephonie_fournisseur as f"; 65 $sql .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid"; 66 $sql .= " AND f.rowid = 4 AND l.statut = 4 ORDER BY s.idp ASC"; 67 68 $resql = $db->query($sql); 69 $result = 1; 70 if ($resql) 71 { 72 $i = 0; 73 $num = $db->num_rows($resql); 74 75 while ($i < $num) 76 { 77 $obj = $db->fetch_object($resql); 78 79 $result = DeletePreselection($host, $user_login, $user_passwd, $obj->ligne, $num_abo); 80 81 if ($result == 0) 82 { 83 $lint = new LigneTel($db); 84 $lint->fetch_by_id($obj->rowid); 85 if ($lint->statut == 4) 86 { 87 $lint->set_statut($user, 5); 88 } 89 } 90 91 $i++; 92 } 93 } 94 95 function DeletePreselection($host, $user_login, $user_passwd, $ligne, $id_person) 96 { 97 global $verbose; 98 //dolibarr_syslog("Appel de DeletePreselection($host, $user_login, ****, $ligne, $id_person)"); 99 100 $url = "/AzurApp_websvc_b3gdb/account.asmx/DeletePreselection?"; 101 102 $url .= "user_login=". $user_login; 103 $url .= "&user_passwd=".$user_passwd; 104 $url .= "&telnum=".$ligne; 105 106 if ($verbose > 2) 107 dolibarr_syslog("$host"); 108 109 if ($verbose > 2) 110 dolibarr_syslog("$url"); 111 112 $fp = fsockopen($host, 80, $errno, $errstr, 30); 113 if (!$fp) 114 { 115 dolibarr_syslog("$errstr ($errno)"); 116 } 117 else 118 { 119 if ($verbose > 2) 120 dolibarr_syslog("Socket Opened send data"); 121 122 $out = "GET $url HTTP/1.1\r\n"; 123 $out .= "Host: $host\r\n"; 124 $out .= "Connection: Close\r\n\r\n"; 125 126 fwrite($fp, $out); 127 128 if ($verbose > 2) 129 dolibarr_syslog("Data sent, waiting for response"); 130 131 $parse = 0; 132 $result = "error"; 133 134 $fresult = ""; 135 136 while (!feof($fp)) 137 { 138 $line = fgets($fp, 1024); 139 140 if ($verbose > 2) 141 dolibarr_syslog($line); 142 143 if ($parse == 1) 144 { 145 preg_match('/^<string xmlns=".*">(.*)<\/string>$/', $line, $results); 146 147 $result = $results[1]; 148 //dolibarr_syslog($line); 149 $parse = 0; 150 } 151 152 if (substr($line,0,38) == '<?xml version="1.0" encoding="utf-8"?>') 153 { 154 $parse = 1; 155 } 156 157 $fresult .= $line; 158 159 } 160 fclose($fp); 161 } 162 163 if ($verbose > 1) 164 dolibarr_syslog("result = ".$result); 165 166 if (substr($result,0,2) == "OK") 167 { 168 dolibarr_syslog("Delete réussi ligne ".$ligne." id client ".$id_person." $result\n"); 169 return 0; 170 } 171 else 172 { 173 dolibarr_syslog("Delete échoué ligne ".$ligne." id client ".$id_person." $result\n"); 174 175 $fp = fopen("/tmp/$ligne.delete","w"); 176 if ($fp) 177 { 178 fwrite($fp, $fresult); 179 fclose($fp); 180 } 181 182 return -1; 183 } 184 } 185 186 ?>
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 |
![]() |