27require 
'../../main.inc.php';
 
   28require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
 
   29require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expeditionstats.class.php';
 
   30require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
 
   35$userid = 
GETPOST(
'userid', 
'int');
 
   36$socid = 
GETPOST(
'socid', 
'int');
 
   38if ($user->socid > 0) {
 
   40  $socid = $user->socid;
 
   49$langs->loadLangs(array(
'sendings', 
'other', 
'companies'));
 
   53  $socid = $user->socid;
 
   68$dir = (!empty($conf->expedition->multidir_temp[$conf->entity]) ? $conf->expedition->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]);
 
   71$stats = 
new ExpeditionStats($db, $socid, 
'', ($userid > 0 ? $userid : 0));
 
   74$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
 
   79if (!$user->hasRight(
'societe', 
'client', 
'voir') || $user->socid) {
 
   80  $filenamenb = $dir.
'/shipmentsnbinyear-'.$user->id.
'-'.$year.
'.png';
 
   82  $filenamenb = $dir.
'/shipmentsnbinyear-'.$year.
'.png';
 
   86$mesg = $px1->isGraphKo();
 
   92  while ($i <= $endyear) {
 
   96  $px1->SetLegend($legend);
 
   97  $px1->SetMaxValue($px1->GetCeilMaxValue());
 
   98  $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
 
   99  $px1->SetWidth($WIDTH);
 
  100  $px1->SetHeight($HEIGHT);
 
  101  $px1->SetYLabel($langs->trans(
"NbOfSendings"));
 
  103  $px1->SetHorizTickIncrement(1);
 
  104  $px1->mode = 
'depth';
 
  105  $px1->SetTitle($langs->trans(
"NumberOfShipmentsByMonth"));
 
  107  $px1->draw($filenamenb, $fileurlnb);
 
  191$data = $stats->getAllByYear();
 
  192$arrayyears = array();
 
  193foreach ($data as $val) {
 
  194  if (!empty($val[
'year'])) {
 
  195    $arrayyears[$val[
'year']] = $val[
'year'];
 
  198if (!count($arrayyears)) {
 
  199  $arrayyears[$nowyear] = $nowyear;
 
  204$head[$h][0] = DOL_URL_ROOT.
'/expedition/stats/index.php';
 
  205$head[$h][1] = $langs->trans(
"ByMonthYear");
 
  206$head[$h][2] = 
'byyear';
 
  209$type = 
'shipment_stats';
 
  216print 
'<div class="fichecenter"><div class="fichethirdleft">';
 
  220print 
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
 
  221print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  223print 
'<table class="noborder centpercent">';
 
  224print 
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
 
  226print 
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
 
  227print 
img_picto(
'', 
'company', 
'class="pictofixedwidth"');
 
  228print $form->select_company($socid, 
'socid', 
'', 1, 0, 0, array(), 0, 
'widthcentpercentminusx maxwidth300', 
'');
 
  231print 
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
 
  232print 
img_picto(
'', 
'user', 
'class="pictofixedwidth"');
 
  233print $form->select_dolusers($userid, 
'userid', 1, 
'', 0, 
'', 
'', 0, 0, 0, 
'', 0, 
'', 
'widthcentpercentminusx maxwidth300');
 
  236print 
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
 
  237if (!in_array($year, $arrayyears)) {
 
  238  $arrayyears[$year] = $year;
 
  240if (!in_array($nowyear, $arrayyears)) {
 
  241  $arrayyears[$nowyear] = $nowyear;
 
  244print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0, 
'', 0, 0, 0, 
'', 
'width75');
 
  246print 
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
 
  252print 
'<div class="div-table-responsive-no-min">';
 
  253print 
'<table class="noborder centpercent">';
 
  254print 
'<tr class="liste_titre" height="24">';
 
  255print 
'<td class="center">'.$langs->trans(
"Year").
'</td>';
 
  256print 
'<td class="right">'.$langs->trans(
"NbOfSendings").
'</td>';
 
  262foreach ($data as $val) {
 
  263  $year = $val[
'year'];
 
  264  while (!empty($year) && $oldyear > $year + 1) { 
 
  268    print 
'<tr class="oddeven" height="24">';
 
  269    print 
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
 
  271    print 
'<td class="right">0</td>';
 
  277  print 
'<tr class="oddeven" height="24">';
 
  278  print 
'<td class="center">';
 
  280    print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a>';
 
  283    print 
'Error: validation date of shipment is not defined. This looks strange because shipment is validated. Try to run /install/repair.php?standard=confirmed';
 
  286  print 
'<td class="right">'.$val[
'nb'].
'</td>';
 
  297print 
'</div><div class="fichetwothirdright">';
 
  301print 
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
 
  311print 
'</td></tr></table>';
 
  315print 
'<div class="clearboth"></div>';
 
  354print 
'<i class="opacitymedium">'.$langs->trans(
"StatsOnShipmentsOnlyValidated").
'</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 shipment 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).
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
 
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.