add option to select contact type associated to commercial agents for margin and commission modules
This commit is contained in:
parent
a9ed3bc175
commit
951b98a963
@ -24,8 +24,11 @@
|
|||||||
include '../../main.inc.php';
|
include '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/commissions/lib/commissions.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/commissions/lib/commissions.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
|
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
$langs->load("bills");
|
||||||
$langs->load("commissions");
|
$langs->load("commissions");
|
||||||
|
|
||||||
if (! $user->admin) accessforbidden();
|
if (! $user->admin) accessforbidden();
|
||||||
@ -68,6 +71,17 @@ if (GETPOST('serviceCommissionRate'))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GETPOST('AGENT_CONTACT_TYPE'))
|
||||||
|
{
|
||||||
|
if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', GETPOST('AGENT_CONTACT_TYPE'), 'chaine', 0, '', $conf->entity) > 0)
|
||||||
|
{
|
||||||
|
$conf->global->AGENT_CONTACT_TYPE = GETPOST('AGENT_CONTACT_TYPE');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -145,6 +159,18 @@ print '</td>';
|
|||||||
print '<td>'.$langs->trans('ServiceCommissionRateDetails').'</td>';
|
print '<td>'.$langs->trans('ServiceCommissionRateDetails').'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// INTERNAL CONTACT TYPE USED AS COMMERCIAL AGENT
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.$langs->trans("AgentContactType").'</td>';
|
||||||
|
print '<td align="left">';
|
||||||
|
$formcompany = new FormCompany($db);
|
||||||
|
$facture = new Facture($db);
|
||||||
|
print $formcompany->selectTypeContact($facture, $conf->global->AGENT_CONTACT_TYPE, "AGENT_CONTACT_TYPE","internal","code",1);
|
||||||
|
print '</td>';
|
||||||
|
print '<td>'.$langs->trans('AgentContactTypeDetails').'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td align="center" colspan="3">';
|
print '<td align="center" colspan="3">';
|
||||||
@ -152,7 +178,6 @@ print '<input type="submit" class="button" />';
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|||||||
@ -134,44 +134,52 @@ print '</td></tr>';
|
|||||||
print "</table>";
|
print "</table>";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,";
|
$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,";
|
||||||
$sql.= " u.login,";
|
$sql.= " u.login,";
|
||||||
$sql.= " f.facnumber, f.total as total_ht,";
|
|
||||||
if ($conf->global->COMMISSION_BASE == "MARGIN") {
|
if ($conf->global->COMMISSION_BASE == "MARGIN") {
|
||||||
$sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ;
|
$sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ;
|
||||||
$sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase," ;
|
$sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase" ;
|
||||||
}
|
}
|
||||||
elseif ($conf->global->COMMISSION_BASE == "TURNOVER") {
|
elseif ($conf->global->COMMISSION_BASE == "TURNOVER") {
|
||||||
$sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) end) as productBase," ;
|
$sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) end) as productBase," ;
|
||||||
$sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase," ;
|
$sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase" ;
|
||||||
}
|
}
|
||||||
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
$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);
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
|
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."user as u";
|
$sql.= ", ".MAIN_DB_PREFIX."user as u";
|
||||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||||
$sql.= " AND sc.fk_soc = f.fk_soc";
|
$sql.= " AND sc.fk_soc = f.fk_soc";
|
||||||
$sql.= " AND sc.fk_user = u.rowid";
|
if (! empty($conf->global->AGENT_CONTACT_TYPE))
|
||||||
|
$sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))";
|
||||||
|
else
|
||||||
|
$sql .= " AND sc.fk_user = u.rowid";
|
||||||
if (GETPOST('unpayed') == 'on')
|
if (GETPOST('unpayed') == 'on')
|
||||||
$sql.= " AND f.fk_statut > 0";
|
$sql.= " AND f.fk_statut > 0";
|
||||||
else
|
else
|
||||||
$sql.= " AND f.fk_statut > 1";
|
$sql.= " AND f.fk_statut > 1";
|
||||||
$sql.= " AND s.entity = ".$conf->entity;
|
$sql.= " AND s.entity = ".$conf->entity;
|
||||||
$sql.= " AND d.fk_facture = f.rowid";
|
$sql.= " AND d.fk_facture = f.rowid";
|
||||||
if ($agentid > 0)
|
if ($agentid > 0) {
|
||||||
$sql.= " AND sc.fk_user = $agentid";
|
if (! empty($conf->global->AGENT_CONTACT_TYPE))
|
||||||
|
$sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))";
|
||||||
|
else
|
||||||
|
$sql .= " AND sc.fk_user = ".$agentid;
|
||||||
|
}
|
||||||
if (!empty($startdate))
|
if (!empty($startdate))
|
||||||
$sql.= " AND f.datef >= '".$startdate."'";
|
$sql.= " AND f.datef >= '".$startdate."'";
|
||||||
if (!empty($enddate))
|
if (!empty($enddate))
|
||||||
$sql.= " AND f.datef <= '".$enddate."'";
|
$sql.= " AND f.datef <= '".$enddate."'";
|
||||||
|
if ($conf->global->COMMISSION_BASE == "MARGIN")
|
||||||
|
$sql .= " AND d.buy_price_ht IS NOT NULL";
|
||||||
if (($conf->global->COMMISSION_BASE == "MARGIN") && isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
if (($conf->global->COMMISSION_BASE == "MARGIN") && isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||||
$sql .= " AND d.buy_price_ht <> 0";
|
$sql .= " AND d.buy_price_ht <> 0";
|
||||||
if ($agentid > 0)
|
if ($agentid > 0)
|
||||||
$sql.= " GROUP BY s.rowid";
|
$sql.= " GROUP BY s.rowid";
|
||||||
else
|
else
|
||||||
$sql.= " GROUP BY sc.fk_user";
|
$sql.= " GROUP BY u.rowid";
|
||||||
$sql.= " ORDER BY $sortfield $sortorder ";
|
$sql.= " ORDER BY $sortfield $sortorder ";
|
||||||
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||||
|
|
||||||
@ -219,6 +227,7 @@ if ($result)
|
|||||||
$cumul_base_service = 0;
|
$cumul_base_service = 0;
|
||||||
$cumul_commission_produit = 0;
|
$cumul_commission_produit = 0;
|
||||||
$cumul_commission_service = 0;
|
$cumul_commission_service = 0;
|
||||||
|
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
$var=True;
|
$var=True;
|
||||||
@ -260,22 +269,22 @@ if ($result)
|
|||||||
// total commission
|
// total commission
|
||||||
print "<td align=\"right\">".price($productCommission + $serviceCommission)."</td>\n";
|
print "<td align=\"right\">".price($productCommission + $serviceCommission)."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
$cumul_base_produit += $productBase;
|
|
||||||
$cumul_base_service += $serviceBase;
|
$cumul_base_produit += round($productBase, $rounding);
|
||||||
$cumul_commission_produit += $productCommission;
|
$cumul_base_service += round($serviceBase, $rounding);
|
||||||
$cumul_commission_service += $serviceCommission;
|
$cumul_commission_produit += round($productCommission, $rounding);
|
||||||
|
$cumul_commission_service += round($serviceCommission, $rounding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// affichage totaux commission
|
// affichage totaux commission
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||||
if (! empty($client))
|
|
||||||
print '<td colspan=2>';
|
|
||||||
else
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $langs->trans('TotalCommission')."</td>";
|
print $langs->trans('Total');
|
||||||
|
print "</td>";
|
||||||
// product commission
|
// product commission
|
||||||
print "<td align=\"right\">".price($cumul_base_produit)."</td>\n";
|
print "<td align=\"right\">".price($cumul_base_produit)."</td>\n";
|
||||||
print "<td align=\"right\">".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."</td>\n";
|
print "<td align=\"right\">".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."</td>\n";
|
||||||
@ -289,6 +298,7 @@ if ($result)
|
|||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
print "</td>";
|
||||||
print "</table>";
|
print "</table>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -39,3 +39,6 @@ CommercialAgent=Commercial agent
|
|||||||
StartDate=Start date
|
StartDate=Start date
|
||||||
EndDate=End date
|
EndDate=End date
|
||||||
Launch=Start
|
Launch=Start
|
||||||
|
|
||||||
|
AgentContactType=Contact type used for commissioning
|
||||||
|
AgentContactTypeDetails=Défine what contact type (linked on invoices) will be associated with commercial agents
|
||||||
@ -47,3 +47,6 @@ MARGIN_TYPE_DETAILS=Raw margin : Selling price - Buying price<br/>Net margin : S
|
|||||||
|
|
||||||
BuyingCost=Cost price
|
BuyingCost=Cost price
|
||||||
UnitCharges=Unit charges
|
UnitCharges=Unit charges
|
||||||
|
|
||||||
|
AgentContactType=Contact type used for commissioning
|
||||||
|
AgentContactTypeDetails=Défine what contact type (linked on invoices) will be associated with commercial agents
|
||||||
@ -1,6 +1,7 @@
|
|||||||
# Dolibarr language file - fr_FR - commissions
|
# Dolibarr language file - fr_FR - commissions
|
||||||
CHARSET=UTF-8
|
CHARSET=UTF-8
|
||||||
|
|
||||||
|
Module60000Desc=Gestion des commissions
|
||||||
commissionsSetup=Paramétrage de la gestion des commissions
|
commissionsSetup=Paramétrage de la gestion des commissions
|
||||||
|
|
||||||
ProductCommissionRate=Taux de commissionnement sur les produits
|
ProductCommissionRate=Taux de commissionnement sur les produits
|
||||||
@ -38,3 +39,6 @@ CommercialAgent=Agent commercial
|
|||||||
StartDate=Date de début
|
StartDate=Date de début
|
||||||
EndDate=Date de fin
|
EndDate=Date de fin
|
||||||
Launch=Démarrer
|
Launch=Démarrer
|
||||||
|
|
||||||
|
AgentContactType=Type de contact commissionné
|
||||||
|
AgentContactTypeDetails=Permet de définir le type de contact associé aux factures qui sera associé aux agents commerciaux
|
||||||
@ -1,6 +1,8 @@
|
|||||||
# Dolibarr language file - fr_FR - margins
|
# Dolibarr language file - fr_FR - margins
|
||||||
CHARSET=UTF-8
|
CHARSET=UTF-8
|
||||||
|
|
||||||
|
Module59000Name=Marges
|
||||||
|
Module59000Desc=Gestion des marges commerciales
|
||||||
Margin=Marge
|
Margin=Marge
|
||||||
Margins=Marges
|
Margins=Marges
|
||||||
TotalMargin=Marge totale
|
TotalMargin=Marge totale
|
||||||
@ -45,3 +47,6 @@ MARGIN_TYPE_DETAILS=Marge brute : Prix de vente HT - Prix d'achat HT<br/>Marge n
|
|||||||
|
|
||||||
BuyingCost=Coût de revient
|
BuyingCost=Coût de revient
|
||||||
UnitCharges=Charge unitaire
|
UnitCharges=Charge unitaire
|
||||||
|
|
||||||
|
AgentContactType=Type de contact commissionné
|
||||||
|
AgentContactTypeDetails=Permet de définir le type de contact associé aux factures qui sera associé aux agents commerciaux
|
||||||
@ -25,8 +25,11 @@ include '../../main.inc.php';
|
|||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
|
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
$langs->load("bills");
|
||||||
$langs->load("margins");
|
$langs->load("margins");
|
||||||
|
|
||||||
if (! $user->admin) accessforbidden();
|
if (! $user->admin) accessforbidden();
|
||||||
@ -89,6 +92,18 @@ if ($action == 'typemarges')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == 'contact')
|
||||||
|
{
|
||||||
|
if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
|
||||||
|
{
|
||||||
|
$conf->global->AGENT_CONTACT_TYPE = $_POST['AGENT_CONTACT_TYPE'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -244,6 +259,25 @@ print '<td>'.$langs->trans('MARGIN_METHODE_FOR_DISCOUNT_DETAILS').'</td>';
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
|
// INTERNAL CONTACT TYPE USED AS COMMERCIAL AGENT
|
||||||
|
$var=!$var;
|
||||||
|
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print "<input type=\"hidden\" name=\"action\" value=\"contact\">";
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.$langs->trans("AgentContactType").'</td>';
|
||||||
|
print '<td align="left">';
|
||||||
|
$formcompany = new FormCompany($db);
|
||||||
|
$facture = new Facture($db);
|
||||||
|
print $formcompany->selectTypeContact($facture, $conf->global->AGENT_CONTACT_TYPE, "AGENT_CONTACT_TYPE","internal","code",1);
|
||||||
|
print '</td>';
|
||||||
|
print '<td>';
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print '</td>';
|
||||||
|
print '<td>'.$langs->trans('AgentContactTypeDetails').'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|||||||
@ -118,35 +118,42 @@ if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
|||||||
print "</table>";
|
print "</table>";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,";
|
$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,";
|
||||||
$sql.= " u.login,";
|
$sql.= " u.login,";
|
||||||
$sql.= " f.facnumber, f.total as total_ht,";
|
|
||||||
$sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,";
|
$sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,";
|
||||||
$sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge," ;
|
$sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - 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.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
$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);
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
|
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."user as u";
|
$sql.= ", ".MAIN_DB_PREFIX."user as u";
|
||||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||||
$sql.= " AND sc.fk_soc = f.fk_soc";
|
$sql.= " AND sc.fk_soc = f.fk_soc";
|
||||||
$sql.= " AND sc.fk_user = u.rowid";
|
if (! empty($conf->global->AGENT_CONTACT_TYPE))
|
||||||
|
$sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))";
|
||||||
|
else
|
||||||
|
$sql .= " AND sc.fk_user = u.rowid";
|
||||||
$sql.= " AND f.fk_statut > 0";
|
$sql.= " AND f.fk_statut > 0";
|
||||||
$sql.= " AND s.entity = ".$conf->entity;
|
$sql.= " AND s.entity = ".$conf->entity;
|
||||||
$sql.= " AND d.fk_facture = f.rowid";
|
$sql.= " AND d.fk_facture = f.rowid";
|
||||||
if ($agentid > 0)
|
if ($agentid > 0) {
|
||||||
$sql.= " AND sc.fk_user = $agentid";
|
if (! empty($conf->global->AGENT_CONTACT_TYPE))
|
||||||
|
$sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))";
|
||||||
|
else
|
||||||
|
$sql .= " AND sc.fk_user = ".$agentid;
|
||||||
|
}
|
||||||
if (!empty($startdate))
|
if (!empty($startdate))
|
||||||
$sql.= " AND f.datef >= '".$startdate."'";
|
$sql.= " AND f.datef >= '".$startdate."'";
|
||||||
if (!empty($enddate))
|
if (!empty($enddate))
|
||||||
$sql.= " AND f.datef <= '".$enddate."'";
|
$sql.= " AND f.datef <= '".$enddate."'";
|
||||||
|
$sql .= " AND d.buy_price_ht IS NOT NULL";
|
||||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||||
$sql .= " AND d.buy_price_ht <> 0";
|
$sql .= " AND d.buy_price_ht <> 0";
|
||||||
if ($agentid > 0)
|
if ($agentid > 0)
|
||||||
$sql.= " GROUP BY s.rowid";
|
$sql.= " GROUP BY s.rowid";
|
||||||
else
|
else
|
||||||
$sql.= " GROUP BY sc.fk_user";
|
$sql.= " GROUP BY u.rowid";
|
||||||
$sql.= " ORDER BY $sortfield $sortorder ";
|
$sql.= " ORDER BY $sortfield $sortorder ";
|
||||||
$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||||
|
|
||||||
@ -168,17 +175,19 @@ if ($result)
|
|||||||
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder);
|
||||||
|
|
||||||
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buying_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$cumul_achat = 0;
|
$cumul_achat = 0;
|
||||||
$cumul_vente = 0;
|
$cumul_vente = 0;
|
||||||
$cumul_qty = 0;
|
$cumul_qty = 0;
|
||||||
|
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
$var=true;
|
$var=true;
|
||||||
@ -211,9 +220,11 @@ if ($result)
|
|||||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
$cumul_achat += $objp->buying_price;
|
|
||||||
$cumul_vente += $objp->selling_price;
|
$cumul_achat += round($objp->buying_price, $rounding);
|
||||||
|
$cumul_vente += round($objp->selling_price, $rounding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,11 +234,9 @@ if ($result)
|
|||||||
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):'';
|
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):'';
|
||||||
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'';
|
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'';
|
||||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||||
if (! empty($client))
|
|
||||||
print '<td colspan=2>';
|
|
||||||
else
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $langs->trans('TotalMargin')."</td>";
|
print $langs->trans('Total');
|
||||||
|
print "</td>";
|
||||||
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
|
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
|
||||||
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
||||||
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
||||||
|
|||||||
@ -158,6 +158,7 @@ if (!empty($startdate))
|
|||||||
$sql.= " AND f.datef >= '".$startdate."'";
|
$sql.= " AND f.datef >= '".$startdate."'";
|
||||||
if (!empty($enddate))
|
if (!empty($enddate))
|
||||||
$sql.= " AND f.datef <= '".$enddate."'";
|
$sql.= " AND f.datef <= '".$enddate."'";
|
||||||
|
$sql .= " AND d.buy_price_ht IS NOT NULL";
|
||||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||||
$sql .= " AND d.buy_price_ht <> 0";
|
$sql .= " AND d.buy_price_ht <> 0";
|
||||||
if ($client)
|
if ($client)
|
||||||
@ -186,17 +187,19 @@ if ($result)
|
|||||||
else
|
else
|
||||||
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&socid=".$socid,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&socid=".$socid,'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buying_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$cumul_achat = 0;
|
$cumul_achat = 0;
|
||||||
$cumul_vente = 0;
|
$cumul_vente = 0;
|
||||||
$cumul_qty = 0;
|
$cumul_qty = 0;
|
||||||
|
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
$var=True;
|
$var=True;
|
||||||
@ -234,8 +237,8 @@ if ($result)
|
|||||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
$cumul_achat += $objp->buying_price;
|
$cumul_achat += round($objp->buying_price, $rounding);
|
||||||
$cumul_vente += $objp->selling_price;
|
$cumul_vente += round($objp->selling_price, $rounding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -162,6 +162,7 @@ if (!empty($startdate))
|
|||||||
$sql.= " AND f.datef >= '".$startdate."'";
|
$sql.= " AND f.datef >= '".$startdate."'";
|
||||||
if (!empty($enddate))
|
if (!empty($enddate))
|
||||||
$sql.= " AND f.datef <= '".$enddate."'";
|
$sql.= " AND f.datef <= '".$enddate."'";
|
||||||
|
$sql .= " AND d.buy_price_ht IS NOT NULL";
|
||||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||||
$sql .= " AND d.buy_price_ht <> 0";
|
$sql .= " AND d.buy_price_ht <> 0";
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
@ -190,17 +191,19 @@ if ($result)
|
|||||||
else
|
else
|
||||||
print_liste_field_titre($langs->trans("ProductService"),$_SERVER["PHP_SELF"],"p.ref","","&id=".$id,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("ProductService"),$_SERVER["PHP_SELF"],"p.ref","","&id=".$id,'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buying_price","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"","","&id=".$id,'align="right"',$sortfield,$sortorder);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$cumul_achat = 0;
|
$cumul_achat = 0;
|
||||||
$cumul_vente = 0;
|
$cumul_vente = 0;
|
||||||
$cumul_qty = 0;
|
$cumul_qty = 0;
|
||||||
|
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
$var=True;
|
$var=True;
|
||||||
@ -241,8 +244,8 @@ if ($result)
|
|||||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
$cumul_achat += $objp->buying_price;
|
$cumul_achat += round($objp->buying_price, $rounding);
|
||||||
$cumul_vente += $objp->selling_price;
|
$cumul_vente += round($objp->selling_price, $rounding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,10 +142,11 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$sql.= " AND s.entity = ".$conf->entity;
|
$sql.= " AND s.entity = ".$conf->entity;
|
||||||
$sql.= " AND d.fk_facture = f.rowid";
|
$sql.= " AND d.fk_facture = f.rowid";
|
||||||
$sql.= " AND d.fk_product =".$object->id;
|
$sql.= " AND d.fk_product =".$object->id;
|
||||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
|
||||||
$sql .= " AND d.buy_price_ht <> 0";
|
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if (! empty($socid)) $sql.= " AND f.fk_soc = $socid";
|
if (! empty($socid)) $sql.= " AND f.fk_soc = $socid";
|
||||||
|
$sql .= " AND d.buy_price_ht IS NOT NULL";
|
||||||
|
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||||
|
$sql .= " AND d.buy_price_ht <> 0";
|
||||||
$sql.= " ORDER BY $sortfield $sortorder ";
|
$sql.= " ORDER BY $sortfield $sortorder ";
|
||||||
$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||||
|
|
||||||
@ -165,19 +166,21 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$object->id,'',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$object->id,'',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$object->id,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$object->id,'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buying_price","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$cumul_achat = 0;
|
$cumul_achat = 0;
|
||||||
$cumul_vente = 0;
|
$cumul_vente = 0;
|
||||||
$cumul_qty = 0;
|
$cumul_qty = 0;
|
||||||
|
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
$var=True;
|
$var=True;
|
||||||
@ -209,8 +212,8 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
|
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
$cumul_achat += $objp->buying_price;
|
$cumul_achat += round($objp->buying_price, $rounding);
|
||||||
$cumul_vente += $objp->selling_price;
|
$cumul_vente += round($objp->selling_price, $rounding);
|
||||||
$cumul_qty += $objp->qty;
|
$cumul_qty += $objp->qty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,6 +138,7 @@ if ($socid > 0)
|
|||||||
$sql.= " AND s.entity = ".$conf->entity;
|
$sql.= " AND s.entity = ".$conf->entity;
|
||||||
$sql.= " AND d.fk_facture = f.rowid";
|
$sql.= " AND d.fk_facture = f.rowid";
|
||||||
$sql.= " AND f.fk_soc = $socid";
|
$sql.= " AND f.fk_soc = $socid";
|
||||||
|
$sql .= " AND d.buy_price_ht IS NOT NULL";
|
||||||
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
|
||||||
$sql .= " AND d.buy_price_ht <> 0";
|
$sql .= " AND d.buy_price_ht <> 0";
|
||||||
$sql.= " GROUP BY f.rowid";
|
$sql.= " GROUP BY f.rowid";
|
||||||
@ -158,18 +159,20 @@ if ($socid > 0)
|
|||||||
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=".$_REQUEST["socid"],'',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=".$_REQUEST["socid"],'',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buying_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||||
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$cumul_achat = 0;
|
$cumul_achat = 0;
|
||||||
$cumul_vente = 0;
|
$cumul_vente = 0;
|
||||||
$cumul_qty = 0;
|
$cumul_qty = 0;
|
||||||
|
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
$var=True;
|
$var=True;
|
||||||
@ -200,8 +203,8 @@ if ($socid > 0)
|
|||||||
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
|
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
$cumul_achat += $objp->buying_price;
|
$cumul_achat += round($objp->buying_price, $rounding);
|
||||||
$cumul_vente += $objp->selling_price;
|
$cumul_vente += round($objp->selling_price, $rounding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user