<?php
session_start();
// ==================	
include("../../asset/theme/css/myfunc.php");		  
include("../../php_crud/my_class.php");
$obj = new my_class();
$branchid = $_SESSION['LOGIN_BRANCH'];
extract($_GET);
$current_session = $_SESSION['ADMISSION_SESSION'];
$selected_admission_details=addslashes(trim($_GET['detailed_id_as_class']));

//echo "current_session: ".$current_session."--class: ".$selected_admission_details;
//exit;
$table_name='_students_admission_form';
$where_cond="_session='".$current_session."' AND _class=".$selected_admission_details;//" AND (_approve_status='A' OR _approve_status='S')   ";
//echo $where_cond;
//$where_cond=" _session='".date('Y')."' AND branch_id=".$branch_id." ";
$all_list=$obj->View_All_By_Cond($table_name,$where_cond);
//print_r($all_list);

foreach($all_list as $val){
	 $admission_id = $val['admission_id'];
	 $branch_id = $val['branch_id'];
	 //echo "admission_id: ".$admission_id."--branch_id: ".$branch_id1;
	 $wher = 'admission_id='.$admission_id.' AND branch_id='.$branch_id;
	 $num_list=$obj->num_of_rows('_students_admission_mark_entry',$wher);
	// print_r($num_list);
	 if($num_list->num>=0){
		 $form_data=array(
				'branch_id'=>$branch_id,
				'admission_id'=>$admission_id,
				'last_update_by'=>isset($_SESSION['LOGIN_USERID'])?$_SESSION['LOGIN_USERID']:'' 
		);
		  $num_list=$obj->Insert_Data_By_Cond('_students_admission_mark_entry', $form_data,$wher);
	 	
	 }
	 	 
	}
	//exit;//echo $num_list['_exam_mark'];

$det_in = $obj->Details_By_Cond("_int_institute_setup_vw","department_id='$dept_id'");
extract($det_in);
//echo $selected_class;
//exit;
$gen_name = "admission_details=".$selected_admission_details."&dept_id=".$dept_id."&selected_shift=".$selected_shift.
"&selected_medium=".$selected_medium."&selected_class=".$selected_class."&selected_dept=".$selected_dept;
//echo $gen_name;
//echo $det_in['shift'].'--'.$det_in['medium'].'--'.$det_in['class'].'--'.$det_in['department'];
?>
<!--<div class="page-content">
<div class="row-fluid">--><div class="widget-box2">
		<!--<div class="widget-header header-color-green2">
			<h4 class="smaller" >
				<small style="color:#fff;">Marks Entry Subject Selection </small>
			</h4>
			<button onclick="return_to_ct_sub_list()" class="btn btn-small btn-success" type="button" id="back_qz_sub_table" style="text-align:right; float:right;">
				<i class="icon-arrow-left icon-on-left"></i>
					BACK
			</button>
		</div>-->
		<div class="widget-body">
			<div class="widget-main">
		<p> 
	<span style="font-size:11px;" class="alert alert-success inline no-margin"><?php echo '<b>Shift:</b> '.$det_in['shift'];?></span> 
    <span style="font-size:11px;" class="alert alert-success inline no-margin"><?php echo '<b>Class:</b> '.$det_in['class']; ?></span> 
	<span style="font-size:11px;" class="alert alert-success inline no-margin"><?php echo '<b>Department:</b> '.$det_in['department'];?></span>
	<span style="font-size:11px;" class="alert alert-success inline no-margin"><?php echo '<b>Session:</b>'.$_SESSION['ADMISSION_SESSION'];?></span>			
		</p>
			</div>
		</div>
</div><br>
<div class="row-fluid">


<div class="span6" id="step">
<!--PAGE CONTENT BEGINS-->

<div class="">
<div class="well">

<div class="row-fluid" id="first_part">
<div class="login-container">


<div class="space-6"></div>

<div class="row-fluid">
<div class="position-relative">
<div id="login-box" class="login-box visible widget-box no-border">
<div class="widget-body">
<div class="widget-main">
<h4 class="header blue lighter bigger">
<i class="icon-coffee green"></i>
Please Enter Excel File
</h4>

<div class="space-6"></div>

<form enctype="multipart/form-data" id="profil_form"/>

<fieldset>
<label>
<span class="block input-icon input-icon-right">
<input type="hidden" name="dept_id" id="dept_id" value="<?php echo $dept_id; ?>"/>
<input type="hidden" name="admission_dtl" id="admission_dtl"  value="<?php echo $selected_admission_details;?>"/>

<input type="file" name="file" id="file" class="input-large">
<i class="icon-cloud-upload"></i>
</span>
</label>
<div class="space"></div>

<div class="clearfix loading-div">


<button onclick="return false;" class="width-30 pull-right btn btn-small btn-primary" id="upload_xlsx" name="upload_xlsx" value="upload" >
<i class="icon-key"></i>
Upload
</button>
</div>
<br>

<div class="space-4"></div>
</fieldset>
</form>

</div><!--/widget-main-->



</div><!--/widget-body-->

</div><!--/login-box-->

</div><!--/position-relative-->
</div>
</div>
</div>	



</div>

</div><!--PAGE CONTENT ENDS-->
</div><!--/.span-->
<div class="span6 abcd"   >
<!--PAGE CONTENT BEGINS-->

<div class="">
<div class="well" style="padding: 33px;">

<div class="row-fluid" id="first_part">
<div class="login-container">


<div class="space-6"></div>

<div class="row-fluid">
<div class="position-relative">
<div id="login-box" class="login-box visible widget-box no-border">
<div class="widget-body">
<div class="widget-main">
<h4 class="header blue lighter bigger">
<i class="icon-coffee green"></i>
Download Sample Format
</h4>

<div class="space-6"></div>


<div >
    <table width="100%">
		<tr>
			<td>
				<p style="font-weight:bold;font-size:15px;">
					<a href="module/admission/admission_empty_mark_sheet_excel_download.php?<?php echo $gen_name;?>">
						Click here </a>							
						To create Excel file without mark
						<!--<?php  //echo $cal;?> ,Section:<?php //echo $section;?>-->
				</p>
			</td>
		</tr>
		<tr>
			<td>
				<p style="font-weight:bold;font-size:15px;font-color:#9999;">
					<a href="module/admission/admission_mark_sheet_excel_download.php?<?php echo $gen_name;?>">
						Download </a>							
						Excel file with existing mark
					<!--<?php  //echo $cal;?> ,Section:<?php //echo $section;?>-->
				</p>
				<hr style="color: #cc99;">
			</td>
		</tr>
	</table>
	</div>

</div><!--/widget-main-->



</div><!--/widget-body-->

</div><!--/login-box-->




</div><!--/position-relative-->
</div>
</div>
</div>	




</div>
</div><!--PAGE CONTENT ENDS-->

</div>



<div class="span6" id="step1" style="display:none;">
<!--PAGE CONTENT BEGINS-->

<div class="">
<div class="well">

<div class="row-fluid" id="first_part">
<div class="login-container">


<div class="space-6"></div>

<div class="row-fluid">
<div class="position-relative">
<div id="login-box" class="login-box visible widget-box no-border">
<div class="widget-body">
<div class="widget-main">
<h4 class="header blue lighter bigger">
<i class="icon-coffee green"></i>
Notice:
</h4>

<div class="space-6"></div>

<?php 

$view = $obj->Details_By_Cond('_int_institute_setup_vw','section_id = "'.$section_id.'"');
$sec = $view['section'];

?>
<div class="row-fluid second" id="second_part" style="display:none;font-size:18px;font-weight:bold">
Result are inserted.
   
</div>

<div class="row-fluid third" id="" style="display:none;font-size:18px;font-weight:bold;">
Please Enter Excel Sheet in Proper Format.
</div>





</div><!--/widget-main-->



</div><!--/widget-body-->

</div><!--/login-box-->




</div><!--/position-relative-->
</div>
</div>
</div>	



</div>
</div><!--PAGE CONTENT ENDS-->

</div><!--/.span-->




<!--</div><!--/.row-fluid
</div><!--/.page-content-->

<!--/#ace-settings-container-->
<!--	</div><!--/.main-content-->
<!-- </div> --><!--/.main-container-->



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

<script type="text/javascript">

     $("#upload_xlsx").click(function(){
     	$this = $(this);
       //alert('hello');
	 
		var shift_id = '<?php echo $selected_shift; ?>';
		var medium_id = '<?php echo $selected_medium;?>';
		var class_id = '<?php echo $selected_class;?>';
		var dept_id = '<?php echo $selected_dept;?>';
       var admission_details ='<?php echo $selected_admission_details;?>';
         var adm_dtl=$("#admission_dtl").val();
		
         var file_ = $("#file").val();
         var file_data = $('#file').prop('files')[0];   
	    var form_data = new FormData();                  
	    form_data.append('file', file_data);
		if(file_==""){
		alert("Select Excel Data ");
		$('#file_data').focus();
		return false;
	    }
		else{
        $.ajax({

                dataType: 'text',  // what to expect back from the PHP script, if anything
                cache: false,
                contentType: false,
                processData: false,
                type:"post" ,
				url:"module/admission/admission_mark_excel_sheet.php?adm_dtl="+adm_dtl+"&dept_id="+dept_id+"&shift_id="+shift_id+
				"&medium_id="+medium_id+"&class_id="+class_id+"&selected_admission_details="+admission_details,
				//url:"module/quize/insert_excel_quize.php?sc_id="+section_idd+"&sess="+session+"&term_id="+term_id+"&subject_id="+subject_id,
			   	data:form_data ,
			   	cache:false ,
			   	success:function(st){	
					alert(st);
					
					/* if(st) {alert('Success');}
					else  { alert('hmm no');} */
					if(st=='ok')
					{
					$('#step').remove();
					$('.second').css("display","block");
					//$('.second').html(st);
					
					$('#step1').css("display","block");}
					else {
						
						$('#step').remove();
					    $('.third').css("display","block");
					   // $('.third').html(st);
					   $('#step1').css("display","block");}
					
					
				  	}
			   	});

	   }
	   //AJAXProcess('module/profile/student/insert_excel_profile','student_form');
			 $this.html('<i class="icon-spinner icon-spin orange bigger-125 icon-loading" ></i> Upload... ');
	  
      	});
</script>