Skip to content

Commit

Permalink
4.6.6 (#223)
Browse files Browse the repository at this point in the history
- support php 8
- show task even if not assigned anymore but with time
- fix chrono icon for apple
- add startime for chrono
- fix filer timesheet
- fix CSRF tocken issues
- fix js error element cannot be null
- fix css error
  • Loading branch information
delcroip authored Apr 9, 2023
1 parent 0af50a8 commit e60c667
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 37 deletions.
11 changes: 11 additions & 0 deletions htdocs/timesheet/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# dolibarr_project_timesheet changelog
4.6.6
- support php 8
- show task even if not assigned anymore but with time
- fix chrono icon for apple
- add startime for chrono
- fix filer timesheet
- fix CSRF tocken issues
- fix js error element cannot be null
- fix css error


4.6.0
- fix missing line in approvals
- fix php _ errors
Expand Down
29 changes: 15 additions & 14 deletions htdocs/timesheet/class/TimesheetTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class TimesheetTask extends Task
public $duration;
public $weekDays;
public $userName;
public $isOpen;

/**
* init the static variable
Expand Down Expand Up @@ -682,13 +683,13 @@ public function getTimesheetLine($headers, $tsUserId = 0, $blockOveride = 0, $ho
* Open task ?
*/
if ($this->status == INVOICED)$blockOveride = 1;// once invoice it should not change
$isOpenStatus = in_array($this->status, array(DRAFT, CANCELLED, REJECTED, PLANNED));

$isOpenStatus = $this->isOpen && in_array($this->status, array(DRAFT, CANCELLED, REJECTED, PLANNED));
if( $blockOveride == 1){
$isOpenStatus = false;
}else if ($blockOveride == -1){
$isOpenStatus = true;
$isOpenStatus = true && $isOpenStatus;
}

/*
* info section
*/
Expand Down Expand Up @@ -1083,6 +1084,9 @@ public function serialize($mode = 0)
$arRet['sender'] = $this->sender;
$arRet['task_timesheet'] = $this->task_timesheet;
$arRet['progress'] = $this->progress;
$arRet['isOpen'] = $this->isOpen;
$arRet['timespent_note'] = $this->timespent_note;

switch($mode) {
default:
case 0:
Expand Down Expand Up @@ -1329,8 +1333,8 @@ public function saveTaskTime($Submitter, $duration, $daynote, $dayKey, $addmode
{
$item = $this->tasklist[$dayKey];
$resArray = ['timeSpendDeleted'=>0, 'timeSpendModified' => 0, 'timeSpendCreated'=>0, 'updateError'=> 0, ];
$item_note = array_key_exists('note',$item ) ? $item['note']: '';
$item_note_old = $this->timespent_note;
$daynote_old = array_key_exists('note', $item) ? $item['note']:'';

$is_today=date("Y-m-d") == date("Y-m-d",$item['date']);
$this->timespent_fk_user = $this->userId;
dol_syslog(__METHOD__." duration Old=".$item['duration']." New="
Expand All @@ -1349,7 +1353,6 @@ public function saveTaskTime($Submitter, $duration, $daynote, $dayKey, $addmode
if ($item['id']>0) {
$this->timespent_id = $item['id'];
$this->timespent_old_duration = $item['duration'];
$this->timespent_note .= $item_note;
if ($addmode) {
if (!empty($daynote)){
$this->timespent_note .= "\n".$daynote;
Expand All @@ -1360,19 +1363,17 @@ public function saveTaskTime($Submitter, $duration, $daynote, $dayKey, $addmode
$this->timespent_duration = $duration;
}

if ($item['duration']!=$this->timespent_duration ||$item_note_old!=$item_note) {
if ($this->timespent_duration>0 || !empty($item_note)) {

if (($this->timespent_duration >0 && $this->timespent_old_duration!=$this->timespent_duration )|| $daynote_old!=$daynote && (!empty($daynote) || $this->timespent_duration >0)) {
dol_syslog(__METHOD__." taskTimeUpdate", LOG_DEBUG);
if ($this->updateTimeSpent($Submitter, 0) >= 0) {
$resArray['timeSpendModified']++;
} else {
}else {
$resArray['updateError']++;
}

} else if($this->timespent_duration == 0 && empty($daynote) ) {

} else {
$resArray['updateError']++;
}
} else {
dol_syslog(__METHOD__." taskTimeDelete", LOG_DEBUG);
if ($this->delTimeSpent($Submitter, 0) >= 0) {
$resArray['timeSpendDeleted']++;
Expand All @@ -1381,7 +1382,7 @@ public function saveTaskTime($Submitter, $duration, $daynote, $dayKey, $addmode
$resArray['updateError']++;
}
}
} elseif ($duration>0 || !empty($daynote)) {
} elseif ($duration>0 || $daynote!='') {
$this->timespent_note = $daynote;
$this->timespent_duration = $duration;

Expand Down
54 changes: 32 additions & 22 deletions htdocs/timesheet/class/TimesheetUserTasks.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,17 @@ public function fetchTaskTimesheet($userid = '')
$whiteList = $staticWhiteList->fetchUserList($userid, $datestart, $datestop);
// Save the param in the SeSSION
$tasksList = array();
$sql = 'SELECT DISTINCT element_id as taskid, prj.fk_soc, tsk.fk_projet, tsk.progress, ';
$sql = 'SELECT DISTINCT tsk.rowid as taskid, prj.fk_soc, tsk.fk_projet, tsk.progress, ctc.element as ectype, ';
$sql .= 'tsk.fk_task_parent, tsk.rowid, app.rowid as appid, prj.ref as prjRef, tsk.ref as tskRef, prj.fk_statut as p_status';
$sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec";
//$sql .= '(CASE WHEN ctc.element=\'project_task\' THEN 1 else 2 END) as prio';
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as tsk";
//$sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ec ON tsk.rowid = ec.element_id and ec.fk_socpeople = '.$userid;
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_contact as ctc ON(ctc.rowid = ec.fk_c_type_contact AND ctc.active = \'1\') ';
$sql .= ' JOIN '.MAIN_DB_PREFIX.'projet_task as tsk ON tsk.rowid = ec.element_id ';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as prj ON prj.rowid = tsk.fk_projet ';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_time as tskt ON tsk.rowid = tskt.fk_task and tskt.fk_user = '.$userid;
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as prj ON prj.rowid = tsk.fk_projet ' ;


//approval
if ($this->status == DRAFT || $this->status == REJECTED) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'project_task_time_approval as app ';
Expand All @@ -517,12 +522,14 @@ public function fetchTaskTimesheet($userid = '')
$sql .= ' AND app.date_end = \''.$this->db->idate($datestop).'\'';
//end approval
$sql .= " WHERE ((ec.fk_socpeople = '".$userid."' AND ctc.element = 'project_task') ";

// SHOW TASK ON PUBLIC PROEJCT
if (getConf('TIMESHEET_ALLOW_PUBLIC') == '1') {
$sql .= ' OR prj.public = \'1\')';
}else{
$sql .= ' )';
$sql .= ' OR prj.public = \'1\'';
}
$sql .= ' OR tskt.task_duration > 0';
$sql .= ' )';

if (getConf('TIMESHEET_HIDE_DRAFT') == '1') {
$sql .= ' AND prj.fk_statut != \'0\'';
}
Expand All @@ -533,11 +540,11 @@ public function fetchTaskTimesheet($userid = '')
// show task only of people on the same project (not used for team leader)
if ( !$user->admin && $userid != $user->id && !in_array($userid, $user->getAllChildIds())){
$sql .= " AND ((tsk.rowid in (SELECT element_id FROM ".MAIN_DB_PREFIX."element_contact as ec LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as ctc ON(ctc.rowid = ec.fk_c_type_contact AND ctc.active = '1')";
$sql .= " WHERE ec.fk_socpeople = '".$user->id."' AND ctc.element = 'project_task' AND element_id = tsk.rowid ))";
$sql .= " WHERE ctc.element = 'project_task' AND element_id = tsk.rowid ))";
$sql .= " OR (prj.rowid in (SELECT element_id FROM ".MAIN_DB_PREFIX."element_contact as ec LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as ctc ON(ctc.rowid = ec.fk_c_type_contact AND ctc.active = '1')";
$sql .= " WHERE ec.fk_socpeople = '".$user->id."' AND ctc.element = 'project' AND element_id = prj.rowid )))";
}
$sql .= ' ORDER BY prj.fk_soc, prjRef, tskRef ';
$sql .= ' ORDER BY prj.fk_soc, prjRef, tskRef';
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
Expand All @@ -551,21 +558,24 @@ public function fetchTaskTimesheet($userid = '')
{
$error = 0;
$obj = $this->db->fetch_object($resql);
$tasksList[$i] = NEW TimesheetTask($this->db, $obj->taskid);
//$tasksList[$i]->id = $obj->taskid;
if ($obj->appid) {
$tasksList[$i]->fetch($obj->appid);
}
$tasksList[$i]->userId = $this->userId;
$tasksList[$i]->date_start_approval = $this->date_start;
$tasksList[$i]->date_end_approval = $this->date_end;
$tasksList[$i]->task_timesheet = $this->id;
$tasksList[$i]->progress = $obj->progress;
$tasksList[$i]->listed = (is_array($whiteList) && array_key_exists($obj->taskid, $whiteList) )?$whiteList[$obj->taskid]:null;
// $tasksList[$i]->pStatus = $obj->p_status;
if (!(array_key_exists($obj->taskid,$tasksList) && $tasksList[$obj->taskid]->isOpen )) {
$tasksList[$obj->taskid] = NEW TimesheetTask($this->db, $obj->taskid);
//$tasksList[$obj->taskid]->id = $obj->taskid;
if ($obj->appid) {
$tasksList[$obj->taskid]->fetch($obj->appid);
}
$tasksList[$obj->taskid]->userId = $this->userId;
$tasksList[$obj->taskid]->date_start_approval = $this->date_start;
$tasksList[$obj->taskid]->date_end_approval = $this->date_end;
$tasksList[$obj->taskid]->task_timesheet = $this->id;
$tasksList[$obj->taskid]->progress = $obj->progress;
$tasksList[$obj->taskid]->isOpen = $obj->ectype == 'project_task' ? true : false;
$tasksList[$obj->taskid]->listed = (is_array($whiteList) && array_key_exists($obj->taskid, $whiteList) )?$whiteList[$obj->taskid]:null;
// $tasksList[$obj->taskid]->pStatus = $obj->p_status;

$ret[$obj->taskid] = $obj->appid;
}
$i++;
$ret[$obj->taskid] = $obj->appid;

}
$this->db->free($resql);
Expand Down
4 changes: 3 additions & 1 deletion htdocs/timesheet/core/modules/modtimesheet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public function __construct($db)
$this->editor_name = 'Patrick Delcroix';
$this->editor_url = 'https://github.com/delcroip';
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = '4.6.5';

$this->version = '4.6.6';

// Key used in llx_cons table to save module status enabled/disabled(where timesheet is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page(0=common, 1=interface, 2=others, 3=very specific)
Expand Down

0 comments on commit e60c667

Please sign in to comment.