Skip to content

Commit

Permalink
Merge pull request #179 from delcroip/develop
Browse files Browse the repository at this point in the history
rev 4.5.0
  • Loading branch information
delcroip authored Feb 20, 2022
2 parents d25a848 + dc5c3a7 commit eadcee9
Show file tree
Hide file tree
Showing 24 changed files with 807 additions and 207 deletions.
1 change: 1 addition & 0 deletions build/makepack-timesheet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ htdocs/timesheet/class/TimesheetUserTasks.class.php
htdocs/timesheet/class/index.php
#homebox
htdocs/timesheet/core/boxes/box_approval.php
htdocs/timesheet/core/boxes/box_time.php
htdocs/timesheet/core/boxes/index.php
#css
htdocs/timesheet/core/css/timesheet.css
Expand Down
4 changes: 3 additions & 1 deletion htdocs/timesheet/AttendanceClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
if (!empty($token)) {
unset($_SESSION['timesheet'][$token]);
}

$token = getToken();
$_SESSION['timesheet'][$token] = array();
/***************************************************
* VIEW
*
Expand Down Expand Up @@ -167,6 +168,7 @@
$html .= '</div>';
}
$html .= '<td span = "0"><input type = "texte" name = "taskSearch" onkeyup = "searchTask(this)"></td></tr>';
$html .= '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token."\"/>\n";
$htmltmp .= $timesheet_attendance->printHTMLTaskList($headers, $userid);
$pattern = "/(progressTask\[[^\]]+\]\[[^\]]+\])/i";
$replacement = '$1" onchange="updateProgress(event);';
Expand Down
15 changes: 13 additions & 2 deletions htdocs/timesheet/Timesheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
$userid = is_object($user)?$user->id:$user;
$postUserId = GETPOST('userid', 'int');
$submitted = GETPOST('submit', 'alpha');
$submitted_next = GETPOST('submit_next', 'alpha');
$save_next = GETPOST('save_next', 'alpha');
$tsUserId = GETPOST('tsUserId', 'int');

$admin = $user->admin || $user->rights->timesheet->timesheet->admin;
Expand All @@ -66,7 +68,7 @@
}
$SubordiateIds = getSubordinates($db, $userid, 2, array(), ALL, $entity = '1');
//$SubordiateIds[] = $userid;
if ($newuserid > 0 && in_array($newuserid, $SubordiateIds) || $admin) {
if ($newuserid > 0 && in_array($newuserid, $SubordiateIds) || $admin || $newuserid == $userid) {
$SubordiateIds[] = $userid;
$userid = $newuserid;
} elseif ($action == 'getOtherTs') {
Expand Down Expand Up @@ -124,7 +126,7 @@
$task_timesheet->update($user);
}
$ret = $task_timesheet->updateActuals($tasktab, $notesTask, $progressTask);
if ($submitted) {
if ($submitted || $submitted_next) {
$task_timesheet->setStatus($user, SUBMITTED);
$ret++;
//$task_timesheet->status = "SUBMITTED";
Expand Down Expand Up @@ -160,6 +162,15 @@
if (!empty($token)) {
unset($_SESSION['timesheet'][$token]);
}

if ($submitted_next ||$saved_next ){
$dateStart = getStartDate($dateStart, 1);
$_SESSION["dateStart"] = $dateStart ;
}




$task_timesheet->fetchAll($dateStart, $whitelistmode);
if ($action == 'importCalandar'){
$task_timesheet->importCalandar();
Expand Down
291 changes: 237 additions & 54 deletions htdocs/timesheet/TimesheetProjectInvoice.php

Large diffs are not rendered by default.

39 changes: 30 additions & 9 deletions htdocs/timesheet/TimesheetReportUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
$short = GETPOST('short', 'int');
$invoicedCol = GETPOST('invoicedcol', 'int');
$ungroup = GETPOST('ungroup', 'int');

$show_all = GETPOST('showAll', 'int');

//$userSelected = $userList[$userIdSelected];
$year = GETPOST('year', 'int');
Expand All @@ -93,8 +93,13 @@

// if the user can see ts for other the user id is diferent
$userIdlist = array();
$userIdlistfull = getSubordinates($db, $userid, 2, array(), ALL, $entity = '1');
if (!empty($userIdSelected) && $userIdSelected <> -999 && $userIdSelected <> $userid) {
$userIdlistfull = getSubordinates($db, $userid, 2, array(), $admin ? ADMIN : ALL, $entity = '1', $admin);
if ($show_all)
{
$userIdlistfull[] = $userid;
$userIdlist = $userIdlistfull;

}else if (!empty($userIdSelected) && $userIdSelected <> $userid) {

$userIdlistfull[] = $userid;
if (in_array($userIdSelected, $userIdlist) || $admin ) {
Expand All @@ -104,10 +109,7 @@
unset($action);
$userIdlist[] = $userid;
}
} elseif ($userIdSelected == -999)
{
$userIdlist = $userIdlistfull;
}else{
} else{
$userIdlist[] = $userid;
}

Expand Down Expand Up @@ -163,6 +165,9 @@
';
if($admin){
$form_output .= $form->select_dolusers($userIdSelected, 'userSelected');
// select short
$form_output .= ' <br><input type = "checkbox" name = "showAll" value = "1" ';
$form_output .= ($show_all?'checked >':'>').$langs->trans('All') ;
} else {
$form_output .= $form->select_dolusers($userIdSelected, 'userSelected', 0, null, 0, $userIdlist);
}
Expand Down Expand Up @@ -222,10 +227,26 @@
$model = $conf->global->TIMESHEET_EXPORT_FORMAT;
//if(!empty($querryRes))$form_output .= '<a class = "butAction" href="?action=getpdf&dateStart='.dol_print_date($dateStart, 'dayxcard').'&dateEnd='.dol_print_date($dateEnd, 'dayxcard').'&projectSelected='.$projectSelectedId.'&mode=DTU&invoicabletaskOnly='.$invoicabletaskOnly.'" >'.$langs->trans('TimesheetPDF').'</a>';
if ( ! empty( $querryRes ) && $conf->global->MAIN_MODULE_EXPORT ) {
$form_output .= '<a class = "butAction" href="?action=getExport&dateStart=' . dol_print_date( $dateStart, 'dayxcard' ) . '&dateEnd=' . dol_print_date( $dateEnd, 'dayxcard' ) . '&userSelected=' . $userIdSelected . '&mode=DTU&model=' . $model . '&invoicabletaskOnly=' . $invoicabletaskOnly . '&ungroup=' . $ungroup . '" >' . $langs->trans( 'Export' ) . '</a>';
$form_output .= '<a class = "butAction" href="?action=getExport&dateStart='
.dol_print_date( $dateStart, 'dayxcard' )
.'&dateEnd=' . dol_print_date( $dateEnd, 'dayxcard' )
.'&userSelected=' . $userIdSelected
.'&mode=DTU&model=' . $model
.'&invoicabletaskOnly=' . $invoicabletaskOnly
.'&ungroup=' . $ungroup
.'&showAll=' . $show_all
. '" >' . $langs->trans( 'Export' ) . '</a>';
}
if ( ! empty( $querryRes ) ) {
$form_output .= '<a class = "butAction" href="?action=getpdf&dateStart=' . dol_print_date( $dateStart, 'dayxcard' ) . '&dateEnd=' . dol_print_date( $dateEnd, 'dayxcard' ) . '&userSelected=' . $userIdSelected . '&mode=DTU&model=' . $model . '&invoicabletaskOnly=' . $invoicabletaskOnly . '&ungroup=' . $ungroup . '" >' . $langs->trans( 'PDF' ) . '</a>';
$form_output .= '<a class = "butAction" href="?action=getpdf&dateStart='
. dol_print_date( $dateStart, 'dayxcard' )
. '&dateEnd=' . dol_print_date( $dateEnd, 'dayxcard' )
. '&userSelected=' . $userIdSelected
. '&mode=DTU&model=' . $model
. '&invoicabletaskOnly=' . $invoicabletaskOnly
. '&ungroup=' . $ungroup
. '&showAll=' . $show_all
. '" >' . $langs->trans( 'PDF' ) . '</a>';
}
$form_output .= '</div></div></form>';

Expand Down
23 changes: 13 additions & 10 deletions htdocs/timesheet/TimesheetTeamApproval.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,23 @@
if ($conf->global->TIMESHEET_ADD_DOCS == 1) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$formfile = new FormFile($db);
$object = $TTU;
$relativepathwithnofile = '';
$modulepart = 'timesheet';
$permission = 1;//$user->rights->timesheet->add;
$param = '&action=viewdoc&id='.$object->id;
$ref = dol_sanitizeFileName($object->ref);
$upload_dir = $conf->timesheet->dir_output.'/tasks/'
$upload_dir = $conf->timesheet->dir_output.'/users/'
.get_exdir($object->id, 2, 0, 0, $object, 'timesheet').$ref;
$filearray = dol_dir_list($upload_dir, 'files',
0, '', '\.meta$', $sortfield,
$filearray = dol_dir_list($upload_dir, 'files', 0, '', '\.meta$', $sortfield,
(strtolower($sortorder) == 'desc'?SORT_DESC:SORT_ASC), 1);
//$param = 'action = submitfile&id='.$object->id;
$param = '';
$disablemove = 1;
$formfile = new FormFile($db);
ob_start();
$formfile->list_of_documents($filearray, $object, $modulepart,
$param, 0, $relativepathwithnofile, $permission);
$formfile->list_of_documents(
$filearray, $object, $modulepart, $param,
0, '', 0, 0, '', 0, '', '', 0, 0,
$upload_dir, $sortfield, $sortorder, $disablemove);
$Form .= ob_get_contents().'<br>'."\n";
ob_end_clean();
}
Expand Down Expand Up @@ -313,9 +315,10 @@ function getTStobeApproved($level, $offset, $role, $subId)
$obj = $db->fetch_object($resql);
$tmpTs = NEW TimesheetUserTasks($db, $obj->fk_userid);
$tmpTs->id = $obj->rowid;
//$tmpTs->userId = $obj->fk_userid;
$tmpTs->userId = $obj->fk_userid;
$tmpTs->date_start = $tmpTs->db->jdate($obj->date_start);
$tmpTs->date_start_end = $tmpTs->db->jdate($obj->date_start);
$tmpTs->ref = $tmpTs->date_start.'_'.$tmpTs->userId;
//$tmpTs->date_end = $tmpTs->db->jdate($obj->date_start);
$tmpTs->status = $obj->status;
$tmpTs->planned_workload = $obj->planned_workload;
$tmpTs->note = $obj->note;
Expand Down
30 changes: 26 additions & 4 deletions htdocs/timesheet/admin/timesheetsetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@
$blockholiday = $conf->global->TIMESHEET_BLOCK_HOLIDAY;
$addpublicholidaytime = $conf->global->TIMESHEET_ADD_PUBLICHOLIDAY_TIME;
$blockpublicholiday = $conf->global->TIMESHEET_BLOCK_PUBLICHOLIDAY;
$overtimecheckweeks = $conf->global->TIMESHEET_OVERTIME_CHECK_WEEKS;
$opendays = str_split($conf->global->TIMESHEET_OPEN_DAYS);

//approval
$approvalbyweek = $conf->global->TIMESHEET_APPROVAL_BY_WEEK;
$maxApproval = $conf->global->TIMESHEET_MAX_APPROVAL;
$apflows = str_split($conf->global->TIMESHEET_APPROVAL_FLOWS);
if (count($apflows) != 6) {
$apflows = array('_', '0', '0', '0', '0', '0');
}

//Invoice part
$invoicemethod = $conf->global->TIMESHEET_INVOICE_METHOD;
$invoicetasktime = $conf->global->TIMESHEET_INVOICE_TASKTIME;
Expand All @@ -94,13 +97,16 @@
$exportFormat = $conf->global->TIMESHEET_EXPORT_FORMAT;
$evalAddLine = $conf->global->TIMESHEET_EVAL_ADDLINE;
$tsRound = intval($conf->global->TIMESHEET_ROUND);
$importagenda = intval($conf->global->TIMESHEET_IMPORT_AGENDA);
$dropdownAjax = $conf->global->MAIN_DISABLE_AJAX_COMBOX;
$searchbox = intval($conf->global->TIMESHEET_SEARCHBOX);
$unblockInvoiced = $conf->global->TIMESHEET_UNBLOCK_INVOICED;
$unblockClosed = $conf->global->TIMESHEET_UNBLOCK_CLOSED;
$reportInvoicedCol= $conf->global->TIMESHEET_REPORT_INVOICED_COL;
$reportUngroup = $conf->global->TIMESHEET_REPORT_UNGROUP;
$allowPublic = $conf->global->TIMESHEET_ALLOW_PUBLIC;


if (count($opendays)!=8) {
$opendays = array('_', '0', '0', '0', '0', '0', '0', '0');
}
Expand Down Expand Up @@ -216,6 +222,10 @@ function null2int($var, $int = 0)
// block public holday
$blockpublicholiday = getpost('blockpublicholiday', 'alpha');
dolibarr_set_const($db, "TIMESHEET_BLOCK_PUBLICHOLIDAY", $blockpublicholiday, 'chaine', 0, '', $conf->entity);

// number of week to check for overtime box
$overtimecheckweeks = getpost('overtimecheckweeks', 'alpha');
dolibarr_set_const($db, "TIMESHEET_OVERTIME_CHECK_WEEKS", $overtimecheckweeks, 'chaine', 0, '', $conf->entity);
//docs
$adddocs = getpost('adddocs', 'int');
dolibarr_set_const($db, "TIMESHEET_ADD_DOCS", $adddocs, 'chaine', 0, '', $conf->entity);
Expand All @@ -238,7 +248,7 @@ function null2int($var, $int = 0)
dolibarr_set_const($db, "TIMESHEET_INVOICE_TASKTIME", $invoicetasktime, 'chaine', 0, '', $conf->entity);
$invoicetimetype = getpost('invoiceTimeType', 'alpha');
dolibarr_set_const($db, "TIMESHEET_INVOICE_TIMETYPE", $invoicetimetype, 'chaine', 0, '', $conf->entity);
$invoiceservice = getpost('invoiceService', 'int');
$invoiceservice = getpost('invoiceservice', 'int');
dolibarr_set_const($db, "TIMESHEET_INVOICE_SERVICE", $invoiceservice, 'int', 0, '', $conf->entity);
$invoiceshowtask = getpost('invoiceShowTask', 'int');
dolibarr_set_const($db, "TIMESHEET_INVOICE_SHOW_TASK", $invoiceshowtask, 'int', 0, '', $conf->entity);
Expand Down Expand Up @@ -276,7 +286,8 @@ function null2int($var, $int = 0)
dolibarr_set_const($db, "TIMESHEET_ALLOW_PUBLIC", $allowPublic, 'int', 0, '', $conf->entity);
$tsRound = getpost('tsRound', 'int');
dolibarr_set_const($db, "TIMESHEET_ROUND", $tsRound, 'int', 0, '', $conf->entity);

$importagenda = getpost('importagenda', 'int');
dolibarr_set_const($db, "TIMESHEET_IMPORT_AGENDA", $importagenda, 'int', 0, '', $conf->entity);

break;
default:
Expand Down Expand Up @@ -402,6 +413,12 @@ function null2int($var, $int = 0)
echo '</td><td align="left">'.$langs->trans("blockpublicholidayDesc").'</td>';
echo '<td align="left"><input type = "checkbox" name = "blockpublicholiday" value="1" ';
echo (($blockpublicholiday == '1')?'checked':'')."></td></tr>";
// overtime week to check
echo '<tr class="oddeven"><td align="left">'.$langs->trans("overtimeCheckWeeks");//FIXTRAD
echo '</td><td align="left">'.$langs->trans("overtimeCheckWeeksDesc").'</td>';// FIXTRAD
echo '<td align="left"><input type = "text" name = "overtimecheckweeks" value="'.$overtimecheckweeks;
echo "\" size = \"4\" ></td></tr>";

// add docs
echo '<tr class="oddeven"><td align="left">'.$langs->trans("adddocs");
echo '</td><td align="left">'.$langs->trans("adddocsDesc").'</td>';
Expand Down Expand Up @@ -673,6 +690,11 @@ function null2int($var, $int = 0)
echo '</td><td align="left">'.$langs->trans("tsRoundDesc").'</td>';
echo '<td align="left"><input type = "text" name = "tsRound" value="'.$tsRound;
echo "\" size = \"4\" ></td></tr>";
// IMPORT AGENDA
echo '<tr class="oddeven" ><td align="left">'.$langs->trans("ImportAgenda");
echo '</td><td align="left">'.$langs->trans("ImportAgendaDesc").'</td>';
echo '<td align="left"><input type = "checkbox" name = "importagenda" value="1" ';
echo (($importagenda == '1')?'checked':'')."></td></tr>";
// eval ADDLINE
echo '<tr class="oddeven"><td align="left">'.$langs->trans("evalAddLine");
echo '</td><td align="left">'.$langs->trans("evalAddLineDesc").'</td>';
Expand Down Expand Up @@ -753,9 +775,9 @@ function null2int($var, $int = 0)
echo '<tr class="oddeven"><td align="left">'.$langs->trans("invoiceService");
echo '</td><td align="left">'.$langs->trans("invoiceServiceDesc").'</td>';
echo '<td align="left">';
$addchoices = array('-999'=> $langs->transnoentitiesnoconv('not2invoice'), -1=> $langs->transnoentitiesnoconv('Custom'));
$addchoices = array('-999'=> $langs->transnoentitiesnoconv('not2invoice'), -997=> $langs->transnoentitiesnoconv('Custom'));
$ajaxNbChar = $conf->global->PRODUIT_USE_SEARCH_TO_SELECT;
$htmlProductArray = array('name' => 'invoiceService', 'ajaxNbChar'=>$ajaxNbChar);
$htmlProductArray = array('name' => 'invoiceservice', 'ajaxNbChar'=>$ajaxNbChar);
$sqlProductArray = array('table' => 'product', 'keyfield' => 'rowid', 'fields' => 'ref, label', 'where' => 'tosell = 1 AND fk_product_type = 1', 'separator' => ' - ');
print select_sellist($sqlProductArray, $htmlProductArray, $invoiceservice, $addchoices);
echo "</td></tr>";
Expand Down
49 changes: 24 additions & 25 deletions htdocs/timesheet/class/TimesheetReport.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,6 @@ public function initBasic($projectid, $userid, $name, $startDate, $stopDate, $mo
$this->invoiceableOnly = $invoiceableOnly;
$this->taskarray = $taskarray;
$this->projectid = $projectid;// coul
if ($projectid && !is_array($projectid)) {
$this->project[$projectid] = new Project($this->db);
$this->project[$projectid]->fetch($projectid);
$this->ref[$projectid] = $this->project[$projectid]->ref.(($conf->global->TIMESHEET_HIDE_REF == 1)
?'':' - '.$this->project[$projectid]->title);
$first = true;
$this->thirdparty[$projectid] = new Societe($this->db);
$this->thirdparty[$projectid]->fetch($this->project[$projectid]->socid);
} elseif (is_array($projectid)){
foreach ($projectid as $id){
$this->project[$id] = new Project($this->db);
$this->project[$id]->fetch($id);
$this->ref[$id] = $this->project[$id]->ref.(($conf->global->TIMESHEET_HIDE_REF == 1)?
'':' - '.$this->project[$id]->title);
$this->thirdparty[$id] = new Societe($this->db);
$this->thirdparty[$id]->fetch($this->project[$id]->socid);
}

$first = true;
}
$this->userid = $userid;// coul
if ($userid && !is_array($userid)) {
$this->user[$userid] = new User($this->db);
Expand Down Expand Up @@ -306,6 +286,8 @@ public function getReportArray($forceGroup = false)
$objtsk = new Task($this->db);
$odlusrid=0;
$objusr = new User($this->db);
$oldsocid = 0;
$objsoc = new Societe($this->db);
// Loop on each record found,
while($i < $numTaskTime)
{
Expand All @@ -325,7 +307,22 @@ public function getReportArray($forceGroup = false)
if ($odlpjtid != $obj->projectid){
$objpjt->fetch($obj->projectid);
$odlpjtid = $obj->projectid;
}
}
if ($oldsocid != $objpjt->socid && $objpjt->socid > 0){
$objsoc->fetch($objpjt->socid);
}
# save the project info
if(!isset($this->project[$objpjt->id])){
$this->project[$objpjt->id] = $objpjt;
$this->ref[$objpjt->id] = $objpjt->ref.(($conf->global->TIMESHEET_HIDE_REF == 1)
?'':' - '.$objpjt->title);
$first = true;
$this->thirdparty[$objpjt->id] = new Societe($this->db);
$this->thirdparty[$objpjt->id]->fetch($objpjt->id);
}

//update third party

$resArray[$obj->id] = array('projectId' => $obj->projectid,
'projectLabel' => $objpjt->ref.(($conf->global->TIMESHEET_HIDE_REF == 0)?'':' - '.$objpjt->title),
'projectRef' => $objpjt->ref,
Expand All @@ -348,7 +345,9 @@ public function getReportArray($forceGroup = false)
'userLink' => $objusr->getNomUrl(0),
'note' =>($obj->note),
'invoiceable' => ($obj->invoiceable==1)?'1':'0',
'invoiced' => ($obj->invoiced==1)?'1':'0');
'invoiced' => ($obj->invoiced==1)?'1':'0',
'socname' => $objpjt->socid>0?($objsoc->code_client != ''? $objsoc->code_client.' - ':'').$objsoc->getNomUrl():''
);
$i++;
}
$this->db->free($resql);
Expand Down Expand Up @@ -607,17 +606,17 @@ public function buildFile($model = 'excel2017new', $save = false)
'taskRef' => 'taskRef', 'tasktitle' => 'taskTitle', 'dateDisplay' => 'Date',
'durationHours' => 'Hours', 'durationDays' => 'Days', 'userId' => 'userId',
'firstName' => 'Firstname', 'lastName' => 'Lastname', 'note' => 'Note',
'invoiceable' => 'Invoiceable','invoiced' => 'Invoiced');
'invoiceable' => 'Invoiceable','invoiced' => 'Invoiced', 'socname' => 'ThirdParty' );
$arrayTypes = array('projectRef' => 'TextAuto', 'projectTitle' => 'TextAuto',
'taskRef' => 'TextAuto', 'tasktitle' => 'TextAuto', 'dateDisplay' => 'Date',
'durationHours' => 'TextAuto', 'durationDays' => 'Numeric', 'userId' => 'Numeric',
'firstName' => 'TextAuto', 'lastName' => 'TextAuto', 'note' => 'TextAuto',
'invoiceable' => 'Numeric','invoiced' => 'TextAuto');
'invoiceable' => 'Numeric','invoiced' => 'TextAuto', 'socname' => 'TextAuto');
$arraySelected = array('projectRef' => 'projectRef', 'projectTitle' => 'projectTitle',
'taskRef' => 'taskRef', 'tasktitle' => 'tasktitle', 'userId' => 'userId',
'firstName' => 'firstName', 'lastName' => 'lastName', 'dateDisplay' => 'date',
'durationHours' => 'durationHours', 'durationDays' => 'durationDays', 'note' => 'note',
'invoiceable' => 'invoiceable','invoiced' => 'invoiced');
'invoiceable' => 'invoiceable','invoiced' => 'invoiced', 'socname' => 'socname');

$resArray = $this->getReportArray(!($this->ungroup ==1));

Expand Down
Loading

0 comments on commit eadcee9

Please sign in to comment.