[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2005 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: mouvementstock.class.php,v 1.6 2005/09/21 23:43:08 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/stock/mouvementstock.class.php,v $ 21 */ 22 23 /** 24 \file htdocs/product/stock/mouvementstock.class.php 25 \ingroup stock 26 \brief Fichier de la classe de gestion des mouvements de stocks 27 \version $Revision: 1.6 $ 28 */ 29 30 31 /** \class MouvementStock 32 \brief Classe permettant la gestion des mouvements de stocks 33 */ 34 35 class MouvementStock 36 { 37 38 function MouvementStock($DB) 39 { 40 $this->db = $DB; 41 } 42 43 /** 44 * \brief Crée un mouvement en base 45 * \return int <0 si ko, >0 si ok 46 */ 47 function _create($user, $product_id, $entrepot_id, $qty, $type) 48 { 49 dolibarr_syslog("mouvementstock.class.php::create $user, $product_id, $entrepot_id, $qty, $type"); 50 51 $this->db->begin(); 52 53 $sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author)"; 54 $sql .= " VALUES (now(), $product_id, $entrepot_id, $qty, $type, $user->id)"; 55 56 if ($this->db->query($sql)) 57 { 58 59 $sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + $qty"; 60 $sql.= " WHERE fk_entrepot = $entrepot_id AND fk_product = $product_id"; 61 62 if ($this->db->query($sql)) 63 { 64 $this->db->commit(); 65 //dolibarr_syslog("mouvementstock.class.php::create update ok"); 66 return 1; 67 } 68 else 69 { 70 $this->db->rollback(); 71 $this->error=$this->db->error() . " - $sql"; 72 dolibarr_syslog("mouvementstock.class.php::create echec update ".$this->error); 73 return -2; 74 } 75 } 76 else 77 { 78 $this->db->rollback(); 79 $this->error=$this->db->error() . " - $sql"; 80 dolibarr_syslog("mouvementstock.class.php::create echec insert ".$this->error); 81 return -1; 82 } 83 84 } 85 86 /* 87 * 88 * 89 */ 90 function livraison($user, $product_id, $entrepot_id, $qty) 91 { 92 93 return $this->_create($user, $product_id, $entrepot_id, (0 - $qty), 2); 94 95 } 96 97 } 98 ?>
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 |
![]() |