[ 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/compta/deplacement/ -> deplacement.class.php (source)

   1  <?php
   2  /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   * 
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: deplacement.class.php,v 1.7 2005/03/18 23:56:42 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/deplacement/deplacement.class.php,v $
  21   */
  22  
  23  class Deplacement
  24  {
  25    var $db;
  26    var $id;
  27    var $user;
  28    var $km;
  29    var $note;
  30  
  31    /*
  32     * Initialistation automatique de la classe
  33     */
  34    function Deplacement($DB)
  35      {
  36        $this->db = $DB;
  37      
  38        return 1;
  39    }
  40    /*
  41     *
  42     */
  43    function create($user)
  44      {
  45        $sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement (datec, fk_user_author) VALUES (now(), $user->id)";
  46  
  47        $result = $this->db->query($sql);
  48        if ($result)
  49      {
  50        $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."deplacement");
  51        if ( $this->update($user) ) 
  52          {
  53            return $this->id;
  54          }
  55      }
  56      }
  57    /*
  58     *
  59     */
  60    function update($user)
  61      {
  62        if (strlen($this->km)==0)
  63      $this->km = 0;
  64  
  65        $sql = "UPDATE ".MAIN_DB_PREFIX."deplacement ";
  66        $sql .= " SET km = $this->km";
  67        $sql .= " , dated = '".$this->db->idate($this->date)."'";
  68        $sql .= " , fk_user = $this->userid";
  69        $sql .= " , fk_soc = $this->socid";
  70        $sql .= " WHERE rowid = ".$this->id;
  71  
  72        $result = $this->db->query($sql);
  73        if ($result)
  74      {
  75        return 1;
  76      }
  77        else
  78      {
  79        print $this->db->error();
  80        print "<br>".$sql;
  81        return 0;
  82      }
  83      }
  84    /*
  85     *
  86     */
  87    function fetch ($id)
  88      {    
  89        $sql = "SELECT fk_user, km, fk_soc,".$this->db->pdate("dated")." as dated";
  90        $sql .= " FROM ".MAIN_DB_PREFIX."deplacement WHERE rowid = $id";
  91  
  92        $result = $this->db->query($sql) ;
  93  
  94        if ( $result )
  95      {
  96        $result = $this->db->fetch_array();
  97  
  98        $this->id       = $id;
  99  
 100        $this->date     = $result["dated"];
 101        $this->userid   = $result["fk_user"];
 102        $this->socid    = $result["fk_soc"];
 103        $this->km       = $result["km"];
 104        return 1;
 105      }
 106      else {
 107        print $this->db->error();
 108        print "<br>".$sql;
 109      }
 110      }
 111    /*
 112     *
 113     */
 114    function delete($id)
 115      {
 116        $sql = "DELETE FROM ".MAIN_DB_PREFIX."deplacement WHERE rowid = $id";
 117  
 118        $result = $this->db->query($sql);
 119        if ($result)
 120      {
 121        return 1;
 122      }
 123        else
 124      {
 125        return 0;
 126      }
 127      }
 128    /*
 129     *
 130     */
 131  
 132  }
 133  
 134  ?>


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