27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/don/class/donstats.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
35 $userid =
GETPOST(
'userid',
'int');
36 $socid =
GETPOST(
'socid',
'int');
38 if ($user->socid > 0) {
40 $socid = $user->socid;
43 $nowyear = strftime(
"%Y",
dol_now());
45 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
49 $langs->loadLangs(array(
"companies",
"other",
"sendings"));
65 $stats =
new DonationStats($db, $socid,
'', ($userid > 0 ? $userid : 0));
68 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
73 if (empty($user->rights->societe->client->voir) || $user->socid) {
74 $filenamenb = $dir.
'/shipmentsnbinyear-'.$user->id.
'-'.$year.
'.png';
76 $filenamenb = $dir.
'/shipmentsnbinyear-'.$year.
'.png';
80 $mesg = $px1->isGraphKo();
83 $i = $startyear; $legend = array();
84 while ($i <= $endyear) {
88 $px1->SetLegend($legend);
89 $px1->SetMaxValue($px1->GetCeilMaxValue());
90 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
91 $px1->SetWidth($WIDTH);
92 $px1->SetHeight($HEIGHT);
93 $px1->SetYLabel($langs->trans(
"NbOfSendings"));
95 $px1->SetHorizTickIncrement(1);
97 $px1->SetTitle($langs->trans(
"NumberOfShipmentsByMonth"));
99 $px1->draw($filenamenb, $fileurlnb);
183 $data = $stats->getAllByYear();
184 $arrayyears = array();
185 foreach ($data as $val) {
186 if (!empty($val[
'year'])) {
187 $arrayyears[$val[
'year']] = $val[
'year'];
190 if (!count($arrayyears)) {
191 $arrayyears[$nowyear] = $nowyear;
196 $head[$h][0] = DOL_URL_ROOT.
'/don/stats/index.php';
197 $head[$h][1] = $langs->trans(
"ByMonthYear");
198 $head[$h][2] =
'byyear';
201 $type =
'donation_stats';
208 print
'<div class="fichecenter"><div class="fichethirdleft">';
212 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
213 print
'<input type="hidden" name="token" value="'.newToken().
'">';
215 print
'<table class="border centpercent">';
216 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
218 print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
219 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
220 print
$form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
223 print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
224 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
225 print
$form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
228 print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
229 if (!in_array($year, $arrayyears)) {
230 $arrayyears[$year] = $year;
232 if (!in_array($nowyear, $arrayyears)) {
233 $arrayyears[$nowyear] = $nowyear;
236 print
$form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
238 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
243 print
'<div class="div-table-responsive-no-min">';
244 print
'<table class="border centpercent">';
245 print
'<tr height="24">';
246 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
247 print
'<td class="center">'.$langs->trans(
"NbOfSendings").
'</td>';
253 foreach ($data as $val) {
254 $year = $val[
'year'];
255 while (!empty($year) && $oldyear > $year + 1) {
257 print
'<tr height="24">';
258 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
260 print
'<td class="right">0</td>';
266 print
'<tr height="24">';
267 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a></td>';
268 print
'<td class="right">'.$val[
'nb'].
'</td>';
279 print
'</div><div class="fichetwothirdright">';
283 print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
293 print
'</td></tr></table>';
296 print
'</div></div>';
297 print
'<div style="clear:both"></div>';
336 print
'<i>'.$langs->trans(
"StatsOnShipmentsOnlyValidated").
'</i>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_mkdir($dir, $dataroot= '', $newmask= '')
Creation of a directory (this can create recursive subdir)
dol_now($mode= 'auto')
Return date for now.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
Class to manage donations statistics.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
static getDefaultGraphSizeForStats($direction, $defaultsize= '')
getDefaultGraphSizeForStats
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).