<?php require "_header.php"; 
?>
<script language="javascript" type="text/javascript">
//document.getElementById("main-content").style.display = 'none';
</script>
<div id="main-report" align="center">
<style>
	.table-report{
		font-family:Verdana, Geneva, sans-serif;
		font-size:11px;
		text-align:left;
		border-right:0px none;
		border-bottom:0px none;
	}
	.table-report-inner{
		font-family:Verdana, Geneva, sans-serif;
		font-size:11px;
	}
	.table-report tr{
		padding:2px 2px 2px 2px;
	}
	.table-report td{
		padding:2px 2px 2px 2px;
		border-top:0px none;
		border-left:0px none;
	}
	.table-report th{
		padding:2px 2px 2px 2px;
		font-weight:bold;
		text-align:left;
		border-top:0px none;
		border-left:0px none;
	}	
	.college_name{
		font-family:QTAbbie;
		font-size:26px;	
		font-weight:bold;
		padding:2px 2px 2px 2px;
		text-align:center;
	}
	.college_address{
		font-family:Tahoma, Geneva, sans-serif;
		font-size:14px;	
		text-align:center;
		padding:2px 2px 2px 2px;
	}
	.report_name{
		font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
		font-size:13px;	
		background-color:#CCC;
		text-align:center;
		font-weight:bold;
		padding:2px 2px 2px 2px;
	}
li{
	padding-bottom:5px;
}
</style>
<?php 
	//$header_row_string="Present Notice Report";
	
	$type 			 = Escape($_REQUEST['report_type']);
	$branch_id 		= Escape($_REQUEST['branch_hidden']);
	$semester_id 	  = Escape($_REQUEST['semester_hidden']);
	$year_id		   = Escape($_REQUEST['year_hidden']);
	$branchyear_id		   = Escape($_REQUEST['branchyear_hidden']);
	$student_id 	   = Escape($_REQUEST['student_hidden']); 
	$batch_id 		 = Escape($_REQUEST['batch_idhidden']);
	$monthname 		= Escape($_REQUEST['monthname']); 
	$year 			 = Escape($_REQUEST['year']);
	
	
		$branch_name = Escape($_REQUEST['branch_disp']);
		$year_name = Escape($_REQUEST['year_disp']);
		$branchyear_name = Escape($_REQUEST['branchyear_disp']);
		$semester_name = Escape($_REQUEST['semester_disp']);
		$month_name 	   = Escape($_REQUEST['month_disp']);
		$batch_name 	   = Escape($_REQUEST['batch_disp']);

	if($branch_id == "" ){?>
		<script language="javascript" type="text/javascript">
			location.href='report-present-notice.php';
		</script><?php
	}
	elseif($_SESSION['VedantnrCollegeId']!="" && isset($_SESSION['VedantnrCollegeId'])){
		ob_start();
		$i=1;
		
		dbquery("SET group_concat_max_len = 102400");
		
		function curmonth_days($branch_id,$semester_id,$year_id,$branchyear_id,$monthname,$year,$subject_id,$batch_id)
		{
			/* START PRESENT DAYS CODE */ 
			$sql_days = "
				SELECT 
					*
				FROM 
					cms_presentmaster 
				WHERE 
					day_working = 1 AND
					Extract(MONTH FROM day_date)= '".$monthname."' AND Extract(YEAR FROM day_date)= '".$year."'
					AND branch_id = '".$branch_id."'
					AND semester_id = '".$semester_id."'
					AND year_id = '".$year_id."'
					AND branchyear_id = '".$branchyear_id."'
					AND subject_id = '".$subject_id."'
					AND college_id = '".$_SESSION['VedantnrCollegeId']."'
					 AND batch_id IN ('".$batch_id."',0)";
			
			$res_days = dbQuery($sql_days);		
			return dbRows($res_days);
			/*$rec_days = dbArray($res_days);
			$rec_days = explode(",",$rec_days['day_present']);
			$rec_days = array_count_values($rec_days);
			return $rec_days[$student_id];*/
			/* END PRESENT DAYS CODE */
		}
		
		function curmonth_presentdays($branch_id,$semester_id,$year_id,$branchyear_id,$monthname,$year,$student_id,$subject_id,$batch_id)
		{
			/* START PRESENT DAYS CODE */ 
			$sql_days = "
				SELECT 
					GROUP_CONCAT(day_present) AS day_present
				FROM 
					cms_presentmaster 
				WHERE 
					day_working = 1 AND
					Extract(MONTH FROM day_date)= '".$monthname."' AND Extract(YEAR FROM day_date)= '".$year."'
					AND branch_id = '".$branch_id."'
					AND semester_id = '".$semester_id."'
					AND year_id = '".$year_id."'
					AND branchyear_id = '".$branchyear_id."'
					AND subject_id = '".$subject_id."'
					AND college_id = '".$_SESSION['VedantnrCollegeId']."'
					AND batch_id IN ('".$batch_id."',0)";
			$res_days = dbQuery($sql_days);		
			$rec_days = dbArray($res_days);
			$rec_days = explode(",",$rec_days['day_present']);
			$rec_days = array_count_values($rec_days);
			
			if($rec_days[$student_id] > 0)
				return $rec_days[$student_id];
			return 0;	
			/* END PRESENT DAYS CODE */
		}
		
		function semester_days($branch_id,$semester_id,$year_id,$branchyear_id,$monthname,$year,$student_id,$batch_id)
		{
			/* START SEMESTER CODE */
			$sql_days1 = "
				SELECT 
					GROUP_CONCAT(day_present) AS day_present
				FROM 
					cms_presentmaster 
				WHERE 
					day_working = 1 
					AND	Extract(YEAR FROM day_date)= '".$year."'
					AND Extract(MONTH FROM day_date) <= '".$monthname."'
					AND branch_id = '".$branch_id."'
					AND semester_id = '".$semester_id."'
					AND year_id = '".$year_id."'
					AND branchyear_id = '".$branchyear_id."'
					AND college_id = '".$_SESSION['VedantnrCollegeId']."'
					 AND batch_id IN ('".$batch_id."',0)";
			$res_days1 = dbQuery($sql_days1);
			$rec_days1 = dbArray($res_days1);
			$day_present1 = explode(",",$rec_days1['day_present']);
			$rec_days = array_count_values($day_present1);
			return $rec_days[$student_id];
			/* END SEMESTER CODE */	
		}
		
		/* START CURRENT MONTH WORKING DAYS CODE */
		function curmonth_workingdays($branch_id,$semester_id,$year_id,$branchyear_id,$monthname,$year,$batch_id)
		{
		$sql_workingdays = "
			SELECT 
				day_present AS day_present,
				day_absent AS day_absent
			FROM 
				cms_presentmaster 
			WHERE 
				day_working = 1 AND
				Extract(MONTH FROM day_date)= '".$monthname."' AND Extract(YEAR FROM day_date)= '".$year."'
				AND branch_id = '".$branch_id."'
				AND semester_id = '".$semester_id."'
				AND year_id = '".$year_id."'
					AND branchyear_id = '".$branchyear_id."'
				AND college_id = '".$_SESSION['VedantnrCollegeId']."'
				 AND batch_id IN ('".$batch_id."',0)";
		$res_workingdays = dbQuery($sql_workingdays);
		$total__workingdays = dbRows($res_workingdays);
		return $total__workingdays;
		}
		/* END CURRENT MONTH WORKING DAYS CODE */
		
		/* START SEMESTER WORKING DAYS CODE */
		function semester_workingdays($branch_id,$semester_id,$year_id,$branchyear_id,$monthname,$year,$batch_id)
		{
		$sql_workingdays1 = "
			SELECT 
				day_present AS day_present,
				day_absent AS day_absent
			FROM 
				cms_presentmaster 
			WHERE 
				day_working = 1 
				AND Extract(YEAR FROM day_date) = '".$year."' 
				AND Extract(MONTH FROM day_date) <= '".$monthname."' 
				AND branch_id = '".$branch_id."'
				AND semester_id = '".$semester_id."'
				AND year_id = '".$year_id."'
					AND branchyear_id = '".$branchyear_id."'
				AND college_id = '".$_SESSION['VedantnrCollegeId']."'
				AND batch_id IN ('".$batch_id."',0)";
		$res_workingdays1 = dbQuery($sql_workingdays1);
		$total__workingdays1 = dbRows($res_workingdays1);
		return $total__workingdays1;
		}
		/* END SEMESTER WORKING DAYS CODE */
		
		/* START SUBJECT CODE */
	
		$sql_subject = "
			SELECT
				DISTINCT sm.subject_name,sm.subject_id
			FROM
				cms_presentmaster pm,
				cms_subjectmaster sm
			WHERE
				sm.subject_id = pm.subject_id AND
				pm.branch_id = '".$branch_id."' AND
				pm.semester_id = '".$semester_id."' 
				AND pm.year_id = '".$year_id."'
				AND pm.branchyear_id = '".$branchyear_id."'and
				pm.college_id = '".$_SESSION['VedantnrCollegeId']."' 
				
			ORDER BY
				sm.subject_id ASC ";
		$res_subject = dbQuery($sql_subject);
		
		/* END SUBJECT CODE */
		
		/* START STUDENT CODE */
		$sql_student = "
					SELECT
						sm.student_id,
						CONCAT(sm.student_surname,' ',sm.student_firstname,' ',sm.student_lastname) AS student_name,
						sd.batch_id,
						sm.student_addressat,
						sm.student_addresspost,
						sm.student_pincode
					FROM
						cms_studentmaster sm,
						cms_studentdetail sd
					WHERE
						sm.student_id = sd.student_id AND
						sm.student_active = 1 AND
						sd.college_id = ".$_SESSION["VedantnrCollegeId"];
		$where = "";
		if($student_id != 0)
			$where .= " AND sm.student_id = $student_id "; 
		if($_REQUEST['batch_idhidden'] != '0')
			$where .= " AND sd.batch_id = '".$_REQUEST['batch_idhidden']."'"; 
		if($branch_id != "")
			$where .= " AND sd.cur_branchid = $branch_id ";
		
		if($semester_id != "")
			$where .= " AND sd.cur_semesterid = $semester_id ";
		if($year_id != "")
			$where .= " AND sd.year_id = '".$year_id."'";

		if($branchyear_id != "")
			$where .= " AND sd.cur_branchyearid = '".$branchyear_id."'";
			 
		
		
	
		if($where != "")
		$sql_student .= $where;	
		$sql_student .= " ORDER BY sm.student_gturegno ASC ";	
		$res_student = dbQuery($sql_student);
		/* END STUDENT CODE */
		
		if(dbRows($res_student)>0){
			while($rec_student = dbArray($res_student)){
				$student_id = $rec_student['student_id'];	
				$batch_id = $rec_student['batch_id'];
				$count_present = 0;
				$count_absent = 0;
				
				$count_present1 = 0;
				$count_absent1 = 0;
				
				$temp_wdays = 0;
				$temp_pdays = 0;
		
			/*	for($i=0; $i<count($day_present); $i++){
					if($day_present[$i] == $student_id){
						$count_present++;
					}
				}
				
				for($i=0; $i<count($day_present1); $i++){
					if($day_present1[$i] == $student_id){
						$count_present1++;
					}
					
				}*/

$total__workingdays1=semester_workingdays($branch_id,$semester_id,$year_id,$branchyear_id,$monthname,$year,$batch_id);			$total__presentdays1 = semester_days($branch_id,$semester_id,$year_id,$branchyear_id,$monthname,$year,$student_id,$batch_id); 
$presentper= $total__workingdays1 != 0 ?number_format(($total__presentdays1*100)/$total__workingdays1,0) :0; 
if($presentper <= $_REQUEST['belowper'])
{
				?>
                	<table width="100%" border="0" cellpadding="2" cellspacing="2" style="font-size:12px; color:#000;">
                    	
		<div class="college_name"><?php echo $_SESSION["VedantnrCollegeName"]; ?></div>
		<div class="college_address"><?php echo $_SESSION["VedantnrCollegeAddress"]; ?></div>
		<div class="college_address">
			
			Email: <?php echo $_SESSION["VedantnrCollegeEmail"]; ?>
			&nbsp;&nbsp;
			Phone: <?php echo $_SESSION["VedantnrCollegePhone"]; ?>
		</div>
                        <tr>
                        	<td colspan="2">પ્રતિ,</td>
                        </tr>
                    	<tr>
                        	<td width="78%" align="left"><textarea rows="5" cols="40"><?php echo $rec_student['student_name'].",\n".str_replace("'","",$rec_student['student_addressat'].$rec_student['student_addresspost']).", Pin: ".$rec_student['student_pincode'];if($rec_student['student_mobilestudents']!="")echo "\n".$rec_student['student_mobilestudents'] ?></textarea>
                            </td>
                            <td width="22%" style="text-align:right;padding-right:5px;vertical-align:top;">
                            <?php echo 'તા.&nbsp;'.date('d-m-Y'); ?></td>
                        </tr>
                        <tr>
                        <td style="height:10px">
                        </td>
                        </tr>
                         <tr>
                        	<td colspan="2" align="center" style="font-weight:bold; font-size:18px">વિષય : વિદ્યાર્થીનું માહિતી પત્રક</td>
                        </tr>
                        <br />
                        
                        <tr>
                        	<td colspan="2">સુજ્ઞ વાલીમિત્ર, </td>
                        </tr>
                        <tr>
                        <td colspan="2">કુશળ હશો. </td>
                        </tr>
                        
                     
                        
                        <tr>
                       <td colspan="2" style="text-align:justify;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;જયભારત સહ જણાવવાનું કે આપનો પાલ્ય  <u><b><?php echo $rec_student['student_name']; ?></b></u> અમારી સંસ્થામાં સેમીસ્ટર <u><b><?php echo $semester_id; ?></b></u> માંબ્રાન્ચ <u><b><?php echo $branch_name; ?></b></u> માં અભ્યાસ કરે છે. સરકારશ્રીના નિયમ અનુસાર ચાલુ સેમીસ્ટર ટુંક સમયમાં પુર્ણ થઇ જશે. હાલમાં આપના બાળકની ચાલુ સેમીસ્ટરની કામગીરી દરમિયાન નીચે જણાવેલ મુદ્દામાં અનિયમિતતા / લાગુ પડે છે. જેથી આપશ્રીને નમ્ર વિનંતી કે કોલેજ કાર્યાલયનો પત્ર મળેથી દિન-૫માં રૂબરૂ  સવારે ૧૦ થી બપોરના ૪ દરમિયાન સંપર્ક કરવો. 
                            </td>
                            </tr>
                            <br />
                            <tr>
                            <td colspan="2" style="text-align:justify;">
                            	<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                તા. ૫-૩-૧૨ ને શનિવાર સુધીમાં વિદ્યાર્થીની હાજરી <b><u>
                                <?php 
						  
						   
echo $presentper."%"; ?></u></b>
છે. જી.ટી.યુ. ના નિયમ અન્વયે ૭૫% હાજરી અનિવાર્ય હોઇ આપશ્રી આપનો પાલ્ય કોલેજમાં નિયમિત હાજર રહે તે બાબતની તકેદારી અચૂક રાખશો.
                                </p>
                                
                               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                               આપનો પાલ્ય નીચે જણાવેલ મુદ્દાઓ પૈકી ટીક ( <img src="true.PNG" width="20px" height="16px"/> ) કરેલ મુદ્દા લાગુ પડે છે.
                           
                          
                     <br/>
                     <tr>
                     <td> <table><tr><td>૧.&nbsp;</td><td ><div style="border:double;border-width:thin ;width:30px; height:25px"></div></td><td> આપની ચાલુ સેમીસ્ટરની ફી બાકી છે.</table></td>
                     <td rowspan="3">
                     <div style="border:double; border-width:thin; padding:3px; width:200px">
                     <b><u>નોંધ : </u></b>તા. ૧-૨-૨૦૧૨ થી જી.ટી.યુ. ના નિયમ અનુસાર દરેક વિદ્યાર્થીને  આજદિન સુધીની હાજરી સરકારશ્રીની વેબસાઇટ ઉપર પુરવામાં આવેલ છે.
                     </div>
                     </td>
                     </tr>
                      <tr>
                      
                      
                     
                            
                            
                     <td colspan="2"> <table ><tr><td>૨.&nbsp; </td><td ><div style="border:double;border-width:thin ;width:30px; height:25px"></div> </td><td>  વિદ્યાર્થીની વર્તણૂંક અંગે મળવા બાબત.</table></td>
                     </tr>
                      <tr>
                     <td colspan="2"><table><tr><td>૩.&nbsp; </td><td> <div style="border:double;border-width:thin ;width:30px; height:25px"></div></td><td>  જી.ટી.યુ. ની પરીક્ષા આપી નથી.</table></td>
                     </tr>
                      <tr>
                     <td colspan="2"><table><tr><td>૪.&nbsp; </td><td ><div style="border:double;border-width:thin ;width:30px; height:25px"></div> </td><td>  સરકારશ્રીના નિયમ અનુસાર હાજરી ઓછી હોઇ ૧ વર્ષ ડીટેઇન થાય છે.</table></td>
                     </tr>
                      <tr>
                     <td colspan="2"><table><tr><td>૫.&nbsp; </td><td ><div style="border:double;border-width:thin ;width:30px; height:25px"></div> </td><td>  સંસ્થામાં લાઇબ્રેરી / લેબોરેટરીમાં ભારે નુકશાન કરવા બાબત.</table></td>
                     </tr>
                     <tr>
                     <td colspan="2" style="height:20px"></td>
                     </tr>
                       
                        <tr>
                      
                       <td colspan="2" style="text-align:left; padding-right:10px;">આપના સહકારની અપેક્ષા સહ આભાર સહ....</td>
                        </tr>
                        <tr>
                        	<td colspan="2" style="text-align:right; padding-right:10px;">શ્રી પ્રો ડી.એન.વંદરા </td>
                        </tr>
                        <tr>
                        	<td colspan="2" style="text-align:right; padding-right:8px;">મેનેજીંગ ડીરેકટર</td>
                        </tr>
                        <tr>
                     <td colspan="2"><div style="border:double; border-width:thin; padding:5px"><b><u>નોંધ</u></b> :- ઉપરોક્ત કોઇપણ મુદ્દા વિશે ફોન ઉપર ચર્ચા કરવી નહિં. જો આપ આપના પાલ્યની શૈક્ષણિક કારકિર્દી ઉજ્જવળ બનાવવા ઇચ્છતા હો તો ઉપરોક્ત જણાવેલ ગંભીર બાબતો માટે રૂબરૂ સંસ્થાનો સંપર્ક કરવા વિનંતી.</div></td>
                        </tr>
                        <tr>
                        	<td colspan="2">
                            	
                           	</td>
                        </tr>
                       
                    </table>
                    <br />
                    <div class="break">&nbsp;</div> 
                <?php
}
			}
			$HtmlCode= ob_get_contents();
			ob_end_flush();
			$HtmlUrl  =	"present-notice-report.html";
			$HtmlPath =	"report/".$HtmlUrl;
			createHTMLReportPage($header_row_string,$HtmlUrl,$HtmlPath,$HtmlCode);
		?>
		<br/>
		<form name="frm" id="frm" action="" method="post">		
			<input type="hidden"   name="txtFile" id="txtFile" value="<?php echo $HtmlUrl ;?>" />
            <input type="button"  name="btnPrint" id="btnPrint" value="Print" onClick="SetPageAction('PRINT');"/>
			<input type="button"  name="btnPdf" id="btnPdf" value="Create PDF" onClick="SetPageAction('PDF');"/>
			<input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onClick="SetPageAction('HTML');"/>
			<input type="button" name="btnWord" id="btnWord" value="Create WORD" onClick="SetPageAction('WORD');"/>
			<input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onClick="SetPageAction('Excel');"/>
		</form>
		<script language="javascript" type="text/javascript">
            function SetPageAction(varAction) {
                if(varAction=="PRINT"){			
                    document.frm.action="print/create-print.php";
                    document.frm.target = "_blank";
                    document.frm.submit();
                }
                else if(varAction=="PDF"){			
                    document.frm.action="convertpdf/create-pdf.php";
                    document.frm.target = "_blank";
                    document.frm.submit();
                }
                else if(varAction=="HTML"){
                    document.frm.action="<?php echo $HtmlPath; ?>";
                    document.frm.target = "_blank";
                    document.frm.submit();
                }
                else if(varAction=="WORD"){
                    document.frm.action="convertword/create-word.php";
                    document.frm.target="_blank";
                    document.frm.submit();
                }
                else if(varAction=="Excel"){
                    document.frm.action="convertword/create-excel.php";
                    document.frm.target="_blank";
                    document.frm.submit();
                }
            }
        </script><?php
		}
		else{
			echo "No data found for selected criteria.";	
		}		
	}  
   	else{
      	echo "Session Expired";      
   	}
?>
</div>
<?php require "_footer.php";?>