Location: PHPKode > projects > Wombat Open Source > wombat/calendar/week_availability.php
<?
include("../inc/local.inc.php");
include("../inc/wombat.inc.php");
include("../inc/header.inc.php");
include("../inc/msg.inc.php");
include("../inc/calendar.inc.php");


?>
<html>
<head>
  <title> Calendar </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?
echo "</head><body>";
if(eregi("MSIE",$_SERVER['HTTP_USER_AGENT'])){
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"genericie.css\" />"; 
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style-ie.css\" />";
}
else {
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"generic.css\" /> <link rel=\"stylesheet\" type=\"text/css\" href=\"style0.css\" />";
}

if (!isset($_GET['month']) && !isset($_GET['year']) && !isset($_GET['day']) ) {
    $month = date("n");
	$year = date("Y");
	$day = date("d");
}
else {
   $month = $_GET['month'];
   $day = $_GET['day'];
   $year = $_GET['year'];

}

$now = mktime(12,0,0,$month, $day, $year);
$current_time = $now;

$firstday = getdate(mktime(0,0,0,1,1,$year));
$firstparamday = 32 - $firstday['wday'];
if($firstparamday < 32)
{
  $firstparamyear = $year - 1;
  $firstparammonth = 12;
}
else 
{
  $firstparamday = 1;
  $firstparamyear = $year;
  $firstparammonth = 1;
}
  
$firstparam = mktime(12,0,0,$firstparammonth,$firstparamday,$firstparamyear);
$curday = mktime(12,0,0,$month,$day,$year);
$diff = $curday - $firstparam;
$currentweek =ceil($diff/(3600*24*7));
if($currentweek == 53){$currentweek = 1;}

$day_of_mth = $day;
$rec = getdate(mktime(0,0,0,$month,$day,$year));
$day_of_mth2 = $rec['wday'];
if($day_of_mth2 == 0)
	$day_of_mth2 = 7;
$firstday_oftheweek = $day_of_mth - $day_of_mth2 + 1;

$cur_time = mktime(12,0,0,$month,$firstday_oftheweek,$year);

?>
<h1> Weekly Availability </h1>
<table >
<tbody>
<td></td>
<form method=POST action=> 

<? for($i=1;$i<=5;$i++){


$startday = date("d",$cur_time);
$startmon = date("n",$cur_time);
$startyear = date("Y",$cur_time);
$last_time = $cur_time + (3600*24*6);
$lastday = date("d",$last_time);
$lastmon = date("n",$last_time);
$lastyear = date("Y",$last_time);
$total_hours =0;

$ls_sqlhour = do_sql("select h.amount_hour, e.login from planned_hour h , employee e where e.emp_id=h.emp_id and starttime=$cur_time");


echo "<td><table>
<h2>Week $currentweek</h2>
$startday ". month_name($startmon) ." - $lastday ".month_name($lastmon)."
<br><input type = hidden name = fs_starttime$i value = $cur_time>
";
while($la_result = mysql_fetch_array($ls_sqlhour)) {
echo "<tr><td><br>".$la_result['login']."</td> <td><br>(".$la_result['amount_hour'].")</td></tr>";
$total_hours = $total_hours + $la_result['amount_hour'];
}
echo "<table><tr><br>Total Availability $total_hours hours</tr></td>";
echo "</table>
</td>";

$cur_time = $cur_time + (3600*24*7);
$currentweek = $currentweek + 1;
if($currentweek == 53){$currentweek = 1;}


}

echo "</tbody>";
echo "</table>";
echo "<br>";
echo "";
echo "<input type=button class=button name=submit value=OK onClick='history.back()'> </form>";
?>

	

<?
echo '<br><form method=post action=gotoweek_hour.php><tr>
   <td colspan="7">' . "<br>Go to week <br>";
   echo "<select name = goto_week>";
   for($i=1;$i<53;$i++){
	echo "<option value=$i> Week $i </option>";
	}  
	echo "</select>";
	   echo "<select name = goto_year>";
   for($i=2000;$i<2007;$i++){
    	echo "<option value=$i> $i </option>";
	}
	echo "</select>";
	echo "<input type=hidden name=lf_day value=$currentweek>";
	echo "<input type=hidden name=lf_year value=$year>";
	echo "<input type=submit class = button value=Go!>";
   echo "</td></tr></form>\n";


include("../inc/footer.inc.php");

?>
</body>
</html>
Return current item: Wombat Open Source