View Calendar
<?php
$monthNames = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sept", "Oct", "Nov", "Dec");
if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];
$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;
if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>
<table width="550px" style="margin: auto;">
<tr>
<td align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse; font-family:Arial, Helvetica, sans-serif;">
<tr align="center" height="30px;" style="background-color:#009933; color:#fff;">
<td colspan="1">
<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF; text-decoration:none;">Prev</a>
</td>
<td colspan="5" style="font-size:20px; font-weight:800;">
<strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong>
</td>
<td colspan="1">
<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF; text-decoration:none;">Next</a>>
</td>
</tr>
<tr height="20px" style="padding:0px 1px; background:#fff; color:#6f6f6f; font-weight:300; font-size:20px;">
<td align="center" width="30px;"style="font-weight: bold;">Sun</td>
<td align="center" width="30px;"style="font-weight: bold;">Mon</td>
<td align="center" width="30px;"style="font-weight: bold;">Tue</td>
<td align="center" width="30px;"style="font-weight: bold;">Wed</td>
<td align="center" width="30px;"style="font-weight: bold;">Thu</td>
<td align="center" width="30px;"style="font-weight: bold;">Fri</td>
<td align="center" width="30px;"style="font-weight: bold;">Sat</td>
</tr>
<?php
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
for ($i=0; $i<($maxday+$startday); $i++)
{
if($cMonth < 10)
{
$month_formated = "0$cMonth";
//echo $month_formated;
}
else
{
$month_formated = $cMonth;
}
if(($i - $startday + 1) < 10)
{
$day_formated = "0".($i - $startday + 1)."";
}
else
{
$day_formated = ($i - $startday + 1);
}
if(($i - $startday + 1) < 10)
{
$day_formated = "0".($i - $startday + 1)."";
}
else
{
$day_formated = ($i - $startday + 1);
}
$dato_formated = "$cYear-$month_formated-$day_formated";
//$dato_formated."</br>";
if(($i % 7) == 0 ) echo "<tr>";
if($i < $startday)
{
echo "<td style='border:1px solid #66CC99;'></td>";
}
else
{
$datee=$i - $startday + 1;
$datee2="$month_formated/$day_formated/$cYear";
$sql=" SELECT * from `bookings` where docdate ='".$datee2."'";
$result = mysqli_query($con, $sql);
if(mysqli_num_rows($result)>0)
{
echo "<td height='50px' align='center' valign='middle' style='background-color:#b4ffc8; border:1px solid #66CC99; font-size:20px; font-weight:700; width: 100px;'><a href='#' class='ghost_ab' data-id=".$datee2." >". ($i - $startday + 1) . "</a></td>";
}
else
{
echo "<td height='50px' align='center' valign='middle' style='background-color:#fff; border:1px solid #66CC99; font-size:20px; font-weight:300; width: 100px;'><a href='#' class='ghost_ab' data-id=".$datee2." >". ($i - $startday + 1) . "</a></td>";
}
}
if(($i % 7) == 6 ) echo "</tr>";
}
?>
</table>
</td>
</tr>
</table>
<?php
$monthNames = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sept", "Oct", "Nov", "Dec");
if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];
$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;
if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>
<table width="550px" style="margin: auto;">
<tr>
<td align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse; font-family:Arial, Helvetica, sans-serif;">
<tr align="center" height="30px;" style="background-color:#009933; color:#fff;">
<td colspan="1">
<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF; text-decoration:none;">Prev</a>
</td>
<td colspan="5" style="font-size:20px; font-weight:800;">
<strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong>
</td>
<td colspan="1">
<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF; text-decoration:none;">Next</a>>
</td>
</tr>
<tr height="20px" style="padding:0px 1px; background:#fff; color:#6f6f6f; font-weight:300; font-size:20px;">
<td align="center" width="30px;"style="font-weight: bold;">Sun</td>
<td align="center" width="30px;"style="font-weight: bold;">Mon</td>
<td align="center" width="30px;"style="font-weight: bold;">Tue</td>
<td align="center" width="30px;"style="font-weight: bold;">Wed</td>
<td align="center" width="30px;"style="font-weight: bold;">Thu</td>
<td align="center" width="30px;"style="font-weight: bold;">Fri</td>
<td align="center" width="30px;"style="font-weight: bold;">Sat</td>
</tr>
<?php
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
for ($i=0; $i<($maxday+$startday); $i++)
{
if($cMonth < 10)
{
$month_formated = "0$cMonth";
//echo $month_formated;
}
else
{
$month_formated = $cMonth;
}
if(($i - $startday + 1) < 10)
{
$day_formated = "0".($i - $startday + 1)."";
}
else
{
$day_formated = ($i - $startday + 1);
}
if(($i - $startday + 1) < 10)
{
$day_formated = "0".($i - $startday + 1)."";
}
else
{
$day_formated = ($i - $startday + 1);
}
$dato_formated = "$cYear-$month_formated-$day_formated";
//$dato_formated."</br>";
if(($i % 7) == 0 ) echo "<tr>";
if($i < $startday)
{
echo "<td style='border:1px solid #66CC99;'></td>";
}
else
{
$datee=$i - $startday + 1;
$datee2="$month_formated/$day_formated/$cYear";
$sql=" SELECT * from `bookings` where docdate ='".$datee2."'";
$result = mysqli_query($con, $sql);
if(mysqli_num_rows($result)>0)
{
echo "<td height='50px' align='center' valign='middle' style='background-color:#b4ffc8; border:1px solid #66CC99; font-size:20px; font-weight:700; width: 100px;'><a href='#' class='ghost_ab' data-id=".$datee2." >". ($i - $startday + 1) . "</a></td>";
}
else
{
echo "<td height='50px' align='center' valign='middle' style='background-color:#fff; border:1px solid #66CC99; font-size:20px; font-weight:300; width: 100px;'><a href='#' class='ghost_ab' data-id=".$datee2." >". ($i - $startday + 1) . "</a></td>";
}
}
if(($i % 7) == 6 ) echo "</tr>";
}
?>
</table>
</td>
</tr>
</table>
No comments:
Post a Comment