[ 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/fournisseur/commande/ -> commande.web.class.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: commande.web.class.php,v 1.1 2005/10/19 13:37:49 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/fournisseur/commande/commande.web.class.php,v $
  20   *
  21   * Classe de commande de ligne au format Texte
  22   *
  23   *
  24   */
  25  require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php";
  26  require_once DOL_DOCUMENT_ROOT."/telephonie/fournisseur/commande/methode.commande.class.php";
  27  
  28  define ('COMMANDETEXT_NOEMAIL', -3);
  29  
  30  class CommandeMethodeWeb extends CommandeMethode
  31  {
  32  
  33    function CommandeMethodeWeb ($DB, $USER=0, $fourn=0)
  34    {
  35      $this->nom = "Méthode web";
  36      $this->db = $DB;
  37      $this->user = $USER;
  38      $this->fourn = $fourn;
  39    }
  40  
  41    function info()
  42    {
  43      return "Commande les lignes au travers du web";
  44    }
  45  
  46    function Create()
  47    {
  48      $this->date = time();
  49  
  50      $this->datef = "comm-".$this->fourn->id."-".strftime("%d%b%y-%H:%M:%S", $this->date);
  51  
  52      $this->filename = $this->datef.".txt";
  53  
  54      $fname = DOL_DATA_ROOT ."/telephonie/ligne/commande/".$this->filename;
  55  
  56      if (strlen(trim($this->fourn->email_commande)) == 0)
  57        {
  58      return -3;
  59        }
  60  
  61      if (file_exists($fname))
  62        {
  63      return 2;
  64        }
  65      else
  66        {
  67      $res = $this->CreateFile($fname);
  68  
  69      if ($res == 0)
  70        {
  71          $res = $res + $this->LogSql();
  72        }
  73  
  74      return $res;
  75        }
  76    }
  77  
  78    /**
  79     * Creation du fichier
  80     *
  81     */
  82  
  83    function CreateFile($fname)
  84    {
  85      $fp = fopen($fname, "w");
  86  
  87      if ($fp)
  88        {
  89      fwrite ($fp, "Numcli;");
  90      fwrite ($fp, "nomclient;");
  91      fwrite ($fp, "NDI\n");
  92  
  93      $this->ligneids = array();
  94      
  95      $sqlall = "SELECT s.nom, s.idp as socid, l.ligne, l.statut, l.rowid";
  96      $sqlall .= " , comm.name, comm.firstname";
  97      
  98      $sqlall .= " FROM ".MAIN_DB_PREFIX."societe as s";
  99      $sqlall .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
 100      $sqlall .= " , ".MAIN_DB_PREFIX."user as comm";
 101      $sqlall .= " , ".MAIN_DB_PREFIX."telephonie_fournisseur as f";
 102  
 103      $sqlall .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid";
 104  
 105      $sqlall .= " AND l.fk_commercial = comm.rowid ";
 106      $sqlall .= " AND f.rowid =".$this->fourn->id;
 107      /*
 108       *
 109       */
 110      $sql = $sqlall;
 111      
 112      $sql .= " AND l.statut in (1,8)";
 113      $sql .= " ORDER BY l.statut ASC";
 114  
 115      $resql = $this->db->query($sql);
 116  
 117      if ($resql)
 118        {
 119          $i = 0;
 120          $num = $this->db->num_rows($resql);
 121          
 122          while ($i < $num)
 123            {
 124          $obj = $this->db->fetch_object($resql);
 125          
 126          if (strlen($obj->ligne)== 10)
 127            {            
 128              $soc = new Societe($this->db);
 129              $soc->fetch($obj->socid);
 130              
 131              fwrite ($fp, $this->fourn->num_client);
 132              fwrite ($fp, ";");
 133              fwrite ($fp, $obj->nom);
 134              fwrite ($fp, ";");
 135              fwrite ($fp, $obj->ligne);
 136              fwrite ($fp, "\n");
 137              
 138              array_push($this->ligneids, $obj->rowid);
 139            }
 140          $i++;
 141            }
 142          
 143          $this->db->free($resql);
 144        }
 145      else 
 146        {
 147          print $this->db->error() . ' ' . $sql;
 148        }
 149  
 150      fclose($fp);
 151      
 152      /*
 153       *
 154       *
 155       */
 156      
 157      foreach ($this->ligneids as $lid)
 158        {
 159          
 160          $lint = new LigneTel($this->db);
 161          $lint->fetch_by_id($lid);
 162          if ($lint->statut == 1)
 163            {
 164          $lint->set_statut($this->user, 9);
 165            }
 166          if ($lint->statut == 8)
 167            {
 168          $lint->set_statut($this->user, 9);
 169            }
 170        }
 171      
 172      return 0;    
 173        }
 174      else
 175        {
 176      return -1;
 177        }
 178    }
 179  }


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