diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 55b82d1063c..d900709b835 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -259,52 +259,50 @@ dol_fiche_head($head,'byyear',$langs->trans("Statistics")); print '
| 0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$oldyear.' | '; - print '0 | '; print ''; print ' | 0 | '; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index e4a37cb5f62..574fde69c2a 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -489,7 +489,7 @@ class ExpenseReport extends CommonObject * Returns the label of a statut * * @param int $status id statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ function LibStatut($status,$mode=0) @@ -514,6 +514,8 @@ class ExpenseReport extends CommonObject if ($mode == 5) return ''.$langs->transnoentities($this->statuts_short[$status]).' '.img_picto($langs->transnoentities($this->statuts_short[$status]),$this->statuts_logo[$status]); + if ($mode == 6) + return $langs->transnoentities($this->statuts[$status]).' '.img_picto($langs->transnoentities($this->statuts_short[$status]),$this->statuts_logo[$status]); } diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 25ead4de0c1..d68483cb32b 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -59,9 +59,9 @@ class ExpenseReportStats extends Stats $this->from = MAIN_DB_PREFIX.$object->table_element." as e"; $this->field='total_ht'; - $this->where = " e.fk_statut > 0"; + //$this->where = " e.fk_statut > 0"; //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have. - $this->where.= ' AND e.entity IN ('.getEntity('expensereport', 1).')'; + $this->where.= ' e.entity IN ('.getEntity('expensereport', 1).')'; //$this->where.= " AND entity = ".$conf->entity; if ($this->socid) @@ -88,7 +88,7 @@ class ExpenseReportStats extends Stats */ function getNbByYear() { - $sql = "SELECT YEAR(date_valid) as dm, count(*)"; + $sql = "SELECT YEAR(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; $sql.= " GROUP BY dm DESC"; $sql.= " WHERE ".$this->where; @@ -105,7 +105,7 @@ class ExpenseReportStats extends Stats */ function getNbByMonth($year) { - $sql = "SELECT MONTH(e.date_valid) as dm, count(*)"; + $sql = "SELECT MONTH(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; $sql.= " WHERE YEAR(e.date_valid) = ".$year; $sql.= " AND ".$this->where; @@ -126,9 +126,9 @@ class ExpenseReportStats extends Stats */ function getAmountByMonth($year) { - $sql = "SELECT date_format(e.date_valid,'%m') as dm, sum(".$this->field.")"; + $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'"; + $sql.= " WHERE date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -146,9 +146,9 @@ class ExpenseReportStats extends Stats */ function getAverageByMonth($year) { - $sql = "SELECT date_format(e.date_valid,'%m') as dm, avg(".$this->field.")"; + $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'"; + $sql.= " WHERE date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -163,7 +163,7 @@ class ExpenseReportStats extends Stats */ function getAllByYear() { - $sql = "SELECT date_format(e.date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql.= " FROM ".$this->from; $sql.= " WHERE ".$this->where; $sql.= " GROUP BY year"; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index b92405424c6..c81996fda3b 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -33,6 +33,9 @@ $langs->load("companies"); $WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); +$mode=GETPOST("mode")?GETPOST("mode"):'customer'; +$object_status=GETPOST('object_status'); + $userid=GETPOST('userid','int'); $socid=GETPOST('socid','int'); if ($socid < 0) $socid=0; $id = GETPOST('id','int'); @@ -52,7 +55,6 @@ $year = GETPOST('year')>0?GETPOST('year'):$nowyear; $startyear=$year-1; $endyear=$year; -$mode=GETPOST("mode")?GETPOST("mode"):'customer'; /* @@ -60,18 +62,19 @@ $mode=GETPOST("mode")?GETPOST("mode"):'customer'; */ $form=new Form($db); - -llxHeader(); +$tmpexpensereport=new ExpenseReport($db); $title=$langs->trans("TripsAndExpensesStatistics"); $dir=$conf->expensereport->dir_temp; +llxHeader('', $title); + print load_fiche_titre($title, $mesg); dol_mkdir($dir); $stats = new ExpenseReportStats($db, $socid, $userid); - +if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND e.fk_statut IN ('.$object_status.')'; // Build graphic number of object // $data = array(array('Lib',val1,val2,val3),...) @@ -227,6 +230,11 @@ $include=''; if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $include='hierarchy'; print $form->select_dolusers($userid, 'userid', 1, '', 0, $include, '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '
| '.$langs->trans("Status").' | '; +$liststatus=$tmpexpensereport->statuts; +print $form->selectarray('object_status', $liststatus, GETPOST('object_status'), -4, 0, 0, '', 1); +print ' | ||
| '.$langs->trans("Year").' | '; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; @@ -247,20 +255,24 @@ print ' | '.$langs->trans("AmountAverage").' | '; print '|
| '.$oldyear.' | '; print '0 | '; print '0 | '; print '0 | '; print '
| '.$year.' | '; print ''.$val['nb'].' | '; print ''.price(price2num($val['total'],'MT'),1).' | '; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index cd0c3fc1598..414bcf709f4 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -221,6 +221,8 @@ else } print '|
| '; $userstatic->id=$users['rowid']; $userstatic->lastname=$users['lastname']; @@ -232,6 +234,7 @@ else print $userstatic->getNomUrl(-1); print ' | '; + // Amount for each type if (count($typeleaves)) { foreach($typeleaves as $key => $val) @@ -249,8 +252,10 @@ else { print ''; } + + // Note print ' | '; - if ($canedit) print ''; + if ($canedit) print ''; print ' | '; print ''; if (! empty($user->rights->holiday->define_holiday)) |