Fix: var init at wrong place

This commit is contained in:
Laurent Destailleur 2014-01-25 23:14:25 +01:00
parent 7149fd76c7
commit f50ad96beb

View File

@ -103,9 +103,9 @@ class box_graph_product_distribution extends ModeleBoxes
$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'];
@ -114,30 +114,30 @@ class box_graph_product_distribution extends ModeleBoxes
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;
@ -157,10 +157,10 @@ class box_graph_product_distribution extends ModeleBoxes
$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);
@ -178,29 +178,29 @@ class box_graph_product_distribution extends ModeleBoxes
//$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';
@ -215,10 +215,10 @@ class box_graph_product_distribution extends ModeleBoxes
$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);
@ -248,18 +248,18 @@ class box_graph_product_distribution extends ModeleBoxes
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';
@ -274,10 +274,10 @@ class box_graph_product_distribution extends ModeleBoxes
$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);
@ -299,7 +299,7 @@ class box_graph_product_distribution extends ModeleBoxes
}
}
}
if (! $mesg)
{
$stringtoshow='';
@ -314,17 +314,17 @@ class box_graph_product_distribution extends ModeleBoxes
$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");
}