<?php
include("header.html");
session_start(); 
require_once('view_users.php');
@header('Content-type: text/html;charset=windows-1256');
/*
 * example for Hijri Date Lib
 * by Saeed Hubaishan
 */
require_once '../hijri.class.php';
date_default_timezone_set('Asia/Aden');

//include_once("slati/index.php");
function buildMonthCal($month, $year, $outmonth = FALSE)
{
	$c = new hijri\Calendar();
	$d = new hijri\datetime(null, null, 'ar', $c);
	list($cday, $cmonth, $cyear) = explode('-', $d->format('_j-_n-_Y'));
	
	$d->setDateHijri($year, $month + 1, 0);
	list($gm2, $gy2) = explode('-', $d->format("M-Y"));
	$d->setDateHijri($year, $month, 1);
	list($start_wd, $month_name, $gm1, $gy1) = explode('-', $d->format("w-_M-M-Y"));
$title = $month_name . " " . $year . " هجري " . $gm1 . (($gy2 != $gy1) ? " " . $gy1 : '') . (($gm2 != $gm1) ? "-" . $gm2 : '') . " " . $gy2 . "م";
	
	$wd = array(0 => 1, 2, 3, 4, 5, 6, 0);
	$month_length = $c->days_in_month($month, $year);
	$b_month = $month - 1;
	$b_year = $year;
	if ($b_month == 0) {
		$b_month = 12;
		$b_year--;
	}
	$a_month = $month + 1;
	$a_year = $year;
	if ($a_month == 13) {
		$a_month = 1;
		$a_year++;
	}
	echo '<div class="navigation"><a class="prev" href="monthCalendar.php?month=' . $b_month . '&year=' . $b_year . '">&lt;</a>' . '<div class="title" >' . $title . '<a class= "next" href="monthCalendar.php?month=' . $a_month . '&year=' . $a_year . '">&gt;</a>' . '</div>
</div>';
	if ($wd[$start_wd] > 0) {
		$d->modify("-" . $wd[$start_wd] . " day");
	}
	echo '<table>
    <tr>
        <th class="weekday">السبت</th>
        <th class="weekday">الاحد</th>
        <th class="weekday">الاثنين</th>
        <th class="weekday">الثلاثاء</th>
        <th class="weekday">الأربعاء</th>
        <th class="weekday">الخميس</th>
        <th class="weekday">الجمعه</th>
    </tr>';
	$dayw = 0;
	do {
		list($hd, $hm, $hy, $gd, $gm, $gy) = explode('-', $d->format("_j-_n-_Y-j-n-Y"));
		if ($dayw == 0) {
			echo "<tr>";
		}
		$class = '';
		if ($cday == $hd && $cmonth == $hm && $cyear == $hy && $sarii ==$sarii) {
			$class = "today";
		} elseif ($hm == $month) {
			$class = "current";
		}

require_once '../hijri.class.php';

//include_once("sd.php");
$bb=("$hd-$hm");
$sari =  $row['sari'];
$sari= "$sari";
echo "$sari";

//include('./Salat.class.php');
//include_once("sd.php");
//include("slati/index.php");
$sari =  $row['sari']; 
echo  $sari;
$sari="$sari";
$md=("$hd-$sari");

if ($hd==$hd AND $hm==$hm)
{
if ($bb==!("$hd-$hm"))
;{
include_once("sd.php");
//	$id=$row['id'];
	$id="0";}
$server = "localhost";
$username = "user_name";
$password = "bass";
$database = "database";
//h

/*foreach($_GET as $KEy => $VAl){$$KEy=htmlspecialchars(strip_tags(addslashes($VAl))); }

foreach($_POST as $KEy => $VAl){$$KEy=htmlspecialchars(strip_tags(addslashes($VAl))); }
*/



list($hd, $hm, $hy, $gd, $gm, $gy) = explode('-', $d->format("_j-_n-_Y-j-n-Y"));

require_once '../hijri.class.php';

$con = mysql_connect($server,$username,$password);

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }



//$d= new hijri\datetime();

//$bb=("$gd-$hm");

mysql_select_db($database, $con);

echo '<form>';



$bb=("$hd-$hm");

$result = mysql_query("
	SELECT sari,zo
,id

FROM rafia_ehdaa 
	WHERE  zo ='$bb' ");

while($row = mysql_fetch_array($result))

{

//print_r($row);

//$zdd =  $row['zo']; 

// $sari =  $row['sari']; 

extract($row); 

//$result = mysql_query($query, $db);

// $id = $row['id'];

 //$row2 = $apt->dbarray($result2);

if($row)

{

$sari =  $row['sari']; 

     $row['sari']; 

       $row['zo'];  

    // $row['zm'];

    $zo= $row['zo']; 

    /*$result=mysql_query("SELECT * FROM `countriestable`");

    echo '<select name="country" size="1">';

	while ($row = mysql_fetch_array($result, MYSQL_BOTH))

    echo '<option value="'.$row[countryNO].'">'.$row[countryName].'</option>';
    echo '</select>';*/

//$sari=$sari;
//

if ($bb==('$zo'));{

//echo $sariii;

//}

//include_once("sd.php");
//$id = '5';
 //$id = $row['id'];
//$sari = $row['sari'];
@header('Content-type: text/plain; charset=windows-1256');
 //echo "[$zo]",$sari; 
$sari="$sari";
$sarii=$row['sari'];
//$id=$row['id'];
$sari="!";
//$sari = '<img src="http://shafeen.atwebpages.com/vb/images/icons/icon1.png"  alt ="'.$row[sari].'"/>';
}}}
}
echo " <td alt='gg' class='$class'><a href='index.php?id=$id&gm=$gm&gd=$gd&gy=$gy&d=$dayw'>$hd $sari<br/>&nbsp;<span class='gre'>$gd </span></a></td>";
		if ($dayw == 6) {
			echo "</tr>";
			$dayw = 0;
			if (($hm > $month) || ($hy > $year) || ($hm == $month && $hd == $month_length)) {
				break;
			}
		} else {
			$dayw++;
		}
		$d->modify("+1 day");
	} while (TRUE);
}
$d = new hijri\datetime();
list($year, $month) = explode(' ', $d->format('_Y _n'));
// echo is_integer($_REQUEST['month'])).$_REQUEST['year'];
if (isset($_REQUEST['month']) && isset($_REQUEST['year'])) {
	$tmonth = (int) $_REQUEST['month'];
	$tyear = (int) $_REQUEST['year'];
	
	if ($tmonth > 0 && $tmonth < 13) {
		$year = $tyear;
		$month = $tmonth;
	}
}

?>
<!DOCTYPE html>
<html laang="ar">
<head>
<meta charset="windows-1256" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>التاريخ الهجري والميلادي مع الاحداث</title>
<!-- add styles and scripts -->
<style>
/* calendar styles */
#calendar {
	-moz-user-select: none;
	border: 1px solid #EEEEEE;
	border-radius: 8px 8px 8px 8px;
	color: #333333;
	font-family: Arial, sans-serif;
	font-size: 1.1em;
	margin: 14px auto;
	padding: 0.4em;
	width: 90%;
	direction: rtl;
}

#calendar .navigation {
	background-color: #CC0000;
	border: 1px solid #E3A1A1;
	border-radius: 8px 8px 8px 8px;
	color: #FFFFFF;
	font-weight: bold;
	padding: 1px;
	position: relative;
}

#calendar .navigation .title{
	background: none repeat scroll 0 0 transparent;
	border-color: rgba(0, 0, 0, 0);
	color: inherit;
	line-height: 1.1em;
	margin: 0 2.3em;
	text-align: center;
text-title:hiii;
}

#calendar .navigation .prev, #calendar .navigation .next {
	text-decoration: none;
	color: #FFFFFF;
	height: 24px;
	opacity: 0.9;
	position: absolute;
	top: 6px;
	width: 36px;
}

#calendar .navigation .prev {
	background-position: 0 0;
	right: 4px;
}

#calendar .navigation .next {
	background-position: -24px 0;
	left: 4px;
}

#calendar .navigation .prev:hover, #calendar .navigation .next:hover {
	opacity: 1;
}

#calendar table {
	border-collapse: collapse;
	font-size: 0.9em;
	table-layout: fixed;
	width: 100%;
}

#calendar table th {
	border: 0 none;
	font-weight: bold;
	padding: 0.7em 0.3em;
	text-align: center;
}

#calendar table td {
	border: 0 none;
	padding: 1px;
}

#calendar table td a {
	background-color: #EEEEEE;
	border: 1px solid #D8DCDF;
	color: #004276;
	display: block;
	font-weight: normal;
	opacity: 0.7;
	padding: 0.2em;
	text-align: right;
	text-decoration: none;
}

#calendar table td a:hover {
	background-color: #F6F6F6;
	border: 1px solid #CDD5DA;
	color: #111111;
}

#calendar table td.current a {
	font-weight: bold;
	opacity: 1;
}

#calendar table td.today a {
	background-color: #FBF8EE;
	border: 1px solid #FCD3A1;
	color: #444444;
	font-weight: bold;
	opacity: 1;
}

#calendar span.gre {
	text-align: left;
	direction: ltr;
	color: #0080CC;
	float: left;
}
</style>
</head>
<body>
	<div id="calendar">
<?php

$bb=("$hd-$hm");
include_once("sd.php");
$sari = $row['sari'];
$id=$row[id];
$zo=$row['zo'];
 //echo "[$zo]",$sari; 

echo $id;

@header('Content-type: text/html;charset=windows-1256 ');
buildMonthCal($month, $year)?>
    </div>
</body>
</html>
