forked from Wavyzz/dolibarr
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -1653,7 +1653,7 @@ class Propal extends CommonObject
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
return 1;
|
||||
return $num;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3814,6 +3814,8 @@ class PropaleLigne extends CommonObjectLine
|
||||
$this->multicurrency_total_tva = $objp->multicurrency_total_tva;
|
||||
$this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
|
||||
|
||||
$this->fetch_optionals();
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2011-2014 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2011-2018 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
@@ -13,7 +13,7 @@
|
||||
* Copyright (C) 2016 Bahfir abbes <dolipar@dolipar.org>
|
||||
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
|
||||
* Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
|
||||
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
|
||||
* Copyright (C) 2018 Frederic France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -448,7 +448,7 @@ abstract class CommonObject
|
||||
*
|
||||
* @param int $withcountry 1=Add country into address string
|
||||
* @param string $sep Separator to use to build string
|
||||
* @param int $withregion 1=Add region into address string
|
||||
* @param int $withregion 1=Add region into address string
|
||||
* @return string Full address string
|
||||
*/
|
||||
function getFullAddress($withcountry=0,$sep="\n",$withregion=0)
|
||||
@@ -717,7 +717,7 @@ abstract class CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
// On recherche id type_contact
|
||||
// We look for id type_contact
|
||||
$sql = "SELECT tc.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||
$sql.= " WHERE tc.element='".$this->db->escape($this->element)."'";
|
||||
@@ -741,7 +741,7 @@ abstract class CommonObject
|
||||
|
||||
$datecreate = dol_now();
|
||||
|
||||
// Socpeople must have already been added by some a trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error
|
||||
// Socpeople must have already been added by some trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error
|
||||
$TListeContacts=$this->liste_contact(-1, $source);
|
||||
$already_added=false;
|
||||
if(!empty($TListeContacts)) {
|
||||
@@ -757,7 +757,7 @@ abstract class CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Insertion dans la base
|
||||
// Insert into database
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
|
||||
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
|
||||
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
|
||||
@@ -832,7 +832,7 @@ abstract class CommonObject
|
||||
*/
|
||||
function update_contact($rowid, $statut, $type_contact_id=0, $fk_socpeople=0)
|
||||
{
|
||||
// Insertion dans la base
|
||||
// Insert into database
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set";
|
||||
$sql.= " statut = ".$statut;
|
||||
if ($type_contact_id) $sql.= ", fk_c_type_contact = '".$type_contact_id ."'";
|
||||
@@ -5022,7 +5022,7 @@ abstract class CommonObject
|
||||
* @param array $val Array of properties for field to show
|
||||
* @param string $key Key of attribute
|
||||
* @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
|
||||
* @param string $moreparam To add more parametes on html input tag
|
||||
* @param string $moreparam To add more parameters on html input tag
|
||||
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
* @param string|int $showsize Value for css to define size. May also be a numeric.
|
||||
@@ -5076,7 +5076,7 @@ abstract class CommonObject
|
||||
else return '';
|
||||
}
|
||||
|
||||
// Use in priorit showsize from parameters, then $val['css'] then autodefine
|
||||
// Use in priority showsize from parameters, then $val['css'] then autodefine
|
||||
if (empty($showsize) && ! empty($val['css']))
|
||||
{
|
||||
$showsize = $val['css'];
|
||||
|
||||
@@ -318,98 +318,15 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
if ($this->statut == 0) $this->brouillon = 1;
|
||||
|
||||
//$result=$this->fetch_lines();
|
||||
$this->lines=array();
|
||||
|
||||
$sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description, l.qty,";
|
||||
$sql.= " l.vat_src_code, l.tva_tx, l.remise_percent, l.subprice,";
|
||||
$sql.= " l.localtax1_tx, l. localtax2_tx, l.localtax1_type, l. localtax2_type, l.total_localtax1, l.total_localtax2,";
|
||||
$sql.= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,";
|
||||
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,";
|
||||
$sql.= " l.fk_unit,";
|
||||
$sql.= " l.date_start, l.date_end,";
|
||||
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc';
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
$sql.= " WHERE l.fk_commande = ".$this->id;
|
||||
$sql.= " ORDER BY l.rang, l.rowid";
|
||||
//print $sql;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch get lines", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
/*
|
||||
* Lines
|
||||
*/
|
||||
$result=$this->fetch_lines();
|
||||
if ($result < 0)
|
||||
{
|
||||
$num = $this->db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
$line = new CommandeFournisseurLigne($this->db);
|
||||
|
||||
$line->id = $objp->rowid;
|
||||
$line->desc = $objp->description;
|
||||
$line->description = $objp->description;
|
||||
$line->qty = $objp->qty;
|
||||
$line->tva_tx = $objp->tva_tx;
|
||||
$line->localtax1_tx = $objp->localtax1_tx;
|
||||
$line->localtax2_tx = $objp->localtax2_tx;
|
||||
$line->localtax1_type = $objp->localtax1_type;
|
||||
$line->localtax2_type = $objp->localtax2_type;
|
||||
$line->subprice = $objp->subprice;
|
||||
$line->pu_ht = $objp->subprice;
|
||||
$line->remise_percent = $objp->remise_percent;
|
||||
|
||||
$line->vat_src_code = $objp->vat_src_code;
|
||||
$line->total_ht = $objp->total_ht;
|
||||
$line->total_tva = $objp->total_tva;
|
||||
$line->total_localtax1 = $objp->total_localtax1;
|
||||
$line->total_localtax2 = $objp->total_localtax2;
|
||||
$line->total_ttc = $objp->total_ttc;
|
||||
$line->product_type = $objp->product_type;
|
||||
|
||||
$line->fk_product = $objp->fk_product;
|
||||
|
||||
$line->libelle = $objp->product_label;
|
||||
$line->product_label = $objp->product_label;
|
||||
$line->product_desc = $objp->product_desc;
|
||||
|
||||
$line->ref = $objp->product_ref; // Ref of product
|
||||
$line->product_ref = $objp->product_ref; // Ref of product
|
||||
$line->ref_fourn = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since
|
||||
$line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since
|
||||
|
||||
$line->date_start = $this->db->jdate($objp->date_start);
|
||||
$line->date_end = $this->db->jdate($objp->date_end);
|
||||
$line->fk_unit = $objp->fk_unit;
|
||||
|
||||
// Multicurrency
|
||||
$line->fk_multicurrency = $objp->fk_multicurrency;
|
||||
$line->multicurrency_code = $objp->multicurrency_code;
|
||||
$line->multicurrency_subprice = $objp->multicurrency_subprice;
|
||||
$line->multicurrency_total_ht = $objp->multicurrency_total_ht;
|
||||
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
|
||||
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
|
||||
|
||||
$line->special_code = $objp->special_code;
|
||||
$line->fk_parent_line = $objp->fk_parent_line;
|
||||
|
||||
$line->rang = $objp->rang;
|
||||
|
||||
$this->lines[$i] = $line;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($result);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." sql=".$sql;
|
||||
return -1;
|
||||
return -3;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -418,6 +335,113 @@ class CommandeFournisseur extends CommonOrder
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load array lines
|
||||
*
|
||||
* @param int $only_product Return only physical products
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch_lines($only_product=0)
|
||||
{
|
||||
//$result=$this->fetch_lines();
|
||||
$this->lines=array();
|
||||
|
||||
$sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description, l.qty,";
|
||||
$sql.= " l.vat_src_code, l.tva_tx, l.remise_percent, l.subprice,";
|
||||
$sql.= " l.localtax1_tx, l. localtax2_tx, l.localtax1_type, l. localtax2_type, l.total_localtax1, l.total_localtax2,";
|
||||
$sql.= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,";
|
||||
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,";
|
||||
$sql.= " l.fk_unit,";
|
||||
$sql.= " l.date_start, l.date_end,";
|
||||
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc';
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
$sql.= " WHERE l.fk_commande = ".$this->id;
|
||||
if ($only_product) $sql .= ' AND p.fk_product_type = 0';
|
||||
$sql.= " ORDER BY l.rang, l.rowid";
|
||||
//print $sql;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch get lines", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $this->db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
$line = new CommandeFournisseurLigne($this->db);
|
||||
|
||||
$line->id = $objp->rowid;
|
||||
$line->desc = $objp->description;
|
||||
$line->description = $objp->description;
|
||||
$line->qty = $objp->qty;
|
||||
$line->tva_tx = $objp->tva_tx;
|
||||
$line->localtax1_tx = $objp->localtax1_tx;
|
||||
$line->localtax2_tx = $objp->localtax2_tx;
|
||||
$line->localtax1_type = $objp->localtax1_type;
|
||||
$line->localtax2_type = $objp->localtax2_type;
|
||||
$line->subprice = $objp->subprice;
|
||||
$line->pu_ht = $objp->subprice;
|
||||
$line->remise_percent = $objp->remise_percent;
|
||||
|
||||
$line->vat_src_code = $objp->vat_src_code;
|
||||
$line->total_ht = $objp->total_ht;
|
||||
$line->total_tva = $objp->total_tva;
|
||||
$line->total_localtax1 = $objp->total_localtax1;
|
||||
$line->total_localtax2 = $objp->total_localtax2;
|
||||
$line->total_ttc = $objp->total_ttc;
|
||||
$line->product_type = $objp->product_type;
|
||||
|
||||
$line->fk_product = $objp->fk_product;
|
||||
|
||||
$line->libelle = $objp->product_label;
|
||||
$line->product_label = $objp->product_label;
|
||||
$line->product_desc = $objp->product_desc;
|
||||
|
||||
$line->ref = $objp->product_ref; // Ref of product
|
||||
$line->product_ref = $objp->product_ref; // Ref of product
|
||||
$line->ref_fourn = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since
|
||||
$line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since
|
||||
|
||||
$line->date_start = $this->db->jdate($objp->date_start);
|
||||
$line->date_end = $this->db->jdate($objp->date_end);
|
||||
$line->fk_unit = $objp->fk_unit;
|
||||
|
||||
// Multicurrency
|
||||
$line->fk_multicurrency = $objp->fk_multicurrency;
|
||||
$line->multicurrency_code = $objp->multicurrency_code;
|
||||
$line->multicurrency_subprice = $objp->multicurrency_subprice;
|
||||
$line->multicurrency_total_ht = $objp->multicurrency_total_ht;
|
||||
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
|
||||
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
|
||||
|
||||
$line->special_code = $objp->special_code;
|
||||
$line->fk_parent_line = $objp->fk_parent_line;
|
||||
|
||||
$line->rang = $objp->rang;
|
||||
|
||||
// Retreive all extrafield
|
||||
// fetch optionals attributes and labels
|
||||
$line->fetch_optionals();
|
||||
|
||||
$this->lines[$i] = $line;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($result);
|
||||
|
||||
return $num;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." sql=".$sql;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate an order
|
||||
*
|
||||
@@ -3161,6 +3185,8 @@ class CommandeFournisseurLigne extends CommonOrderLine
|
||||
$this->multicurrency_total_tva = $objp->multicurrency_total_tva;
|
||||
$this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
|
||||
|
||||
$this->fetch_optionals();
|
||||
|
||||
$this->db->free($result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2695,6 +2695,8 @@ class SupplierInvoiceLine extends CommonObjectLine
|
||||
$this->multicurrency_total_tva = $obj->multicurrency_total_tva;
|
||||
$this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
|
||||
|
||||
$this->fetch_optionals();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user