28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/reception/class/receptionstats.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
36 $userid =
GETPOST(
'userid',
'int');
37 $socid =
GETPOST(
'socid',
'int');
41 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
44 $langs->loadLangs(array(
"receptions",
"other",
"companies"));
48 $socid = $user->socid;
61 print
load_fiche_titre($langs->trans(
"StatisticsOfReceptions"),
'',
'dollyrevert');
63 $dir = (!empty($conf->reception->multidir_temp[$conf->entity]) ? $conf->reception->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]);
66 $stats =
new ReceptionStats($db, $socid,
'', ($userid > 0 ? $userid : 0));
69 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
74 if (empty($user->rights->societe->client->voir) || $user->socid) {
75 $filenamenb = $dir.
'/receptionsnbinyear-'.$user->id.
'-'.$year.
'.png';
77 $filenamenb = $dir.
'/receptionsnbinyear-'.$year.
'.png';
81 $mesg = $px1->isGraphKo();
85 $i = $startyear; $legend = array();
86 while ($i <= $endyear) {
90 $px1->SetLegend($legend);
91 $px1->SetMaxValue($px1->GetCeilMaxValue());
92 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
93 $px1->SetWidth($WIDTH);
94 $px1->SetHeight($HEIGHT);
95 $px1->SetYLabel($langs->trans(
"NbOfReceptions"));
97 $px1->SetHorizTickIncrement(1);
99 $px1->SetTitle($langs->trans(
"NumberOfReceptionsByMonth"));
101 $px1->draw($filenamenb, $fileurlnb);
185 $data = $stats->getAllByYear();
186 $arrayyears = array();
187 foreach ($data as $val) {
188 if (!empty($val[
'year'])) {
189 $arrayyears[$val[
'year']] = $val[
'year'];
192 if (!count($arrayyears)) {
193 $arrayyears[$nowyear] = $nowyear;
198 $head[$h][0] = DOL_URL_ROOT.
'/reception/stats/index.php';
199 $head[$h][1] = $langs->trans(
"ByMonthYear");
200 $head[$h][2] =
'byyear';
203 $type =
'reception_stats';
210 print
'<div class="fichecenter"><div class="fichethirdleft">';
214 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
215 print
'<input type="hidden" name="token" value="'.newToken().
'">';
217 print
'<table class="noborder centpercent">';
218 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
220 print
'<tr><td>'.$langs->trans(
"ThirdParty").
'</td><td>';
221 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
222 print
$form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
225 print
'<tr><td>'.$langs->trans(
"CreatedBy").
'</td><td>';
226 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
227 print
$form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
230 print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
231 if (!in_array($year, $arrayyears)) {
232 $arrayyears[$year] = $year;
234 if (!in_array($nowyear, $arrayyears)) {
235 $arrayyears[$nowyear] = $nowyear;
238 print
$form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
240 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
245 print
'<table class="noborder centpercent">';
246 print
'<tr class="liste_titre" height="24">';
247 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
248 print
'<td class="right">'.$langs->trans(
"NbOfReceptions").
'</td>';
254 foreach ($data as $val) {
255 $year = $val[
'year'];
256 while (!empty($year) && $oldyear > $year + 1) {
260 print
'<tr class="oddeven" height="24">';
261 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
263 print
'<td class="right">0</td>';
269 print
'<tr class="oddeven" height="24">';
270 print
'<td class="center">';
272 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a>';
274 print $langs->trans(
"ValidationDateNotDefinedEvenIfReceptionValidated");
277 print
'<td class="right">'.$val[
'nb'].
'</td>';
287 print
'</div><div class="fichetwothirdright">';
291 print
'<table class="border centpercent"><tr valign="top"><td class="center">';
301 print
'</td></tr></table>';
304 print
'</div></div>';
305 print
'<div style="clear:both"></div>';
344 print
'<i class="opacitymedium">'.$langs->trans(
"StatsOnReceptionsOnlyValidated").
'</i>';
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage reception statistics.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.