Skip to content

Commit

Permalink
Fix: var init at wrong place
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 25, 2014
1 parent 7149fd7 commit f50ad96
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions htdocs/core/boxes/box_graph_product_distribution.php
Expand Up @@ -103,9 +103,9 @@ function loadBox($max=5)
$showordernb=$tmparray['showordernb'];
}
if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; }
if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
if (empty($conf->propal->enabled) || empty($user->rights->propal->lire)) $showpropalnb=0;
if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;
if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
if (empty($conf->propal->enabled) || empty($user->rights->propal->lire)) $showpropalnb=0;
if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;

$nowarray=dol_getdate(dol_now(),true);
if (empty($year)) $year=$nowarray['year'];
Expand All @@ -114,30 +114,30 @@ function loadBox($max=5)
if ($showinvoicenb) $nbofgraph++;
if ($showpropalnb) $nbofgraph++;
if ($showordernb) $nbofgraph++;

$paramtitle=$langs->trans("Products").'/'.$langs->trans("Services");
if (empty($conf->produit->enabled)) $paramtitle=$langs->trans("Services");
if (empty($conf->service->enabled)) $paramtitle=$langs->trans("Products");

$socid=empty($user->societe_id)?0:$user->societe_id;
$userid=0; // No filter on user creation


$WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320';
$HEIGHT='192';

if (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
{

$WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320';
$HEIGHT='192';


// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showinvoicenb)
{
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';

$showpointvalue = 1; $nocolor = 0;
$mode='customer';
$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid>0?$userid:0));
$data1 = $stats_invoice->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24)));
if (empty($data1))
if (empty($data1))
{
$showpointvalue=0;
$nocolor=1;
Expand All @@ -157,10 +157,10 @@ function loadBox($max=5)
$legend[]=$data1[$i][0];
$i++;
}

$px1->SetData($data1);
unset($data1);

if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
$px1->SetPrecisionY(0);
$px1->SetLegend($legend);
Expand All @@ -178,29 +178,29 @@ function loadBox($max=5)
//$px1->mode='depth';
$px1->SetType(array('pie'));
$px1->SetTitle($langs->trans("BoxProductDistributionFor",$paramtitle,$langs->transnoentitiesnoconv("Invoices")));

$px1->draw($filenamenb,$fileurlnb);
}
}
}

if (! empty($conf->propal->enabled) && ! empty($user->rights->propal->lire))
{
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showpropalnb)
{
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';

$showpointvalue = 1; $nocolor = 0;
$stats_proposal = new PropaleStats($this->db, $socid, ($userid>0?$userid:0));
$data2 = $stats_proposal->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24)));
if (empty($data2))
if (empty($data2))
{
$showpointvalue = 0;
$nocolor = 1;
$data2=array(array(0=>$langs->trans("None"),1=>1));
}

$filenamenb = $dir."/prodserforpropal-".$year.".png";
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=proposalstats&file=prodserforpropal-'.$year.'.png';

Expand All @@ -215,10 +215,10 @@ function loadBox($max=5)
$legend[]=$data2[$i][0];
$i++;
}

$px2->SetData($data2);
unset($data2);

if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
$px2->SetPrecisionY(0);
$px2->SetLegend($legend);
Expand Down Expand Up @@ -248,18 +248,18 @@ function loadBox($max=5)
if ($showordernb)
{
include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';

$showpointvalue = 1; $nocolor = 0;
$mode='customer';
$stats_order = new CommandeStats($this->db, $socid, $mode, ($userid>0?$userid:0));
$data3 = $stats_order->getAllByProductEntry($year,(GETPOST('action')==$refreshaction?-1:(3600*24)));
if (empty($data3))
if (empty($data3))
{
$showpointvalue = 0;
$nocolor = 1;
$data3=array(array(0=>$langs->trans("None"),1=>1));
}

$filenamenb = $dir."/prodserfororder-".$year.".png";
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=prodserfororder-'.$year.'.png';

Expand All @@ -274,10 +274,10 @@ function loadBox($max=5)
$legend[]=$data3[$i][0];
$i++;
}

$px3->SetData($data3);
unset($data3);

if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
$px3->SetPrecisionY(0);
$px3->SetLegend($legend);
Expand All @@ -299,7 +299,7 @@ function loadBox($max=5)
}
}
}

if (! $mesg)
{
$stringtoshow='';
Expand All @@ -314,17 +314,17 @@ function loadBox($max=5)
$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire))
if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire))
{
$stringtoshow.='<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb?' checked="true"':'').'> '.$langs->trans("ForCustomersInvoices");
$stringtoshow.=' &nbsp; ';
}
if (! empty($conf->propal->enabled) || ! empty($user->rights->propal->lire))
if (! empty($conf->propal->enabled) || ! empty($user->rights->propal->lire))
{
$stringtoshow.='<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb?' checked="true"':'').'> '.$langs->trans("ForProposals");
$stringtoshow.='&nbsp;';
}
if (! empty($conf->commande->enabled) || ! empty($user->rights->commande->lire))
if (! empty($conf->commande->enabled) || ! empty($user->rights->commande->lire))
{
$stringtoshow.='<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb?' checked="true"':'').'> '.$langs->trans("ForCustomersOrders");
}
Expand Down

0 comments on commit f50ad96

Please sign in to comment.