68 global $conf, $user, $langs;
72 $refreshaction =
'refresh_'.$this->boxcode;
77 $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
82 $text = $langs->trans(
"Turnover", $max);
83 $this->info_box_head = array(
88 'subtext'=>$langs->trans(
"Filter"),
89 'subpicto'=>
'filter.png',
90 'subclass'=>
'linkobject boxfilter',
98 $socid = $user->socid;
100 if (!$user->hasRight(
'societe',
'client',
'voir') || $socid) {
101 $prefix .=
'private-'.$user->id.
'-';
104 if ($user->hasRight(
'facture',
'lire')) {
107 $param_year =
'DOLUSERCOOKIE_box_'.$this->boxcode.
'_year';
108 $param_showtot =
'DOLUSERCOOKIE_box_'.$this->boxcode.
'_showtot';
110 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
111 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facturestats.class.php';
112 $autosetarray = preg_split(
"/[,;:]+/",
GETPOST(
'DOL_AUTOSET_COOKIE'));
113 if (in_array(
'DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) {
114 $endyear =
GETPOST($param_year,
'int');
115 $showtot =
GETPOST($param_showtot,
'alpha');
117 $tmparray = json_decode($_COOKIE[
'DOLUSERCOOKIE_box_'.$this->boxcode],
true);
118 $endyear = $tmparray[
'year'];
119 $showtot = $tmparray[
'showtot'];
121 if (empty($showtot)) {
125 if (empty($endyear)) {
126 $endyear = $nowarray[
'year'];
128 $numberyears = (!
getDolGlobalString(
'MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH') ? 5 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
129 $startyear = $endyear - $numberyears;
132 $WIDTH = (($showtot) || !empty($conf->dol_optimize_smallscreen)) ?
'256' :
'320';
138 $data2 = $stats->getAmountByYear($numberyears);
140 $filenamenb = $dir.
"/".$prefix.
"invoicesamountyears-".$endyear.
".png";
142 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstats&file=invoicesamountyears-'.$endyear.
'.png';
143 if ($mode ==
'supplier') {
144 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountyears-'.$endyear.
'.png';
148 $mesg = $px2->isGraphKo();
150 $langs->load(
"bills");
152 $px2->SetData($data2);
164 $px2->SetLegend([$langs->trans(
"AmountOfBillsHT")]);
165 $px2->SetMaxValue($px2->GetCeilMaxValue());
166 $px2->SetWidth($WIDTH);
167 $px2->SetHeight($HEIGHT);
168 $px2->SetYLabel($langs->trans(
"AmountOfBillsHT"));
170 $px2->SetHorizTickIncrement(1);
171 $px2->SetCssPrefix(
"cssboxes");
172 $px2->mode =
'depth';
173 $px2->SetTitle($langs->trans(
"Turnover"));
175 $px2->draw($filenamenb, $fileurlnb);
178 if (empty($conf->use_javascript_ajax)) {
179 $langs->load(
"errors");
180 $mesg = $langs->trans(
"WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
185 $stringtoshow .=
'<script nonce="'.getNonce().
'" type="text/javascript" language="javascript">
186 jQuery(document).ready(function() {
187 jQuery("#idsubimg'.$this->boxcode.
'").click(function() {
188 jQuery("#idfilter'.$this->boxcode.
'").toggle();
192 $stringtoshow .=
'<div class="center hideobject" id="idfilter'.$this->boxcode.
'">';
193 $stringtoshow .=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
194 $stringtoshow .=
'<input type="hidden" name="token" value="'.newToken().
'">';
195 $stringtoshow .=
'<input type="hidden" name="action" value="'.$refreshaction.
'">';
196 $stringtoshow .=
'<input type="hidden" name="page_y" value="">';
197 $stringtoshow .=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.
':year,showtot">';
198 $stringtoshow .= $langs->trans(
"Year").
' <input class="flat" size="4" type="text" name="'.$param_year.
'" value="'.$endyear.
'">';
199 $stringtoshow .=
'<input class="reposition inline-block valigntextbottom" type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'',
'', 1).
'">';
200 $stringtoshow .=
'</form>';
201 $stringtoshow .=
'</div>';
202 $stringtoshow .= $px2->show();
203 $this->info_box_contents[0][0] = array(
'tr'=>
'class="oddeven nohover"',
'td' =>
'class="nohover center"',
'textnoformat'=>$stringtoshow);
205 $this->info_box_contents[0][0] = array(
'tr'=>
'class="oddeven nohover"',
'td' =>
'class="nohover left"',
'maxlength'=>500,
'text' => $mesg);
208 $this->info_box_contents[0][0] = array(
209 'td' =>
'class="nohover left"',
210 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'