<?php 
session_start();
// ============
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class_for_web.php");
$obj = new my_class();
$dpt = '';
extract($_GET);
$branch_id = $_SESSION['LOGIN_BRANCH'];

$table_name='_students_admission_form f INNER JOIN _students_admission_mark_entry e ON f.admission_id = e.admission_id';

$where_cond="f._session='2016' AND f.branch_id=".$branch_id." AND f._class='".$class."' AND (f._approve_status='A' OR f._approve_status='S') AND e.selection_status=1 ";
//$where_cond=" f._session='".date('Y')."' AND f.branch_id=".$branch_id." AND f._class='".$class."' AND (f._approve_status='A' OR f._approve_status='S') ";
if($dpt){
	 $where_cond= $where_cond." AND f._department='".$dpt."' ";

	}
$where_cond =$where_cond.'ORDER BY e.serial_num ASC';	
// echo 'SELECT * FROM '.$table_name.' WHERE'.$where_cond ;	
$can_list=$obj->View_All_By_Cond($table_name,$where_cond);
$result = array();
$i =0;
if(count($can_list)>0){
	foreach ($can_list AS $index1 => $value1) {
		$result[$i]['mark_entry_id'] = $value1['mark_entry_id'];
		$result[$i]['_candidate_name'] = $value1['_candidate_name'];
		$result[$i]['admission_form_id'] = $value1['admission_form_id'];
		$result[$i]['_class'] = $value1['_class'];
		$result[$i]['exam_mark'] = $value1['exam_mark'];
		$i++;
	}
}





?>

<div class="row-fluid">
			<div class="span12" style="margin-right:0; margin-bottom:10px" >
                <button class="btn btn-small btn-primary " id="print-admission" style="float:right">
										<i class="icon-print "></i>
										Print
									</button>
            </div>    
            <div class="span12" style="margin-left:0">
            <form id="mark-info" >

            <table id="sample-table-22" class="table table-striped table-bordered table-hover">
                <thead>
                <th>Sl</th>
                <th>Name</th>
                <th>Form No</th>
                <th>Class</th>
                <th>Mark</th>
                <th>Action</th>
                </thead>
                <tbody>
                    <?php
                    $sl = 1;
					$i = 0;
                    
					
					foreach ($result AS $index1 => $value1) {

                        echo "<tr>";
						  
                     ?>  
                       <td><?php echo $sl ; ?>   </td>
                       
                       <td><?php echo $value1['_father_name'] ; ?> </td>
                       <td><?php echo $value1['admission_form_id'] ?> </td>
                       <td><?php echo $value1['_class'];   ?></td>
					   <td> <?php echo $value1['exam_mark']; ?> </td>
					   <td> 
                        
                        	<input type="hidden" value="<?php echo $value1['mark_entry_id']; ?>" class="mark_entry_id" />
                       		<span style="color:#DD5A43; cursor:pointer " class="remove_row">
														<i class="icon-trash bigger-130"></i>
													</span> 
                        </td>	
     <?php   $sl++;  $i++; } ?>
                </tbody>	

            </table>
            
             
             <input type="hidden" value="<?php echo $branch_id; ?>" id="branch_id" />
             
            </form> 
             
        </div>
</div>

<script>

            var oTable2 = $('#sample-table-22').dataTable({
                "aoColumns": [
                    {"bSortable": true},
                    null, null, null, null, 
                    {"bSortable": true}
                ]});
				
	$( ".remove_row" ).click(function() {
// $("").on("click", function(event){	
//$("table").on("click", ".btn-single-approve", function(event){		
		
		 $this = $(this);
		 $paent = $this.parent();
		 
		 mark = $( this ).parent().find( ".mark_entry_id" ).val();
		 branch_id = $( "#branch_id" ).val();
		 var dataStr = "mark=" + mark+"&branch_id=" + branch_id; 
		$.ajax({
            type: 'post',
            url: "module/admission/manual_unapprove_selected_candidat_by_exam.php",
            data: dataStr,
            success: function (response)
            {
               $this.parent().parent().remove();
			
			  // alert(response);
			//  var num = classCount('btn-single-unapprove') ;
			 // $(".approved_num").text(num);
            }
        });

		return false;
	});		
	$("#print-admission" ).click(function() {	
		branch_id = $( "#branch_id" ).val();
		 var dataStr = "branch_id=" + branch_id; 
		return false;
		
		$.ajax({
            type: 'post',
            url: "module/admission/pdf_generator_admission_approved_candidate.php",
            data: dataStr,
            success: function (response)
            {
               
			
			  // alert(response);
			//  var num = classCount('btn-single-unapprove') ;
			 // $(".approved_num").text(num);
            }
        });
		
	});	 
		
				
</script>				

