Skip to content

Commit

Permalink
Fix list of object referers should not be set to invoice by default (may
Browse files Browse the repository at this point in the history
be module is disabed). I replace with a message to choose list.
  • Loading branch information
eldy committed Feb 17, 2016
1 parent 14fb2c9 commit 633de3b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
16 changes: 12 additions & 4 deletions htdocs/core/lib/product.lib.php
Expand Up @@ -101,7 +101,7 @@ function product_prepare_head($object)
$head[$h][2] = 'stats';
$h++;

$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$object->id;
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?showmessage=1&id=".$object->id;
$head[$h][1] = $langs->trans('Referers');
$head[$h][2] = 'referers';
$h++;
Expand Down Expand Up @@ -201,22 +201,25 @@ function product_admin_prepare_head()
*
* @param Product $product Product object
* @param int $socid Thirdparty id
* @return integer
* @return integer NB of lines shown into array
*/
function show_stats_for_company($product,$socid)
{
global $conf,$langs,$user,$db;

$nblines = 0;

print '<tr>';
print '<td align="left" width="25%" valign="top">'.$langs->trans("Referers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfReferers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("NbOfObjectReferers").'</td>';
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
print '</tr>';

// Propals
if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
{
$nblines++;
$ret=$product->load_stats_propale($socid);
if ($ret < 0) dol_print_error($db);
$langs->load("propal");
Expand All @@ -234,6 +237,7 @@ function show_stats_for_company($product,$socid)
// Commandes clients
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
{
$nblines++;
$ret=$product->load_stats_commande($socid);
if ($ret < 0) dol_print_error($db);
$langs->load("orders");
Expand All @@ -251,6 +255,7 @@ function show_stats_for_company($product,$socid)
// Commandes fournisseurs
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
{
$nblines++;
$ret=$product->load_stats_commande_fournisseur($socid);
if ($ret < 0) dol_print_error($db);
$langs->load("orders");
Expand All @@ -268,6 +273,7 @@ function show_stats_for_company($product,$socid)
// 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");
Expand All @@ -285,6 +291,7 @@ function show_stats_for_company($product,$socid)
// Factures clients
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
{
$nblines++;
$ret=$product->load_stats_facture($socid);
if ($ret < 0) dol_print_error($db);
$langs->load("bills");
Expand All @@ -302,6 +309,7 @@ function show_stats_for_company($product,$socid)
// Factures fournisseurs
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
{
$nblines++;
$ret=$product->load_stats_facture_fournisseur($socid);
if ($ret < 0) dol_print_error($db);
$langs->load("bills");
Expand All @@ -317,7 +325,7 @@ function show_stats_for_company($product,$socid)
print '</tr>';
}

return 0;
return $nblines++;
}


Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/main.lang
Expand Up @@ -537,6 +537,7 @@ NbOfCustomers=Number of customers
NbOfLines=Number of lines
NbOfObjects=Number of objects
NbOfReferers=Number of referrers
NbOfObjectReferers=Number of refering objects
Referers=Refering objects
TotalQuantity=Total quantity
DateFromTo=From %s to %s
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/products.lang
Expand Up @@ -313,3 +313,4 @@ DefaultPriceRealPriceMayDependOnCustomer=Default price, real price may depend on
WarningSelectOneDocument=Please select at least one document
DefaultUnitToShow=Unit
NbOfQtyInProposals=Qty in proposals
ClinkOnALinkOfColumn=Click on a link of column %s to get a detailed view...
15 changes: 10 additions & 5 deletions htdocs/product/stats/facture.php
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
Expand Down Expand Up @@ -48,7 +48,7 @@
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('productstatsinvoice'));

$mesg = '';
$showmessage=GETPOST('showmessage');

$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
Expand All @@ -67,6 +67,8 @@
$search_year='';
}



/*
* View
*/
Expand Down Expand Up @@ -107,7 +109,7 @@
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';

show_stats_for_company($product,$socid);
$nboflines = show_stats_for_company($product,$socid);

print "</table>";

Expand All @@ -116,8 +118,11 @@

dol_fiche_end();


if ($user->rights->facture->lire)
if ($showmessage && $nboflines > 1)
{
print $langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers"));
}
elseif ($user->rights->facture->lire)
{
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
$sql.= " f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,";
Expand Down

0 comments on commit 633de3b

Please sign in to comment.