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;
78 if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
80 $text = $langs->trans(
"Turnover", $max);
81 $this->info_box_head = array(
86 'subtext'=>$langs->trans(
"Filter"),
87 'subpicto'=>
'filter.png',
88 'subclass'=>
'linkobject boxfilter',
95 if ($user->socid) $socid = $user->socid;
96 if (empty($user->rights->societe->client->voir) || $socid) $prefix .=
'private-'.$user->id.
'-';
98 if ($user->hasRight(
'facture',
'lire')) {
101 $param_year =
'DOLUSERCOOKIE_box_'.$this->boxcode.
'_year';
102 $param_showtot =
'DOLUSERCOOKIE_box_'.$this->boxcode.
'_showtot';
104 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
105 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facturestats.class.php';
106 $autosetarray = preg_split(
"/[,;:]+/",
GETPOST(
'DOL_AUTOSET_COOKIE'));
107 if (in_array(
'DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) {
108 $endyear =
GETPOST($param_year,
'int');
109 $showtot =
GETPOST($param_showtot,
'alpha');
111 $tmparray = json_decode($_COOKIE[
'DOLUSERCOOKIE_box_'.$this->boxcode],
true);
112 $endyear = $tmparray[
'year'];
113 $showtot = $tmparray[
'showtot'];
115 if (empty($showtot)) { $showtot = 1; }
117 if (empty($endyear)) $endyear = $nowarray[
'year'];
118 $numberyears = (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 5 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
119 $startyear = $endyear - $numberyears;
122 $WIDTH = (($showtot) || !empty($conf->dol_optimize_smallscreen)) ?
'256' :
'320';
128 $data2 = $stats->getAmountByYear($numberyears);
130 $filenamenb = $dir.
"/".$prefix.
"invoicesamountyears-".$endyear.
".png";
132 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstats&file=invoicesamountyears-'.$endyear.
'.png';
133 if ($mode ==
'supplier') {
134 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountyears-'.$endyear.
'.png';
138 $mesg = $px2->isGraphKo();
140 $langs->load(
"bills");
142 $px2->SetData($data2);
154 $px2->SetLegend([$langs->trans(
"AmountOfBillsHT")]);
155 $px2->SetMaxValue($px2->GetCeilMaxValue());
156 $px2->SetWidth($WIDTH);
157 $px2->SetHeight($HEIGHT);
158 $px2->SetYLabel($langs->trans(
"AmountOfBillsHT"));
160 $px2->SetHorizTickIncrement(1);
161 $px2->SetCssPrefix(
"cssboxes");
162 $px2->mode =
'depth';
163 $px2->SetTitle($langs->trans(
"Turnover"));
165 $px2->draw($filenamenb, $fileurlnb);
168 if (empty($conf->use_javascript_ajax)) {
169 $langs->load(
"errors");
170 $mesg = $langs->trans(
"WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
175 $stringtoshow .=
'<script nonce="'.getNonce().
'" type="text/javascript" language="javascript">
176 jQuery(document).ready(function() {
177 jQuery("#idsubimg'.$this->boxcode.
'").click(function() {
178 jQuery("#idfilter'.$this->boxcode.
'").toggle();
182 $stringtoshow .=
'<div class="center hideobject" id="idfilter'.$this->boxcode.
'">';
183 $stringtoshow .=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
184 $stringtoshow .=
'<input type="hidden" name="token" value="'.newToken().
'">';
185 $stringtoshow .=
'<input type="hidden" name="action" value="'.$refreshaction.
'">';
186 $stringtoshow .=
'<input type="hidden" name="page_y" value="">';
187 $stringtoshow .=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.
':year,showtot">';
188 $stringtoshow .= $langs->trans(
"Year").
' <input class="flat" size="4" type="text" name="'.$param_year.
'" value="'.$endyear.
'">';
189 $stringtoshow .=
'<input class="reposition inline-block valigntextbottom" type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'',
'', 1).
'">';
190 $stringtoshow .=
'</form>';
191 $stringtoshow .=
'</div>';
192 $stringtoshow .= $px2->show();
193 $this->info_box_contents[0][0] = array(
'tr'=>
'class="oddeven nohover"',
'td' =>
'class="nohover center"',
'textnoformat'=>$stringtoshow);
195 $this->info_box_contents[0][0] = array(
'tr'=>
'class="oddeven nohover"',
'td' =>
'class="nohover left"',
'maxlength'=>500,
'text' => $mesg);
198 $this->info_box_contents[0][0] = array(
199 'td' =>
'class="nohover left"',
200 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'