[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/telephonie/script/ -> presel_view.php (source)

   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_view.php,v 1.1 2005/12/01 14:24:26 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/presel_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  
  27  $host          = CMD_PRESEL_WEB_HOST;
  28  $user_login    = CMD_PRESEL_WEB_USER;
  29  $user_passwd   = CMD_PRESEL_WEB_PASS;
  30  
  31  $ids = array();
  32  
  33  if ($argv[1])
  34  {
  35    $debug = 0;
  36    array_push($ids, $argv[1]);
  37  }
  38  else
  39  {
  40    $sql = "SELECT rowid,ligne";
  41    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne";
  42    $sql .= " WHERE fk_fournisseur = 4";
  43    $sql .= " AND statut = 9";
  44    if ($debug)
  45      {
  46        $sql .= " LIMIT 1";
  47      }
  48    $resql = $db->query($sql);
  49    
  50    if ($resql)
  51      {      
  52        while ($row = $db->fetch_row($resql))
  53      {
  54        array_push($ids, $row[1]);
  55      }
  56      }
  57    else
  58      {
  59        print $db->error();
  60        exit(1);
  61      }
  62  }
  63  
  64  GetPreselection_byRef($db, $host, $user_login, $user_passwd, $ids, $debug);
  65  
  66  /*
  67   * Fonctions
  68   *
  69   */
  70  
  71  function GetPreselection_byRef($db, $host, $user_login, $user_passwd, $ids, $debug)
  72  {  
  73    $numcli = sizeof($ids);
  74    $i = 0;
  75    print "Nombre de lignes $numcli\n";
  76    foreach($ids as $cli)
  77      {
  78        $i++;
  79        $fp = @fsockopen($host, 80, $errno, $errstr, 30);
  80        if (!$fp)
  81      {
  82        print "Impossible de se connecter au server $errstr ($errno)";
  83      }
  84        else
  85      {
  86        $ligne_numero = "";
  87        $ligne_service = "";
  88        $ligne_presel = "";
  89  
  90        //GetPreselection_byRef  
  91        $url = "/AzurApp_websvc_b3gdb/account.asmx/GetPreselection_byRef?";
  92  
  93        $url .= "user_login=".  $user_login;
  94        $url .= "&user_passwd=".$user_passwd;
  95        $url .= "&telnum=".$cli;
  96  
  97        $out = "GET $url HTTP/1.1\r\n";
  98        $out .= "Host: $host\r\n";
  99        $out .= "Connection: Close\r\n\r\n";
 100        
 101        fwrite($fp, $out);
 102        
 103        while (!feof($fp))
 104          {
 105            $line = fgets($fp, 1024);
 106            if ($debug)
 107          {
 108            print $line;
 109          }
 110            if (preg_match("/<Preselection .* \/>/",$line))
 111          {          
 112            $results = split(" ",trim($line));
 113            //print_r($results);
 114            
 115            $array = array();
 116            preg_match('/telnum="([0123456789]*)"/', $line, $array);
 117            $ligne_numero = $array[1];
 118            
 119            $array = array();
 120            preg_match('/ServiceActive="([\S]*)"/i', $line, $array);
 121            $service_active = $array[1];
 122  
 123            $array = array();
 124            preg_match('/PreSelectionActive="([\S]*)"/i', $line, $array);
 125            $presel_active = $array[1];
 126  
 127            $array = array();
 128            preg_match('/Service_Statut="([\S]*)"/i', $line, $array);
 129            $ligne_service = $array[1];
 130            
 131            $array = array();
 132            preg_match('/PreSelection_Statut="([\S]*)"/i', $line, $array);
 133            $ligne_presel = $array[1];
 134            
 135            print "$i/$numcli ";
 136            print $ligne_numero." ";
 137            print "$service_active/$presel_active ";
 138            print substr($ligne_service.str_repeat(" ",20),0,20);
 139            print substr($ligne_presel.str_repeat(" ",20),0,20);
 140            print "\n";
 141          }
 142  
 143            if (preg_match("/<Error .* \/>/",$line))
 144          {          
 145            $array = array();
 146            preg_match('/libelle="(.*)" xmlns:d4p1/', $line, $array);
 147  
 148            print "$i/$numcli ";
 149            print "$cli ErreurAPI ".$array[1]."\n";
 150          }
 151          }
 152        fclose($fp);
 153      }
 154      }
 155  }
 156  
 157  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics