Skip to content
Snippets Groups Projects
Commit c59d216c authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

NEW Can read time spent of others (hierarchy only or all if granted)

parent bebf2b33
No related branches found
No related tags found
No related merge requests found
<?php
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/actions_setnotes.inc.php
* \brief Code for actions on setting notes of object page
*/
// $action must be defined
// $_FILES may be defined
// $nomessageinsetmoduleoptions can be set to 1
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$db->begin();
// Process common param fields
foreach($_POST as $key => $val)
{
if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ...
{
$param=GETPOST("param".$reg[1],'alpha');
$value=GETPOST("value".$reg[1],'alpha');
if ($param)
{
$res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
}
// Process upload fields
if (GETPOST('upload','alpha') && GETPOST('keyforuploaddir','aZ09'))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$keyforuploaddir=GETPOST('keyforuploaddir','aZ09');
$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->$keyforuploaddir)));
foreach($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
if (! $tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
else
{
$upload_dir=$tmpdir;
}
}
if ($upload_dir)
{
$result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', '');
if ($result <= 0) $error++;
}
}
if (! $error)
{
$db->commit();
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
}
}
......@@ -1391,7 +1391,7 @@ class Form
* @deprecated
* @see select_dolusers()
*/
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude=null,$disabled=0,$include='',$enableonly='',$force_entity=0)
{
print $this->select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly,$force_entity);
}
......@@ -1411,13 +1411,13 @@ class Form
* @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
* @param string $morefilter Add more filters into sql request
* @param integer $show_every 0=default list, 1=add also a value "Everybody" at beginning of list
* @param string $enableonlytext If option $enableonly is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty.
* @param string $enableonlytext If option $enableonlytext is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty.
* @param string $morecss More css
* @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on).
* @return string HTML select string
* @see select_dolgroups
*/
function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0)
function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0)
{
global $conf,$user,$langs;
......@@ -1613,7 +1613,7 @@ class Form
* @return string HTML select string
* @see select_dolgroups
*/
function select_dolusers_forevent($action='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='')
function select_dolusers_forevent($action='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='')
{
global $conf,$user,$langs;
......
......@@ -358,7 +358,7 @@ class FormCompany
*
* @param string $selected Title preselected
* @param string $htmlname Name of HTML select combo field
* @param string $morecss Add more css on SELECT element
* @param string $morecss Add more css on SELECT element
* @return string String with HTML select
*/
function select_civility($selected='',$htmlname='civility_id',$morecss='maxwidth100')
......@@ -563,11 +563,11 @@ class FormCompany
$events=array();
// Add an entry 'method' to say 'yes, we must execute url with param action = method';
// Add an entry 'url' to say which url to execute
// Add an entry htmlname to say which element we must change once url is called
// Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines
// Add an entry htmlname to say which element we must change once url is called
// Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines
// To refresh contacts list on thirdparty list change
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events
{
print '<script type="text/javascript">
......@@ -583,7 +583,7 @@ class FormCompany
/* Clean contact */
$("div#s2id_contactid>a>span").html(\'\');
});
// Function used to execute events when search_htmlname change
function runJsCodeForEvent'.$htmlname.'(obj) {
var id = $("#'.$htmlname.'").val();
......@@ -693,16 +693,17 @@ class FormCompany
* @param string $source Source ('internal' or 'external')
* @param string $sortorder Sort criteria ('position', 'code', ...)
* @param int $showempty 1=Add en empty line
* @param string $morecss Add more css to select component
* @return void
*/
function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0)
function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0, $morecss='')
{
global $user, $langs;
if (is_object($object) && method_exists($object, 'liste_type_contact'))
{
$lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1);
print '<select class="flat valignmiddle" name="'.$htmlname.'" id="'.$htmlname.'">';
print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($showempty) print '<option value="0"></option>';
foreach($lesTypes as $key=>$value)
{
......@@ -791,7 +792,7 @@ class FormCompany
$maxlength=$formlength;
if (empty($formlength)) { $formlength=24; $maxlength=128; }
$out = '<input type="text" '.($morecss?'class="'.$morecss.'" ':'').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">';
return $out;
......
......@@ -68,7 +68,7 @@ class FormProjets
global $langs,$conf,$form;
$out='';
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT))
{
$placeholder='';
......@@ -92,7 +92,7 @@ class FormProjets
else
{
$out.=$this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid);
if ($discard_closed)
if ($discard_closed)
{
if (class_exists('Form'))
{
......@@ -101,8 +101,8 @@ class FormProjets
}
}
}
if (empty($nooutput))
if (empty($nooutput))
{
print $out;
return '';
......@@ -136,10 +136,10 @@ class FormProjets
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (empty($htmlid)) $htmlid = $htmlname;
$out='';
$outarray=array();
$hideunselectables = false;
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
......@@ -170,21 +170,19 @@ class FormProjets
$resql=$this->db->query($sql);
if ($resql)
{
$minmax='maxwidth500';
$morecss='maxwidth500';
// Use select2 selector
$nodatarole='';
if (! empty($conf->use_javascript_ajax))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
$out.=$comboenhancement;
$nodatarole=($comboenhancement?' data-role="none"':'');
$minmax='minwidth100 maxwidth300';
$morecss='minwidth100 maxwidth300';
}
if (empty($option_only)) {
$out.= '<select class="flat'.($minmax?' '.$minmax:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlid.'" name="'.$htmlname.'"'.$nodatarole.'>';
$out.= '<select class="flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlid.'" name="'.$htmlname.'">';
}
if (!empty($show_empty)) {
$out.= '<option value="0">&nbsp;</option>';
......@@ -213,12 +211,12 @@ class FormProjets
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$labeltoshow.=', '.dol_trunc($obj->title, $maxlength);
if ($obj->name)
if ($obj->name)
{
$labeltoshow.=' - '.$obj->name;
if ($obj->name_alias) $labeltoshow.=' ('.$obj->name_alias.')';
}
$disabled=0;
if ($obj->fk_statut == 0)
{
......@@ -277,7 +275,7 @@ class FormProjets
if (!$mode) {
if (empty($option_only)) $out.= '</select>';
if (empty($nooutput))
if (empty($nooutput))
{
print $out;
return '';
......@@ -302,13 +300,14 @@ class FormProjets
* @param string $htmlname Name of HTML select
* @param int $maxlength Maximum length of label
* @param int $option_only Return only html options lines without the select tag
* @param int $show_empty Add an empty line
* @param string $show_empty Add an empty line ('1' or string to show for empty line)
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
* @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled
* @param string $morecss More css added to the select component
* @return int Nbr of project if OK, <0 if KO
*/
function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0)
function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500')
{
global $user,$conf,$langs;
......@@ -339,28 +338,26 @@ class FormProjets
if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
$sql.= " ORDER BY p.ref, t.ref ASC";
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$minmax='maxwidth500';
// Use select2 selector
$nodatarole='';
if (! empty($conf->use_javascript_ajax))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
$out.=$comboenhancement;
$nodatarole=($comboenhancement?' data-role="none"':'');
$minmax='minwidth200 maxwidth500';
$morecss='minwidth200 maxwidth500';
}
if (empty($option_only)) {
$out.= '<select class="valignmiddle flat'.($minmax?' '.$minmax:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>';
$out.= '<select class="valignmiddle flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.$htmlname.'">';
}
if (!empty($show_empty)) {
$out.= '<option value="0">&nbsp;</option>';
if (! empty($show_empty)) {
$out.= '<option value="0" class="optiongrey">';
if (! is_numeric($show_empty)) $out.=$show_empty;
else $out.='&nbsp;';
$out.= '</option>';
}
$num = $this->db->num_rows($resql);
$i = 0;
......@@ -370,7 +367,7 @@ class FormProjets
{
$obj = $this->db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire))
{
// Do nothing
}
......@@ -382,7 +379,7 @@ class FormProjets
continue;
}
$labeltoshow=dol_trunc($obj->ref,18);
$labeltoshow=dol_trunc($obj->ref,18); // Project ref
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$labeltoshow.=' '.dol_trunc($obj->title,$maxlength);
......@@ -532,7 +529,6 @@ class FormProjets
$sql.= " ORDER BY ref DESC";
dol_syslog(get_class($this).'::select_element', LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
......
/* Copyright (C) 2014 delcroip <delcroip@gmail.com>
* Laurent Destailleur 2015 <eldy@users.sourceforge.net>
/* Copyright (C) 2014 delcroip <delcroip@gmail.com>
* Copyright (C) 2015-2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
......
......@@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
function project_prepare_head($object)
{
global $db, $langs, $conf, $user;
$h = 0;
$head = array();
......@@ -119,7 +119,7 @@ function project_prepare_head($object)
}
$head[$h][2] = 'agenda';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove');
return $head;
......@@ -163,7 +163,7 @@ function task_prepare_head($object)
if ($obj) $nbTimeSpent=1;
}
else dol_print_error($db);
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
$head[$h][1] = $langs->trans("TimeSpent");
if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>';
......@@ -208,9 +208,10 @@ function task_prepare_head($object)
* Prepare array with list of tabs
*
* @param string $mode Mode
* @param string $fuser Filter on user
* @return array Array of tabs to show
*/
function project_timesheet_prepare_head($mode)
function project_timesheet_prepare_head($mode, $fuser=null)
{
global $langs, $conf, $user;
$h = 0;
......@@ -218,9 +219,13 @@ function project_timesheet_prepare_head($mode)
$h = 0;
$param='';
$param.=($mode?'&mode='.$mode:'');
if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id;
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
{
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($mode?'?mode='.$mode:'');
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:'');
$head[$h][1] = $langs->trans("InputPerWeek");
$head[$h][2] = 'inputperweek';
$h++;
......@@ -228,7 +233,7 @@ function project_timesheet_prepare_head($mode)
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
{
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:'');
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:'');
$head[$h][1] = $langs->trans("InputPerDay");
$head[$h][2] = 'inputperday';
$h++;
......@@ -507,7 +512,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
$level--;
}
$total_projectlinesa_spent += $lines[$i]->duration;
$total_projectlinesa_planned += $lines[$i]->planned_workload;
if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
......@@ -571,9 +576,9 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$lastprojectid=0;
$workloadforid=array();
$lineswithoutlevel0=array();
$numlines=count($lines);
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
if ($parent == 0) // Always and only if at first level
{
......@@ -581,7 +586,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
{
if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
}
}
}
//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
for ($i = 0 ; $i < $numlines ; $i++)
......@@ -594,7 +599,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
......@@ -604,7 +609,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$projectstatic->id = $lines[$i]->fk_project;
}
}
if (empty($workloadforid[$projectstatic->id]))
{
if ($preselectedday)
......@@ -613,7 +618,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$workloadforid[$projectstatic->id]=1;
}
}
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->title=$lines[$i]->projectlabel;
......@@ -621,7 +626,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$taskstatic->id=$lines[$i]->id;
print "<tr ".$bc[$var].">\n";
print '<tr class="oddeven">'."\n";
// User
print '<td class="nowrap">';
print $fuser->getNomUrl(1, 'withproject', 'time');
print '</td>';
// Ref
print '<td>';
......@@ -656,7 +666,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print $thirdpartystatic->getNomUrl(1, 'project', 10);
print '</td>';
}
// Planned Workload
print '<td align="right">';
if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
......@@ -707,7 +717,10 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print '<td class="nowrap" align="center">';
$tableCell=$form->select_date($preselectedday,$lines[$i]->id,1,1,2,"addtime",0,0,1,$disabledtask);
print $tableCell;
print '</td><td align="right">';
print '</td>';
// Duration
print '<td align="right">';
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
$alreadyspent='';
......@@ -723,24 +736,25 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print '</td>';
print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));
print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>';
print '</textarea>';
print '</td>';
// Warning
print '<td align="right">';
print '<textarea name="'.$lines[$i]->id.'note" rows="2" id="note">';
print '</textarea>';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $langs->transnoentitiesnoconv("AssignTaskToUser", '...')));
print '</td>';
print "</tr>\n";
}
$inc++;
$level++;
if ($lines[$i]->id > 0)
if ($lines[$i]->id > 0)
{
if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $var);
else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $var);
else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $var);
}
$level--;
}
......@@ -781,7 +795,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$lastprojectid=0;
$workloadforid=array();
$lineswithoutlevel0=array();
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
if ($parent == 0) // Always and only if at first level
{
......@@ -792,18 +806,18 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
}
//dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
for ($i = 0 ; $i < $numlines ; $i++)
{
if ($parent == 0) $level = 0;
if ($lines[$i]->fk_task_parent == $parent)
{
// If we want all or we have a role on task, we show it
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
......@@ -811,14 +825,19 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$lastprojectid=$lines[$i]->fk_project;
$projectstatic->id = $lines[$i]->fk_project;
}
if (empty($workloadforid[$projectstatic->id]))
{
$projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
$workloadforid[$projectstatic->id]=1;
}
print "<tr ".$bc[$var].">\n";
print '<tr class="oddeven">'."\n";
// User
print '<td class="nowrap">';
print $fuser->getNomUrl(1, 'withproject', 'time');
print '</td>';
// Ref
print '<td class="nowrap">';
......@@ -842,7 +861,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
print "</td>\n";
// Project
print '<td class="nowrap">'.$var;
print '<td class="nowrap">';
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->title=$lines[$i]->projectlabel;
......@@ -860,7 +879,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
print $thirdpartystatic->getNomUrl(1, 'project');
print '</td>';
}
// Planned Workload
print '<td align="right">';
if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
......@@ -908,7 +927,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
}
//var_dump($projectstatic->weekWorkLoadPerTask);
// Fields to show current time
$tableCell=''; $modeinput='hours';
for ($idw = 0; $idw < 7; $idw++)
......@@ -919,7 +938,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$alreadyspent='';
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
$tableCell ='<td align="center" class="hide'.$idw.'">';
if ($alreadyspent)
{
......@@ -934,10 +953,11 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$tableCell.='</td>';
print $tableCell;
}
// Warning
print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $langs->transnoentitiesnoconv("AssignTaskToUser", '...')));
print '</td>';
print "</tr>\n";
......@@ -946,7 +966,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
// Call to show task with a lower level (task under the current task)
$inc++;
$level++;
if ($lines[$i]->id > 0)
if ($lines[$i]->id > 0)
{
if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $var);
else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $var);
......@@ -1020,7 +1040,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
$projectstatic=new Project($db);
$thirdpartystatic=new Societe($db);
$sortfield='';
$sortorder='';
$project_year_filter=0;
......@@ -1029,7 +1049,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
$arrayidtypeofcontact=array();
print '<table class="noborder" width="100%">';
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
......@@ -1072,11 +1092,11 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
$sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")";
}
}
// Get id of project we must show tasks
$arrayidofprojects=array();
$sql1 = "SELECT p.rowid as projectid";
$sql1.= $sql;
$sql1.= $sql;
$resql = $db->query($sql1);
if ($resql)
{
......@@ -1091,7 +1111,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
}
else dol_print_error($db);
if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1;
// Get list of project with calculation on tasks
$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,";
$sql2.= " p.dateo, p.datee,";
......@@ -1122,7 +1142,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
print_liste_field_titre($langs->trans("OpportunityAmount"),"","","","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("OpportunityStatus"),"","","","",'align="right"',$sortfield,$sortorder);
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print_liste_field_titre($langs->trans("Tasks"),"","","","",'align="right"',$sortfield,$sortorder);
if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre($langs->trans("PlannedWorkload"),"","","","",'align="right"',$sortfield,$sortorder);
......@@ -1130,7 +1150,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
}
print_liste_field_titre($langs->trans("Status"),"","","","",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
while ($i < $num)
{
$objp = $db->fetch_object($resql);
......@@ -1148,8 +1168,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
$projectstatic->title = $objp->title;
$projectstatic->datee = $db->jdate($objp->datee);
$projectstatic->dateo = $db->jdate($objp->dateo);
print '<tr class="oddeven">';
print '<td>';
print $projectstatic->getNomUrl(1);
......@@ -1174,17 +1194,17 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
if ($code) print $langs->trans("OppStatus".$code);
print '</td>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<td align="right">'.$objp->nb.'</td>';
$plannedworkload=$objp->planned_workload;
$total_plannedworkload+=$plannedworkload;
if (! in_array('plannedworkload', $hiddenfields))
{
print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
}
if (! in_array('declaredprogress', $hiddenfields))
if (! in_array('declaredprogress', $hiddenfields))
{
$declaredprogressworkload=$objp->declared_progess_workload;
$total_declaredprogressworkload+=$declaredprogressworkload;
......@@ -1194,7 +1214,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
print '</td>';
}
}
print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>';
print "</tr>\n";
......@@ -1213,7 +1233,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
print '<td class="liste_total" align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>';
print '<td class="liste_total" align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).'</td>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<td class="liste_total" align="right">'.$total_task.'</td>';
if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
......@@ -1221,7 +1241,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
}
print '<td class="liste_total"></td>';
print '</tr>';
$db->free($resql);
}
else
......
......@@ -614,7 +614,7 @@ Permission32=Create/modify products
Permission34=Delete products
Permission36=See/manage hidden products
Permission38=Export products
Permission41=Read projects and tasks (shared project and projects i'm contact for). Can also enter time consumed on assigned tasks (timesheet)
Permission41=Read projects and tasks (shared project and projects i'm contact for). Can also enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet)
Permission42=Create/modify projects (shared project and projects i'm contact for). Can also create tasks and assign users to project and tasks
Permission44=Delete projects (shared project and projects i'm contact for)
Permission45=Export projects
......
......@@ -53,7 +53,7 @@ TaskTimeNote=Note
TaskTimeDate=Date
TasksOnOpenedProject=Tasks on open projects
WorkloadNotDefined=Workload not defined
NewTimeSpent=New time spent
NewTimeSpent=Time spent
MyTimeSpent=My time spent
Tasks=Tasks
Task=Task
......@@ -107,6 +107,7 @@ ConfirmReOpenAProject=Are you sure you want to re-open this project?
ProjectContact=Project contacts
ActionsOnProject=Events on project
YouAreNotContactOfProject=You are not a contact of this private project
UserIsNotContactOfProject=User is not a contact of this private project
DeleteATimeSpent=Delete time spent
ConfirmDeleteATimeSpent=Are you sure you want to delete this time spent?
DoNotShowMyTasksOnly=See also tasks not assigned to me
......@@ -115,7 +116,7 @@ TaskRessourceLinks=Resources
ProjectsDedicatedToThisThirdParty=Projects dedicated to this third party
NoTasks=No tasks for this project
LinkedToAnotherCompany=Linked to other third party
TaskIsNotAffectedToYou=Task not assigned to you
TaskIsNotAssignedToUser=Task not assigned to user. Use button '<strong>%s</strong>' to assign task now.
ErrorTimeSpentIsEmpty=Time spent is empty
ThisWillAlsoRemoveTasks=This action will also delete all tasks of project (<b>%s</b> tasks at the moment) and all inputs of time spent.
IfNeedToUseOhterObjectKeepEmpty=If some objects (invoice, order, ...), belonging to another third party, must be linked to the project to create, keep this empty to have the project being multi third parties.
......@@ -166,13 +167,15 @@ FirstAddRessourceToAllocateTime=Assign a user resource to task to allocate time
InputPerDay=Input per day
InputPerWeek=Input per week
InputPerAction=Input per action
TimeAlreadyRecorded=Time spent already recorded for this task/day and user %s
TimeAlreadyRecorded=This is time spent already recorded for this task/day and user %s
ProjectsWithThisUserAsContact=Projects with this user as contact
TasksWithThisUserAsContact=Tasks assigned to this user
ResourceNotAssignedToProject=Not assigned to project
ResourceNotAssignedToTheTask=Not assigned to the task
TasksAssignedTo=Tasks assigned to
AssignTaskToMe=Assign task to me
AssignTaskToUser=Assign task to %s
SelectTaskToAssign=Select task to assign...
AssignTask=Assign
ProjectOverview=Overview
ManageTasks=Use projects to follow tasks and time
......
......@@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$langs->load('projects');
$langs->load('users');
$action=GETPOST('action','aZ09');
$mode=GETPOST("mode");
......@@ -62,6 +63,8 @@ $month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("mo
$day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d"));
$day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int');
$search_task_ref=GETPOST('search_task_ref', 'alpha');
$search_task_label=GETPOST('search_task_label', 'alpha');
$search_project_ref=GETPOST('search_project_ref', 'alpha');
......@@ -75,6 +78,17 @@ $daytoparse = $now;
if ($yearofday && $monthofday && $dayofday) $daytoparse=dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime'
else if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day, $year); // this are value submited after submit of action 'submitdateselect'
if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id)
{
$usertoprocess=$user;
}
else
{
$usertoprocess=new User($db);
$usertoprocess->fetch($search_usertoprocessid);
}
$search_usertoprocessid=$usertoprocess->id;
$object=new Task($db);
......@@ -83,9 +97,10 @@ $object=new Task($db);
*/
// Purge criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{
$action = '';
$search_usertoprocessid = '';
$search_task_ref = '';
$search_task_label = '';
$search_project_ref = '';
......@@ -125,7 +140,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
}
if (! $error)
{
$idfortaskuser=$user->id;
$idfortaskuser=$usertoprocess->id;
$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
if ($result >= 0 || $result == -2) // Contact add ok or already contact of task
......@@ -143,7 +158,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
$project->fetch($object->fk_project);
// Get type
$listofprojcontact=$project->liste_type_contact('internal');
if (count($listofprojcontact))
{
$typeforprojectcontact=reset(array_keys($listofprojcontact));
......@@ -151,7 +166,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
}
}
}
else
else
{
dol_print_error($db);
}
......@@ -175,6 +190,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
if (! $error)
{
setEventMessages("TaskAssignedToEnterTime", null);
$taskid=0;
}
$action='';
......@@ -247,12 +263,12 @@ if ($action == 'addtime' && $user->rights->projet->lire)
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
// Redirect to avoid submit twice on back
header('Location: '.$_SERVER["PHP_SELF"].($projectid?'?id='.$projectid:'?').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday);
header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday);
exit;
}
}
else
{
else
{
setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
}
}
......@@ -286,8 +302,6 @@ $next_day = $next['mday'];
$title=$langs->trans("TimeSpent");
if ($mine) $title=$langs->trans("MyTimeSpent");
$usertoprocess = $user;
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
if ($id)
......@@ -314,8 +328,9 @@ llxHeader("",$title,"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');
$param='';
$param.=($mode?'&amp;mode='.$mode:'');
$param.=($search_project_ref?'&amp;search_project_ref='.$search_project_ref:'');
$param.=($mode?'&mode='.$mode:'');
$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:'');
$param.=($search_userassignedid > 0?'&search_userassignedid='.$search_usertoprocessid:'');
// Show navigation bar
$nav ='<a class="inline-block valignmiddle" href="?year='.$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
......@@ -337,7 +352,7 @@ print '<input type="hidden" name="addtimeyear" value="'.$tmp['year'].'">';
print '<input type="hidden" name="addtimemonth" value="'.$tmp['mon'].'">';
print '<input type="hidden" name="addtimeday" value="'.$tmp['mday'].'">';
$head=project_timesheet_prepare_head($mode);
$head=project_timesheet_prepare_head($mode, $usertoprocess);
dol_fiche_head($head, 'inputperday', '', -1, 'task');
// Show description of content
......@@ -360,45 +375,17 @@ print '</div>';
dol_fiche_end();
// Filter on user
/* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>';
dol_fiche_end();
*/
// Filter on user
/* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>';
dol_fiche_end();
*/
// Add a new project/task
//print '<br>';
//print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
//print '<input type="hidden" name="action" value="assigntask">';
//print '<input type="hidden" name="mode" value="'.$mode.'">';
//print '<input type="hidden" name="year" value="'.$year.'">';
//print '<input type="hidden" name="month" value="'.$month.'">';
//print '<input type="hidden" name="day" value="'.$day.'">';
print '<div class="floatright right">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
print '<div class="floatright right'.($conf->dol_optimize_smallscreen?' centpercent':'').'">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
print '<div class="float valignmiddle">';
print $langs->trans("AssignTaskToMe").'<br>';
$titleassigntask = $langs->trans("AssignTaskToMe");
if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs));
print '<div class="taskiddiv inline-block">';
$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1);
print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0);
print '<input type="submit" class="button valignmiddle" name="assigntask" value="'.$langs->trans("AssignTask").'">';
//print '</form>';
print '</div>';
print ' ';
print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200');
print '<input type="submit" class="button valignmiddle" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).'">';
print '</div>';
print '<div class="clearboth" style="padding-bottom: 8px;"></div>';
......@@ -408,6 +395,11 @@ print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">';
$usersettoshow='hierarchyme';
if ($user->rights->projet->all->lire) $usersettoshow='';
print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150');
print '</td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
......@@ -427,6 +419,7 @@ print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("User").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td>'.$langs->trans("ProjectRef").'</td>';
......@@ -436,12 +429,15 @@ if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
}
print '<td align="right" class="maxwidth100">'.$langs->trans("PlannedWorkload").'</td>';
print '<td align="right" class="maxwidth100">'.$langs->trans("ProgressDeclared").'</td>';
print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'</td>';
/*print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'</td>';
if ($usertoprocess->id == $user->id) print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpentByYou").'</td>';
else print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpentByUser").'</td>';
else print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpentByUser").'</td>';*/
print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</td>';
print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'</td>';
print '<td align="center">'.$langs->trans("HourStart").'</td>';
print '<td align="center" colspan="2">'.$langs->trans("Duration").'</td>';
print '<td align="center">'.$langs->trans("Duration").'</td>';
print '<td align="right">'.$langs->trans("Note").'</td>';
print '<td align="center"></td>';
print "</tr>\n";
......@@ -455,7 +451,7 @@ if (count($tasksarray) > 0)
}
else
{
print '<tr><td colspan="10">'.$langs->trans("NoTasks").'</td></tr>';
print '<tr><td colspan="14">'.$langs->trans("NoTasks").'</td></tr>';
}
print "</table>";
print '</div>';
......
......@@ -58,11 +58,14 @@ $nowtmp=dol_getdate($now);
$nowday=$nowtmp['mday'];
$nowmonth=$nowtmp['mon'];
$nowyear=$nowtmp['year'];
$year=GETPOST('reyear')?GETPOST('reyear','int'):(GETPOST("year")?GETPOST("year","int"):date("Y"));
$month=GETPOST('remonth')?GETPOST('remonth','int'):(GETPOST("month")?GETPOST("month","int"):date("m"));
$day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"):date("d"));
$day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int');
$search_task_ref=GETPOST('search_task_ref', 'alpha');
$search_task_label=GETPOST('search_task_label', 'alpha');
$search_project_ref=GETPOST('search_project_ref', 'alpha');
......@@ -88,7 +91,16 @@ $next_day = $next['day'];
$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year);
$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd');
$usertoprocess=$user;
if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id)
{
$usertoprocess=$user;
}
else
{
$usertoprocess=new User($db);
$usertoprocess->fetch($search_usertoprocessid);
}
$search_usertoprocessid=$usertoprocess->id;
$object=new Task($db);
......@@ -98,9 +110,10 @@ $object=new Task($db);
*/
// Purge criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{
$action = '';
$search_usertoprocessid = '';
$search_task_ref = '';
$search_task_label = '';
$search_project_ref = '';
......@@ -137,13 +150,13 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
$error++;
}
if (! $error)
{
$idfortaskuser=$user->id;
$idfortaskuser=$usertoprocess->id;
$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
if (! $result || $result == -2) // Contact add ok or already contact of task
if ($result >= 0 || $result == -2) // Contact add ok or already contact of task
{
// Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project)
$sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
......@@ -158,7 +171,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
$project->fetch($object->fk_project);
// Get type
$listofprojcontact=$project->liste_type_contact('internal');
if (count($listofprojcontact))
{
$typeforprojectcontact=reset(array_keys($listofprojcontact));
......@@ -166,7 +179,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
}
}
}
else
else
{
dol_print_error($db);
}
......@@ -190,6 +203,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
if (! $error)
{
setEventMessages("TaskAssignedToEnterTime", null);
$taskid=0;
}
$action='';
......@@ -233,16 +247,16 @@ if ($action == 'addtime' && $user->rights->projet->lire)
$error++;
break;
}
$updateoftaskdone++;
}
}
}
if (! $updateoftaskdone) // Check to update progress if no update were done on task.
{
$object->fetch($taskid);
//var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit;
//var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit;
if ($object->progress != GETPOST($taskid . 'progress', 'int'))
{
$object->progress = GETPOST($taskid . 'progress', 'int');
......@@ -262,7 +276,7 @@ if ($action == 'addtime' && $user->rights->projet->lire)
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
// Redirect to avoid submit twice on back
header('Location: '.$_SERVER["PHP_SELF"].($projectid?'?id='.$projectid:'?').($mode?'&mode='.$mode:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:''));
header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:''));
exit;
}
}
......@@ -312,14 +326,15 @@ llxHeader("",$title,"",'','','',array('/core/js/timesheet.js'));
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');
$param='';
$param.=($mode?'&amp;mode='.$mode:'');
$param.=($search_project_ref?'&amp;search_project_ref='.$search_project_ref:'');
$param.=($mode?'&mode='.$mode:'');
$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:'');
$param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.$search_usertoprocessid:'');
// Show navigation bar
$nav ='<a class="inline-block valignmiddle" href="?year='.$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
$nav ='<a class="inline-block valignmiddle" href="?year='.$prev_year."&month=".$prev_month."&day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("WeekShort")." ".$week." </span>\n";
$nav.='<a class="inline-block valignmiddle" href="?year='.$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param.'">'.img_next($langs->trans("Next"))."</a>\n";
$nav.=" &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$nav.='<a class="inline-block valignmiddle" href="?year='.$next_year."&month=".$next_month."&day=".$next_day.$param.'">'.img_next($langs->trans("Next"))."</a>\n";
$nav.=" &nbsp; (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$nav.='<br>'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' ';
$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
......@@ -333,7 +348,7 @@ print '<input type="hidden" name="day" value="'.$day.'">';
print '<input type="hidden" name="month" value="'.$month.'">';
print '<input type="hidden" name="year" value="'.$year.'">';
$head=project_timesheet_prepare_head($mode);
$head=project_timesheet_prepare_head($mode, $usertoprocess);
dol_fiche_head($head, 'inputperweek', '', -1, 'task');
// Show description of content
......@@ -356,44 +371,17 @@ print '</div>';
dol_fiche_end();
// Filter on user
/* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>';
dol_fiche_end();
*/
// Filter on user
/* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>';
dol_fiche_end();
*/
// Add a new project/task
//print '<br>';
//print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
//print '<input type="hidden" name="action" value="assigntask">';
//print '<input type="hidden" name="mode" value="'.$mode.'">';
//print '<input type="hidden" name="year" value="'.$year.'">';
//print '<input type="hidden" name="month" value="'.$month.'">';
//print '<input type="hidden" name="day" value="'.$day.'">';
print '<div class="floatright right">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
print '<div class="floatright right'.($conf->dol_optimize_smallscreen?' centpercent':'').'">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
print '<div class="float valignmiddle">';
print $langs->trans("AssignTaskToMe").'<br>';
$titleassigntask = $langs->trans("AssignTaskToMe");
if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs));
print '<div class="taskiddiv inline-block">';
$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1);
print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0);
print '<input type="submit" class="button valignmiddle" name="assigntask" value="'.$langs->trans("AssignTask").'">';
//print '</form>';
print '</div>';
print ' ';
print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200');
print '<input type="submit" class="button valignmiddle" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).'">';
print '</div>';
print '<div class="clearboth" style="padding-bottom: 8px;"></div>';
......@@ -403,6 +391,11 @@ print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">';
$usersettoshow='hierarchyme';
if ($user->rights->projet->all->lire) $usersettoshow='';
print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150');
print '</td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
......@@ -423,6 +416,7 @@ print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("User").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td>'.$langs->trans("ProjectRef").'</td>';
......@@ -432,9 +426,11 @@ if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
}
print '<td align="right" class="maxwidth75">'.$langs->trans("PlannedWorkload").'</td>';
print '<td align="right" class="maxwidth75">'.$langs->trans("ProgressDeclared").'</td>';
/*print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpent").'</td>';
if ($usertoprocess->id == $user->id) print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpentByYou").'</td>';
else print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpentByUser").'</td>';*/
print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</td>';
print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpent").'</td>';
if ($usertoprocess->id == $user->id) print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpentByYou").'</td>';
else print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpentByUser").'</td>';
$startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']);
......@@ -452,16 +448,16 @@ if (count($tasksarray) > 0)
{
//var_dump($tasksarray);
//var_dump($tasksrole);
$j=0;
$level=0;
projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask);
$colspan=7;
$colspan=8;
if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++;
print '<tr class="liste_total">
<td class="liste_total" colspan="'.$colspan.'" align="right">'.$langs->trans("Total").'</td>
<td class="liste_total" colspan="'.$colspan.'">'.$langs->trans("Total").'</td>
<td class="liste_total hide0" align="center"><div id="totalDay[0]">&nbsp;</div></td>
<td class="liste_total hide1" align="center"><div id="totalDay[1]">&nbsp;</div></td>
<td class="liste_total hide2" align="center"><div id="totalDay[2]">&nbsp;</div></td>
......@@ -474,7 +470,7 @@ if (count($tasksarray) > 0)
}
else
{
print '<tr><td colspan="11">'.$langs->trans("NoTasks").'</td></tr>';
print '<tr><td colspan="16">'.$langs->trans("NoTasks").'</td></tr>';
}
print "</table>";
print '</div>';
......
......@@ -134,7 +134,7 @@ if (empty($reshook))
$error++;
setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
}
if (! $error)
{
$error=0;
......@@ -308,8 +308,8 @@ if (empty($reshook))
setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors');
}
}
if ($error)
{
$db->rollback();
......@@ -322,7 +322,7 @@ if (empty($reshook))
if (GETPOST('socid','int') > 0) $object->fetch_thirdparty(GETPOST('socid','int'));
else unset($object->thirdparty);
}
}
// Build doc
......@@ -623,7 +623,7 @@ if ($action == 'create' && $user->rights->projet->creer)
{
print ' &nbsp; &nbsp; ';
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
}
}
print '</div>';
print '</form>';
......@@ -645,12 +645,12 @@ if ($action == 'create' && $user->rights->projet->creer)
});
</script>';
}
elseif ($object->id > 0)
elseif ($object->id > 0)
{
/*
* Show or edit
*/
$res=$object->fetch_optionals($object->id,$extralabels);
// To verify role of users
......@@ -711,10 +711,11 @@ elseif ($object->id > 0)
print '<input type="hidden" name="comefromclone" value="'.$comefromclone.'">';
$head=project_prepare_head($object);
dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project'));
if ($action == 'edit' && $userWrite > 0)
{
dol_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public?'projectpub':'project'));
print '<table class="border" width="100%">';
// Ref
......@@ -835,27 +836,30 @@ elseif ($object->id > 0)
}
else
{
dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project'));
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$object->title;
// Thirdparty
if ($object->thirdparty->id > 0)
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ';
if ($object->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project');
$morehtmlref .= $object->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$objectsListId = $object->getProjectsAuthorizedForUser($user,0,0);
$object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
......@@ -889,7 +893,7 @@ elseif ($object->id > 0)
if (strcmp($object->opp_amount,'')) print price($object->opp_amount,0,$langs,1,0,0,$conf->currency);
print '</td></tr>';
}
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
$start = dol_print_date($object->date_start,'dayhour');
......@@ -899,7 +903,7 @@ elseif ($object->id > 0)
print ($end?$end:'?');
if ($object->hasDelay()) print img_warning("Late");
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($object->budget_amount, '')) print price($object->budget_amount,0,$langs,1,0,0,$conf->currency);
......@@ -908,16 +912,16 @@ elseif ($object->id > 0)
// 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($object->description);
......@@ -929,13 +933,13 @@ elseif ($object->id > 0)
print $form->showCategories($object->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
}
......@@ -956,7 +960,7 @@ elseif ($object->id > 0)
{
$defaultcheckedwhenoppclose=1;
if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0;
print '<!-- Javascript to manage opportunity status change -->';
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
......@@ -973,9 +977,9 @@ elseif ($object->id > 0)
jQuery("#divtocloseproject").show();
if (defaultcloseproject) jQuery("#inputcloseproject").prop("checked", true);
else jQuery("#inputcloseproject").prop("checked", false);
/* Make close project visible or not */
if (elemcode == \'WON\' || elemcode == \'LOST\')
if (elemcode == \'WON\' || elemcode == \'LOST\')
{
jQuery("#divtocloseproject").show();
}
......@@ -983,7 +987,7 @@ elseif ($object->id > 0)
{
jQuery("#divtocloseproject").hide();
}
/* Change percent of default percent of new status is higher */
if (parseFloat(jQuery("#opp_percent").val()) != parseFloat(defaultpercent))
{
......@@ -1010,7 +1014,7 @@ elseif ($object->id > 0)
{
if ($action != "edit" )
{
// Create event
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
// "workflow" action so should appears somewhere else on
......
......@@ -340,9 +340,9 @@ input.buttongen {
vertical-align: middle;
}
span.timesheetalreadyrecorded input {
/*font-size: smaller;*/
border: none;
/*background: transparent;*/
border-bottom: solid 1px rgba(0,0,0,0.4);
margin-right: 1px !important;
}
select.flat, form.flat select {
......@@ -363,8 +363,10 @@ select.flat, form.flat select {
.opacitytransp {
opacity: 0;
}
select:invalid { color: gray; }
input:disabled {
select:invalid {
color: gray;
}
input:disabled {
background:#ddd;
}
......@@ -988,7 +990,7 @@ div.fiche {
div.fiche {
margin-<?php print $left; ?>: <?php print (GETPOST('optioncss','aZ09') == 'print'?6:($dol_hide_leftmenu?'6':'26')); ?>px;
margin-<?php print $right; ?>: <?php print (GETPOST('optioncss','aZ09') == 'print'?8:(empty($conf->dol_optimize_smallscreen)?'16':'6')); ?>px;
margin-<?php print $right; ?>: <?php print (GETPOST('optioncss','aZ09') == 'print'?8:(empty($conf->dol_optimize_smallscreen)?'16':'12')); ?>px;
<?php if (! empty($conf->dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'."\n"; ?>
<?php if (! empty($conf->dol_hide_leftmenu)) print 'margin-bottom: 12px;'."\n"; ?>
}
......@@ -2683,7 +2685,7 @@ input.liste_titre {
}
.noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total {
/* background: #F0F0F0; */
height: 32px;
}
.noborder tr.liste_total td, tr.liste_total td, form.liste_total div {
color: #552266;
......
......@@ -337,9 +337,9 @@ input.buttongen {
vertical-align: middle;
}
span.timesheetalreadyrecorded input {
/*font-size: smaller;*/
border: none;
/*background: transparent;*/
border-bottom: solid 1px rgba(0,0,0,0.1);
margin-right: 1px !important;
}
select.flat, form.flat select {
......@@ -1027,7 +1027,7 @@ div.fiche {
div.fiche {
margin-<?php print $left; ?>: <?php print (GETPOST('optioncss','aZ09') == 'print'?6:($dol_hide_leftmenu?'4':'20')); ?>px;
margin-<?php print $right; ?>: <?php print (GETPOST('optioncss','aZ09') == 'print'?8:(empty($conf->dol_optimize_smallscreen)?'16':'4')); ?>px;
margin-<?php print $right; ?>: <?php print (GETPOST('optioncss','aZ09') == 'print'?8:(empty($conf->dol_optimize_smallscreen)?'16':'12')); ?>px;
<?php if (! empty($conf->dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?>
margin-bottom: 15px;
}
......@@ -2769,7 +2769,7 @@ input.liste_titre {
}
.noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total {
/* background: #F0F0F0; */
height: 32px;
}
.noborder tr.liste_total td, tr.liste_total td, form.liste_total div {
/* border-top: 1px solid #f4f4f4; */
......@@ -2777,7 +2777,6 @@ input.liste_titre {
font-weight: normal;
white-space: nowrap;
padding: 4px;
height: 20px;
}
tr.liste_sub_total, tr.liste_sub_total td {
border-bottom: 2px solid #aaa;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment