--- /tmp/dsg/dolibarr/htdocs/reception/stats/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/reception/stats/client_index.php @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -38,4 +37,11 @@ - -$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear; -$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); +// Security check +if ($user->socid > 0) +{ + $action = ''; + $socid = $user->socid; +} + +$nowyear = strftime("%Y", dol_now()); +$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; +//$startyear=$year-2; +$startyear = $year - 1; @@ -44,7 +50,4 @@ -$langs->loadLangs(array("receptions", "other", "companies")); - -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'reception', 0, ''); +$langs->load("reception"); +$langs->load("other"); +$langs->load("companies"); + @@ -63 +66 @@ -$dir = (!empty($conf->reception->multidir_temp[$conf->entity]) ? $conf->reception->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]); + @@ -74,4 +77,7 @@ -if (!$user->hasRight('societe', 'client', 'voir') || $user->socid) { - $filenamenb = $dir.'/receptionsnbinyear-'.$user->id.'-'.$year.'.png'; -} else { - $filenamenb = $dir.'/receptionsnbinyear-'.$year.'.png'; +if (!$user->rights->societe->client->voir || $user->socid) +{ + $filenamenb = $dir.'/receptionsnbinyear-'.$user->id.'-'.$year.'.png'; +} +else +{ + $filenamenb = $dir.'/receptionsnbinyear-'.$year.'.png'; @@ -82,21 +88,21 @@ -$fileurlnb = ''; -if (!$mesg) { - $px1->SetData($data); - $i = $startyear; - $legend = array(); - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px1->SetLegend($legend); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); - $px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfReceptions")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfReceptionsByMonth")); - - $px1->draw($filenamenb, $fileurlnb); +if (!$mesg) +{ + $px1->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("NbOfReceptions")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NumberOfReceptionsByMonth")); + + $px1->draw($filenamenb, $fileurlnb); @@ -111,3 +117,3 @@ -if (empty($user->rights->societe->client->voir) || $user->socid) -{ - $filenameamount = $dir.'/receptionsamountinyear-'.$user->id.'-'.$year.'.png'; +if (!$user->rights->societe->client->voir || $user->socid) +{ + $filenameamount = $dir.'/receptionsamountinyear-'.$user->id.'-'.$year.'.png'; @@ -117 +123 @@ - $filenameamount = $dir.'/receptionsamountinyear-'.$year.'.png'; + $filenameamount = $dir.'/receptionsamountinyear-'.$year.'.png'; @@ -124,19 +130,19 @@ - $px2->SetData($data); - $i=$startyear;$legend=array(); - while ($i <= $endyear) - { - $legend[]=$i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0,$px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfReceptions")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode='depth'; - $px2->SetTitle($langs->trans("AmountOfReceptionsByMonthHT")); - - $px2->draw($filenameamount,$fileurlamount); + $px2->SetData($data); + $i=$startyear;$legend=array(); + while ($i <= $endyear) + { + $legend[]=$i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0,$px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfReceptions")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode='depth'; + $px2->SetTitle($langs->trans("AmountOfReceptionsByMonthHT")); + + $px2->draw($filenameamount,$fileurlamount); @@ -149,3 +155,3 @@ -if (empty($user->rights->societe->client->voir) || $user->socid) -{ - $filename_avg = $dir.'/receptionsaverage-'.$user->id.'-'.$year.'.png'; +if (!$user->rights->societe->client->voir || $user->socid) +{ + $filename_avg = $dir.'/receptionsaverage-'.$user->id.'-'.$year.'.png'; @@ -155 +161 @@ - $filename_avg = $dir.'/receptionsaverage-'.$year.'.png'; + $filename_avg = $dir.'/receptionsaverage-'.$year.'.png'; @@ -162,19 +168,19 @@ - $px3->SetData($data); - $i=$startyear;$legend=array(); - while ($i <= $endyear) - { - $legend[]=$i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode='depth'; - $px3->SetTitle($langs->trans("AmountAverage")); - - $px3->draw($filename_avg,$fileurl_avg); + $px3->SetData($data); + $i=$startyear;$legend=array(); + while ($i <= $endyear) + { + $legend[]=$i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode='depth'; + $px3->SetTitle($langs->trans("AmountAverage")); + + $px3->draw($filename_avg,$fileurl_avg); @@ -193,3 +199 @@ -if (!count($arrayyears)) { - $arrayyears[$nowyear] = $nowyear; -} +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -208 +212 @@ -print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); +dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); @@ -214,31 +218,28 @@ -// Show filter box -print '
'; -print ''; - -print ''; -print ''; -// Company -print ''; -// User -print ''; -// Year -print ''; -print ''; -print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; -print img_picto('', 'company', 'class="pictofixedwidth"'); -print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth300', ''); -print '
'.$langs->trans("CreatedBy").''; -print img_picto('', 'user', 'class="pictofixedwidth"'); -print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); -print '
'.$langs->trans("Year").''; -if (!in_array($year, $arrayyears)) { - $arrayyears[$year] = $year; -} -if (!in_array($nowyear, $arrayyears)) { - $arrayyears[$nowyear] = $nowyear; -} -arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); -print '
'; -print '
'; -print '

'; +//if (empty($socid)) +//{ + // Show filter box + print '
'; + print ''; + + print ''; + print ''; + // Company + print ''; + // User + print ''; + // Year + print ''; + print ''; + print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; + print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, '', 'style="width: 95%"'); + print '
'.$langs->trans("CreatedBy").''; + print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print '
'.$langs->trans("Year").''; + if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; + if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; + arsort($arrayyears); + print $form->selectarray('year', $arrayyears, $year, 0); + print '
'; + print '
'; + print '

'; +//} @@ -255 +256,2 @@ -foreach ($data as $val) { +foreach ($data as $val) +{ @@ -257 +259,2 @@ - while (!empty($year) && $oldyear > $year + 1) { // If we have empty year + while (!empty($year) && $oldyear > $year + 1) + { // If we have empty year @@ -272,5 +275,2 @@ - if ($year) { - print ''.$year.''; - } else { - print $langs->trans("ValidationDateNotDefinedEvenIfReceptionValidated"); - } + if ($year) print ''.$year.''; + else print $langs->trans("ValidationDateNotDefinedEvenIfReceptionValidated"); @@ -288 +288 @@ -print '
'; +print '
'; @@ -293,8 +293,7 @@ -if ($mesg) { - print $mesg; -} else { - print $px1->show(); - print "
\n"; - /*print $px2->show(); - print "
\n"; - print $px3->show();*/ +if ($mesg) { print $mesg; } +else { + print $px1->show(); + print "
\n"; + /*print $px2->show(); + print "
\n"; + print $px3->show();*/ @@ -305,4 +304,4 @@ -print '
'; -print '
'; - -print dol_get_fiche_end(); +print ''; +print '
'; + +dol_fiche_end(); @@ -327,11 +326,11 @@ - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); - $nbproduct = $row[0]; - $year = $row[1]; - print ""; - print ''.$year.''.$nbproduct.''; - $i++; - } + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $nbproduct = $row[0]; + $year = $row[1]; + print ""; + print ''.$year.''.$nbproduct.''; + $i++; + } --- /tmp/dsg/dolibarr/htdocs/reception/stats/github_19.0.3_month.php +++ /tmp/dsg/dolibarr/htdocs/reception/stats/client_month.php @@ -25 +24,0 @@ -// Load Dolibarr environment @@ -30,10 +28,0 @@ - -$year = GETPOST("year", 'int'); -$socid = GETPOST("socid", 'int'); -$userid = GETPOST("userid", 'int'); - -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'reception', 0, ''); @@ -53,3 +42,4 @@ -print load_fiche_titre($langs->trans("StatisticsOfReceptions").' '.GETPOST("year", 'int'), $mesg); -$stats = new ReceptionStats($db, $socid, '', ($userid > 0 ? $userid : 0)); -$data = $stats->getNbByMonth($year); +print load_fiche_titre($langs->trans("StatisticsOfReceptions").' '.$_GET["year"], $mesg); + +$stats = new ReceptionStats($db); +$data = $stats->getNbReceptionByMonth($_GET["year"]); @@ -64,7 +54,8 @@ -if (!$mesg) { - $px->SetData($data); - $px->SetMaxValue($px->GetCeilMaxValue()); - $px->SetWidth($WIDTH); - $px->SetHeight($HEIGHT); - $px->SetYLabel($langs->trans("NbOfOrders")); - $px->SetShading(3); +if (!$mesg) +{ + $px->SetData($data); + $px->SetMaxValue($px->GetCeilMaxValue()); + $px->SetWidth($WIDTH); + $px->SetHeight($HEIGHT); + $px->SetYLabel($langs->trans("NbOfOrders")); + $px->SetShading(3); @@ -72 +63 @@ - $px->draw($filename, $fileurl); + $px->draw($filename, $fileurl);