\n";
echo " th, td\n";
echo " { font-size: 11pt;\n";
echo " padding-right: 1em;\n";
echo " }\n";
echo " table\n";
echo " { border-collapse: collapse;\n";
echo " }\n";
echo "\n";
include_once '../../modules/comFunctions.php';
include_once '../../modules/config.php';
include_once '../../modules/sql.php';
function makeTimeSheet($user, $period, $detailed = true)
{ $str = "Time Sheet";
if (!$detailed) $str .= " Summary";
$str .= " for ".$user['fName']." ".$user['lName']." for ".formatDate($period['cStart'])." to ".formatDate($period['cEnd']);
echo "
\n";
echo " \n";
echo " "; if ($detailed) echo "Date"; echo " | \n";
echo " "; if ($detailed) echo "Start"; echo " | \n";
echo " "; if ($detailed) echo "End"; echo " | \n";
echo " "; if ($detailed) echo "SubTtl"; echo " | \n";
if ($user['access'] & 0x002)
echo " Bank | \n";
echo " "; if ($detailed) echo "Absence"; echo " | \n";
echo " Reg | \n";
echo " OT | \n";
echo "
\n";
$nonAdjTtl = 0;
$timeList = sqlSelect("times", "wDate > '".$period['pEnd']."' and wDate < '".$period['cEndFlag']."' and empNo = '".$user['empNo']."'", "", "wDate");
while ($time = mysql_fetch_assoc($timeList['r']))
{ if ($detailed)
{ $dow = getDayOfWeek($time['wDate']);
$dTime = processTimeDif($time['wStart'], $time['wEnd']);
$nonAdjTtl += $dTime;
echo " \n";
echo " "; if ($lastDow != $dow) echo $dow['l']; echo " | \n";
echo " "; if ($lastDow != $dow) echo $dow['f']; echo " | \n";
echo " ".$time['wStart']." | \n";
echo " ".formatTime($time['wEnd'])." | \n";
echo " ".sprintf("%01.2f", $dTime)." | \n";
if ($user['access'] & 0x002)
echo " ".$time['dailyAdj']." | \n";
echo " ".$time['excuse']." | \n";
echo " ".$time['tTime']." | \n";
echo " ".$time['oTime']." | \n";
echo "
\n";
$lastDow = $dow;
}
$dailyAdjTtl += $time['dailyAdj'];
$tTimeTtl += $time['tTime'];
$oTimeTtl += $time['oTime'];
}
echo " \n";
echo " Period "; if ($user['access'] & 0x002) echo "Sub"; echo "Total: | \n";
echo " ".sprintf("%01.2f", $nonAdjTtl)." | \n";
if ($user['access'] & 0x002)
echo " ".sprintf("%01.2f", $dailyAdjTtl)." | \n";
echo " | \n";
echo " ".sprintf("%01.2f", $tTimeTtl)." | \n";
echo " ".sprintf("%01.2f", $oTimeTtl)." | \n";
echo "
\n";
if ($user['access'] & 0x002)
{ //$old_Ent = sqlSelect("employees", "empNo='".$_REQUEST['empNo']."'");
//$old_Ent = mysql_fetch_assoc($old_Ent['r']);
// this block fetches all banking with dates NEWER than the specified period so that it can be allowed for in the reporting
$cumAdj = 0;
$adjs = sqlSelect("timebank", "tDate>'".$period['cEnd']."' and empNo='".$user['empNo']."'"); // this will fetch all entries NEWER than the selected period
while ($adj = mysql_fetch_assoc($adjs['r']))
$cumAdj += ($adj['intAdj'] + $adj['extAdj']);
$adjs = sqlSelect("times", "wDate>'".$period['cEnd']."' and empNo='".$user['empNo']."'"); // this will fetch all entries NEWER than the selected period
while ($adj = mysql_fetch_assoc($adjs['r']))
$cumAdj += $adj['dailyAdj'];
// end of block
$intAdj = sqlSelect("timebank", "tDate='".$period['cEnd']."' and empNo='".$user['empNo']."'");
if ($intAdj['n'])
{ $intAdj = mysql_fetch_assoc($intAdj['r']);
$extAdj = $intAdj['extAdj'];
$intComment = $intAdj['intComment'];
$extComment = $intAdj['extComment'];
$intAdj = $intAdj['intAdj']; // this must be LAST because the value is assigned to the container variable
}
else
{ $intAdj = 0;
$extAdj = 0;
$intComment = "";
$extComment = "";
}
$openBal = $user['bank'] - $intAdj - $extAdj - $dailyAdjTtl;
echo " \n";
echo " Timebank Opening Balance: | \n";
echo " ".sprintf("%01.2f", ($openBal - $cumAdj))." | \n";
echo "
\n";
echo " \n";
echo " External Adjustments: | \n";
echo " ".sprintf("%01.2f", $extAdj)." | \n";
echo " $extComment | \n";
echo "
\n";
echo " \n";
echo " Debits and Credits: | \n";
echo " ";
echo sprintf("%01.2f", $intAdj);
echo " | \n";
echo " $intComment | \n";
echo "
\n";
echo " \n";
echo " Timebank Closing Balance: | \n";
echo " ".sprintf("%01.2f", ($user['bank'] - $cumAdj))." | \n";
echo " Period Total: | \n";
}
echo "style=\"text-align:right; font-weight: bold;\">Period Total: \n";
echo " ".sprintf("%01.2f", ($tTimeTtl - $intAdj))." | \n";
echo " ".sprintf("%01.2f", $oTimeTtl)." | \n";
echo "
\n";
}
echo "
\n";
}
if (empty($_REQUEST['period']))
$period = calcDates(date("Ymd"));
else
$period = calcDates($_REQUEST['period']);
$str = "wDate > '".$period['pEnd']."' and wDate < '".$period['cEndFlag']."'";
if (!empty($_REQUEST['empNo']))
$str .= " and times.empNo = '".$_REQUEST['empNo']."'";
$sheetList = sqlSelect("times, employees", "times.empNo=employees.empNo and $str", "lName, fName");
$_REQUEST['mode'] = "1";
if (array_key_exists("doPrint", $_REQUEST))
{ $doPrint = " onLoad=\"window.print();\"";
}
echo "\n";
while ($sheet = mysql_fetch_assoc($sheetList['r']))
{ if ($hasRun)
echo "