function generateTimesheet($uid = 0, $disabled = false, $isapproval = false, $forWhichUser = 0) { global $startStamp, $numberOfDays, $_USER; if ($uid == 0) { $uid = $_USER['uid']; } if ($forWhichUser != 0) { $uid = $forWhichUser; } $ts = new nexTime(); $output = ''; $output .= $ts->generateTableHeader($disabled, $isapproval, $ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $uid)); $retval = $ts->generateTimesheetRows($uid, $startStamp, $numberOfDays, NULL, 0, $disabled, $isapproval); $output .= $retval[1]; $output .= $ts->generateTableFooter($isapproval, $retval[2], $retval[3], $retval[4], $retval[5], $ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $uid)); $output .= $ts->generateTotalRowCount($retval[0]); return $output; }
//specific user //first, detect if they should be seeing this user's timesheets $shouldBeApproving = $ts->testIfUserCanApprove($uid, $emp); if (!$shouldBeApproving) { echo $LANG_NEXTIME['should_not_be_approving']; echo COM_siteFooter(); exit(0); } if ($showAsTimesheet == 1) { $output = ''; if (SEC_inGroup('nexTime Finance') && !SEC_inGroup('Root')) { //disable it all $T->set_var('comment_disable', ' disabled '); $T->set_var('comment_edit_disable', 'display:none'); $output .= $ts->generateTableHeader(true, true, $ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $emp)); $retval = $ts->generateTimesheetRows($emp, $startStamp, $numberOfDays, null, 0, true, true); $output .= $retval[1]; $output .= $ts->generateTableFooter(true, $retval[2], $retval[3], $retval[4], $retval[5], $ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $emp)); $output .= $ts->generateTotalRowCount($retval[0]); } else { //enable the timesheet for editing $output .= $ts->generateTableHeader(false, true, $ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $emp)); $retval = $ts->generateTimesheetRows($emp, $startStamp, $numberOfDays, null, 0, false, true); $output .= $retval[1]; if ($ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $emp)) { $output .= $ts->generateTableFooter(true, $retval[2], $retval[3], $retval[4], $retval[5], $ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $emp)); } else { $output .= $ts->generateTableFooter(false, $retval[2], $retval[3], $retval[4], $retval[5], $ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $emp)); } $output .= $ts->generateTotalRowCount($retval[0]); }
$endStamp = strtotime($end_date); $numberOfDays = intval(($endStamp - $startStamp) / 60 / 60 / 24) + 1; if ($endStamp < $startStamp) { //Hey! You can't have an end date thats less than the start date... echo '<br><br><a href="index.php">' . $LANG_NEXTIME['end_date_before_start']; echo $LANG_NEXTIME['back_link_label'] . '</a>'; echo COM_siteFooter(); exit(0); } $ts = new nexTime(); $T = new Template($CONF_NEXTIME['template_path']); $T->set_file(array('page' => 'entry.thtml', 'javascript' => 'nextime.js.thtml')); $T->set_var('site_url', $_CONF['site_url']); $T->set_var($LANG_NEXTIME); $T->set_var('allfields', $ts->getTableColumns('nextime_timesheet_entry')); $T->set_var('start_date', $start_date); $T->set_var('end_date', $end_date); $T->set_var('emp', $_USER['uid']); $T->set_var('approved_by', $_USER['uid']); $T->parse('output', 'javascript'); $output = ''; $output .= $ts->generateTableHeader(false, false, $ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $uid)); $retval = $ts->generateTimesheetRows($uid, $startStamp, $numberOfDays); $output .= $retval[1]; $output .= $ts->generateTableFooter(false, $retval[2], $retval[3], $retval[4], $retval[5], $ts->determineIfItemIsInLockRangeByDateStamp($startStamp, $uid)); $output .= $ts->generateTotalRowCount($retval[0]); $T->set_var('timesheet', $output); $T->parse('output', 'page', true); echo $T->finish($T->get_var('output')); echo "<br>"; echo COM_siteFooter();