28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/don/class/donstats.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
36$userid =
GETPOST(
'userid',
'int');
37$socid =
GETPOST(
'socid',
'int');
39if ($user->socid > 0) {
41 $socid = $user->socid;
46$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
50$langs->loadLangs(array(
"companies",
"other",
"sendings"));
66$stats =
new DonationStats($db, $socid,
'', ($userid > 0 ? $userid : 0));
69$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
74if (empty($user->rights->societe->client->voir) || $user->socid) {
75 $filenamenb = $dir.
'/donationnbinyear-'.$user->id.
'-'.$year.
'.png';
77 $filenamenb = $dir.
'/donationnbinyear-'.$year.
'.png';
81$mesg = $px1->isGraphKo();
84 $i = $startyear; $legend = array();
85 while ($i <= $endyear) {
89 $px1->SetLegend($legend);
90 $px1->SetMaxValue($px1->GetCeilMaxValue());
91 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
92 $px1->SetWidth($WIDTH);
93 $px1->SetHeight($HEIGHT);
94 $px1->SetYLabel($langs->trans(
"NbOfDonations"));
96 $px1->SetHorizTickIncrement(1);
98 $px1->SetTitle($langs->trans(
"NumberOfDonationsByMonth"));
100 $px1->draw($filenamenb, $fileurlnb);
184$data = $stats->getAllByYear();
185$arrayyears = array();
186foreach ($data as $val) {
187 if (!empty($val[
'year'])) {
188 $arrayyears[$val[
'year']] = $val[
'year'];
191if (!count($arrayyears)) {
192 $arrayyears[$nowyear] = $nowyear;
197$head[$h][0] = DOL_URL_ROOT.
'/don/stats/index.php';
198$head[$h][1] = $langs->trans(
"ByMonthYear");
199$head[$h][2] =
'byyear';
202$type =
'donation_stats';
209print
'<div class="fichecenter"><div class="fichethirdleft">';
213print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
214print
'<input type="hidden" name="token" value="'.newToken().
'">';
216print
'<table class="border centpercent">';
217print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
219print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
220print
img_picto(
'',
'company',
'class="pictofixedwidth"');
221print $form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
224print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
225print
img_picto(
'',
'user',
'class="pictofixedwidth"');
226print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
229print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
230if (!in_array($year, $arrayyears)) {
231 $arrayyears[$year] = $year;
233if (!in_array($nowyear, $arrayyears)) {
234 $arrayyears[$nowyear] = $nowyear;
237print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
239print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
244print
'<div class="div-table-responsive-no-min">';
245print
'<table class="border centpercent">';
246print
'<tr height="24">';
247print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
248print
'<td class="right">'.$langs->trans(
"NbOfDonations").
'</td>';
254foreach ($data as $val) {
255 $year = $val[
'year'];
256 while (!empty($year) && $oldyear > $year + 1) {
258 print
'<tr height="24">';
259 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
261 print
'<td class="right">0</td>';
267 print
'<tr height="24">';
268 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a></td>';
269 print
'<td class="right">'.$val[
'nb'].
'</td>';
280print
'</div><div class="fichetwothirdright">';
284print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
294print
'</td></tr></table>';
298print
'<div class="clearboth"></div>';
337print
'<i>'.$langs->trans(
"StatsOnDonationsOnlyValidated").
'</i>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage donations statistics.
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='', $dragdropfile=0)
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)