<?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);
//$subject_id;
$subject_id;
$section_id;
$ct_id;
$ct_date;
$exam_session;
$session;
$exam_term;
$base_url= $_SESSION["BASE_URL"];

$newDate = date("Y-m-d", strtotime($ct_date));
$gen_name = "section_id=".$section_id."&ct_id=".$ct_id.
			"&subject_id=".$subject_id."&session=".$session."&exam_term=".$exam_term;
// =================================================

if($subject_id){
	foreach($obj->View_Student_List("sc._id='$section_id' AND bsf._session='$session' AND pf_std._status='A'") as $value){
		
		$form_data = array(
	        '_br_id'=>$_SESSION['LOGIN_BRANCH'],
			'_ct_id'=>$ct_id,
			'_subject_id'=>$subject_id,
			'_date'=>$newDate,
			'_exam_session'=>$exam_session,
			'_exam_term'=>$exam_term,
			'_section_id'=>$section_id,
			'_std_id'=>$value['_id'],
			'_atd_status'=>'P',
			'_status'=>'I',
			'_entry_by'=>$_SESSION['LOGIN_USERID'],
			'_entry_date'=>date("Y:m:d h:i:s")
		);

		$obj->Insert_Data_By_Cond("_ct_mark_sheet", $form_data,"_br_id='".$_SESSION['LOGIN_BRANCH']."' AND _ct_id='$ct_id' AND _subject_id='$subject_id' AND _exam_term='$exam_term' AND _std_id='".$value['_id']."'");
	}
}
$det_in = $obj->Details_By_Cond("_int_institute_setup_vw","section_id='$section_id'");
extract($det_in);
$sub = $obj->Details_By_Cond("_int_subject","_id=$subject_id");
//$type = $obj->Details_By_Cond("_qz_quize_type","_br_id='".$_SESSION['LOGIN_BRANCH']."' AND _id='$quiz_type_id'");
$ct_dtls = $obj->Details_By_Cond("_ct_class_test_add","_br_id='$branchid' AND _id='$ct_id'");
?>

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

<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>Student Type:</b> '.$det_in['student_type'];?></span>  
					<span style="font-size:11px;" class="alert alert-success inline no-margin"><?php echo '<b>Section:</b> '.$det_in['section']; ?> </span> 
					<span style="font-size:11px;" class="alert alert-success inline no-margin"><?php echo '<b>Quiz Name:</b> '.$ct_dtls['_ct_name']; ?> </span> 
				</p>
				<p>
					<span style="font-size:11px;" class="alert alert-success inline no-margin"><?php echo '<b>Subject Name:</b> '.$sub['_subject_full_name']; ?> </span> 
				</p> 
			</div>
		</div>
</div></div>
<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="section_idd" id="section_idd" value="<?php echo $section_id; ?>"/>
<input type="hidden" name="session_value" id="session_value"  value="<?php echo $session;?>"/>

<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>

<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/ct/ct_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/ct/ct_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);

        var section_id = '<?php echo $section_id; ?>';
        var ct_id = '<?php echo $ct_id; ?>';
        var subject_id = '<?php echo $subject_id; ?>';
        var ct_date = '<?php echo $ct_date; ?>';
        var exam_term = '<?php echo $exam_term; ?>';
		
        var section_idd=$("#section_idd").val();
         var session=$("#session_value").val();
		 /* alert(session);
		exit(); */
         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/ct/ct_inser_excel_quize.php?sc_id="+section_id+"&subject_id="+subject_id+"&ct_id="+ct_id+"&ct_date="+ct_date+"&session="+session+"&exam_term="+exam_term,
				//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");
					$('#step1').css("display","block");}
					else {
						
						$('#step').remove();
					    $('.third').css("display","block");
					   $('#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>