Fix filter on opportunity status
This commit is contained in:
parent
278e90cf0a
commit
3a32b08512
@ -521,7 +521,7 @@ class FormProjets
|
||||
* @param int $useshortlabel Use short label
|
||||
* @return int|string The HTML select list of element or '' if nothing or -1 if KO
|
||||
*/
|
||||
function selectOpportunityStatus($htmlname,$preselected=0,$showempty=1,$useshortlabel=0)
|
||||
function selectOpportunityStatus($htmlname,$preselected=0,$showempty=1,$useshortlabel=0,$showallnone=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@ -530,8 +530,6 @@ class FormProjets
|
||||
$sql.= " WHERE active = 1";
|
||||
$sql.= " ORDER BY position";
|
||||
|
||||
dol_syslog(get_class($this).'::selectOpportunityStatus', LOG_DEBUG);
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -541,6 +539,8 @@ class FormProjets
|
||||
{
|
||||
$sellist = '<select class="flat oppstatus" name="'.$htmlname.'">';
|
||||
if ($showempty) $sellist.= '<option value="-1"></option>';
|
||||
if ($showallnone) $sellist.= '<option value="all">--'.$langs->trans("Alls").'--</option>';
|
||||
if ($showallnone) $sellist.= '<option value="none">--'.$langs->trans("None").'--</option>';
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
@ -108,6 +108,7 @@ Yes=Yes
|
||||
no=no
|
||||
No=No
|
||||
All=All
|
||||
Alls=All
|
||||
Home=Home
|
||||
Help=Help
|
||||
OnlineHelp=Online help
|
||||
|
||||
@ -69,7 +69,7 @@ $search_societe=GETPOST("search_societe");
|
||||
$search_year=GETPOST("search_year");
|
||||
$search_all=GETPOST("search_all");
|
||||
$search_status=GETPOST("search_status",'int');
|
||||
$search_opp_status=GETPOST("search_opp_status",'int');
|
||||
$search_opp_status=GETPOST("search_opp_status",'alpha');
|
||||
$search_public=GETPOST("search_public",'int');
|
||||
$search_user=GETPOST('search_user','int');
|
||||
$search_sale=GETPOST('search_sale','int');
|
||||
@ -126,7 +126,7 @@ llxHeader("",$langs->trans("Projects"),"EN:Module_Projects|FR:Module_Projets|ES:
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:($user->rights->projet->all->lire?2:0)),1,$socid);
|
||||
|
||||
$sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat";
|
||||
$sql.= ", p.datec as date_create, p.dateo as date_start, p.datee as date_end";
|
||||
$sql.= ", p.datec as date_create, p.dateo as date_start, p.datee as date_end, p.opp_amount";
|
||||
$sql.= ", s.nom as name, s.rowid as socid";
|
||||
$sql.= ", cls.code as opp_status_code";
|
||||
// Add fields for extrafields
|
||||
@ -183,7 +183,12 @@ else if ($year > 0)
|
||||
}
|
||||
if ($search_all) $sql .= natural_search(array('p.ref','p.title','s.nom'), $search_all);
|
||||
if ($search_status >= 0) $sql .= " AND p.fk_statut = ".$db->escape($search_status);
|
||||
if ($search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status);
|
||||
if ($search_opp_status)
|
||||
{
|
||||
if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status);
|
||||
if ($search_opp_status == 'all') $sql .= " AND p.fk_opp_status IS NOT NULL";
|
||||
if ($search_opp_status == 'none') $sql .= " AND p.fk_opp_status IS NULL";
|
||||
}
|
||||
if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public);
|
||||
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
|
||||
if ($search_user > 0) $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='project' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user;
|
||||
@ -214,7 +219,7 @@ if ($resql)
|
||||
if ($search_label != '') $param.='&search_label='.$search_label;
|
||||
if ($search_societe != '') $param.='&search_societe='.$search_societe;
|
||||
if ($search_status >= 0) $param.='&search_status='.$search_status;
|
||||
if ($search_opp_status >= 0) $param.='&search_opp_status='.$search_opp_status;
|
||||
if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','none'))) $param.='&search_opp_status='.urlencode($search_opp_status);
|
||||
if ($search_public != '') $param.='&search_public='.$search_public;
|
||||
if ($search_user > 0) $param.='&search_user='.$search_user;
|
||||
if ($search_sale > 0) $param.='&search_sale='.$search_sale;
|
||||
@ -280,8 +285,8 @@ if ($resql)
|
||||
print_liste_field_titre($langs->trans("Visibility"),$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder);
|
||||
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
|
||||
{
|
||||
print_liste_field_titre($langs->trans("OpportunityAmountShort"),$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("OpportunityStatusShort"),$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("OpportunityAmountShort"),$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("OpportunityStatusShort"),$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'align="center"',$sortfield,$sortorder);
|
||||
}
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
@ -331,8 +336,8 @@ if ($resql)
|
||||
{
|
||||
print '<td class="liste_titre nowrap">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre nowrap">';
|
||||
print $formproject->selectOpportunityStatus('search_opp_status',$search_opp_status,1,1);
|
||||
print '<td class="liste_titre nowrap center">';
|
||||
print $formproject->selectOpportunityStatus('search_opp_status',$search_opp_status,1,1,1);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -448,11 +453,11 @@ if ($resql)
|
||||
|
||||
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
|
||||
{
|
||||
print '<td>';
|
||||
if ($objp->opp_status_code) print $langs->trans("OppAmount".$objp->opp_amount);
|
||||
print '<td align="right">';
|
||||
if ($objp->opp_status_code) print price($objp->opp_amount, 1, '', 1, - 1, - 1, $conf->currency);
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print '<td align="middle">';
|
||||
if ($objp->opp_status_code) print $langs->trans("OppStatusShort".$objp->opp_status_code);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user