Finish work "Can filter on status on objects on the "statistics" pages"

This commit is contained in:
Laurent Destailleur 2016-12-16 01:26:01 +01:00
parent 5c6ecf9aeb
commit c9ce955505
2 changed files with 12 additions and 3 deletions

View File

@ -61,6 +61,7 @@ class FichinterStats extends Stats
$this->userid = $userid;
$this->cachefilesuffix = $mode;
$this->where.= " c.entity = ".$conf->entity;
if ($mode == 'customer')
{
$object=new Fichinter($this->db);
@ -68,10 +69,8 @@ class FichinterStats extends Stats
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
$this->field='0';
$this->field_line='0';
$this->where.= " c.fk_statut > 0"; // Not draft and not cancelled
//$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled
}
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
$this->where.= " AND c.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($this->socid)
{

View File

@ -47,6 +47,8 @@ $year = GETPOST('year')>0?GETPOST('year'):$nowyear;
$startyear=$year-1;
$endyear=$year;
$object_status=GETPOST('object_status');
$langs->load('interventions');
$langs->load('companies');
$langs->load('other');
@ -58,6 +60,7 @@ $langs->load('suppliers');
*/
$form=new Form($db);
$objectstatic=new FichInter($db);
if ($mode == 'customer')
{
@ -72,6 +75,7 @@ print load_fiche_titre($title,'','title_commercial.png');
dol_mkdir($dir);
$stats = new FichinterStats($db, $socid, $mode, ($userid>0?$userid:0));
if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_statut IN ('.$object_status.')';
// Build graphic number of object
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
@ -249,6 +253,12 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
// User
print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
// Status
print '<tr><td align="left">'.$langs->trans("Status").'</td><td align="left">';
$liststatus=$objectstatic->statuts_short;
if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
print $form->selectarray('object_status', $liststatus, $object_status, 1, 0, 0, '', 1);
print '</td></tr>';
// Year
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;