60 global $conf, $user, $langs;
64 $refreshaction =
'refresh_'.$this->boxcode;
74 $text = $langs->trans(
"Turnover", $max);
75 $this->info_box_head = array(
80 'subtext'=>$langs->trans(
"Filter"),
81 'subpicto'=>
'filter.png',
82 'subclass'=>
'linkobject boxfilter',
90 $socid = $user->socid;
92 if (!$user->hasRight(
'societe',
'client',
'voir')) {
93 $prefix .=
'private-'.$user->id.
'-';
96 if ($user->hasRight(
'facture',
'lire')) {
99 $param_year =
'DOLUSERCOOKIE_box_'.$this->boxcode.
'_year';
100 $param_showtot =
'DOLUSERCOOKIE_box_'.$this->boxcode.
'_showtot';
102 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
103 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facturestats.class.php';
104 $autosetarray = preg_split(
"/[,;:]+/",
GETPOST(
'DOL_AUTOSET_COOKIE'));
105 if (in_array(
'DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) {
107 $showtot =
GETPOST($param_showtot,
'alpha');
109 $tmparray = json_decode($_COOKIE[
'DOLUSERCOOKIE_box_'.$this->boxcode],
true);
110 $endyear = $tmparray[
'year'];
111 $showtot = $tmparray[
'showtot'];
113 if (empty($showtot)) {
117 if (empty($endyear)) {
118 $endyear = $nowarray[
'year'];
121 $startyear = $endyear - $numberyears;
124 $WIDTH = (($showtot) || !empty($conf->dol_optimize_smallscreen)) ?
'256' :
'320';
130 $data2 = $stats->getAmountByYear($numberyears);
132 $filenamenb = $dir.
"/".$prefix.
"invoicesamountyears-".$endyear.
".png";
134 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstats&file=invoicesamountyears-'.$endyear.
'.png';
135 if ($mode ==
'supplier') {
136 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountyears-'.$endyear.
'.png';
140 $mesg = $px2->isGraphKo();
142 $langs->load(
"bills");
144 $px2->SetData($data2);
156 $px2->SetLegend([$langs->trans(
"AmountOfBillsHT")]);
157 $px2->SetMaxValue($px2->GetCeilMaxValue());
158 $px2->SetWidth($WIDTH);
159 $px2->SetHeight($HEIGHT);
160 $px2->SetYLabel($langs->trans(
"AmountOfBillsHT"));
162 $px2->SetHorizTickIncrement(1);
163 $px2->SetCssPrefix(
"cssboxes");
164 $px2->mode =
'depth';
165 $px2->SetTitle($langs->trans(
"Turnover"));
167 $px2->draw($filenamenb, $fileurlnb);
170 if (empty($conf->use_javascript_ajax)) {
171 $langs->load(
"errors");
172 $mesg = $langs->trans(
"WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
177 $stringtoshow .=
'<script nonce="'.getNonce().
'" type="text/javascript" language="javascript">
178 jQuery(document).ready(function() {
179 jQuery("#idsubimg'.$this->boxcode.
'").click(function() {
180 jQuery("#idfilter'.$this->boxcode.
'").toggle();
184 $stringtoshow .=
'<div class="center hideobject" id="idfilter'.$this->boxcode.
'">';
185 $stringtoshow .=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
186 $stringtoshow .=
'<input type="hidden" name="token" value="'.newToken().
'">';
187 $stringtoshow .=
'<input type="hidden" name="action" value="'.$refreshaction.
'">';
188 $stringtoshow .=
'<input type="hidden" name="page_y" value="">';
189 $stringtoshow .=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.
':year,showtot">';
190 $stringtoshow .= $langs->trans(
"Year").
' <input class="flat" size="4" type="text" name="'.$param_year.
'" value="'.$endyear.
'">';
191 $stringtoshow .=
'<input class="reposition inline-block valigntextbottom" type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'',
'', 1).
'">';
192 $stringtoshow .=
'</form>';
193 $stringtoshow .=
'</div>';
194 $stringtoshow .= $px2->show();
195 $this->info_box_contents[0][0] = array(
'tr'=>
'class="oddeven nohover"',
'td' =>
'class="nohover center"',
'textnoformat'=>$stringtoshow);
197 $this->info_box_contents[0][0] = array(
'tr'=>
'class="oddeven nohover"',
'td' =>
'class="nohover left"',
'maxlength'=>500,
'text' => $mesg);
200 $this->info_box_contents[0][0] = array(
201 'td' =>
'class="nohover left"',
202 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'