Fix restore of last_search_value ko

This commit is contained in:
Laurent Destailleur 2017-06-07 10:55:39 +02:00
parent 0486a18972
commit 0805c693ae
6 changed files with 242 additions and 237 deletions

View File

@ -36,7 +36,7 @@ class Task extends CommonObject
public $fk_element='fk_task';
public $picto = 'task';
protected $childtables=array('projet_task_time'); // To test if we can delete object
var $fk_task_parent;
var $label;
var $description;
@ -59,7 +59,7 @@ class Task extends CommonObject
var $timespent_nblinesnull;
var $timespent_nblines;
// For detail of lines of timespent record, there is the property ->lines in common
// Var used to call method addTimeSpent(). Bad practice.
var $timespent_id;
var $timespent_duration;
@ -100,7 +100,7 @@ class Task extends CommonObject
// Clean parameters
$this->label = trim($this->label);
$this->description = trim($this->description);
// Check parameters
// Put here code to add control on parameters values
@ -226,7 +226,7 @@ class Task extends CommonObject
if ($resql)
{
$num_rows = $this->db->num_rows($resql);
if ($num_rows)
{
$obj = $this->db->fetch_object($resql);
@ -409,7 +409,7 @@ class Task extends CommonObject
$this->db->rollback();
return 0;
}
if (! $error)
{
// Delete linked contacts
@ -534,7 +534,7 @@ class Task extends CommonObject
return -1;
}
}
/**
* Return nb of time spent
*
@ -579,14 +579,15 @@ class Task extends CommonObject
* @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string
* @param string $sep Separator between ref and label if option addlabel is set
* @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='',$mode='task', $addlabel=0, $sep=' - ', $notooltip=0)
function getNomUrl($withpicto=0,$option='',$mode='task', $addlabel=0, $sep=' - ', $notooltip=0, $save_lastsearch_value=-1)
{
global $conf, $langs, $user;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result='';
$label = '<u>' . $langs->trans("ShowTask") . '</u>';
if (! empty($this->ref))
@ -597,8 +598,12 @@ class Task extends CommonObject
{
$label .= "<br>".get_date_range($this->date_start,$this->date_end,'',$langs,0);
}
$url = DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option=='withproject'?'&withproject=1':'');
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
$linkclose = '';
if (empty($notooltip))
@ -611,11 +616,11 @@ class Task extends CommonObject
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
}
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
$picto='projecttask';
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
@ -706,7 +711,7 @@ class Task extends CommonObject
$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec2";
$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2";
}
else
else
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
}
@ -790,7 +795,7 @@ class Task extends CommonObject
$tasks[$i]->date_start = $this->db->jdate($obj->date_start);
$tasks[$i]->date_end = $this->db->jdate($obj->date_end);
$tasks[$i]->rang = $obj->rang;
$tasks[$i]->thirdparty_id = $obj->thirdparty_id;
$tasks[$i]->thirdparty_name = $obj->thirdparty_name;
}
@ -963,7 +968,7 @@ class Task extends CommonObject
$tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time");
$ret = $tasktime_id;
$this->timespent_id = $ret;
if (! $notrigger)
{
// Call trigger
@ -1027,10 +1032,10 @@ class Task extends CommonObject
global $langs;
$id=$this->id;
if (empty($id))
if (empty($id))
{
dol_syslog("getSummaryOfTimeSpent called on a not loaded task", LOG_ERR);
return -1;
return -1;
}
$result=array();
@ -1045,7 +1050,7 @@ class Task extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql.= " WHERE t.fk_task = ".$id;
if ($userid > 0) $sql.=" AND t.fk_user = ".$userid;
dol_syslog(get_class($this)."::getSummaryOfTimeSpent", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
@ -1055,14 +1060,14 @@ class Task extends CommonObject
$result['min_date'] = $obj->min_date; // deprecated. use the ->timespent_xxx instead
$result['max_date'] = $obj->max_date; // deprecated. use the ->timespent_xxx instead
$result['total_duration'] = $obj->total_duration; // deprecated. use the ->timespent_xxx instead
$this->timespent_min_date=$this->db->jdate($obj->min_date);
$this->timespent_max_date=$this->db->jdate($obj->max_date);
$this->timespent_total_duration=$obj->total_duration;
$this->timespent_total_amount=$obj->total_amount;
$this->timespent_nblinesnull=($obj->nblinesnull?$obj->nblinesnull:0);
$this->timespent_nblines=($obj->nblines?$obj->nblines:0);
$this->db->free($resql);
}
else
@ -1357,7 +1362,7 @@ class Task extends CommonObject
$clone_task->fetch($fromid);
$clone_task->fetch_optionals();
//var_dump($clone_task->array_options);exit;
$origin_task->fetch($fromid);
$defaultref='';
@ -1680,7 +1685,7 @@ class Task extends CommonObject
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@ -1690,12 +1695,12 @@ class Task extends CommonObject
function load_board($user)
{
global $conf, $langs;
$mine=0; $socid=$user->societe_id;
$projectstatic = new Project($this->db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
// List of tasks (does not care about permissions. Filtering will be done later)
$sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,";
$sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,";
@ -1718,29 +1723,29 @@ class Task extends CommonObject
if ($resql)
{
$task_static = new Task($this->db);
$response = new WorkboardResponse();
$response->warning_delay = $conf->projet->task->warning_delay/60/60/24;
$response->label = $langs->trans("OpenedTasks");
if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project';
else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&amp;mainmenu=project';
$response->img = img_object('',"task");
// This assignment in condition is not a bug. It allows walking the results.
while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;
$task_static->projectstatus = $obj->projectstatus;
$task_static->progress = $obj->progress;
$task_static->fk_statut = $obj->status;
$task_static->date_end = $this->db->jdate($obj->datee);
if ($task_static->hasDelay()) {
$response->nbtodolate++;
}
}
return $response;
}
else
@ -1749,7 +1754,7 @@ class Task extends CommonObject
return -1;
}
}
/**
* Is the task delayed?
*
@ -1758,7 +1763,7 @@ class Task extends CommonObject
public function hasDelay()
{
global $conf;
if (! ($this->progress >= 0 && $this->progress < 100)) {
return false;
}
@ -1768,5 +1773,5 @@ class Task extends CommonObject
$datetouse = ($this->date_end > 0) ? $this->date_end : ($this->datee > 0 ? $this->datee : 0);
return ($datetouse > 0 && ($datetouse < ($now - $conf->projet->task->warning_delay)));
}
}
}

View File

@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref))
if ($object->fetch($id, $ref) > 0)
{
$id = $object->id; // So when doing a search from ref, id is also set correctly.
$result=$projectstatic->fetch($object->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
@ -192,83 +192,83 @@ if ($id > 0 || ! empty($ref))
$param=($mode=='mine'?'&mode=mine':'');
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
// Thirdparty
if ($projectstatic->thirdparty->id > 0)
if ($projectstatic->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0);
$projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
@ -284,16 +284,16 @@ if ($id > 0 || ! empty($ref))
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
if (! GETPOST('withproject') || empty($projectstatic->id))
{
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1);
$object->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
$morehtmlref='';
// Project
if (empty($withproject))
{
@ -301,13 +301,13 @@ if ($id > 0 || ! empty($ref))
$morehtmlref.=$langs->trans("Project").': ';
$morehtmlref.=$projectstatic->getNomUrl(1);
$morehtmlref.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1);
dol_fiche_end();
@ -385,7 +385,7 @@ if ($id > 0 || ! empty($ref))
print '<input type="hidden" name="id" value="'.$object->id.'">';
if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">';
print '<tr class="oddeven">';
print '<td class="nowrap">';

View File

@ -136,84 +136,84 @@ if ($object->id > 0)
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
// Thirdparty
if ($projectstatic->thirdparty->id > 0)
if ($projectstatic->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0);
$projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
}
@ -227,7 +227,7 @@ if ($object->id > 0)
{
$totalsize+=$file['size'];
}
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
@ -237,9 +237,9 @@ if ($object->id > 0)
$object->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
$morehtmlref='';
// Project
if (empty($withproject))
{
@ -247,17 +247,17 @@ if ($object->id > 0)
$morehtmlref.=$langs->trans("Project").': ';
$morehtmlref.=$projectstatic->getNomUrl(1);
$morehtmlref.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -268,7 +268,7 @@ if ($object->id > 0)
print "</table>\n";
print '</div>';
dol_fiche_end();
print '<br>';

View File

@ -114,9 +114,9 @@ if ($object->id > 0)
$param=($mode=='mine'?'&mode=mine':'');
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
@ -126,92 +126,92 @@ if ($object->id > 0)
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0);
$projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
}
$head = task_prepare_head($object);
dol_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask');
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
if (! GETPOST('withproject') || empty($projectstatic->id))
{
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1);
$object->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
$morehtmlref='';
// Project
if (empty($withproject))
{
@ -219,17 +219,17 @@ if ($object->id > 0)
$morehtmlref.=$langs->trans("Project").': ';
$morehtmlref.=$projectstatic->getNomUrl(1);
$morehtmlref.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass='titlefield';
@ -237,7 +237,7 @@ if ($object->id > 0)
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
dol_fiche_end();
}

View File

@ -226,85 +226,85 @@ if ($id > 0 || ! empty($ref))
$param=($mode=='mine'?'&mode=mine':'');
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
// Thirdparty
if ($projectstatic->thirdparty->id > 0)
if ($projectstatic->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0);
$projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
print '<br>';
@ -430,7 +430,7 @@ if ($id > 0 || ! empty($ref))
* Fiche tache en mode visu
*/
$param=($withproject?'&withproject=1':'');
$linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
$linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>':'';
dol_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask');
@ -445,9 +445,9 @@ if ($id > 0 || ! empty($ref))
$object->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
$morehtmlref='';
// Project
if (empty($withproject))
{
@ -455,18 +455,18 @@ if ($id > 0 || ! empty($ref))
$morehtmlref.=$langs->trans("Project").': ';
$morehtmlref.=$projectstatic->getNomUrl(1);
$morehtmlref.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Date start - Date end
@ -520,9 +520,9 @@ if ($id > 0 || ! empty($ref))
}
print '</table>';
print '</div>';
dol_fiche_end();
}
@ -532,7 +532,7 @@ if ($id > 0 || ! empty($ref))
/*
* Actions
*/
print '<div class="tabsAction">';
$parameters = array();
@ -549,7 +549,7 @@ if ($id > 0 || ! empty($ref))
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Modify').'</a>';
}
// Delete
if ($user->rights->projet->supprimer)
{
@ -566,13 +566,13 @@ if ($id > 0 || ! empty($ref))
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
}
print '</div>';
}
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
/*
* Documents generes
*/
@ -587,7 +587,7 @@ if ($id > 0 || ! empty($ref))
print $formfile->showdocuments('project_task',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
print '</div></div></div>';
}
}

View File

@ -190,7 +190,7 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->lire
{
$object->fetch($id, $ref);
// TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids))
$object->timespent_id = $_POST["lineid"];
$object->timespent_note = $_POST["timespent_note_line"];
$object->timespent_old_duration = $_POST["old_duration"];
@ -262,10 +262,10 @@ $projectidforalltimes=0;
if (GETPOST('projectid'))
{
$projectidforalltimes=GETPOST('projectid','int');
}
/*
* View
*/
@ -292,10 +292,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$result=$projectstatic->fetch($object->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$res=$projectstatic->fetch_optionals($object->id,$extralabels_projet);
$object->project = clone $projectstatic;
}
$userWrite = $projectstatic->restrictedProjectArea($user,'write');
if ($projectstatic->id > 0)
@ -310,88 +310,88 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$param=($mode=='mine'?'&mode=mine':'');
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
// Thirdparty
if ($projectstatic->thirdparty->id > 0)
if ($projectstatic->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0);
$projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
}
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
/*
* Actions
*/
@ -399,7 +399,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes))
{
print '<div class="tabsAction">';
if ($user->rights->projet->all->creer || $user->rights->projet->creer)
{
if ($object->public || $userWrite > 0)
@ -415,12 +415,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'</a>';
}
print '</div>';
}
}
}
if (empty($projectidforalltimes))
{
$head=task_prepare_head($object);
@ -440,9 +440,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$object->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
$morehtmlref='';
// Project
if (empty($withproject))
{
@ -450,18 +450,18 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$morehtmlref.=$langs->trans("Project").': ';
$morehtmlref.=$projectstatic->getNomUrl(1);
$morehtmlref.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -482,12 +482,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '</table>';
print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Progress declared
print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td>';
print $object->progress.' %';
@ -508,10 +508,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
@ -583,18 +583,18 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '</td></tr>';
print '</table></form>';
print '<br>';
}
}
if ($projectstatic->id > 0)
{
{
if ($action == 'deleteline')
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.'&lineid='.$_GET["lineid"].($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1);
}
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager->initHooks(array('tasktimelist'));
$extrafields = new ExtraFields($db);
@ -619,12 +619,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
/*
* List of time spent
*/
$tasks = array();
$sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,";
$sql .= " pt.ref, pt.label,";
$sql .= " u.lastname, u.firstname, u.login, u.photo";
@ -638,7 +638,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
if ($search_task_label) $sql .= natural_search('pt.label', $search_task_label);
if ($search_user > 0) $sql .= natural_search('t.fk_user', $search_user);
$sql .= $db->order($sortfield, $sortorder);
$var=true;
$resql = $db->query($sql);
if ($resql)
@ -668,9 +668,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
dol_print_error($db);
}
$arrayofselected=is_array($toselect)?$toselect:array();
$params='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@ -687,8 +687,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
if ($id) $params.='&amp;id='.$id;
if ($projectid) $params.='&amp;projectid='.$projectid;
if ($withproject) $params.='&amp;withproject='.$withproject;
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
@ -696,9 +696,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
//if ($user->rights->projet->creer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -708,31 +708,31 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="projectid" value="'.$projectidforalltimes.'">';
print '<input type="hidden" name="withproject" value="'.$withproject.'">';
$moreforfilter = '';
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if (! empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// Fields title search
print '<tr class="liste_titre_filter">';
// Date
@ -783,14 +783,14 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
print '</tr>'."\n";
print '</tr>'."\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$params,'',$sortfield,$sortorder);
if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task
{
if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$params,'',$sortfield,$sortorder);
if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$params,'',$sortfield,$sortorder);
if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$params,'',$sortfield,$sortorder);
if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$params,'',$sortfield,$sortorder);
}
if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$params,'',$sortfield,$sortorder);
if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$params,'',$sortfield,$sortorder);
@ -800,9 +800,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
/*
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
@ -817,17 +817,17 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print "</tr>\n";
$tasktmp = new Task($db);
$i = 0;
$childids = $user->getAllChildIds();
$total = 0;
$totalvalue = 0;
$totalarray=array();
foreach ($tasks as $task_time)
{
print '<tr class="oddeven">';
$date1=$db->jdate($task_time->task_date);
@ -858,26 +858,26 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$tasktmp->id = $task_time->fk_task;
$tasktmp->ref = $task_time->ref;
$tasktmp->label = $task_time->label;
print $tasktmp->getNomUrl(1, 'withproject', 'time');
print $tasktmp->getNomUrl(1, 'withproject', 'time');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
// Task label
if (! empty($arrayfields['t.task_label']['checked']))
{
if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task
{
print '<td class="nowrap">';
print $task_time->label;
print $task_time->label;
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
// User
if (! empty($arrayfields['author']['checked']))
if (! empty($arrayfields['author']['checked']))
{
print '<td>';
if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid)
@ -907,7 +907,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
}
// Note
if (! empty($arrayfields['t.note']['checked']))
if (! empty($arrayfields['t.note']['checked']))
{
print '<td align="left">';
if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid)
@ -921,7 +921,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Time spent
if (! empty($arrayfields['t.task_duration']['checked']))
{
@ -940,9 +940,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield'];
$totalarray['totalduration'] += $task_time->task_duration;
}
// Value spent
if (! empty($arrayfields['value']['checked']))
if (! empty($arrayfields['value']['checked']))
{
print '<td align="right">';
$value = price2num($task_time->thm * $task_time->task_duration / 3600);
@ -957,7 +957,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="center"">';
if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid)
@ -975,7 +975,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '<a href="'.$_SERVER["PHP_SELF"].'?'.($projectidforalltimes?'projectid='.$projectidforalltimes.'&amp;':'').'id='.$task_time->fk_task.'&amp;action=editline&amp;lineid='.$task_time->rowid.($withproject?'&amp;withproject=1':'').'">';
print img_edit();
print '</a>';
print '&nbsp;';
print '<a href="'.$_SERVER["PHP_SELF"].'?'.($projectidforalltimes?'projectid='.$projectidforalltimes.'&amp;':'').'id='.$task_time->fk_task.'&amp;action=deleteline&amp;lineid='.$task_time->rowid.($withproject?'&amp;withproject=1':'').'">';
print img_delete();
@ -984,12 +984,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;
}
// Show total line
if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield']))
{