NEW Add supplier proposals into stats of product page.
This commit is contained in:
parent
fa18e788b5
commit
a3c555049d
@ -309,7 +309,7 @@ function show_stats_for_company($product,$socid)
|
||||
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Propals
|
||||
// Customer proposals
|
||||
if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
|
||||
{
|
||||
$nblines++;
|
||||
@ -327,7 +327,25 @@ function show_stats_for_company($product,$socid)
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Commandes clients
|
||||
// Supplier proposals
|
||||
if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_proposal_supplier($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("propal");
|
||||
print '<tr><td>';
|
||||
print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("SupplierProposals").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print $product->stats_proposal_supplier['suppliers'];
|
||||
print '</td><td align="right">';
|
||||
print $product->stats_proposal_supplier['nb'];
|
||||
print '</td><td align="right">';
|
||||
print $product->stats_proposal_supplier['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Customer orders
|
||||
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
|
||||
{
|
||||
$nblines++;
|
||||
@ -345,7 +363,7 @@ function show_stats_for_company($product,$socid)
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Commandes fournisseurs
|
||||
// Supplier orders
|
||||
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
|
||||
{
|
||||
$nblines++;
|
||||
@ -363,25 +381,7 @@ function show_stats_for_company($product,$socid)
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Contrats
|
||||
if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_contrat($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("contracts");
|
||||
print '<tr><td>';
|
||||
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print $product->stats_contrat['customers'];
|
||||
print '</td><td align="right">';
|
||||
print $product->stats_contrat['nb'];
|
||||
print '</td><td align="right">';
|
||||
print $product->stats_contrat['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Factures clients
|
||||
// Customer invoices
|
||||
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
{
|
||||
$nblines++;
|
||||
@ -399,7 +399,7 @@ function show_stats_for_company($product,$socid)
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Factures fournisseurs
|
||||
// Supplier invoices
|
||||
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
$nblines++;
|
||||
@ -418,6 +418,25 @@ function show_stats_for_company($product,$socid)
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Contracts
|
||||
if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_contrat($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("contracts");
|
||||
print '<tr><td>';
|
||||
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print $product->stats_contrat['customers'];
|
||||
print '</td><td align="right">';
|
||||
print $product->stats_contrat['nb'];
|
||||
print '</td><td align="right">';
|
||||
print $product->stats_contrat['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
return $nblines++;
|
||||
}
|
||||
|
||||
|
||||
@ -2133,6 +2133,49 @@ class Product extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Charge tableau des stats propale pour le produit/service
|
||||
*
|
||||
* @param int $socid Id thirdparty
|
||||
* @return array Tableau des stats
|
||||
*/
|
||||
function load_stats_proposal_supplier($socid=0)
|
||||
{
|
||||
global $conf;
|
||||
global $user;
|
||||
|
||||
$sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_suppliers, COUNT(DISTINCT p.rowid) as nb,";
|
||||
$sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as pd";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."supplier_proposal as p";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE p.rowid = pd.fk_supplier_proposal";
|
||||
$sql.= " AND p.fk_soc = s.rowid";
|
||||
$sql.= " AND p.entity IN (".getEntity('supplier_proposal').")";
|
||||
$sql.= " AND pd.fk_product = ".$this->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
//$sql.= " AND pr.fk_statut != 0";
|
||||
if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ( $result )
|
||||
{
|
||||
$obj=$this->db->fetch_object($result);
|
||||
$this->stats_proposal_supplier['suppliers']=$obj->nb_suppliers;
|
||||
$this->stats_proposal_supplier['nb']=$obj->nb;
|
||||
$this->stats_proposal_supplier['rows']=$obj->nb_rows;
|
||||
$this->stats_proposal_supplier['qty']=$obj->qty?$obj->qty:0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Charge tableau des stats commande client pour le produit/service
|
||||
*
|
||||
|
||||
@ -228,7 +228,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td>'.$societestatic->getNomUrl(1).'</td>';
|
||||
print "<td>".$objp->code_client."</td>\n";
|
||||
print '<td align="center">';
|
||||
print dol_print_date($db->jdate($objp->date_commande))."</td>";
|
||||
print dol_print_date($db->jdate($objp->date_commande), 'dayhour')."</td>";
|
||||
print '<td align="center">'.$objp->qty."</td>\n";
|
||||
print '<td align="right">'.price($objp->total_ht)."</td>\n";
|
||||
print '<td align="right">'.$orderstatic->LibStatut($objp->statut,$objp->facture,5).'</td>';
|
||||
|
||||
@ -236,7 +236,7 @@ if ($id > 0 || ! empty($ref)) {
|
||||
print '<td>' . $societestatic->getNomUrl(1) . '</td>';
|
||||
print "<td>" . $objp->code_client . "</td>\n";
|
||||
print '<td align="center">';
|
||||
print dol_print_date($db->jdate($objp->date_commande)) . "</td>";
|
||||
print dol_print_date($db->jdate($objp->date_commande), 'dayhour') . "</td>";
|
||||
print '<td align="center">' . $objp->qty . "</td>\n";
|
||||
print '<td align="right">' . price($objp->total_ht) . "</td>\n";
|
||||
print '<td align="right">' . $supplierorderstatic->getLibStatut(4) . '</td>';
|
||||
|
||||
@ -190,7 +190,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->name,44).'</a></td>';
|
||||
print "<td>".$objp->code_client."</td>\n";
|
||||
print "<td align=\"center\">";
|
||||
print dol_print_date($db->jdate($objp->date_contrat))."</td>";
|
||||
print dol_print_date($db->jdate($objp->date_contrat), 'dayhour')."</td>";
|
||||
//print "<td align=\"right\">".price($objp->total_ht)."</td>\n";
|
||||
//print '<td align="right">';
|
||||
print '<td align="center">'.($objp->nb_initial>0?$objp->nb_initial:'').'</td>';
|
||||
|
||||
@ -251,7 +251,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td>'.$societestatic->getNomUrl(1).'</td>';
|
||||
print "<td>".$objp->code_client."</td>\n";
|
||||
print '<td align="center">';
|
||||
print dol_print_date($db->jdate($objp->datef),'day')."</td>";
|
||||
print dol_print_date($db->jdate($objp->datef),'dayhour')."</td>";
|
||||
print '<td align="center">'.$objp->qty."</td>\n";
|
||||
print '<td align="right">'.price($objp->total_ht)."</td>\n";
|
||||
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).'</td>';
|
||||
|
||||
@ -229,7 +229,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td>' . $societestatic->getNomUrl(1) . '</td>';
|
||||
print "<td>" . $objp->code_client . "</td>\n";
|
||||
print '<td align="center">';
|
||||
print dol_print_date($db->jdate($objp->datef)) . "</td>";
|
||||
print dol_print_date($db->jdate($objp->datef), 'dayhour') . "</td>";
|
||||
print '<td align="center">' . $objp->qty . "</td>\n";
|
||||
print '<td align="right">' . price($objp->total_ht) . "</td>\n";
|
||||
print '<td align="right">' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . '</td>';
|
||||
|
||||
@ -230,7 +230,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$societestatic->fetch($objp->socid);
|
||||
print '<td>'.$societestatic->getNomUrl(1).'</td>';
|
||||
print '<td align="center">';
|
||||
print dol_print_date($db->jdate($objp->datep)) . "</td>";
|
||||
print dol_print_date($db->jdate($objp->datep), 'dayhour') . "</td>";
|
||||
print "<td align=\"center\">" . $objp->qty . "</td>\n";
|
||||
print '<td align="right">' . price($objp->amount) . '</td>' . "\n";
|
||||
print '<td align="right">' . $propalstatic->LibStatut($objp->statut, 5) . '</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user