Current File : /home/inlingua/public_html/dwarka/icentex/general_leave/classaffect_ajax.php |
<?php
session_start();
// Include the database connection details
require('../dbConnection.php');
// Include the table handler class
require('../dbHandler.class.php');
$notshowaffected=1;
// Init and connect to database
$dbObject = new dbHandler();
$dbObject->connect();
$fromdate=$_GET['fromdate'];
$todate= $_GET['todate'];
$fromDate = $fromdate;
$toDate = $todate;
$dateMonthYearArr = array();
$fromDateTS = strtotime($fromDate);
$toDateTS = strtotime($toDate);
for ($currentDateTS = $fromDateTS; $currentDateTS <= $toDateTS; $currentDateTS += (60 * 60 * 24)) {
// use date() and $currentDateTS to format the dates in between
$currentDateStr = date("Y-m-d",$currentDateTS);
$dateMonthYearArr[] = $currentDateStr;
//print $currentDateStr.�<br />�;
}
//print_r($dateMonthYearArr);
foreach($dateMonthYearArr as $val)
{
$str.="(startdate<='".$val."' AND enddate>='".$val."') || ";
}
//echo $str;
$str1=substr($str, 0, -4);
//echo "djdjjdjd \n";
$query="SELECT *
FROM `ingl_course`
WHERE (".$str1.") AND instructor='".$_SESSION[id]."' ";
$result=mysqli_query($conn,$query);
while($num =mysqli_fetch_array($result))
{
$days=explode(",",$num['courseday']);
$ct=0;
$cdates="";
$fromDateTS1 = strtotime($num['startdate']);
$toDateTS1 = strtotime($num['enddate']);
for ($currentDateTS1 = $fromDateTS1; $currentDateTS1 <= $toDateTS1; $currentDateTS1 += (60 * 60 * 24)) {
// use date() and $currentDateTS to format the dates in between
$currentDateStr1 = date("Y-m-d",$currentDateTS1);
foreach($dateMonthYearArr as $val)
{
if($val==$currentDateStr1)
{
$dayw=date("D",$currentDateTS1);
if(in_array($dayw,$days))
{
$cdates.="".$currentDateStr1.",";
$ct++;
}
}
}
//print $currentDateStr.�<br />�;
}
if($ct>0)
{
$notshowaffected=0;
echo 'Level:'.$num['level'].' - CourseID:'.$num['courseid'].' - Branch:'.$num['branch'].'-Dates:'.substr($cdates,0,-1).'';
echo " \n\n";
}
}
//if($notshowaffected==1) echo "No Classes Affected";
if($notshowaffected==1) echo "No Classes Affected";
?>