Current File : /home/inlingua/www/noida/icentex/admin_fd/instr_ajax.php
<?php 
require('../dbConnection.php');

// Include common functions
require('../commonFunc.php');

// Include common functions
require('../globalVars.php');

// Include the table handler class
require('../dbHandler.class.php');
// Init and connect to database
$dbObject = new dbHandler();
$dbObject->connect();
$cid=$_REQUEST['CID'];
 
$dt = date("Y-m-d");
$fdate=date("Y-m-01", strtotime($dt));
$edate= date("Y-m-t", strtotime($dt));
 
//$sqlQ = "SELECT  * FROM ingl_course where instructor='".$cid."' ";
 $sqlQ = "select * from ingl_course where instructor='".$cid."' && ((enddate>='".$fdate."') && ( enddate<='".$edate."' )) ";
//echo $sqlQuery;
$res=mysqli_query($conn,$sqlQ) or die();

$sqlQuery = "SELECT  * FROM timesheet_user where recNo='".$cid."' ";
//echo $sqlQuery;
$result=mysqli_query($conn,$sqlQuery) or die();
$results=mysqli_fetch_assoc($result);

$echovalue ="<table width='100%'>";

$echovalue .="<tr>";	
$echovalue .="<td><b>Course Id  </b></td>";	
$echovalue .="<td><b>Branch Name </b></td>";	
$echovalue .="<td><b>Level </b></td>";	
$echovalue .="<td><b>Start date  </b></td>";	
$echovalue .="<td><b>End date  </b></td>";
$echovalue .="<td><b>Total Hours</b></td>";
$echovalue .="<td><b>Done Hours</b></td>";
$echovalue .="<td><b>Current Mon. Hours</b></td></tr>";
$total=0;
while($num=mysqli_fetch_object($res))
{
	
	$doneh=$num->daily_hours * $num->doneclass;	

	$days=explode(",",$num->courseday);
	
	
	
if($num->enddate>=$edate)
{
$enddate=$edate;	
}else {
$enddate=$num->enddate;	
}
	$curmdoneh=0;
	
	while (strtotime($fdate) <= strtotime($enddate)) {
		  $getday=date('D', strtotime($fdate));
		
		 
            if(in_array($getday,$days) && $fdate >=$num->startdate)
			{
			 $curmdoneh +=1;
			 
			 			 
			}				
			   
     $fdate = date ("Y-m-d", strtotime("+1 day", strtotime($fdate)));
		
	}
$currentmdoneh=$num->daily_hours * $curmdoneh;
$echovalue .="<tr>";	
$echovalue .="<td>".$num->courseid."<br></td>";	
$echovalue .="<td>".$num->branch."<br></td>";	
$echovalue .="<td>".$num->level."</td>";	
$echovalue .="<td>".$num->startdate."</td>";	
$echovalue .="<td>".$num->enddate."</td>";	
$echovalue .="<td>".$num->totalhours."</td>";
$echovalue .="<td>".$doneh."</td>";
$echovalue .="<td>".$currentmdoneh."</td></tr>";
	
$total=$total+$doneh;
}		
$echovalue .="</table>";
echo $echovalue;
echo '<p>'.'<b>Contract Hours:</b> '.$results['startingHours']. '<b> Completed Hours: </b>'.$total.'</p>';


?>