New: Some changes to support the type of line in entities.

This commit is contained in:
Laurent Destailleur 2009-03-12 22:33:26 +00:00
parent 446c92c484
commit 439a0f3260
3 changed files with 36 additions and 22 deletions

View File

@ -657,6 +657,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
$desc = $prod->description; $desc = $prod->description;
$desc.= ($prod->description && $_POST['np_desc']) ? "\n" : ""; $desc.= ($prod->description && $_POST['np_desc']) ? "\n" : "";
$desc.= $_POST['np_desc']; $desc.= $_POST['np_desc'];
$type = $prod->type;
} }
else else
{ {
@ -664,6 +665,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
$tva_tx=eregi_replace('\*','',$_POST['np_tva_tx']); $tva_tx=eregi_replace('\*','',$_POST['np_tva_tx']);
$tva_npr=eregi('\*',$_POST['np_tva_tx'])?1:0; $tva_npr=eregi('\*',$_POST['np_tva_tx'])?1:0;
$desc=$_POST['dp_desc']; $desc=$_POST['dp_desc'];
$type=$_POST["type"];
} }
$info_bits=0; $info_bits=0;
@ -686,7 +688,8 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
$_POST['remise_percent'], $_POST['remise_percent'],
$price_base_type, $price_base_type,
$pu_ttc, $pu_ttc,
$info_bits $info_bits,
$type
); );
if ($result > 0) if ($result > 0)

View File

@ -1426,19 +1426,24 @@ class CommandeFournisseurLigne extends CommandeLigne
var $tva_tx; var $tva_tx;
var $subprice; var $subprice;
var $remise_percent; var $remise_percent;
var $desc; // Description ligne
var $fk_product; // Id of predefined product
var $product_type = 0; // Type 0 = product, 1 = Service
var $total_ht; var $total_ht;
var $total_tva; var $total_tva;
var $total_ttc; var $total_ttc;
var $fk_product;
var $desc; // Description ligne
// From llx_product // From llx_product
var $libelle; // Label produit var $libelle; // Label produit
var $product_desc; // Description produit var $product_desc; // Description produit
// From llx_product_fournisseur // From llx_product_fournisseur
var $ref_fourn; // R<EFBFBD>f<EFBFBD>rence fournisseur var $ref_fourn; // Ref supplier
/**
* Constructor
*/
function CommandeFournisseurLigne($DB) function CommandeFournisseurLigne($DB)
{ {
$this->db= $DB; $this->db= $DB;
@ -1450,7 +1455,7 @@ class CommandeFournisseurLigne extends CommandeLigne
*/ */
function fetch($rowid) function fetch($rowid)
{ {
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.description, cd.qty, cd.tva_tx,'; $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx,';
$sql.= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql.= ' cd.remise, cd.remise_percent, cd.subprice,';
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
@ -1474,6 +1479,7 @@ class CommandeFournisseurLigne extends CommandeLigne
$this->total_ht = $objp->total_ht; $this->total_ht = $objp->total_ht;
$this->total_tva = $objp->total_tva; $this->total_tva = $objp->total_tva;
$this->total_ttc = $objp->total_ttc; $this->total_ttc = $objp->total_ttc;
$this->product_type = $objp->product_type;
$this->ref = $objp->product_ref; $this->ref = $objp->product_ref;
$this->product_libelle = $objp->product_libelle; $this->product_libelle = $objp->product_libelle;

View File

@ -253,29 +253,29 @@ class Propal extends CommonObject
} }
/** /**
* \brief Ajout d'un produit dans la proposition, en base * \brief Add new line in database
* \param propalid Id de la propale * \param propalid Id de la propale
* \param desc Description de la ligne * \param desc Description de la ligne
* \param pu_ht Prix unitaire * \param pu_ht Prix unitaire
* \param qty Quantit<EFBFBD> * \param qty Quantite
* \param txtva Taux de tva forc<EFBFBD>, sinon -1 * \param txtva Taux de tva force, sinon -1
* \param fk_product Id du produit/service pred<EFBFBD>fini * \param fk_product Id du produit/service predefini
* \param remise_percent Pourcentage de remise de la ligne * \param remise_percent Pourcentage de remise de la ligne
* \param price_base_type HT or TTC * \param price_base_type HT or TTC
* \param pu_ttc Prix unitaire TTC * \param pu_ttc Prix unitaire TTC
* \param info_bits Bits de type de lignes * \param info_bits Bits de type de lignes
* \return int >0 si ok, <0 si ko * \return int >0 if OK, <0 if KO
* \see add_product * \see add_product
* \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete d<EFBFBD>fini * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit) * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/ */
function addline($propalid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0) function addline($propalid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0)
{ {
global $conf; global $conf;
dol_syslog("Propal::Addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits"); dol_syslog("Propal::Addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type");
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
if ($this->statut == 0) if ($this->statut == 0)
@ -343,6 +343,7 @@ class Propal extends CommonObject
$ligne->total_ht=$total_ht; $ligne->total_ht=$total_ht;
$ligne->total_tva=$total_tva; $ligne->total_tva=$total_tva;
$ligne->total_ttc=$total_ttc; $ligne->total_ttc=$total_ttc;
$ligne->product_type=$type;
// Mise en option de la ligne // Mise en option de la ligne
//if ($conf->global->PROPALE_USE_OPTION_LINE && !$qty) $ligne->special_code=3; //if ($conf->global->PROPALE_USE_OPTION_LINE && !$qty) $ligne->special_code=3;
@ -2008,8 +2009,9 @@ class PropaleLigne
// From llx_propaldet // From llx_propaldet
var $rowid; var $rowid;
var $fk_propal; var $fk_propal;
var $desc; // Description ligne var $desc; // Description ligne
var $fk_product; // Id produit pr<70>d<EFBFBD>fini var $fk_product; // Id produit predefini
var $product_type = 0; // Type 0 = product, 1 = Service
var $qty; var $qty;
var $tva_tx; var $tva_tx;
@ -2113,15 +2115,18 @@ class PropaleLigne
dol_syslog("PropaleLigne::insert rang=".$this->rang); dol_syslog("PropaleLigne::insert rang=".$this->rang);
$this->db->begin(); $this->db->begin();
// Nettoyage parameteres // Clean parameters
if (! $this->remise) $this->remise=0; if (! $this->remise) $this->remise=0;
if (! $this->remise_percent) $this->remise_percent=0; if (! $this->remise_percent) $this->remise_percent=0;
if (! $this->info_bits) $this->info_bits=0; if (! $this->info_bits) $this->info_bits=0;
// Check parameters
if ($this->type < 0) return -1;
$rangtouse=$this->rang; $rangtouse=$this->rang;
if ($rangtouse == -1) if ($rangtouse == -1)
{ {
// R<EFBFBD>cup<EFBFBD>re rang max de la propale dans $rangmax // Get max value for rang
$sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'propaldet'; $sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'propaldet';
$sql.= ' WHERE fk_propal ='.$this->fk_propal; $sql.= ' WHERE fk_propal ='.$this->fk_propal;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -2140,13 +2145,14 @@ class PropaleLigne
// Insertion dans base de la ligne // Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet';
$sql.= ' (fk_propal, description, fk_product, fk_remise_except, qty, tva_tx,'; $sql.= ' (fk_propal, description, fk_product, product_type, fk_remise_except, qty, tva_tx,';
$sql.= ' subprice, remise_percent, '; $sql.= ' subprice, remise_percent, ';
$sql.= ' info_bits, '; $sql.= ' info_bits, ';
$sql.= ' total_ht, total_tva, total_ttc, marge_tx, marque_tx, special_code, rang)'; $sql.= ' total_ht, total_tva, total_ttc, marge_tx, marque_tx, special_code, rang)';
$sql.= " VALUES (".$this->fk_propal.","; $sql.= " VALUES (".$this->fk_propal.",";
$sql.= " '".addslashes($this->desc)."',"; $sql.= " '".addslashes($this->desc)."',";
$sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").","; $sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").",";
$sql.= " '".$this->product_type."',";
$sql.= " ".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").","; $sql.= " ".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").",";
$sql.= " ".price2num($this->qty).","; $sql.= " ".price2num($this->qty).",";
$sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->tva_tx).",";
@ -2166,7 +2172,6 @@ class PropaleLigne
$sql.= ')'; $sql.= ')';
dol_syslog("PropaleLigne::insert sql=$sql"); dol_syslog("PropaleLigne::insert sql=$sql");
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -2177,7 +2182,7 @@ class PropaleLigne
else else
{ {
$this->error=$this->db->error()." sql=".$sql; $this->error=$this->db->error()." sql=".$sql;
dol_syslog("PropaleLigne::insert Error ".$this->error); dol_syslog("PropaleLigne::insert Error ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -2223,7 +2228,7 @@ class PropaleLigne
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("PropaleLigne::update Error ".$this->error); dol_syslog("PropaleLigne::update Error ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -2256,7 +2261,7 @@ class PropaleLigne
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("PropaleLigne::update_total Error ".$this->error); dol_syslog("PropaleLigne::update_total Error ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }