New: Some changes to support the type of line in entities.
This commit is contained in:
parent
446c92c484
commit
439a0f3260
@ -657,6 +657,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
|
||||
$desc = $prod->description;
|
||||
$desc.= ($prod->description && $_POST['np_desc']) ? "\n" : "";
|
||||
$desc.= $_POST['np_desc'];
|
||||
$type = $prod->type;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -664,6 +665,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
|
||||
$tva_tx=eregi_replace('\*','',$_POST['np_tva_tx']);
|
||||
$tva_npr=eregi('\*',$_POST['np_tva_tx'])?1:0;
|
||||
$desc=$_POST['dp_desc'];
|
||||
$type=$_POST["type"];
|
||||
}
|
||||
|
||||
$info_bits=0;
|
||||
@ -686,7 +688,8 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
|
||||
$_POST['remise_percent'],
|
||||
$price_base_type,
|
||||
$pu_ttc,
|
||||
$info_bits
|
||||
$info_bits,
|
||||
$type
|
||||
);
|
||||
|
||||
if ($result > 0)
|
||||
|
||||
@ -1426,19 +1426,24 @@ class CommandeFournisseurLigne extends CommandeLigne
|
||||
var $tva_tx;
|
||||
var $subprice;
|
||||
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_tva;
|
||||
var $total_ttc;
|
||||
var $fk_product;
|
||||
var $desc; // Description ligne
|
||||
|
||||
// From llx_product
|
||||
var $libelle; // Label produit
|
||||
var $product_desc; // Description produit
|
||||
|
||||
// From llx_product_fournisseur
|
||||
var $ref_fourn; // R<EFBFBD>f<EFBFBD>rence fournisseur
|
||||
var $ref_fourn; // Ref supplier
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function CommandeFournisseurLigne($DB)
|
||||
{
|
||||
$this->db= $DB;
|
||||
@ -1450,7 +1455,7 @@ class CommandeFournisseurLigne extends CommandeLigne
|
||||
*/
|
||||
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.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';
|
||||
@ -1474,6 +1479,7 @@ class CommandeFournisseurLigne extends CommandeLigne
|
||||
$this->total_ht = $objp->total_ht;
|
||||
$this->total_tva = $objp->total_tva;
|
||||
$this->total_ttc = $objp->total_ttc;
|
||||
$this->product_type = $objp->product_type;
|
||||
|
||||
$this->ref = $objp->product_ref;
|
||||
$this->product_libelle = $objp->product_libelle;
|
||||
|
||||
@ -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 desc Description de la ligne
|
||||
* \param pu_ht Prix unitaire
|
||||
* \param qty Quantit<EFBFBD>
|
||||
* \param txtva Taux de tva forc<EFBFBD>, sinon -1
|
||||
* \param fk_product Id du produit/service pred<EFBFBD>fini
|
||||
* \param qty Quantite
|
||||
* \param txtva Taux de tva force, sinon -1
|
||||
* \param fk_product Id du produit/service predefini
|
||||
* \param remise_percent Pourcentage de remise de la ligne
|
||||
* \param price_base_type HT or TTC
|
||||
* \param pu_ttc Prix unitaire TTC
|
||||
* \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
|
||||
* \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)
|
||||
* 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;
|
||||
|
||||
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');
|
||||
|
||||
if ($this->statut == 0)
|
||||
@ -343,6 +343,7 @@ class Propal extends CommonObject
|
||||
$ligne->total_ht=$total_ht;
|
||||
$ligne->total_tva=$total_tva;
|
||||
$ligne->total_ttc=$total_ttc;
|
||||
$ligne->product_type=$type;
|
||||
|
||||
// Mise en option de la ligne
|
||||
//if ($conf->global->PROPALE_USE_OPTION_LINE && !$qty) $ligne->special_code=3;
|
||||
@ -2008,8 +2009,9 @@ class PropaleLigne
|
||||
// From llx_propaldet
|
||||
var $rowid;
|
||||
var $fk_propal;
|
||||
var $desc; // Description ligne
|
||||
var $fk_product; // Id produit pr<70>d<EFBFBD>fini
|
||||
var $desc; // Description ligne
|
||||
var $fk_product; // Id produit predefini
|
||||
var $product_type = 0; // Type 0 = product, 1 = Service
|
||||
|
||||
var $qty;
|
||||
var $tva_tx;
|
||||
@ -2113,15 +2115,18 @@ class PropaleLigne
|
||||
dol_syslog("PropaleLigne::insert rang=".$this->rang);
|
||||
$this->db->begin();
|
||||
|
||||
// Nettoyage parameteres
|
||||
// Clean parameters
|
||||
if (! $this->remise) $this->remise=0;
|
||||
if (! $this->remise_percent) $this->remise_percent=0;
|
||||
if (! $this->info_bits) $this->info_bits=0;
|
||||
|
||||
// Check parameters
|
||||
if ($this->type < 0) return -1;
|
||||
|
||||
$rangtouse=$this->rang;
|
||||
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.= ' WHERE fk_propal ='.$this->fk_propal;
|
||||
$resql = $this->db->query($sql);
|
||||
@ -2140,13 +2145,14 @@ class PropaleLigne
|
||||
|
||||
// Insertion dans base de la ligne
|
||||
$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.= ' info_bits, ';
|
||||
$sql.= ' total_ht, total_tva, total_ttc, marge_tx, marque_tx, special_code, rang)';
|
||||
$sql.= " VALUES (".$this->fk_propal.",";
|
||||
$sql.= " '".addslashes($this->desc)."',";
|
||||
$sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").",";
|
||||
$sql.= " '".$this->product_type."',";
|
||||
$sql.= " ".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").",";
|
||||
$sql.= " ".price2num($this->qty).",";
|
||||
$sql.= " ".price2num($this->tva_tx).",";
|
||||
@ -2166,7 +2172,6 @@ class PropaleLigne
|
||||
$sql.= ')';
|
||||
|
||||
dol_syslog("PropaleLigne::insert sql=$sql");
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -2177,7 +2182,7 @@ class PropaleLigne
|
||||
else
|
||||
{
|
||||
$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();
|
||||
return -1;
|
||||
}
|
||||
@ -2223,7 +2228,7 @@ class PropaleLigne
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog("PropaleLigne::update Error ".$this->error);
|
||||
dol_syslog("PropaleLigne::update Error ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
@ -2256,7 +2261,7 @@ class PropaleLigne
|
||||
else
|
||||
{
|
||||
$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();
|
||||
return -2;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user