User must not see invoices if no rights
This commit is contained in:
parent
bcd441cc1e
commit
fada3ca9a2
@ -128,6 +128,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
if ($user->rights->facture->lire) {
|
||||||
$sql = "SELECT s.nom, s.rowid as socid, s.code_client,";
|
$sql = "SELECT s.nom, s.rowid as socid, s.code_client,";
|
||||||
$sql.= " f.rowid as facid, f.facnumber, f.total as total_ht,";
|
$sql.= " f.rowid as facid, f.facnumber, f.total as total_ht,";
|
||||||
$sql.= " f.datef, f.paye, f.fk_statut as statut,";
|
$sql.= " f.datef, f.paye, f.fk_statut as statut,";
|
||||||
@ -156,14 +157,13 @@ if ($id > 0 || ! empty($ref))
|
|||||||
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||||
dol_syslog('margin:tabs:productMargins.php', LOG_DEBUG);
|
dol_syslog('margin:tabs:productMargins.php', LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
|
|
||||||
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$object->id",$sortfield,$sortorder,'',0,0,'');
|
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$object->id",$sortfield,$sortorder,'',0,0,'');
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$object->id,'',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$object->id,'',$sortfield,$sortorder);
|
||||||
@ -186,26 +186,21 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$cumul_qty = 0;
|
$cumul_qty = 0;
|
||||||
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0) {
|
||||||
{
|
|
||||||
$var=True;
|
$var=True;
|
||||||
while ($i < $num /*&& $i < $conf->liste_limit*/)
|
while ($i < $num /*&& $i < $conf->liste_limit*/) {
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
if ($objp->marge < 0)
|
if ($objp->marge < 0) {
|
||||||
{
|
|
||||||
$marginRate = ($objp->buying_price != 0)?-1*(100 * $objp->marge / $objp->buying_price):'' ;
|
$marginRate = ($objp->buying_price != 0)?-1*(100 * $objp->marge / $objp->buying_price):'' ;
|
||||||
$markRate = ($objp->selling_price != 0)?-1*(100 * $objp->marge / $objp->selling_price):'' ;
|
$markRate = ($objp->selling_price != 0)?-1*(100 * $objp->marge / $objp->selling_price):'' ;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ;
|
$marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ;
|
||||||
$markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ;
|
$markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<tr ".$bc[$var].">";
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$invoicestatic->id=$objp->facid;
|
$invoicestatic->id=$objp->facid;
|
||||||
$invoicestatic->ref=$objp->facnumber;
|
$invoicestatic->ref=$objp->facnumber;
|
||||||
@ -235,40 +230,34 @@ if ($id > 0 || ! empty($ref))
|
|||||||
// affichage totaux marges
|
// affichage totaux marges
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
$totalMargin = $cumul_vente - $cumul_achat;
|
$totalMargin = $cumul_vente - $cumul_achat;
|
||||||
if ($totalMargin < 0)
|
if ($totalMargin < 0) {
|
||||||
{
|
|
||||||
$marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):'';
|
$marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):'';
|
||||||
$markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):'';
|
$markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):'';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
|
$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
|
||||||
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
|
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
|
||||||
}
|
}
|
||||||
print '<tr class="liste_total">';
|
print '<tr class="liste_total">';
|
||||||
print '<td colspan=4>'.$langs->trans('TotalMargin')."</td>";
|
print '<td colspan=4>'.$langs->trans('TotalMargin')."</td>";
|
||||||
print "<td align=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n";
|
print '<td align="right">'.price($cumul_vente, null, null, null, null, $rounding)."</td>\n";
|
||||||
print "<td align=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n";
|
print '<td align="right">'.price($cumul_achat, null, null, null, null, $rounding)."</td>\n";
|
||||||
print "<td align=\"right\">".price($cumul_qty, null, null, null, null, $rounding)."</td>\n";
|
print '<td align="right">'.price($cumul_qty, null, null, null, null, $rounding)."</td>\n";
|
||||||
print "<td align=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n";
|
print '<td align="right">'.price($totalMargin, null, null, null, null, $rounding)."</td>\n";
|
||||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
|
print '<td align="right">'.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
|
||||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
|
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
|
||||||
print '<td align="right"> </td>';
|
print '<td align="right"> </td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
$db->free($result);
|
$db->free($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
dol_print_error();
|
dol_print_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -120,6 +120,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
if ($user->rights->facture->lire) {
|
||||||
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,";
|
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,";
|
||||||
$sql.= " f.facnumber, f.total as total_ht,";
|
$sql.= " f.facnumber, f.total as total_ht,";
|
||||||
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty";
|
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty";
|
||||||
@ -138,14 +139,13 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
|
|
||||||
print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,'');
|
print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,'');
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","","&id=".$product->id,'',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","","&id=".$product->id,'',$sortfield,$sortorder);
|
||||||
@ -157,15 +157,13 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$product->id,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$product->id,'align="right"',$sortfield,$sortorder);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0) {
|
||||||
{
|
|
||||||
$var=True;
|
$var=True;
|
||||||
while ($i < $num && $i < $conf->liste_limit)
|
while ($i < $num && $i < $conf->liste_limit) {
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
print "<tr ".$bc[$var].">";
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$invoicestatic->id=$objp->facid;
|
$invoicestatic->id=$objp->facid;
|
||||||
$invoicestatic->ref=$objp->facnumber;
|
$invoicestatic->ref=$objp->facnumber;
|
||||||
@ -173,27 +171,24 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'</a></td>';
|
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'</a></td>';
|
||||||
print "<td>".$objp->code_client."</td>\n";
|
print "<td>".$objp->code_client."</td>\n";
|
||||||
print "<td align=\"center\">";
|
print '<td align="center">';
|
||||||
print dol_print_date($db->jdate($objp->datef),'day')."</td>";
|
print dol_print_date($db->jdate($objp->datef),'day')."</td>";
|
||||||
print "<td align=\"center\">".$objp->qty."</td>\n";
|
print '<td align="center">'.$objp->qty."</td>\n";
|
||||||
print "<td align=\"right\">".price($objp->total_ht)."</td>\n";
|
print '<td align="right">'.price($objp->total_ht)."</td>\n";
|
||||||
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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
$db->free($result);
|
$db->free($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
dol_print_error();
|
dol_print_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user