61 global $conf, $user, $langs;
65 $refreshaction =
'refresh_'.$this->boxcode;
75 $text = $langs->trans(
"Turnover", $max);
76 $this->info_box_head = array(
81 'subtext' => $langs->trans(
"Filter"),
82 'subpicto' =>
'filter.png',
83 'subclass' =>
'linkobject boxfilter',
91 $socid = $user->socid;
93 if (!$user->hasRight(
'societe',
'client',
'voir')) {
94 $prefix .=
'private-'.$user->id.
'-';
97 if ($user->hasRight(
'facture',
'lire')) {
100 $param_year =
'DOLUSER_box_'.$this->boxcode.
'_year';
101 $param_showtot =
'DOLUSER_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(
'DOLUSER_box_'.$this->boxcode, $autosetarray)) {
108 $showtot =
GETPOST($param_showtot,
'alpha');
110 $tmparray = json_decode($_COOKIE[
'DOLUSER_box_'.$this->boxcode],
true);
111 $endyear = $tmparray[
'year'];
112 $showtot = $tmparray[
'showtot'];
114 if (empty($showtot)) {
118 if (empty($endyear)) {
119 $endyear = $nowarray[
'year'];
122 $startyear = $endyear - $numberyears;
125 $WIDTH = (($showtot) || !empty($conf->dol_optimize_smallscreen)) ?
'256' :
'320';
129 $stats->where =
"f.fk_statut > 0";
132 $data2 = $stats->getAmountByYear($numberyears);
134 $filenamenb = $dir.
"/".$prefix.
"invoicesamountyears-".$endyear.
".png";
136 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstats&file=invoicesamountyears-'.$endyear.
'.png';
137 if ($mode ==
'supplier') {
138 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountyears-'.$endyear.
'.png';
142 $mesg = $px2->isGraphKo();
144 $langs->load(
"bills");
146 $px2->SetData($data2);
158 $px2->SetLegend([$langs->trans(
"AmountOfBillsHT")]);
159 $px2->SetMaxValue($px2->GetCeilMaxValue());
160 $px2->SetWidth($WIDTH);
161 $px2->SetHeight($HEIGHT);
162 $px2->SetYLabel($langs->trans(
"AmountOfBillsHT"));
164 $px2->SetHorizTickIncrement(1);
165 $px2->SetCssPrefix(
"cssboxes");
166 $px2->mode =
'depth';
167 $px2->SetTitle($langs->trans(
"Turnover"));
169 $px2->draw($filenamenb, $fileurlnb);
172 if (empty($conf->use_javascript_ajax)) {
173 $langs->load(
"errors");
174 $mesg = $langs->trans(
"WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
179 $stringtoshow .=
'<script nonce="'.getNonce().
'" type="text/javascript" language="javascript">
180 jQuery(document).ready(function() {
181 jQuery("#idsubimg'.$this->boxcode.
'").click(function() {
182 jQuery("#idfilter'.$this->boxcode.
'").toggle();
186 $stringtoshow .=
'<div class="center hideobject" id="idfilter'.$this->boxcode.
'">';
187 $stringtoshow .=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
188 $stringtoshow .=
'<input type="hidden" name="token" value="'.newToken().
'">';
189 $stringtoshow .=
'<input type="hidden" name="action" value="'.$refreshaction.
'">';
190 $stringtoshow .=
'<input type="hidden" name="page_y" value="">';
191 $stringtoshow .=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSER_box_'.$this->boxcode.
':year,showtot">';
192 $stringtoshow .= $langs->trans(
"Year").
' <input class="flat" size="4" type="text" name="'.$param_year.
'" value="'.$endyear.
'">';
193 $stringtoshow .=
'<input class="reposition inline-block valigntextbottom" type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'', 0, 1).
'">';
194 $stringtoshow .=
'</form>';
195 $stringtoshow .=
'</div>';
196 $stringtoshow .= $px2->show();
197 $this->info_box_contents[0][0] = array(
'tr' =>
'class="oddeven nohover"',
'td' =>
'class="nohover center"',
'textnoformat' => $stringtoshow);
199 $this->info_box_contents[0][0] = array(
'tr' =>
'class="oddeven nohover"',
'td' =>
'class="nohover left"',
'maxlength' => 500,
'text' => $mesg);
202 $this->info_box_contents[0][0] = array(
203 'td' =>
'class="nohover left"',
204 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'