NEW Add status into filters of graph
This commit is contained in:
parent
8eb4a208ce
commit
c28ff6c257
@ -58,8 +58,8 @@ $search_montant_ht=GETPOST('search_montant_ht','alpha');
|
|||||||
$search_author=GETPOST('search_author','alpha');
|
$search_author=GETPOST('search_author','alpha');
|
||||||
$search_product_category=GETPOST('search_product_category','int');
|
$search_product_category=GETPOST('search_product_category','int');
|
||||||
$search_town=GETPOST('search_town','alpha');
|
$search_town=GETPOST('search_town','alpha');
|
||||||
$viewstatut=$db->escape(GETPOST('viewstatut'));
|
$viewstatut=GETPOST('viewstatut');
|
||||||
$object_statut=$db->escape(GETPOST('propal_statut'));
|
$object_statut=GETPOST('propal_statut');
|
||||||
|
|
||||||
$sall=GETPOST("sall");
|
$sall=GETPOST("sall");
|
||||||
$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
|
$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -28,10 +28,13 @@
|
|||||||
require '../../../main.inc.php';
|
require '../../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
|
||||||
|
|
||||||
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
|
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
|
||||||
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
|
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
|
||||||
|
|
||||||
|
$object_statut=GETPOST('propal_statut');
|
||||||
|
|
||||||
$userid=GETPOST('userid','int');
|
$userid=GETPOST('userid','int');
|
||||||
$socid=GETPOST('socid','int');
|
$socid=GETPOST('socid','int');
|
||||||
// Security check
|
// Security check
|
||||||
@ -55,11 +58,12 @@ $mode=GETPOST('mode');
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
|
$formpropal=new FormPropal($db);
|
||||||
|
|
||||||
$langs->load('propal');
|
$langs->load('propal');
|
||||||
$langs->load('other');
|
$langs->load('other');
|
||||||
|
|
||||||
llxHeader();
|
llxHeader('', $langs->trans("ProposalsStatistics"));
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("ProposalsStatistics"),'','title_commercial.png');
|
print_fiche_titre($langs->trans("ProposalsStatistics"),'','title_commercial.png');
|
||||||
|
|
||||||
@ -67,7 +71,9 @@ $dir=$conf->propal->dir_temp;
|
|||||||
|
|
||||||
dol_mkdir($dir);
|
dol_mkdir($dir);
|
||||||
|
|
||||||
|
|
||||||
$stats = new PropaleStats($db, $socid, ($userid>0?$userid:0));
|
$stats = new PropaleStats($db, $socid, ($userid>0?$userid:0));
|
||||||
|
if ($object_statut != '' && $object_statut >= 0) $stats->where .= ' AND p.fk_statut IN ('.$object_statut.')';
|
||||||
|
|
||||||
// Build graphic number of object
|
// Build graphic number of object
|
||||||
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
||||||
@ -113,7 +119,7 @@ if (! $mesg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build graphic amount of object
|
// Build graphic amount of object
|
||||||
$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
|
$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,0);
|
||||||
// $data = array(array('Lib',val1,val2,val3),...)
|
// $data = array(array('Lib',val1,val2,val3),...)
|
||||||
|
|
||||||
if (!$user->rights->societe->client->voir || $user->societe_id)
|
if (!$user->rights->societe->client->voir || $user->societe_id)
|
||||||
@ -154,7 +160,7 @@ if (! $mesg)
|
|||||||
$px2->draw($filenameamount,$fileurlamount);
|
$px2->draw($filenameamount,$fileurlamount);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
|
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear, $filter);
|
||||||
|
|
||||||
$fileurl_avg='';
|
$fileurl_avg='';
|
||||||
if (!$user->rights->societe->client->voir || $user->societe_id)
|
if (!$user->rights->societe->client->voir || $user->societe_id)
|
||||||
@ -239,6 +245,10 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
|||||||
print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
|
print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
|
||||||
print $form->select_dolusers($userid,'userid',1);
|
print $form->select_dolusers($userid,'userid',1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
// Status
|
||||||
|
print '<tr><td align="left">'.$langs->trans("Status").'</td><td align="left">';
|
||||||
|
$formpropal->selectProposalStatus($object_statut,0,1);
|
||||||
|
print '</td></tr>';
|
||||||
// Year
|
// Year
|
||||||
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
|
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
|
||||||
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
|
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
|
||||||
|
|||||||
@ -45,11 +45,13 @@ class FormPropal
|
|||||||
* Return combo list of differents status of a proposal
|
* Return combo list of differents status of a proposal
|
||||||
* Values are id of table c_propalst
|
* Values are id of table c_propalst
|
||||||
*
|
*
|
||||||
* @param string $selected Preselected value
|
* @param string $selected Preselected value
|
||||||
* @param int $short Use short labels
|
* @param int $short Use short labels
|
||||||
|
* @param int $excludedraft 0=All status, 1=Exclude draft status
|
||||||
|
* @param int $showempty 1=Add empty line
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function selectProposalStatus($selected='',$short=0)
|
function selectProposalStatus($selected='',$short=0, $excludedraft=0, $showempty=1)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ class FormPropal
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
print '<select class="flat" name="propal_statut">';
|
print '<select class="flat" name="propal_statut">';
|
||||||
print '<option value=""> </option>';
|
if ($showempty) print '<option value=""> </option>';
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if ($num)
|
if ($num)
|
||||||
@ -69,6 +71,14 @@ class FormPropal
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
if ($excludedraft)
|
||||||
|
{
|
||||||
|
if ($obj->code == 'Draft' || $obj->code == 'PR_DRAFT')
|
||||||
|
{
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($selected == $obj->id)
|
if ($selected == $obj->id)
|
||||||
{
|
{
|
||||||
print '<option value="'.$obj->id.'" selected>';
|
print '<option value="'.$obj->id.'" selected>';
|
||||||
@ -83,7 +93,7 @@ class FormPropal
|
|||||||
print $langs->trans("PropalStatus".$key.($short?'Short':''));
|
print $langs->trans("PropalStatus".$key.($short?'Short':''));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Opened','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed');
|
$conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Opened','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed');
|
||||||
if (! empty($conv_to_new_code[$obj->code])) $key=$conv_to_new_code[$obj->code];
|
if (! empty($conv_to_new_code[$obj->code])) $key=$conv_to_new_code[$obj->code];
|
||||||
print ($langs->trans("PropalStatus".$key.($short?'Short':''))!="PropalStatus".$key.($short?'Short':''))?$langs->trans("PropalStatus".$key.($short?'Short':'')):$obj->label;
|
print ($langs->trans("PropalStatus".$key.($short?'Short':''))!="PropalStatus".$key.($short?'Short':''))?$langs->trans("PropalStatus".$key.($short?'Short':'')):$obj->label;
|
||||||
|
|||||||
@ -125,7 +125,10 @@ abstract class Stats
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return amount of elements by month for several years
|
* Return amount of elements by month for several years.
|
||||||
|
* Criterias used to build request are defined into the constructor of parent class into xxx/class/xxxstats.class.php
|
||||||
|
* The caller of class can add more filters into sql request by adding criteris into the $stats->where property just after
|
||||||
|
* calling constructor.
|
||||||
*
|
*
|
||||||
* @param int $endyear Start year
|
* @param int $endyear Start year
|
||||||
* @param int $startyear End year
|
* @param int $startyear End year
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user