23 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
31 var $boxcode=
"invoicespermonth";
32 var $boximg=
"object_bill";
33 var $boxlabel=
"BoxCustomersInvoicesPerMonth";
34 var $depends = array(
"facture");
41 var $info_box_head = array();
42 var $info_box_contents = array();
57 $this->hidden = ! ($user->rights->facture->lire);
68 global $conf, $user, $langs, $db;
72 $refreshaction=
'refresh_'.$this->boxcode;
77 $text = $langs->trans(
"BoxCustomersInvoicesPerMonth",$max);
78 $this->info_box_head = array(
83 'subtext'=>$langs->trans(
"Filter"),
84 'subpicto'=>
'filter.png',
85 'subclass'=>
'linkobject boxfilter',
92 if ($user->societe_id) $socid=$user->societe_id;
93 if (! $user->rights->societe->client->voir || $socid) $prefix.=
'private-'.$user->id.
'-';
95 if ($user->rights->facture->lire)
99 $param_year=
'DOLUSERCOOKIE_box_'.$this->boxcode.
'_year';
100 $param_shownb=
'DOLUSERCOOKIE_box_'.$this->boxcode.
'_shownb';
101 $param_showtot=
'DOLUSERCOOKIE_box_'.$this->boxcode.
'_showtot';
103 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
104 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facturestats.class.php';
105 $autosetarray=preg_split(
"/[,;:]+/",
GETPOST(
'DOL_AUTOSET_COOKIE'));
106 if (in_array(
'DOLUSERCOOKIE_box_'.$this->boxcode,$autosetarray))
108 $endyear=
GETPOST($param_year,
'int');
109 $shownb=
GETPOST($param_shownb,
'alpha');
110 $showtot=
GETPOST($param_showtot,
'alpha');
114 $tmparray=json_decode($_COOKIE[
'DOLUSERCOOKIE_box_'.$this->boxcode],
true);
115 $endyear=$tmparray[
'year'];
116 $shownb=$tmparray[
'shownb'];
117 $showtot=$tmparray[
'showtot'];
119 if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; }
121 if (empty($endyear)) $endyear=$nowarray[
'year'];
122 $startyear=$endyear-1;
124 $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?
'256':
'320';
132 $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (
GETPOST(
'action',
'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
134 $filenamenb = $dir.
"/".$prefix.
"invoicesnbinyear-".$endyear.
".png";
135 if ($mode ==
'customer') $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$endyear.
'.png';
136 if ($mode ==
'supplier') $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$endyear.
'.png';
139 $mesg = $px1->isGraphKo();
142 $langs->load(
"bills");
144 $px1->SetData($data1);
146 $px1->SetPrecisionY(0);
147 $i=$startyear;$legend=array();
148 while ($i <= $endyear)
153 $px1->SetLegend($legend);
154 $px1->SetMaxValue($px1->GetCeilMaxValue());
155 $px1->SetWidth($WIDTH);
156 $px1->SetHeight($HEIGHT);
157 $px1->SetYLabel($langs->trans(
"NumberOfBills"));
159 $px1->SetHorizTickIncrement(1);
160 $px1->SetPrecisionY(0);
161 $px1->SetCssPrefix(
"cssboxes");
163 $px1->SetTitle($langs->trans(
"NumberOfBillsByMonth"));
165 $px1->draw($filenamenb,$fileurlnb);
172 $data2 = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,(
GETPOST(
'action',
'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
174 $filenamenb = $dir.
"/".$prefix.
"invoicesamountinyear-".$endyear.
".png";
175 if ($mode ==
'customer') $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.
'.png';
176 if ($mode ==
'supplier') $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$endyear.
'.png';
179 $mesg = $px2->isGraphKo();
182 $langs->load(
"bills");
184 $px2->SetData($data2);
186 $px2->SetPrecisionY(0);
187 $i=$startyear;$legend=array();
188 while ($i <= $endyear)
193 $px2->SetLegend($legend);
194 $px2->SetMaxValue($px2->GetCeilMaxValue());
195 $px2->SetWidth($WIDTH);
196 $px2->SetHeight($HEIGHT);
197 $px2->SetYLabel($langs->trans(
"AmountOfBillsHT"));
199 $px2->SetHorizTickIncrement(1);
200 $px2->SetPrecisionY(0);
201 $px2->SetCssPrefix(
"cssboxes");
203 $px2->SetTitle($langs->trans(
"AmountOfBillsByMonthHT"));
205 $px2->draw($filenamenb,$fileurlnb);
209 if (empty($conf->use_javascript_ajax))
211 $langs->load(
"errors");
212 $mesg=$langs->trans(
"WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
218 $stringtoshow.=
'<script type="text/javascript" language="javascript"> 219 jQuery(document).ready(function() { 220 jQuery("#idsubimg'.$this->boxcode.
'").click(function() { 221 jQuery("#idfilter'.$this->boxcode.
'").toggle(); 225 $stringtoshow.=
'<div class="center hideobject" id="idfilter'.$this->boxcode.
'">';
226 $stringtoshow.=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
227 $stringtoshow.=
'<input type="hidden" name="action" value="'.$refreshaction.
'">';
228 $stringtoshow.=
'<input type="hidden" name="page_y" value="">';
229 $stringtoshow.=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.
':year,shownb,showtot">';
230 $stringtoshow.=
'<input type="checkbox" name="'.$param_shownb.
'"'.($shownb?
' checked':
'').
'> '.$langs->trans(
"NumberOfBillsByMonth");
231 $stringtoshow.=
' ';
232 $stringtoshow.=
'<input type="checkbox" name="'.$param_showtot.
'"'.($showtot?
' checked':
'').
'> '.$langs->trans(
"AmountOfBillsByMonthHT");
233 $stringtoshow.=
'<br>';
234 $stringtoshow.=$langs->trans(
"Year").
' <input class="flat" size="4" type="text" name="'.$param_year.
'" value="'.$endyear.
'">';
235 $stringtoshow.=
'<input class="reposition inline-block valigntextbottom" type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'',
'',1).
'">';
236 $stringtoshow.=
'</form>';
237 $stringtoshow.=
'</div>';
238 if ($shownb && $showtot)
240 $stringtoshow.=
'<div class="fichecenter">';
241 $stringtoshow.=
'<div class="fichehalfleft">';
243 if ($shownb) $stringtoshow.=$px1->show();
244 if ($shownb && $showtot)
246 $stringtoshow.=
'</div>';
247 $stringtoshow.=
'<div class="fichehalfright">';
249 if ($showtot) $stringtoshow.=$px2->show();
250 if ($shownb && $showtot)
252 $stringtoshow.=
'</div>';
253 $stringtoshow.=
'</div>';
255 $this->info_box_contents[0][0] = array(
'tr'=>
'class="oddeven nohover"',
'td' =>
'align="center" class="nohover"',
'textnoformat'=>$stringtoshow);
259 $this->info_box_contents[0][0] = array(
'tr'=>
'class="oddeven nohover"',
'td' =>
'align="left" class="nohover"',
'maxlength'=>500,
'text' => $mesg);
263 $this->info_box_contents[0][0] = array(
264 'td' =>
'align="left" class="nohover opacitymedium"',
265 'text' => $langs->trans(
"ReadPermissionNotAllowed")
278 function showBox($head = null, $contents = null, $nooutput=0)
280 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
loadBox($max=5)
Load data into info_box_contents array to show array later.
Class to manage the box to show last invoices.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
dol_now($mode='gmt')
Return date for now.
__construct($db, $param)
Constructor.
dol_getdate($timestamp, $fast=false)
Return an array with locale date info.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
Class to manage stats for invoices (customer and supplier)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.