<?php
session_start();
// ============
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
$obj=new my_class();
// ============

extract($_GET);

$section_id;

$session;
 $class_id;

//echo '</br>';
 $department_id;
 
  $select_type_value;

?>

<style type="text/css">
	.input-append, .input-prepend {
		margin-bottom: 0px !important;
	}
	select, input{
    	height: 22px !important;
    	padding: 0px !important;
    	font-size: 11px !important;
		font-color:#FFFFF;
	}
	.table th, .table td{
		padding: 2px !important;
	}
	.dataTable th[class*="sort"]::after {
	    margin-right: 0;
	}
	.select_in{
		max-width:90px !important;
	}
</style>

<?php

			$section_ids=$obj->View_All_child($department_id,'SC'); 
			$src_section_id="0".$section_ids;
			$section_id="0".$section_ids;
			
$det_in = $obj->Details_By_Cond("_int_institute_setup_vw","section_id in ($section_id)");

$tch_id = $obj->Details_By_Cond("_r_class_routine","_section_id in ($section_id) AND _teacher_type='CT' AND _teacher_id!='0' GROUP BY _teacher_type");
$teacher_id =  $tch_id['_teacher_id'];

$tch_det = $obj->Details_By_Cond("_pf_emp_personal_info","_id='$teacher_id'");

$total_row = $obj->View_Student_List_rows("sc._id in ($section_id) and bsf._session='$session'");

$src_section_id= $section_id;
			
			
?>

<div class="row-fluid">
<legend>
	Student Promotion for (<?php echo 'Class: '.$det_in['class'].', Department: '.$det_in['department'].', Student Type: '.$det_in['student_type'].', Section: '.$det_in['section']; ?>).
</legend>
</div>

<script src="module/exam/js/std_promotion.js" type="text/javascript"></script>
<!-- ==================================== -->
<form class="form-vertical" id="promotion_form">

<div class="row-fluid">	
	<input type="hidden" name="pre_sec_id" id="pre_sec_id" value="<?php echo $section_id; ?>">	

	<input type="hidden" name="total_row" id="total_row" value="<?php echo $total_row; ?>">				
	
	<table id="sample-table-273" class="table table-striped table-bordered table-hover" style="font-size:10px;">
		<thead>
			<th>Sl</th>
			<th>Student ID</th>
			<th>Name</th>
			<th>Roll</th>
			<th style="text-align: center;">
				<span>Branch</span></br>
				<span>
					<select class="select_in m_branch" id="m_branch" onchange="call_m_info(this.value,<?php echo $det_in['institute_id']; ?>,'br')" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT branch_id,branch","institute_id='".$det_in['institute_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['branch_id']==$value['branch_id']) echo 'selected'; ?> value="<?php echo $value['branch_id']; ?>"><?php echo $value['branch']; ?></option>
			   			<?php } ?>
			   		</select>
		   		</span>
			</th>
			<th style="text-align: center;">
				<span>Shift</span></br>
				<span>
					<select class="select_in m_shift" id="m_shift" onchange="call_m_info(this.value,<?php echo $det_in['branch_id']; ?>,'sh')" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT shift_id,shift","branch_id='".$det_in['branch_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['shift_id']==$value['shift_id']) echo 'selected'; ?> value="<?php echo $value['shift_id']; ?>"><?php echo $value['shift']; ?></option>
			   			<?php } ?>
			   		</select>
		   		</span>
			</th>
			<th style="text-align: center;">
				<span>Medim</span></br>
				<span>
					<select class="select_in m_medium" id="m_medium" onchange="call_m_info(this.value,<?php echo $det_in['shift_id']; ?>,'me')" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT medium_id,medium","shift_id='".$det_in['shift_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['medium_id']==$value['medium_id']) echo 'selected'; ?> value="<?php echo $value['medium_id']; ?>"><?php echo $value['medium']; ?></option>
			   			<?php } ?>
			   		</select>
		   		</span>
			</th>
			<th style="text-align: center;">
				<span>Class</span></br>
				<span>
					<select class="select_in m_class" id="m_class" onchange="call_m_info(this.value,<?php echo $det_in['medium_id']; ?>,'cl')" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT class_id,class","medium_id='".$det_in['medium_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['class_id']==$value['class_id']) echo 'selected'; ?> value="<?php echo $value['class_id']; ?>"><?php echo $value['class']; ?></option>
			   			<?php } ?>
			   		</select>
		   		</span>
			</th>
			<th style="text-align: center;">
				<span>Department</span></br>
				<span>
					<select class="select_in m_dept" id="m_dept" onchange="call_m_info(this.value,<?php echo $det_in['medium_id']; ?>,'dp')" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT department_id,department","class_id='".$det_in['class_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['department_id']==$value['department_id']) echo 'selected'; ?> value="<?php echo $value['department_id']; ?>"><?php echo $value['department']; ?></option>
			   			<?php } ?>
			   		</select>
		   		</span>
			</th>
			<th style="text-align: center;">
				<span>Student Type</span></br>
				<span>
					<select class="select_in m_std_type" id="m_std_type" onchange="call_m_info(this.value,<?php echo $det_in['medium_id']; ?>,'st')" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT student_type_id,student_type","department_id='".$det_in['department_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['student_type_id']==$value['student_type_id']) echo 'selected'; ?> value="<?php echo $value['student_type_id']; ?>"><?php echo $value['student_type']; ?></option>
			   			<?php } ?>
			   		</select>
		   		</span>
			</th>
			<th style="text-align: center;">
			
			
				<span>Section</span></br>
				<span>
					<select class="select_in m_section" id="m_section" onchange="call_m_info(this.value,<?php echo $det_in['medium_id']; ?>,'sc')" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT section_id,section","student_type_id='".$det_in['student_type_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['section_id']==$value['section_id']) echo 'selected'; ?> value="<?php echo $value['section_id']; ?>"><?php echo $value['section']; ?></option>
			   			<?php } ?>
			   		</select>
		   		</span>
			</th>
			
			<th style="text-align: center;">
			
			<span>Session</span></br>
			<span>
			
		
			
				<select class="select_in m_session" id="m_session" name="session" onchange="call_m_info(this.value,<?php echo $det_in['medium_id']; ?>,'se')" style="margin-bottom: 0;">
									<!--<option value="">--- Select ---</option>
-->									<?php
									for ($j=date('Y')-1; $j < date('Y')+2; $j++) { 							
									?>
									<option <?php if($j==$session){echo 'selected';} ?> value="<?php echo $j; ?>"><?php echo $j; ?></option>
									<?php } ?>
								</select>
			
			
			</span>
			
		
			
			</th>
			

		</thead>
		<tbody>
			<?php
			$i=0;
			

			

			
			foreach($obj->View_pass_Student_List("sc._id in ($src_section_id) AND pf_std._id!='' and bsf._session=$session and mod(bsf._position_class,2)=$select_type_value and bsf._position_class>0 ORDER BY bsf._position_class ASC") as $value_s){
			
			$i++;	
			?>	
			<tr>
				<td class="td_pad">
					<input type="hidden" name="base_info_id_<?php echo $i; ?>" value="<?php echo $value_s['_base_id']; ?>">
					
					<input type="hidden" name="class_position_<?php echo $i; ?>" value="<?php echo $value_s['_position_class']; ?>">
				</td>
				<td class="td_pad"><?php echo $value_s['_uniq_id']; ?></td>
				<td class="td_pad"><?php echo $value_s['_full_name']; if(!empty($value_s['_nick_name'])){echo ' ('.$value_s['_nick_name'].')'; } ?></td>
				<td class="td_pad"><?php echo $value_s['_section_roll']; ?></td>
				
				
				<td class="td_pad" style="text-align: center;">
					<select class="select_in branch" id="branch_<?php echo $i; ?>" onchange="call_info(this.value,<?php echo $det_in['institute_id']; ?>,'br',<?php echo $i;?>)" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT branch_id,branch","institute_id='".$det_in['institute_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['branch_id']==$value['branch_id']) echo 'selected'; ?> value="<?php echo $value['branch_id']; ?>"><?php echo $value['branch']; ?></option>
			   			<?php } ?>
			   		</select>
				</td>
				<td class="td_pad" style="text-align: center;">
					<select class="select_in shift" id="shift_<?php echo $i; ?>" onchange="call_info(this.value,<?php echo $det_in['branch_id']; ?>,'sh',<?php echo $i;?>)" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT shift_id,shift","branch_id='".$det_in['branch_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['shift_id']==$value['shift_id']) echo 'selected'; ?> value="<?php echo $value['shift_id']; ?>"><?php echo $value['shift']; ?></option>
			   			<?php } ?>
			   		</select>
				</td>
				<td class="td_pad" style="text-align: center;">
					<select class="select_in medium" id="medium_<?php echo $i; ?>" onchange="call_info(this.value,<?php echo $det_in['shift_id']; ?>,'me',<?php echo $i;?>)" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT medium_id,medium","shift_id='".$det_in['shift_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['medium_id']==$value['medium_id']) echo 'selected'; ?> value="<?php echo $value['medium_id']; ?>"><?php echo $value['medium']; ?></option>
			   			<?php } ?>
			   		</select>
				</td>
				<td class="td_pad" style="text-align: center;">
					<select class="select_in class" id="class_<?php echo $i; ?>" onchange="call_info(this.value,<?php echo $det_in['medium_id']; ?>,'cl',<?php echo $i;?>)" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT class_id,class","medium_id='".$det_in['medium_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['class_id']==$value['class_id']) echo 'selected'; ?> value="<?php echo $value['class_id']; ?>"><?php echo $value['class']; ?></option>
			   			<?php } ?>
			   		</select>
				</td>
				<td class="td_pad" style="text-align: center;">
					<select class="select_in dept" id="dept_<?php echo $i; ?>" onchange="call_info(this.value,<?php echo $det_in['class_id']; ?>,'dp',<?php echo $i;?>)" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT department_id,department","class_id='".$det_in['class_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['department_id']==$value['department_id']) echo 'selected'; ?> value="<?php echo $value['department_id']; ?>"><?php echo $value['department']; ?></option>
			   			<?php } ?>
			   		</select>
				</td>
				<td class="td_pad" style="text-align: center;">
					<select class="select_in std_type" id="std_type_<?php echo $i; ?>" onchange="call_info(this.value,<?php echo $det_in['department_id']; ?>,'st',<?php echo $i;?>)" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT student_type_id,student_type","department_id='".$det_in['department_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['student_type_id']==$value['student_type_id']) echo 'selected'; ?> value="<?php echo $value['student_type_id']; ?>"><?php echo $value['student_type']; ?></option>
			   			<?php } ?>
			   		</select>
				</td>
				<td class="td_pad" style="text-align: center;">
					<select class="select_in section" id="section_<?php echo $i; ?>" name="section_<?php echo $i; ?>" onchange="call_info(this.value,<?php echo $det_in['student_type_id']; ?>,'sc',<?php echo $i;?>)" style="margin-bottom: 0;">
			   			<option value="">- - - -</option>
			   			<?php
			   			foreach($obj->View_colmn_By_Cond("_int_institute_setup_vw","DISTINCT section_id,section","student_type_id='".$det_in['student_type_id']."'") as $value){
						extract($value);
						?>
			   			<option <?php if($det_in['section_id']==$value['section_id']) echo 'selected'; ?> value="<?php echo $value['section_id']; ?>"><?php echo $value['section']; ?></option>
			   			<?php } ?>
			   		</select>
				</td>	
				
				
				<td class="td_pad" style="text-align: center;">
				
				
				<select class="select_in session" id="session_<?php echo $i; ?>" name="session_<?php echo $i; ?>" onchange="call_info(this.value,<?php echo $session; ?>,'se',<?php echo $i;?>)" style="margin-bottom: 0;">
									<!--<option value="">--- Select ---</option>
-->									<?php
									for ($j=date('Y')-1; $j < date('Y')+2; $j++) { 							
									?>
									<option <?php if($j==$session){echo 'selected';} ?> value="<?php echo $j; ?>"><?php echo $j; ?></option>
									<?php } ?>
								</select>
			
					
					
					
				</td>	
				
				
				
				


				
			</tr>	
			<?php } ?>
			
			
		</tbody>	

	</table>

</div>

<!-- ========================== -->

<div class="row-fluid">	
	<div class="span5"><b>Class Teacher name:</b> <?php echo $tch_det['_full_name']; if(!empty($tch_det['_nick_name'])){ echo ' ('.$tch_det['_nick_name'].')';} ?></div>

	<div class="span3"><b>Mobile No:</b> <?php echo $tch_det['_contact_mobile_no']; ?></div>
</div>

<!-- =========================== -->

<div class="row-fluid">									
	<div class="span12">			
		<div class="control-group">
			<label class="control-label" for="form-field-1">&nbsp;</label>

			<div class="controls">
				<button class="btn btn-small btn-success" type="button" id="btn_save_promossion">
					<i class="icon-ok bigger-100"></i>Save
				</button>

				&nbsp; &nbsp; &nbsp;
				<button class="btn btn-small btn-danger" type="reset" id="btn_reset">
					<i class="icon-undo bigger-100"></i>
					Reset
				</button>
			</div>
		</div>
	</div>
	
</div>


</form>


<script type="text/javascript">

	// var oTable2 = $('#sample-table-273').dataTable( {
	// 	"aoColumns": [
	//       { "bSortable": true },
	//       null, null,null,null,null,null,null,null,null,null,null,null,
	// 	  { "bSortable": true }
	// 	]
	// } );

</script>