Fix on filter on project list

This commit is contained in:
Laurent Destailleur 2017-07-31 04:52:27 +02:00
parent 800aa4d5b6
commit 2f68d446ef
3 changed files with 45 additions and 36 deletions

View File

@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
$search_project_user = GETPOST('search_project_user','int');
$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0;
if ($search_project_user == $user->id) $mine = 1;
// Security check
$socid=0;
@ -98,7 +100,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
{
$listofsearchfields['search_task']=array('text'=>'Task');
}
if (count($listofsearchfields))
{
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
@ -114,7 +116,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
print '</tr>';
$i++;
}
print '</table>';
print '</table>';
print '</form>';
print '<br>';
}
@ -148,7 +150,7 @@ if ( $resql )
while ($row = $db->fetch_object($resql))
{
print '<tr class="oddeven">';
print '<td>';
$projectstatic->id=$row->rowid;
@ -205,7 +207,7 @@ if ( $resql )
while ($row = $db->fetch_object($resql))
{
print '<tr class="oddeven">';
print '<td>';
$projectstatic->id=$row->rowid;
@ -237,14 +239,14 @@ print "</table>";
if ($db->type != 'pgsql')
{
print '<br>';
// Affichage de la liste des projets de la semaine
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
@ -256,16 +258,16 @@ if ($db->type != 'pgsql')
$sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ...";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
$resql = $db->query($sql);
if ( $resql )
{
$total = 0;
$var=true;
while ($row = $db->fetch_object($resql))
{
print '<tr class="oddeven">';
print '<td>';
$projectstatic->id=$row->rowid;
@ -278,7 +280,7 @@ if ($db->type != 'pgsql')
print "</tr>\n";
$total += $row->nb;
}
$db->free($resql);
}
else
@ -302,7 +304,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH))
print '<td>'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now,"%B %Y").'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
@ -314,12 +316,12 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH))
$sql.= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public";
$resql = $db->query($sql);
if ( $resql )
{
$var=false;
while ($row = $db->fetch_object($resql))
{
print '<tr class="oddeven">';
@ -331,7 +333,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH))
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
}
$db->free($resql);
}
@ -383,7 +385,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
}
$db->free($resql);
}
@ -430,12 +432,12 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
}
else dol_print_error($db);
if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found
// Tasks for all resources of all opened projects and time spent for each task/resource
// This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
// Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list
$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
$sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,";
@ -489,7 +491,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
while ($i < $num && $i < $max)
{
$obj = $db->fetch_object($resql);
$username='';
if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user
@ -509,7 +511,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
$projectstatic->public = $obj->public;
$projectstatic->dateo = $db->jdate($obj->projdateo);
$projectstatic->datee = $db->jdate($obj->projdatee);
print $projectstatic->getNomUrl(1,'',0,'','<br>');
print '</td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
@ -536,7 +538,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
$taskstatic->datee = $db->jdate($obj->datee);
print '<td align="center">'.dol_print_date($db->jdate($obj->dateo),'day').'</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->datee),'day');
print dol_print_date($obj->date_end,'dayhour');
print dol_print_date($obj->date_end,'dayhour');
if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
print '</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';

View File

@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->load("projects");
$langs->load("companies");
$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0;
$search_project_user = GETPOST('search_project_user','int');
$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0;
if ($search_project_user == $user->id) $mine = 1;
// Security check
$socid=0;
@ -122,7 +123,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
{
$listofsearchfields['search_project']=array('text'=>'Project');
}
if (count($listofsearchfields))
{
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
@ -138,7 +139,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
print '</tr>';
$i++;
}
print '</table>';
print '</table>';
print '</form>';
print '<br>';
}
@ -185,7 +186,7 @@ if ( $resql )
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap">';
if ($obj->socid)
@ -217,9 +218,9 @@ if (! empty($conf->global->PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA))
{
// This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
// Add constant PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA to show this list
print '<br>';
print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array());
}

View File

@ -261,8 +261,8 @@ if ($search_project_user > 0)
}
$sql.= " WHERE p.entity IN (".getEntity('project').')';
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
// No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
if ($socid > 0) $sql.= " AND (p.fk_soc = ".$socid.")";
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
@ -487,19 +487,25 @@ print '<tr class="liste_titre_filter">';
if (! empty($arrayfields['p.ref']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="6">';
print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">';
print '</td>';
}
if (! empty($arrayfields['p.title']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_label" size="8" value="'.$search_label.'">';
print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">';
print '</td>';
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_societe" size="8" value="'.$search_societe.'">';
if ($socid > 0)
{
$tmpthirdparty=new Societe($db);
$tmpthirdparty->fetch($socid);
$search_societe=$tmpthirdparty->nom;
}
print '<input type="text" class="flat" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
print '</td>';
}
// Sale representative
@ -511,8 +517,8 @@ if (! empty($arrayfields['commercial']['checked']))
if (! empty($arrayfields['p.dateo']['checked']))
{
print '<td class="liste_titre center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="'.$search_sday.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="'.$search_smonth.'">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">';
$formother->select_year($search_syear?$search_syear:-1,'search_syear',1, 20, 5);
print '</td>';
}
@ -520,8 +526,8 @@ if (! empty($arrayfields['p.dateo']['checked']))
if (! empty($arrayfields['p.datee']['checked']))
{
print '<td class="liste_titre center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="'.$search_eday.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="'.$search_emonth.'">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">';
$formother->select_year($search_eyear?$search_eyear:-1,'search_eyear',1, 20, 5);
print '</td>';
}