diff --git a/build/makepack-timesheet.conf b/build/makepack-timesheet.conf index 11fba84..05d07f9 100644 --- a/build/makepack-timesheet.conf +++ b/build/makepack-timesheet.conf @@ -79,7 +79,7 @@ htdocs/timesheet/sql/llx_project_task_timesheet.sql htdocs/timesheet/sql/llx_project_task_timesheet.key.sql htdocs/timesheet/sql/llx_project_task_time_approval.sql htdocs/timesheet/sql/llx_project_task_time_approval.key.sql -htdocs/timesheet/sql/llx_projet_task_time.key.sql +htdocs/timesheet/sql/llx_element_time.key.sql htdocs/timesheet/sql/index.php #mains htdocs/timesheet/AttendanceClock.php diff --git a/htdocs/timesheet/ChangeLog.md b/htdocs/timesheet/ChangeLog.md index fce022b..2dbc683 100644 --- a/htdocs/timesheet/ChangeLog.md +++ b/htdocs/timesheet/ChangeLog.md @@ -1,4 +1,8 @@ # dolibarr_project_timesheet changelog +5.0.0 + - Support Dolibarr 18 + + 4.6.7 - support chrono on PSQL - better chrono error management diff --git a/htdocs/timesheet/Timesheet.php b/htdocs/timesheet/Timesheet.php index 13d6eb0..a48417f 100644 --- a/htdocs/timesheet/Timesheet.php +++ b/htdocs/timesheet/Timesheet.php @@ -197,12 +197,7 @@ $ref = dol_sanitizeFileName($object->ref); $upload_dir = $conf->timesheet->dir_output.'/users/' .get_exdir($object->id, 2, 0, 0, $object, 'timesheet').$ref; - if (version_compare(DOL_VERSION, "4.0") >= 0) { - include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; - } else{ - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; - //require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - } + include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; } /*************************************************** * VIEW diff --git a/htdocs/timesheet/TimesheetFavouriteAdmin.php b/htdocs/timesheet/TimesheetFavouriteAdmin.php index 526fe2f..e173c4e 100644 --- a/htdocs/timesheet/TimesheetFavouriteAdmin.php +++ b/htdocs/timesheet/TimesheetFavouriteAdmin.php @@ -245,11 +245,7 @@ case 'create': default: //document handling - if (version_compare(DOL_VERSION, "4.0") >= 0) { - include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; - } else{ - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; - } + include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; if (isset($_GET['urlfile'])) $action = 'viewdoc'; break; } diff --git a/htdocs/timesheet/TimesheetProjectInvoice.php b/htdocs/timesheet/TimesheetProjectInvoice.php index bcdc404..77eb78a 100644 --- a/htdocs/timesheet/TimesheetProjectInvoice.php +++ b/htdocs/timesheet/TimesheetProjectInvoice.php @@ -76,18 +76,18 @@ //steps switch($step) { case 2: - $fields = ($mode == 'user')?'fk_user':(($mode == 'taskUser')?'fk_user, fk_task':'fk_task'); - $sql = 'SELECT '.$fields.', SUM(tt.task_duration) as duration, '; + $fields = ($mode == 'user')?'fk_user':(($mode == 'taskUser')?'fk_user, fk_element':'fk_element'); + $sql = 'SELECT '.$fields.', SUM(tt.element_duration) as duration, '; if ($db->type!='pgsql') { $sql .= " GROUP_CONCAT(tt.rowid SEPARATOR ', ') as task_time_list"; } else{ $sql .= " STRING_AGG(to_char(tt.rowid, '9999999999999999'), ', ') as task_time_list"; } - $sql .= ' From '.MAIN_DB_PREFIX.'projet_task_time as tt'; - $sql .= ' JOIN '.MAIN_DB_PREFIX.'projet_task as t ON tt.fk_task = t.rowid'; + $sql .= ' From '.MAIN_DB_PREFIX.'element_time as tt'; + $sql .= ' JOIN '.MAIN_DB_PREFIX.'projet_task as t ON tt.fk_element = t.rowid'; if ($invoicabletaskOnly == 1)$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as tske ON tske.fk_object = t.rowid '; - $sql .= ' WHERE t.fk_projet='.$projectId; - $sql .= " AND DATE(tt.task_datehour) BETWEEN '".$db->idate($dateStart); + $sql .= " WHERE tt.elementtype = 'task' and t.fk_projet=".$projectId; + $sql .= " AND DATE(tt.element_datehour) BETWEEN '".$db->idate($dateStart); $sql .= "' AND '".$db->idate($dateEnd)."'"; if ($invoicabletaskOnly == 1)$sql .= ' AND tske.invoiceable = \'1\''; if ($ts2Invoice!='all') { @@ -132,12 +132,12 @@ break; case 'taskUser': //step 2.3 get the list of taskUser (all or approved) - $resArray[] = array("USER" => $obj->fk_user, "TASK" =>$obj->fk_task, "DURATION"=>$duration, 'LIST'=>$obj->task_time_list); + $resArray[] = array("USER" => $obj->fk_user, "TASK" =>$obj->fk_element, "DURATION"=>$duration, 'LIST'=>$obj->task_time_list); break; default: case 'task': //step 2.1 get the list of task (all or approved) - $resArray[] = array("USER" => "any", "TASK" =>$obj->fk_task, "DURATION"=>$duration, 'LIST'=>$obj->task_time_list); + $resArray[] = array("USER" => "any", "TASK" =>$obj->fk_element, "DURATION"=>$duration, 'LIST'=>$obj->task_time_list); break; } $i++; @@ -464,7 +464,6 @@ // End of object creation, we show it if (1) { - if (version_compare(DOL_VERSION, "4.9.9") >= 0) { foreach ($task_time_array AS $idLine => $task_time_list) { //dol_syslog("ProjectInvoice::setnvoice".$idLine.' '.$task_time_list, LOG_DEBUG); Update_task_time_invoice($id, $idLine, $task_time_list); @@ -473,7 +472,6 @@ //dol_syslog("ProjectInvoice::setnvoice".$idLine.' '.$task_time_list, LOG_DEBUG); Update_task_time_invoice(-1, -1, $task_time_list); } - } ob_start(); header('Location: ' . $object->getNomUrl(0, '', 0, 1, '')); ob_end_flush(); @@ -594,14 +592,11 @@ $Form .= ($ts2Invoice == "all"?"checked":"").'> ' .$langs->trans("All").""; // not alreqdy invoice - if (version_compare(DOL_VERSION, "4.9.9") >= 0) { - $Form .= '' - .$langs->trans('TimesheetNotInvoiced'); - $Form .= '' - .''; - } else{ - $Form .= ''; - } + $Form .= '' + .$langs->trans('TimesheetNotInvoiced'); + $Form .= '' + .''; + //$invoicabletaskOnly $Form .= ''.$langs->trans('InvoicableOnly'); $Form .= 'ref); $upload_dir = $conf->timesheet->dir_output.'/tasks/' .get_exdir($object->id, 2, 0, 0, $object, 'timesheet').$ref; - if (version_compare(DOL_VERSION, "4.0") >= 0) { - include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; - } else{ - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; - } + include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; } //Removing the $token array so the order can't be submitted two times if (isset($_SESSION['timesheet'][$token])) { diff --git a/htdocs/timesheet/class/TimesheetReport.class.php b/htdocs/timesheet/class/TimesheetReport.class.php index c45cf47..2397911 100644 --- a/htdocs/timesheet/class/TimesheetReport.class.php +++ b/htdocs/timesheet/class/TimesheetReport.class.php @@ -120,7 +120,7 @@ public function initBasic($projectid, $userid, $name, $startDate, $stopDate, $mo .str_replace('/', '-', dol_print_date($stopDate, 'day')); switch($mode){ case 'PDT': //project / task / Days //FIXME dayoff missing - $this->modeSQLOrder = 'ORDER BY ptt.fk_user,tsk.fk_projet, DATE(ptt.task_datehour), tsk.rowid ASC '; + $this->modeSQLOrder = 'ORDER BY ptt.fk_user,tsk.fk_projet, DATE(ptt.element_datehour), tsk.rowid ASC '; //title $this->lvl0Title = 'userName'; $this->lvl1Title = 'projectLabel'; @@ -137,7 +137,7 @@ public function initBasic($projectid, $userid, $name, $startDate, $stopDate, $mo $this->lvl2Key = 'dateDisplay'; break; case 'DPT'://day /project /task - $this->modeSQLOrder = 'ORDER BY ptt.fk_user,DATE(ptt.task_datehour), tsk.fk_projet, tsk.rowid ASC '; + $this->modeSQLOrder = 'ORDER BY ptt.fk_user,DATE(ptt.element_datehour), tsk.fk_projet, tsk.rowid ASC '; //title $this->lvl0Title = 'userName'; $this->lvl1Title = 'dateDisplay'; @@ -154,7 +154,7 @@ public function initBasic($projectid, $userid, $name, $startDate, $stopDate, $mo $this->lvl2Key = 'projectId'; break; case 'PTD'://day /project /task - $this->modeSQLOrder = 'ORDER BY ptt.fk_user,tsk.fk_projet, tsk.rowid, DATE(ptt.task_datehour) ASC '; + $this->modeSQLOrder = 'ORDER BY ptt.fk_user,tsk.fk_projet, tsk.rowid, DATE(ptt.element_datehour) ASC '; //title $this->lvl0Title = 'userName'; $this->lvl1Title = 'projectLabel'; @@ -171,7 +171,7 @@ public function initBasic($projectid, $userid, $name, $startDate, $stopDate, $mo $this->lvl2Key = 'taskId'; break; case 'UDT': //project / task / Days //FIXME dayoff missing - $this->modeSQLOrder = 'ORDER BY tsk.fk_projet,ptt.fk_user, DATE(ptt.task_datehour), tsk.rowid ASC '; + $this->modeSQLOrder = 'ORDER BY tsk.fk_projet,ptt.fk_user, DATE(ptt.element_datehour), tsk.rowid ASC '; //title $this->lvl0Title = 'projectLabel'; $this->lvl1Title = 'userName'; @@ -188,7 +188,7 @@ public function initBasic($projectid, $userid, $name, $startDate, $stopDate, $mo $this->lvl2Key = 'dateDisplay'; break; case 'DUT'://day /project /task - $this->modeSQLOrder = 'ORDER BY tsk.fk_projet,DATE(ptt.task_datehour), ptt.fk_user, tsk.rowid ASC '; + $this->modeSQLOrder = 'ORDER BY tsk.fk_projet,DATE(ptt.element_datehour), ptt.fk_user, tsk.rowid ASC '; //title $this->lvl0Title = 'projectLabel'; $this->lvl1Title = 'dateDisplay'; @@ -205,7 +205,7 @@ public function initBasic($projectid, $userid, $name, $startDate, $stopDate, $mo $this->lvl2Key = 'userId'; break; case 'UTD'://day /project /task - $this->modeSQLOrder = ' ORDER BY tsk.fk_projet,ptt.fk_user, tsk.rowid, DATE(ptt.task_datehour) ASC '; + $this->modeSQLOrder = ' ORDER BY tsk.fk_projet,ptt.fk_user, tsk.rowid, DATE(ptt.element_datehour) ASC '; $this->lvl0Title='projectLabel'; $this->lvl1Title = 'userName'; $this->lvl2Title = 'taskLabel'; @@ -235,25 +235,21 @@ public function getReportArray($forceGroup = false) $first = true; $sql = 'SELECT tsk.fk_projet as projectid, ptt.fk_user as userid, tsk.rowid as taskid, '; - if (version_compare(DOL_VERSION, "4.9.9") >= 0) { - $sql .= ' (ptt.invoice_id > 0 or ptt.invoice_line_id>0) AS invoiced,'; - }else{ - $sql .= ' 0 AS invoiced,'; - } + $sql .= ' (ptt.invoice_id > 0 or ptt.invoice_line_id>0) AS invoiced,'; if ($forceGroup == 1){ if ($this->db->type!='pgsql') { $sql .= " MAX(ptt.rowid) as id, GROUP_CONCAT(ptt.note SEPARATOR '. ') as note, MAX(tske.invoiceable) as invoicable, "; } else { $sql .= " MAX(ptt.rowid) as id, STRING_AGG(ptt.note, '. ') as note, MAX(tske.invoiceable) as invoicable, "; } - $sql .= ' DATE(ptt.task_datehour) AS task_date, SUM(ptt.task_duration) as duration '; + $sql .= ' DATE(ptt.element_datehour) AS element_date, SUM(ptt.element_duration) as duration '; }else{ $sql .= " ptt.rowid as id, ptt.note as note, tske.invoiceable as invoicable, "; - $sql .= ' DATE(ptt.task_datehour) AS task_date, ptt.task_duration as duration '; + $sql .= ' DATE(ptt.element_datehour) AS element_date, ptt.element_duration as duration '; } - $sql .= ' FROM '.MAIN_DB_PREFIX.'projet_task_time as ptt '; - $sql .= ' JOIN '.MAIN_DB_PREFIX.'projet_task as tsk ON tsk.rowid = fk_task '; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as tske ON tske.fk_object = fk_task '; + $sql .= ' FROM '.MAIN_DB_PREFIX.'element_time as ptt '; + $sql .= ' JOIN '.MAIN_DB_PREFIX."projet_task as tsk ON tsk.rowid = fk_element and elementtype = 'task' "; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as tske ON tske.fk_object = tsk.rowid '; $sql .= ' WHERE '; if (!empty($this->userid)) { $sql .= ' ptt.fk_user IN (\''.implode("','", array_keys($this->user)).'\') '; @@ -270,10 +266,10 @@ public function getReportArray($forceGroup = false) $sql .= ($first?'':'AND ').'tske.invoiceable = \'1\''; } - $sql .= ($first?'':'AND ').' DATE(task_datehour) >= \''.$this->db->idate($this->startDate).'\''; - $sql .= ' AND DATE(task_datehour) <= \''.$this->db->idate($this->stopDate).'\''; - $sql .= ' AND (ptt.task_duration > 0 or LENGTH(ptt.note)>0)'; - if ($forceGroup == 1)$sql .= ' GROUP BY ptt.fk_user, tsk.fk_projet, tsk.rowid, DATE(ptt.task_datehour), (ptt.invoice_id > 0 or ptt.invoice_line_id>0)'; + $sql .= ($first?'':'AND ').' DATE(element_datehour) >= \''.$this->db->idate($this->startDate).'\''; + $sql .= ' AND DATE(element_datehour) <= \''.$this->db->idate($this->stopDate).'\''; + $sql .= ' AND (ptt.element_duration > 0 or LENGTH(ptt.note)>0)'; + if ($forceGroup == 1)$sql .= ' GROUP BY ptt.fk_user, tsk.fk_projet, tsk.rowid, DATE(ptt.element_datehour), (ptt.invoice_id > 0 or ptt.invoice_line_id>0)'; $sql .= $this->modeSQLOrder; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -333,8 +329,8 @@ public function getReportArray($forceGroup = false) 'taskRef' => $objtsk->ref, 'taskLink' => $objtsk->getNomUrl(0, "withproject", "task", getConf('TIMESHEET_HIDE_REF')), 'tasktitle' => $objtsk->label, - 'date' => $this->db->jdate($obj->task_date), - 'dateDisplay' => dol_print_date($this->db->jdate($obj->task_date), 'day'), + 'date' => $this->db->jdate($obj->element_date), + 'dateDisplay' => dol_print_date($this->db->jdate($obj->element_date), 'day'), 'duration' => $obj->duration, 'durationHours' => formatTime($obj->duration, 0), 'durationDays' => formatTime($obj->duration, -3), diff --git a/htdocs/timesheet/class/TimesheetTask.class.php b/htdocs/timesheet/class/TimesheetTask.class.php index 9f944ad..ae6700f 100644 --- a/htdocs/timesheet/class/TimesheetTask.class.php +++ b/htdocs/timesheet/class/TimesheetTask.class.php @@ -429,7 +429,7 @@ public function delete($user, $notrigger = 0) } } $ids = implode(', ', $idList); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET fk_task_time_approval = \''; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'element_time SET fk_task_time_approval = \''; $sql .= $this->appId.'\', status = \''.$status.'\' WHERE rowid in ('.$ids.')'; // SQL start dol_syslog(__METHOD__, LOG_DEBUG); @@ -561,26 +561,22 @@ public function getActuals($timeStart = 0, $timeEnd = 0, $userid = 0) $this->timespent_fk_user = $userid; $dayelapsed = getDayInterval($timeStart, $timeEnd); if ($dayelapsed<1)return -1; - $sql = "SELECT ptt.rowid, ptt.task_duration, DATE(ptt.task_datehour) AS task_date, ptt.note"; - if (version_compare(DOL_VERSION, "4.9.9") >= 0) { - $sql .= ', (ptt.invoice_id > 0 or ptt.invoice_line_id>0) AS invoiced'; - }else{ - $sql .= ', 0 AS invoiced'; - } - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt"; + $sql = "SELECT ptt.rowid, ptt.element_duration, DATE(ptt.element_datehour) AS element_date, ptt.note"; + $sql .= ', (ptt.invoice_id > 0 or ptt.invoice_line_id>0) AS invoiced'; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time AS ptt"; $sql .= " WHERE "; if ($this->id == -1 && is_array($this->exclusionlist)){ - $sql .= " ptt.fk_task not in ('".implode("','",$this->exclusionlist)."') "; + $sql .= " ptt.elementtype = 'task' and ptt.fk_element not in ('".implode("','",$this->exclusionlist)."') "; $sql .= " AND (ptt.fk_user = '".$userid."') "; - $sql .= " AND (DATE(ptt.task_datehour) >= '".$this->db->idate($timeStart)."') "; - $sql .= " AND (DATE(ptt.task_datehour)<'".$this->db->idate($timeEnd)."')"; + $sql .= " AND (DATE(ptt.element_datehour) >= '".$this->db->idate($timeStart)."') "; + $sql .= " AND (DATE(ptt.element_datehour)<'".$this->db->idate($timeEnd)."')"; }elseif (in_array($this->status, array(SUBMITTED, UNDERAPPROVAL, APPROVED, CHALLENGED, INVOICED))) { $sql .= ' ptt.fk_task_time_approval = \''.$this->appId.'\''; } else { - $sql .= " ptt.fk_task = '".$this->id."' "; + $sql .= " ptt.fk_element = '".$this->id."' and ptt.elementtype = 'task' "; $sql .= " AND (ptt.fk_user = '".$userid."') "; - $sql .= " AND (DATE(ptt.task_datehour) >= '".$this->db->idate($timeStart)."') "; - $sql .= " AND (DATE(ptt.task_datehour)<'".$this->db->idate($timeEnd)."')"; + $sql .= " AND (DATE(ptt.element_datehour) >= '".$this->db->idate($timeStart)."') "; + $sql .= " AND (DATE(ptt.element_datehour)<'".$this->db->idate($timeEnd)."')"; } dol_syslog(__METHOD__, LOG_DEBUG); $other = array(); @@ -602,7 +598,7 @@ public function getActuals($timeStart = 0, $timeEnd = 0, $userid = 0) $error = 0; $obj = $this->db->fetch_object($resql); - $dateCur = $this->db->jdate($obj->task_date); + $dateCur = $this->db->jdate($obj->element_date); $day = getDayInterval($timeStart, $dateCur); if(!isset($this->tasklist[$day]['note'])){ $this->tasklist[$day]['note'] = ''; @@ -614,11 +610,12 @@ public function getActuals($timeStart = 0, $timeEnd = 0, $userid = 0) } $this->tasklist[$day] = array('id'=>$obj->rowid, 'date'=>$dateCur, - 'duration'=> $obj->task_duration, 'note'=>$obj->note, + 'duration'=> $obj->element_duration, 'note'=>$obj->note, + 'invoiced' => $obj->invoiced); if (is_array($other[$day]) > 0) $this->tasklist[$day]['other'] = $other[$day]; - // $this->tasklistAll[] = array('day' => $day, 'id'=>$obj->rowid, 'date'=>$dateCur, 'duration'=>$obj->task_duration, 'note'=>$obj->note, 'invoiced' => $obj->invoiced); + // $this->tasklistAll[] = array('day' => $day, 'id'=>$obj->rowid, 'date'=>$dateCur, 'duration'=>$obj->element_duration, 'note'=>$obj->note, 'invoiced' => $obj->invoiced); $i++; } $this->db->free($resql); @@ -1152,9 +1149,9 @@ public function updateTimeUsed() $this->db->begin(); $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task AS pt "; - $sql .= "SET duration_effective = (SELECT SUM(ptt.task_duration) "; - $sql .= "FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt "; - $sql .= "WHERE ptt.fk_task = '".$this->id."') "; + $sql .= "SET duration_effective = (SELECT SUM(ptt.element_duration) "; + $sql .= "FROM ".MAIN_DB_PREFIX."element_time AS ptt "; + $sql .= "WHERE ptt.elementtype = 'task' and ptt.fk_element = '".$this->id."') "; if (isset($this->progress) && $this->progress != '') $sql .= " , progress = '".$this->progress."'"; $sql .= " WHERE pt.rowid = '".$this->id."' "; dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/timesheet/class/TimesheetUserTasks.class.php b/htdocs/timesheet/class/TimesheetUserTasks.class.php index 4c80808..5bcb7a7 100644 --- a/htdocs/timesheet/class/TimesheetUserTasks.class.php +++ b/htdocs/timesheet/class/TimesheetUserTasks.class.php @@ -507,7 +507,7 @@ public function fetchTaskTimesheet($userid = '') //$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 .= ' 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."element_time as tskt ON tsk.rowid = tskt.fk_element and tskt.elementtype = 'task' and tskt.fk_user = ".$userid; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as prj ON prj.rowid = tsk.fk_projet ' ; @@ -527,7 +527,7 @@ public function fetchTaskTimesheet($userid = '') if (getConf('TIMESHEET_ALLOW_PUBLIC') == '1') { $sql .= ' OR prj.public = \'1\''; } - $sql .= ' OR tskt.task_duration > 0'; + $sql .= ' OR tskt.element_duration > 0'; $sql .= ' )'; if (getConf('TIMESHEET_HIDE_DRAFT') == '1') { @@ -1336,13 +1336,14 @@ public function sendTimesheetReminders() $date_start = getStartDate(time(), -1); $date_end = getEndDate($date_start); $ret = true; - $sql = "SELECT SUM(pt.task_duration)/3600 as duration, u.weeklyhours + $sql = "SELECT SUM(pt.element_duration)/3600 as duration, u.weeklyhours u.email, u.weeklyhours FROM ".MAIN_DB_PREFIX."element_contact as ec ON t.rowid = ec.element_id LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as ctc ON ctc.rowid = fk_c_type_contact - LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time pt ON pt.fk_user = fk_socpeople + LEFT JOIN ".MAIN_DB_PREFIX."element_time pt ON pt.fk_user = fk_socpeople LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = fk_socpeople WHERE (ctc.element in (\'project\') + and pt.element_date BETWEEN $date_start AND $date_end and pt.task_date BETWEEN $date_start AND $date_end GROUP BY u.rowid "; diff --git a/htdocs/timesheet/core/boxes/box_time.php b/htdocs/timesheet/core/boxes/box_time.php index 27144fc..52f9612 100644 --- a/htdocs/timesheet/core/boxes/box_time.php +++ b/htdocs/timesheet/core/boxes/box_time.php @@ -75,21 +75,21 @@ public function loadBox($max = 5) digit d order by 1 ) - SELECT SUM(pt.task_duration)/3600 as duration, + SELECT SUM(pt.element_duration)/3600 as duration, w.week, u.weeklyhours FROM (SELECT YEARWEEK(DATE_ADD(NOW(), INTERVAL - num WEEK)) as week FROM seq WHERE num <= ".getConf('TIMESHEET_OVERTIME_CHECK_WEEKS',4)." AND num > 1 ) as w - LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time pt ON YEARWEEK(pt.task_date) = w.week + LEFT JOIN ".MAIN_DB_PREFIX."element_time pt ON YEARWEEK(pt.element_date) = w.week LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = ".$userid." WHERE pt.fk_user = ".$userid." OR pt.fk_user is null GROUP BY w.week;"; }else { // to be validated - $sqlweek = "SELECT SUM(pt.task_duration)/3600 as duration, TO_CHAR(generate_series, 'YYYYWW') as week, u.weeklyhours + $sqlweek = "SELECT SUM(pt.element_duration)/3600 as duration, TO_CHAR(generate_series, 'YYYYWW') as week, u.weeklyhours FROM generate_series(DATE_TRUNC('week', (now() - INTERVAL '".getConf('TIMESHEET_OVERTIME_CHECK_WEEKS',4)." week'))::timestamp, DATE_TRUNC('week', (now() - INTERVAL '1 WEEK' ))::timestamp, interval '1 week') - LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time pt ON (generate_series = DATE_TRUNC('week',pt.task_date)) + LEFT JOIN ".MAIN_DB_PREFIX."element_time pt ON (generate_series = DATE_TRUNC('week',pt.element_date)) LEFT JOIN ".MAIN_DB_PREFIX."user u on (pt.fk_user = ".$userid.") WHERE pt.fk_user = ".$userid." OR pt.fk_user is null GROUP BY generate_series, u.weeklyhours;"; } diff --git a/htdocs/timesheet/core/modules/modtimesheet.class.php b/htdocs/timesheet/core/modules/modtimesheet.class.php index c314207..28a4076 100644 --- a/htdocs/timesheet/core/modules/modtimesheet.class.php +++ b/htdocs/timesheet/core/modules/modtimesheet.class.php @@ -55,7 +55,8 @@ public function __construct($db) $this->editor_url = 'https://github.com/delcroip'; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = '4.6.7'; + $this->version = '5.0.0'; + // Key used in llx_cons table to save module status enabled/disabled(where timesheet is value of property name of module in uppercase) @@ -100,7 +101,7 @@ public function __construct($db) $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with $this->phpmin = array(5, 0); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3, 5); // Minimum version of Dolibarr required by module + $this->need_dolibarr_version = array(18, 0); // Minimum version of Dolibarr required by module $this->langfiles = array("timesheet@timesheet"); // Constants // List of particular constants to add when module is enabled(key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) diff --git a/htdocs/timesheet/sql/llx_projet_task_time.key.sql b/htdocs/timesheet/sql/llx_projet_task_time.key.sql index f637950..98ed45c 100644 --- a/htdocs/timesheet/sql/llx_projet_task_time.key.sql +++ b/htdocs/timesheet/sql/llx_projet_task_time.key.sql @@ -17,11 +17,11 @@ -- =================================================================== -- TS Revision 2.0.2 -ALTER TABLE llx_projet_task_time ADD COLUMN status integer default 1; -- enum('DRAFT','SUBMITTED','APPROVED','CANCELLED','REJECTED','CHALLENGED','INVOICED','UNDERAPPROVAL','PLANNED') DEFAULT 'DRAFT'; -ALTER TABLE llx_projet_task_time ADD COLUMN fk_task_time_approval integer; +ALTER TABLE llx_element_time ADD COLUMN status integer default 1; -- enum('DRAFT','SUBMITTED','APPROVED','CANCELLED','REJECTED','CHALLENGED','INVOICED','UNDERAPPROVAL','PLANNED') DEFAULT 'DRAFT'; +ALTER TABLE llx_element_time ADD COLUMN fk_task_time_approval integer; -ALTER TABLE llx_projet_task_time ADD CONSTRAINT fk_ptt_ptta_id FOREIGN KEY (fk_task_time_approval) REFERENCES llx_project_task_time_approval(rowid) ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE llx_element_time ADD CONSTRAINT fk_ptt_ptta_id FOREIGN KEY (fk_task_time_approval) REFERENCES llx_project_task_time_approval(rowid) ON DELETE SET NULL ON UPDATE CASCADE; --/*llx_projet_task_tim remove enum 2.3.3.5 --> 2.4*/ -ALTER TABLE llx_projet_task_time MODIFY COLUMN status integer default 1; +ALTER TABLE llx_element_time MODIFY COLUMN status integer default 1;