Ajout fonctions de ventilation
This commit is contained in:
parent
8a7ae586c1
commit
7cfb9eeba4
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -161,7 +161,6 @@ class CommandeFournisseur extends Commande
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Insère ligne de log
|
||||
* \param user Utilisateur qui modifie la commande
|
||||
@ -183,7 +182,6 @@ class CommandeFournisseur extends Commande
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Valide la commande
|
||||
* \param user Utilisateur qui valide
|
||||
@ -703,7 +701,87 @@ class CommandeFournisseur extends Commande
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Dispatch un element de la commande dans un stock
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DispatchProducts($user, $products, $qtys, $entrepots)
|
||||
{
|
||||
global $conf;
|
||||
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if ( is_array($products) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$res = $this->DispatchProduct($user, $product, $qty, $entrepot);
|
||||
}
|
||||
|
||||
$this->db->rollback();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function DispatchProduct($user, $product, $qty, $entrepot)
|
||||
{
|
||||
global $conf;
|
||||
$error = 0;
|
||||
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
|
||||
|
||||
dolibarr_syslog("CommandeFournisseur::DispatchProduct");
|
||||
|
||||
if ( ($this->statut == 3 || $this->statut == 4) && $qty > 0)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_dispatch ";
|
||||
$sql.= " (fk_commande,fk_product, qty, fk_entrepot, fk_user, datec) VALUES ";
|
||||
$sql.= " ('".$this->id."','".$product."','".$qty."','".$entrepot."','".$user->id."',now() );";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$error = -1;
|
||||
}
|
||||
// Si module stock géré et que expedition faite depuis un entrepot
|
||||
if (!$error && $conf->stock->enabled && $entrepot)
|
||||
{
|
||||
/*
|
||||
* Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
|
||||
*/
|
||||
$mouv = new MouvementStock($this->db);
|
||||
$result=$mouv->reception($user, $product, $entrepot, $qty);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$this->db->error()." - sql=$sql";
|
||||
dolibarr_syslog("CommandeFournisseur::DispatchProduct".$this->error);
|
||||
$error = -2;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Supprime une ligne de la commande
|
||||
*
|
||||
@ -834,7 +912,6 @@ class CommandeFournisseur extends Commande
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Positionne modele derniere generation
|
||||
* \param user Objet use qui modifie
|
||||
@ -860,8 +937,6 @@ class CommandeFournisseur extends Commande
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user