Skip to content

Commit

Permalink
Merge pull request #118 from delcroip/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
delcroip authored Jul 5, 2020
2 parents 87d079c + d4d5713 commit 8d04b82
Show file tree
Hide file tree
Showing 18 changed files with 393 additions and 165 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.3.0
- new: possibility to ungroup reports
- fix: remove closed project (without end date) task
- new: improve timesheet box (add ts to submit and layout imnprovement)

4.2.2
- new: show the time not editable (when there is several task time for ady/task)

4.2.1
- fix: blank timesheet page

4.2.0
- fix: send approval reminder
- fix: favorite edit card update the task when the project is selected
Expand Down
48 changes: 31 additions & 17 deletions htdocs/timesheet/TimesheetReportProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@
$exportfriendly = GETPOST('exportfriendly', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
$short = GETPOST('short', 'int');
$invoicedCol = GETPOST('invoicedcol', 'int');

$ungroup = GETPOST('ungroup', 'int');

$mode = GETPOST('mode', 'alpha');

$model = GETPOST('model', 'alpha');
if(empty($mode)){
$mode = 'UTD';
$ungroup = $conf->global->TIMESHEET_REPORT_UNGROUP;
$invoicedCol = $conf->global->TIMESHEET_REPORT_INVOICED_COL;
}

$projectSelectedId = GETPOST('projectSelected');
Expand Down Expand Up @@ -108,7 +115,7 @@
$projectIdlist = array_keys($projectList);
}
$reportStatic = new TimesheetReport($db);
$reportStatic->initBasic($projectIdlist, '', '', $dateStart, $dateEnd, $mode, $invoicabletaskOnly);
$reportStatic->initBasic($projectIdlist, '', '', $dateStart, $dateEnd, $mode, $invoicabletaskOnly,$short,$invoicedCol,$ungroup);
if($action == 'getpdf') {
$pdf = new pdf_rat($db);
//$outputlangs = $langs;
Expand Down Expand Up @@ -169,10 +176,8 @@
<td>'.$langs->trans('Project').'</td>
<td>'.$langs->trans('DateStart').'</td>
<td>'.$langs->trans('DateEnd').'</td>
<td>'.$langs->trans('short').'</td>
<td>'.$langs->trans('InvoicableOnly').'</td>
<td>'.$langs->trans('exportfriendly').'</td>
<td>'.$langs->trans('Mode').'</td>
<td>'.$langs->trans('Options').'</td>
<td></td>
</tr>
<tr >
Expand All @@ -191,15 +196,6 @@
// select end date
$Form .= '<td>'.$form->select_date($dateEnd, 'dateEnd', 0, 0, 0, "", 1, 1, 1)."</td>";
//$Form .= '<td> '.$htmlother->select_month($month, 'month').' - '.$htmlother->selectyear($year, 'year', 0, 10, 3)
// Select short
$Form .= ' <td><input type = "checkbox" name = "short" value = "1" ';
$Form .= (($short == 1)?'checked>':'>').'</td>' ;
// Select invoiceable only
$Form .= '<td><input type = "checkbox" name = "invoicabletaskOnly" value = "1" ';
$Form .= (($invoicabletaskOnly == 1)?'checked>':'>').'</td>';
// Select Export friendly
$Form .= '<td><input type = "checkbox" name = "exportfriendly" value = "1" ';
$Form .= (($exportfriendly == 1)?'checked>':'>').'</td>';
// Select mode
$Form .= '<td><input type = "radio" name = "mode" value = "UTD" '.($mode == 'UTD'?'checked':'');
$Form .= '> '.$langs->trans('User').' / '.$langs->trans('Task').' / '.$langs->trans('Date').'<br>';
Expand All @@ -208,15 +204,33 @@
$Form .= '<input type = "radio" name = "mode" value = "DUT" '.($mode == 'DUT'?'checked':'');
$Form .= '> '.$langs->trans('Date').' / '.$langs->trans('User').' / '.$langs->trans('Task').'<br>';

$Form .= '</td></tr></table>';
$Form .= '</td>';
// select short
$Form .= ' <td><input type = "checkbox" name = "short" value = "1" ';
$Form .= (($short == 1)?'checked>':'>').$langs->trans('short').'</br>' ;
// Select invoiceable only
$Form .= '<input type = "checkbox" name = "invoicabletaskOnly" value = "1" ';
$Form .= (($invoicabletaskOnly == 1)?'checked>':'>').$langs->trans('InvoicableOnly').'</br>';
// Select Export friendly
$Form .= '<input type = "checkbox" name = "exportfriendly" value = "1" ';
$Form .= (($exportfriendly == 1)?'checked>':'>').$langs->trans('exportfriendly').'</br>';
// Select show invoice
$Form .= '<input type = "checkbox" name = "invoicedcol" value = "1" ';
$Form .= (($invoicedCol == 1)?'checked>':'>'). $langs->trans('reportInvoicedCol').'</br>';
// Select Export friendly
$Form .= '<input type = "checkbox" name = "ungroup" value = "1" ';
$Form .= (($ungroup == 1)?'checked>':'>').$langs->trans('reportUngroup').'</td>';

$Form .= '</tr></table>';

//submit
$model = $conf->global->TIMESHEET_EXPORT_FORMAT;
$Form .= '<input class = "butAction" type = "submit" value = "'.$langs->trans('getReport').'">';
if(!empty($querryRes) && ($user->rights->facture->creer || version_compare(DOL_VERSION, "3.7") <= 0))$Form .= '<a class = "butAction" href = "TimesheetProjectInvoice.php?step=0&dateStart='.dol_print_date($dateStart, 'dayxcard').'&invoicabletaskOnly='.$invoicabletaskOnly.'&dateEnd='.dol_print_date($dateEnd, 'dayxcard').'&projectid='.$projectSelectedId.'" >'.$langs->trans('Invoice').'</a>';

if(!empty($querryRes))$Form .= '<a class = "butAction" href="?action=getpdf&dateStart='.dol_print_date($dateStart, 'dayxcard').'&dateEnd='.dol_print_date($dateEnd, 'dayxcard').'&projectSelected='.$projectSelectedId.'&mode='.$mode.'&invoicabletaskOnly='.$invoicabletaskOnly.'" >'.$langs->trans('TimesheetPDF').'</a>';
if(!empty($querryRes) && $conf->global->MAIN_MODULE_EXPORT)$Form .= '<a class = "butAction" href="?action=getExport&dateStart='.dol_print_date($dateStart, 'dayxcard').'&dateEnd='.dol_print_date($dateEnd, 'dayxcard').'&projectSelected='.$projectSelectedId.'&mode='.$mode.'&model='.$model.'&invoicabletaskOnly='.$invoicabletaskOnly.'" >'.$langs->trans('Export').'</a>';
if(!empty($querryRes))$Form .= '<a class = "butAction" href="?action=reportproject&dateStart='.dol_print_date($dateStart, 'dayxcard').'&dateEnd='.dol_print_date($dateEnd, 'dayxcard').'&projectSelected='.$projectSelectedId.'&mode='.$mode.'&invoicabletaskOnly='.$invoicabletaskOnly.'" >'.$langs->trans('Refresh').'</a>';
if(!empty($querryRes))$Form .= '<a class = "butAction" href="?action=getpdf&dateStart='.dol_print_date($dateStart, 'dayxcard').'&dateEnd='.dol_print_date($dateEnd, 'dayxcard').'&projectSelected='.$projectSelectedId.'&mode='.$mode.'&invoicabletaskOnly='.$invoicabletaskOnly.'&ungroup='.$ungroup.'" >'.$langs->trans('TimesheetPDF').'</a>';
if(!empty($querryRes) && $conf->global->MAIN_MODULE_EXPORT)$Form .= '<a class = "butAction" href="?action=getExport&dateStart='.dol_print_date($dateStart, 'dayxcard').'&dateEnd='.dol_print_date($dateEnd, 'dayxcard').'&projectSelected='.$projectSelectedId.'&mode='.$mode.'&model='.$model.'&invoicabletaskOnly='.$invoicabletaskOnly.'&ungroup='.$ungroup.'" >'.$langs->trans('Export').'</a>';
if(!empty($querryRes))$Form .= '<a class = "butAction" href="?action=reportproject&dateStart='.dol_print_date($dateStart, 'dayxcard').'&dateEnd='.dol_print_date($dateEnd, 'dayxcard').'&projectSelected='.$projectSelectedId.'&mode='.$mode.'&invoicabletaskOnly='.$invoicabletaskOnly.'&ungroup='.$ungroup.'" >'.$langs->trans('Refresh').'</a>';
$Form .= '</form>';
if(!($optioncss != '' && !empty($_POST['userSelected']))) echo $Form;
echo $querryRes;
Expand Down
52 changes: 34 additions & 18 deletions htdocs/timesheet/TimesheetReportUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,21 @@
//$toDatemonth = GETPOST('toDatemonth', 'int');
//$toDateyear = GETPOST('toDateyear', 'int');
$mode = GETPOST('mode', 'alpha');
$short = GETPOST('short', 'int');
$invoicedCol = GETPOST('invoicedcol', 'int');
$ungroup = GETPOST('ungroup', 'int');
$model = GETPOST('model', 'alpha');
if(empty($mode))$mode = 'PTD';
$short = GETPOST('short', 'int');;
if(empty($mode)){
$mode = 'PTD';
$ungroup = $conf->global->TIMESHEET_REPORT_UNGROUP;
$invoicedCol = $conf->global->TIMESHEET_REPORT_INVOICED_COL;
}
$short = GETPOST('short', 'int');
$invoicedCol = GETPOST('invoicedcol', 'int');
$ungroup = GETPOST('ungroup', 'int');

//$userSelected = $userList[$userIdSelected];
$year = GETPOST('year', 'int');;
$year = GETPOST('year', 'int');
//$month = GETPOST('month', 'int');;//strtotime(str_replace('/', '-', $_POST['Date']));
//$firstDay = ($month)?strtotime('01-'.$month.'-'. $year):strtotime('first day of previous month');
//$lastDay = ($month)?strtotime('last day of this month', $firstDay):strtotime('last day of previous month');
Expand Down Expand Up @@ -110,7 +120,7 @@
$userIdlist = array_keys($userList);
}
$reportStatic = new TimesheetReport($db);
$reportStatic->initBasic('', $userIdlist, $reportName, $dateStart, $dateEnd, $mode, $invoicabletaskOnly);
$reportStatic->initBasic('', $userIdlist, $reportName, $dateStart, $dateEnd, $mode, $invoicabletaskOnly,$short,$invoicedCol,$ungroup);
if($action == 'getpdf') {
$pdf = new pdf_rat($db);
//$outputlangs = $langs;
Expand Down Expand Up @@ -163,11 +173,8 @@
<td>'.$langs->trans('User').'</td>
<td>'.$langs->trans('DateStart').'</td>
<td>'.$langs->trans('DateEnd').'</td>
<td>'.$langs->trans('short').'</td>
<td>'.$langs->trans('InvoicableOnly').'</td>
<td>'.$langs->trans('exportfriendly').'</td>
<td>'.$langs->trans('Mode').'</td>
<td></td>
<td>'.$langs->trans('Options').'</td>
</tr>
<tr >
<td><select name = "userSelected">
Expand All @@ -194,26 +201,35 @@
// select end date
$Form .= '<td>'.$form->select_date($dateEnd, 'dateEnd', 0, 0, 0, "", 1, 1, 1)."</td>";
//$Form .= '<td>'.$htmlother->select_month($month, 'month').' - '.$htmlother->selectyear($year, 'year', 0, 10, 3).' </td>';
$Form .= ' <td><input type = "checkbox" name = "short" value = "1" ';
$Form .= (($short == 1)?'checked>':'>').'</td>' ;
// Select invoiceable only
$Form .= '<td><input type = "checkbox" name = "invoicabletaskOnly" value = "1" ';
$Form .= (($invoicabletaskOnly == 1)?'checked>':'>').'</td>';
// Select Export friendly
$Form .= '<td><input type = "checkbox" name = "exportfriendly" value = "1" ';
$Form .= (($exportfriendly == 1)?'checked>':'>').'</td>';
// Select mode
$Form .= '<td><input type = "radio" name = "mode" value = "PTD" '.($mode == 'PTD'?'checked':'');
$Form .= '> '.$langs->trans('Project').' / '.$langs->trans('Task').' / '.$langs->trans('Date').'<br>';
$Form .= '<input type = "radio" name = "mode" value = "PDT" '.($mode == 'PDT'?'checked':'');
$Form .= '> '.$langs->trans('Project').' / '.$langs->trans('Date').' / '.$langs->trans('Task').'<br>';
$Form .= '<input type = "radio" name = "mode" value = "DPT" '.($mode == 'DPT'?'checked':'');
$Form .= '> '.$langs->trans('Date').' / '.$langs->trans('Project').' / '.$langs->trans('Task').'<br>';
$Form .= '</td></tr></table>';
$Form .= '</td>';
// select short
$Form .= ' <td><input type = "checkbox" name = "short" value = "1" ';
$Form .= (($short == 1)?'checked>':'>').$langs->trans('short').'</br>' ;
// Select invoiceable only
$Form .= '<input type = "checkbox" name = "invoicabletaskOnly" value = "1" ';
$Form .= (($invoicabletaskOnly == 1)?'checked>':'>').$langs->trans('InvoicableOnly').'</br>';
// Select Export friendly
$Form .= '<input type = "checkbox" name = "exportfriendly" value = "1" ';
$Form .= (($exportfriendly == 1)?'checked>':'>').$langs->trans('exportfriendly').'</br>';
// Select show invoice
$Form .= '<input type = "checkbox" name = "invoicedcol" value = "1" ';
$Form .= (($invoicedCol == 1)?'checked>':'>'). $langs->trans('reportInvoicedCol').'</br>';
// Select Export friendly
$Form .= '<input type = "checkbox" name = "ungroup" value = "1" ';
$Form .= (($ungroup == 1)?'checked>':'>').$langs->trans('reportUngroup').'</td>';

$Form .= '</tr></table>';
$Form .= '<input class = "butAction" type = "submit" value = "'.$langs->trans('getReport').'">';
$model = $conf->global->TIMESHEET_EXPORT_FORMAT;
//if(!empty($querryRes))$Form .= '<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 .= '<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.'" >'.$langs->trans('Export').'</a>';
if(!empty($querryRes) && $conf->global->MAIN_MODULE_EXPORT)$Form .= '<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 .= '</form>';
if(!($optioncss != '' && !empty($userIdSelected))) echo $Form;
// section to generate
Expand Down
18 changes: 17 additions & 1 deletion htdocs/timesheet/admin/timesheetsetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
$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;

if(count($opendays)!=8) {
$opendays = array('_', '0', '0', '0', '0', '0', '0', '0');
Expand Down Expand Up @@ -253,6 +254,10 @@ function null2int($var, $int = 0)
dolibarr_set_const($db, "TIMESHEET_UNBLOCK_INVOICED", $unblockInvoiced, 'int', 0, '', $conf->entity);
$unblockClosed = getpost('unblockClosed', 'int');
dolibarr_set_const($db, "TIMESHEET_UNBLOCK_CLOSED", $unblockClosed, 'int', 0, '', $conf->entity);
$reportInvoicedCol = getpost('reportInvoicedCol', 'int');
dolibarr_set_const($db, "TIMESHEET_REPORT_INVOICED_COL", $reportInvoicedCol, 'int', 0, '', $conf->entity);
$reportUngroup = getpost('reportUngroup', 'int');
dolibarr_set_const($db, "TIMESHEET_REPORT_UNGROUP", $reportUngroup, 'int', 0, '', $conf->entity);
$tsRound = getpost('tsRound', 'int');
dolibarr_set_const($db, "TIMESHEET_ROUND", $tsRound, 'int', 0, '', $conf->entity);

Expand Down Expand Up @@ -645,6 +650,17 @@ function null2int($var, $int = 0)
echo '</td><td align = "left">'.$langs->trans("unblockClosedDesc").'</td>';
echo '<td align = "left"><input type = "checkbox" name = "unblockClosed" value = "1" ';
echo (($unblockClosed == '1')?'checked':'')."></td></tr>\n\t\t";
// show invoiced col in reports
echo '<tr class = "oddeven"><td align = "left">'.$langs->trans("reportInvoicedCol");
echo '</td><td align = "left">'.$langs->trans("reportInvoicedColDesc").'</td>';
echo '<td align = "left"><input type = "checkbox" name = "reportInvoicedCol" value = "1" ';
echo (($reportInvoicedCol == '1')?'checked':'')."></td></tr>\n\t\t";
// ungroup lvl3 reports
echo '<tr class = "oddeven"><td align = "left">'.$langs->trans("reportUngroup");
echo '</td><td align = "left">'.$langs->trans("reportUngroupDesc").'</td>';
echo '<td align = "left"><input type = "checkbox" name = "reportUngroup" value = "1" ';
echo (($reportUngroup == '1')?'checked':'')."></td></tr>\n\t\t";



echo '</table>'."\n\t\t";
Expand Down
8 changes: 5 additions & 3 deletions htdocs/timesheet/class/AttendanceEvent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ public function fetchTasks($userid = '', $date = '')
$userid = $this->userid;
}
$this->userid = $userid;
$datestart = strtotime('yesterday midnight', $date);
$datestop = strtotime('today midnight', $date);
$datestart = strtotime('today midnight', $date);
$datestop = strtotime(' tomorrow midnight', $date) -1;
$tasksList = array();
$sql = 'SELECT DISTINCT element_id as taskid, prj.fk_soc, prj.ref, tsk.ref';
$sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec";
Expand All @@ -789,7 +789,9 @@ public function fetchTasks($userid = '', $date = '')
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as prj ON prj.rowid = tsk.fk_projet ';
$sql .= " WHERE ec.fk_socpeople = '".$userid."' AND ctc.element = 'project_task' ";
if($conf->global->TIMESHEET_HIDE_DRAFT == '1') {
$sql .= ' AND prj.fk_statut>\'0\' ';
$sql .= ' AND prj.fk_statut = 1)';
}else{
$sql .= ' AND prj.fk_statut in (0, 1)';
}
$sql .= ' AND (prj.datee >= \''.$this->db->idate($datestart).'\' OR prj.datee IS NULL)';
$sql .= ' AND (prj.dateo <= \''.$this->db->idate($datestop).'\' OR prj.dateo IS NULL)';
Expand Down
Loading

0 comments on commit 8d04b82

Please sign in to comment.