";
print '';
$invoicestatic->id=$objp->facid;
$invoicestatic->ref=$objp->facnumber;
print $invoicestatic->getNomUrl(1);
print " | \n";
print "";
print dol_print_date($db->jdate($objp->datef),'day')." | ";
print "".price($objp->selling_price, null, null, null, null, $rounding)." | \n";
print "".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)." | \n";
print "".price($objp->marge, null, null, null, null, $rounding)." | \n";
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")." | \n";
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")." | \n";
print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).' | ';
print "
\n";
$i++;
$cumul_achat += $objp->buying_price;
$cumul_vente += $objp->selling_price;
}
}
// affichage totaux marges
$var=!$var;
$totalMargin = $cumul_vente - $cumul_achat;
if ($totalMargin < 0)
{
$marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):'';
}
else
{
$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
}
print '';
print ''.$langs->trans('TotalMargin')." | ";
print "".price($cumul_vente, null, null, null, null, $rounding)." | \n";
print "".price($cumul_achat, null, null, null, null, $rounding)." | \n";
print "".price($totalMargin, null, null, null, null, $rounding)." | \n";
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")." | \n";
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")." | \n";
print ' | ';
print "
\n";
}
else
{
dol_print_error($db);
}
print "