Merge pull request #918 from FHenry/develop
Fix margin calculation problem, and add myuser_fullname and myuser_logo
This commit is contained in:
commit
3bbde9b8e4
@ -49,6 +49,7 @@ abstract class CommonDocGenerator
|
||||
return array(
|
||||
'myuser_lastname'=>$user->lastname,
|
||||
'myuser_firstname'=>$user->firstname,
|
||||
'myuser_fullname'=>$user->getFullName($outputlangs,1),
|
||||
'myuser_login'=>$user->login,
|
||||
'myuser_phone'=>$user->office_phone,
|
||||
'myuser_address'=>$user->address,
|
||||
@ -61,6 +62,7 @@ abstract class CommonDocGenerator
|
||||
'myuser_fax'=>$user->office_fax,
|
||||
'myuser_mobile'=>$user->user_mobile,
|
||||
'myuser_email'=>$user->email,
|
||||
'myuser_logo'=>$logotouse,
|
||||
'myuser_web'=>'' // url not exist in $user object
|
||||
);
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ $sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, u.rowid as agen
|
||||
$sql.= " u.login, u.lastname, u.firstname,";
|
||||
$sql.= " sum(d.total_ht) as selling_price,";
|
||||
$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, ";
|
||||
$sql.= $db->ifsql('f.type =2','sum(((d.total_ht/d.qty) + d.buy_price_ht) * d.qty)','sum(((d.total_ht/d.qty) - d.buy_price_ht) * d.qty)')." as marge" ;
|
||||
$sql.= $db->ifsql('f.type =2','sum(d.total_ht + (d.buy_price_ht * d.qty))','sum(d.total_ht - (d.buy_price_ht * d.qty))')." as marge" ;
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE);
|
||||
|
||||
@ -157,7 +157,7 @@ $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client,";
|
||||
$sql.= " f.facnumber, f.total as total_ht,";
|
||||
$sql.= " sum(d.total_ht) as selling_price,";
|
||||
$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, ";
|
||||
$sql.= $db->ifsql('f.type =2','sum(((d.total_ht/d.qty) + d.buy_price_ht) * d.qty)','sum(((d.total_ht/d.qty) - d.buy_price_ht) * d.qty)')." as marge," ;
|
||||
$sql.= $db->ifsql('f.type =2','sum(d.total_ht + (d.buy_price_ht * d.qty))','sum(d.total_ht - (d.buy_price_ht * d.qty))')." as marge," ;
|
||||
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
|
||||
@ -159,7 +159,7 @@ $sql = "SELECT DISTINCT d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref
|
||||
$sql.= " f.facnumber, f.total as total_ht,";
|
||||
$sql.= " sum(d.total_ht) as selling_price,";
|
||||
$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, ";
|
||||
$sql.= $db->ifsql('f.type =2','sum(((d.total_ht/d.qty) + d.buy_price_ht) * d.qty)','sum(((d.total_ht/d.qty) - d.buy_price_ht) * d.qty)')." as marge," ;
|
||||
$sql.= $db->ifsql('f.type =2','sum(d.total_ht + (d.buy_price_ht * d.qty))','sum(d.total_ht - (d.buy_price_ht * d.qty))')." as marge," ;
|
||||
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."product as p";
|
||||
|
||||
@ -133,7 +133,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= " d.total_ht as selling_price,";
|
||||
$sql.= $db->ifsql('f.type =2','(d.buy_price_ht * d.qty *-1)','(d.buy_price_ht * d.qty)')." as buying_price, ";
|
||||
$sql.= $db->ifsql('f.type =2','d.qty *-1','d.qty')." as qty,";
|
||||
$sql.= $db->ifsql('f.type =2','(((d.total_ht/d.qty) + d.buy_price_ht) * d.qty)','(((d.total_ht/d.qty) - d.buy_price_ht) * d.qty)')." as marge," ;
|
||||
$sql.= $db->ifsql('f.type =2','d.total_ht + (d.buy_price_ht * d.qty)','d.total_ht - (d.buy_price_ht * d.qty)')." as marge," ;
|
||||
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
|
||||
@ -131,7 +131,7 @@ if ($socid > 0)
|
||||
$sql.= " sum(d.total_ht) as selling_price,";
|
||||
|
||||
$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, ";
|
||||
$sql.= $db->ifsql('f.type =2','sum(((d.total_ht/d.qty) + d.buy_price_ht) * d.qty)','sum(((d.total_ht/d.qty) - d.buy_price_ht) * d.qty)')." as marge," ;
|
||||
$sql.= $db->ifsql('f.type =2','sum(d.total_ht + (d.buy_price_ht * d.qty))','sum(d.total_ht - (d.buy_price_ht * d.qty))')." as marge," ;
|
||||
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user