Clean project pages to work like other modules

This commit is contained in:
Laurent Destailleur 2016-01-18 16:43:15 +01:00
parent 8e882b4cc2
commit 0f456c46ab
7 changed files with 99 additions and 97 deletions

View File

@ -348,6 +348,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->public=$lines[$i]->public;
$projectstatic->title=$lines[$i]->projectlabel;
if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1);
else print $projectstatic->getNomUrl(1,'nolink');
//if ($showlineingray) print '</i>';

View File

@ -31,6 +31,7 @@ AllProjects=All projects
OpenedProjects=Opened projects
OpenedTasks=Opened tasks
OpportunitiesStatusForOpenedProjects=Opportunities amount of opened projects by status
OpportunitiesStatusForProjects=Opportunities amount of projects by status
ProjectsList=List of projects
ShowProject=Show project
SetProject=Set project

View File

@ -48,6 +48,7 @@ $langs->load("projects");
$now = dol_now();
$projectstatic=new Project($db);
$taskstatic=new Task($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project
$tasktmp=new Task($db);
@ -94,6 +95,7 @@ if (count($listofsearchfields))
print '<br>';
}
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/* Affichage de la liste des projets d'aujourd'hui */
print '<table class="noborder" width="100%">';
@ -150,7 +152,6 @@ print "</table>";
// TODO Do not use date_add function to be compatible with all database
if ($db->type != 'pgsql')
{
/* Affichage de la liste des projets d'hier */
print '<br><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
@ -207,61 +208,60 @@ if ($db->type != 'pgsql')
// TODO Do not use week function to be compatible with all database
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, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
$sql.= " , ".MAIN_DB_PREFIX."projet_task_time as tt";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND tt.fk_task = t.rowid";
$sql.= " AND tt.fk_user = ".$user->id;
$sql.= " AND week(task_date) = '".strftime("%W",time())."'";
$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))
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>';
$projectstatic->id=$row->rowid;
$projectstatic->ref=$row->ref;
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print "</tr>\n";
$total += $row->nb;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print "</tr>\n";
print "</table><br>";
{
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, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
$sql.= " , ".MAIN_DB_PREFIX."projet_task_time as tt";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND tt.fk_task = t.rowid";
$sql.= " AND tt.fk_user = ".$user->id;
$sql.= " AND week(task_date) = '".strftime("%W",time())."'";
$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))
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>';
$projectstatic->id=$row->rowid;
$projectstatic->ref=$row->ref;
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print "</tr>\n";
$total += $row->nb;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print "</tr>\n";
print "</table><br>";
}
/* Affichage de la liste des projets du mois */
@ -364,18 +364,16 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
print "</table>";
}
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
if (empty($conf->global->PROJECT_HIDE_TASKS))
if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA))
{
// 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, t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
$sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.dateo as projdateo, p.datee as projdatee,";
$sql.= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
@ -409,9 +407,9 @@ if (empty($conf->global->PROJECT_HIDE_TASKS))
print '<th align="center">'.$langs->trans('DateStart').'</th>';
print '<th align="center">'.$langs->trans('DateEnd').'</th>';
print '<th align="right">'.$langs->trans('PlannedWorkload').'</th>';
print '<th align="right">'.$langs->trans("ProgressDeclared").'</td>';
print '<th align="right">'.$langs->trans('TimeSpent').'</th>';
print '<th align="right">'.$langs->trans("ProgressCalculated").'</td>';
print '<th align="right">'.$langs->trans("ProgressDeclared").'</td>';
print '</tr>';
while ($i < $num && $i < $max)
@ -433,8 +431,11 @@ if (empty($conf->global->PROJECT_HIDE_TASKS))
$projectstatic->id=$obj->projectid;
$projectstatic->ref=$obj->ref;
$projectstatic->title=$obj->title;
print $projectstatic->getNomUrl(1,'',16,'','<br>');
//print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$obj->projectid.'">'.$obj->title.'</a>';
$projectstatic->statut = $obj->status;
$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))
{
@ -453,14 +454,19 @@ if (empty($conf->global->PROJECT_HIDE_TASKS))
}
else print $langs->trans("NoTasks");
print '</td>';
$taskstatic->projectstatus = $obj->projectstatus;
$taskstatic->progress = $obj->progress;
$taskstatic->fk_statut = $obj->status;
$taskstatic->dateo = $db->jdate($obj->dateo);
$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').'</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->datee),'day');
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">';
print convertSecondToTime($obj->planned_workload, 'all');
print '</a></td>';
print '<td align="right">';
print ($obj->taskid>0)?$obj->progress.'%':'';
print '</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
print convertSecondToTime($obj->timespent, 'all');
print '</a></td>';
@ -475,6 +481,9 @@ if (empty($conf->global->PROJECT_HIDE_TASKS))
}
print $percentcompletion;
print '</td>';
print '<td align="right">';
print ($obj->taskid>0)?$obj->progress.'%':'';
print '</td>';
print "</tr>\n";
$i++;

View File

@ -57,7 +57,8 @@ class ProjectStats extends Stats
$sql .= " SUM(t.opp_amount), t.fk_opp_status, cls.code, cls.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t, ".MAIN_DB_PREFIX."c_lead_status as cls";
$sql .= $this->buildWhere();
$sql .= " AND t.fk_opp_status = cls.rowid AND t.fk_statut = 1";
$sql .= " AND t.fk_opp_status = cls.rowid";
$sql .= " AND t.fk_statut <> 0"; // We want historic also, so all projects
$sql .= " GROUP BY t.fk_opp_status, cls.code, cls.label";
$result = array ();

View File

@ -193,13 +193,15 @@ else
}
print "</table>";
print '<br>';
print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array());
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());
}
print '</div></div></div>';

View File

@ -121,15 +121,15 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
$px->setShowPointValue($showpointvalue);
$px->setShowPercent(1);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetWidth(300);
$px->SetHeight(300);
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetCssPrefix("cssboxes");
$px->SetType(array (
'pie'
));
$px->SetTitle($langs->trans('OpportunitiesStatusForOpenedProjects'));
$px->SetTitle($langs->trans('OpportunitiesStatusForProjects'));
$result=$px->draw($filenamenb, $fileurlnb);
if ($result<0) {
setEventMessages($px->error, null, 'errors');
@ -304,11 +304,11 @@ print '<br><br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre" height="24">';
print '<td align="center">'.$langs->trans("Year").'</td>';
print '<td align="center">'.$langs->trans("NbOfProjects").'</td>';
print '<td align="right">'.$langs->trans("NbOfProjects").'</td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">'.$langs->trans("AmountAverage").'</td>';
print '<td align="right">'.$langs->trans("OpportunityAmount").'</td>';
print '<td align="right">'.$langs->trans("AmountAverage").'</td>';
}
print '</tr>';

View File

@ -234,18 +234,6 @@ print "</table>";
print '</form>';
print '</div>';
/*
* Actions
*/
if ($user->rights->projet->creer)
{
print '<div class="tabsAction">';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/tasks.php?action=create">'.$langs->trans('AddTask').'</a>';
print '</div>';
}
llxFooter();