Merge branch '7.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/fourn/class/fournisseur.product.class.php
	htdocs/projet/class/projectstats.class.php
This commit is contained in:
Laurent Destailleur 2018-06-20 21:56:10 +02:00
commit 07c514b85c
2 changed files with 50 additions and 46 deletions

View File

@ -434,8 +434,9 @@ class ProductFournisseur extends Product
function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) function fetch_product_fournisseur_price($rowid, $ignore_expression = 0)
{ {
global $conf; global $conf;
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.fk_availability,";
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,";
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
$sql.= " pfp.supplier_reputation"; $sql.= " pfp.supplier_reputation";
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
@ -462,8 +463,7 @@ class ProductFournisseur extends Product
$this->fourn_remise = $obj->remise; $this->fourn_remise = $obj->remise;
$this->fourn_unitprice = $obj->unitprice; $this->fourn_unitprice = $obj->unitprice;
$this->fourn_tva_tx = $obj->tva_tx; $this->fourn_tva_tx = $obj->tva_tx;
// TODO $this->fourn_tva_npr = $obj->fourn_tva_npr;
// $this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ?
// Add also localtaxes // Add also localtaxes
$this->fk_availability = $obj->fk_availability; $this->fk_availability = $obj->fk_availability;
$this->delivery_time_days = $obj->delivery_time_days; $this->delivery_time_days = $obj->delivery_time_days;

View File

@ -124,6 +124,9 @@ class ProjectStats extends Stats
$sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb, SUM(t.opp_amount) as total, AVG(t.opp_amount) as avg,"; $sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb, SUM(t.opp_amount) as total, AVG(t.opp_amount) as avg,";
$sql.= " SUM(t.opp_amount * ".$this->db->ifsql("t.opp_percent IS NULL".($wonlostfilter?" OR cls.code IN ('WON','LOST')":""), '0', 't.opp_percent')." / 100) as weighted"; $sql.= " SUM(t.opp_amount * ".$this->db->ifsql("t.opp_percent IS NULL".($wonlostfilter?" OR cls.code IN ('WON','LOST')":""), '0', 't.opp_percent')." / 100) as weighted";
$sql.= " FROM " . MAIN_DB_PREFIX . "projet as t LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls ON cls.rowid = t.fk_opp_status"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet as t LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls ON cls.rowid = t.fk_opp_status";
// No check is done on company permission because readability is managed by public status of project and assignement.
//if (! $user->rights->societe->client->voir && ! $user->soc_id)
// $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql.= $this->buildWhere(); $sql.= $this->buildWhere();
// For external user, no check is done on company permission because readability is managed by public status of project and assignement. // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
//if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; //if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid;
@ -157,6 +160,7 @@ class ProjectStats extends Stats
if (! empty($this->userid)) if (! empty($this->userid))
$sqlwhere[] = ' t.fk_user_resp=' . $this->userid; $sqlwhere[] = ' t.fk_user_resp=' . $this->userid;
// Forced filter on socid is similar to forced filter on project. TODO Use project assignement to allow to not use filter on project // Forced filter on socid is similar to forced filter on project. TODO Use project assignement to allow to not use filter on project
if (! empty($this->socid)) if (! empty($this->socid))
$sqlwhere[] = ' t.fk_soc=' . $this->socid; $sqlwhere[] = ' t.fk_soc=' . $this->socid;