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

$base_url= $_SESSION["BASE_URL"];
?>
<style type="text/css">
i{
	cursor:pointer;
}

.select_list{
	width: 200px;
}

.input_sub{
	width: 185px;
}
.select_list1{
	width: 100px;
	float: left;
	margin-left: 3px;
	margin-right: 3px;
}


</style>


<script src="module/attendance/js/attendance_subject.js" type="text/javascript"></script>
<div class="page-content" style="padding-left:0px">

<div class="page-header position-relative">
            <h1 style="font-size: 18px;">
                <i class="icon-hand-right green"></i>
               Dowload Attendance Form
            </h1>
    
        </div>


<div class="row-fluid" id="first_part">
<form class="form-vertical" >
	 <input type="hidden" id="branchid" name="branchid" value="<?php echo $_SESSION['LOGIN_BRANCH'];?>"/>
	   


<div class="row-fluid">
	<div class="span3">
		<div class="control-group" >
			<label class="control-label" for="form-field-1">Select Shift<font color="#FF0000">*</font></label>

			<div class="controls">
			  	<select id="shift_id" onchange="call_medium(this.value)">
				<option value="">---SELECT---</option>
				<?php 
				$table_name="_int_institute_setup";
				$column="_id,_name";
				$where_cond="_pid='".$_SESSION['LOGIN_BRANCH']."' AND _type='SH' AND _status='A'";
				$data_list=$obj->View_all_data_row_column_By_Cond($table_name,$column,$where_cond);
									
				foreach($data_list AS $index1=>$data4_institute){ echo "<option value='".$data4_institute['_id']."'>".$data4_institute['_name']."</option>";
				}
				?>
				</select>
			</div>
		</div>
			
					
	</div>	

	<div class="span3">
		<div class="control-group" >
				<label class="control-label" for="form-field-1">Select Medium<font color="#FF0000">*</font></label>

				<div class="controls" id="branch_control">
					<select class="select_list" id="medium_id" onchange="call_class(this.value)">
			   		<option value="">- - - - - -</option>
			    </select>
				</div>
			</div>
	</div>
	
	<div class="span3">
		<div class="control-group" >
			<label class="control-label" for="form-field-1">Select Class<font color="#FF0000">*</font></label>
			<div class="controls" id="branch_control">
				<select class="select_list" id="class_id" onchange="call_department(this.value)">
		   		<option value="">- - - - - -</option>
		    </select>
			</div>
		</div>
	</div>

	<div class="span3">
		<div class="control-group" >
			<label class="control-label" for="form-field-1">Select Department<font color="#FF0000">*</font></label>
			<div class="controls" id="branch_control">
				<select class="select_list" id="department_id" onchange="call_std_type(this.value)">
		   		<option value="">- - - - - -</option>
		    </select>
			</div>
		</div>
	</div>


</div>


<div class="row-fluid">
	
	<div class="span3">
		<div class="control-group" >
			<label class="control-label" for="form-field-1">Select Student Type<font color="#FF0000">*</font></label>
			<div class="controls" id="branch_control">
				<select class="select_list" id="student_type_id" onchange="call_section(this.value)">
		   		<option value="">- - - - - -</option>
		    </select>
			</div>
		</div>
	</div>

	<div class="span3">
		<div class="control-group" >
			<label class="control-label" for="form-field-1">Select Section<font color="#FF0000">*</font></label>
			<div class="controls" id="branch_control">
				<select class="select_list" id="section_id">
		   		<option value="">- - - - - -</option>
		    </select>
			</div>
		</div>
	</div>


</div>

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

	<div class="row-fluid">
		
		<div class="span4">
				
				<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="atten_download_sheet">
							<i class="icon-cloud-upload"></i>
							Download   
						</button> 
					</div>
				</div>
		</div>
		
	</div>	
</form>
</div>

</div>
<!-- ============================================================================ -->


<div class="row-fluid data_to_show_atd_sub"  id="second_part">
</div>

<script>
$("#atten_download_sheet").click(function(){
	$this = $(this);
	var shift_id = $("#shift_id").val();
	var medium_id = $("#medium_id").val();
	var class_id = $("#class_id").val();
	var class_name = $("#class_id :selected").text();
	var department_id = $("#department_id").val();
	var department_name = $("#department_id :selected").text();
	var student_type_id = $("#student_type_id").val();
	var student_type_name = $("#student_type_id :selected").text();
	var section_id = $("#section_id").val();	
	var section_name = $("#section_id :selected").text();			
	var operation="creat_xls";
	
	var dataStr="operation="+operation+"&class_id="+class_id+"&class_name="+class_name+"&department_id="+department_id+"&department_name="+department_name+"&student_type_name="+student_type_name+"&section_id="+section_id+"&section_name="+section_name;
	var dataStr1="class_id="+class_id+"&section_id="+section_id;
	
//	$(".icon-loading").css('display','block');
//	$(this).html('<i class="icon-ok bigger-100"></i> Download');
	$this.html('<i class="icon-spinner icon-spin orange bigger-125 icon-loading" ></i> Download... ');
	
	if(shift_id==""){
		alert("Select Shift Name");
		$('#shift_id').focus();
		return false;
	}
	else if(medium_id==""){
		alert("Select Medium Name");
		$('#medium_id').focus();
		return false;
	}
	else if(class_id==""){
		alert("Select Class Name");
		$('#class_id').focus();
		return false;
	}
	else if(department_id==""){
		alert("Select Department Name");
		$('#department_id').focus();
		return false;
	}
	else if(student_type_id==""){
		alert("Select Student Type");
		$('#student_type_id').focus();
		return false;
	}
	else if(section_id==""){
		alert("Select Section Name");
		$('#section_id').focus();
		return false;
	}		
	else{
		$.ajax({
			type:"post",
			url:"module/attendance/attencance_by_sheet/create_attendance_xlx_sheet.php",
			data:dataStr ,
			success:function(st){
				//alert(st);
				$this.html('<i class="icon-cloud-upload"></i> Download');
				window.open('<?php echo $base_url.'/module/attendance/attencance_by_sheet/download_sheet.php?FILE=Section_'; ?>'+section_name+'_'+section_id+'_Attendance.xlsx');
				
			}
		}); 
	}
});

</script>
