       
      <!-- start page content -->
            <div class="page-content-wrapper">
                <div class="page-content">
                    <div class="page-bar">
                        <div class="page-title-breadcrumb">
                            <div class=" pull-left">
                                <div class="page-title">All Re-Reg Student List</div>
                            </div>
                            <ol class="breadcrumb page-breadcrumb pull-right">
                                <li><i class="fa fa-home"></i>&nbsp;<a class="parent-item" href="index.html">Home</a>&nbsp;<i class="fa fa-angle-right"></i>
                                </li>
                                <li><a class="parent-item" href="">Courses</a>&nbsp;<i class="fa fa-angle-right"></i>
                                </li>
                                <li class="active">All Re-Reg Student List</li>
                            </ol>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                                                 
                                <div class="tab-content">
                                    <div class="tab-pane active fontawesome-demo" id="tab1">
                                        <div class="row">
					                        <div class="col-md-12">
					                            <div class="card card-box">
					                                <div class="card-head">
					                                    <header>All Re-Reg Student List</header>
					                                    <div class="tools">
					                                        <a class="fa fa-repeat btn-color box-refresh" href="javascript:;"></a>
						                                    <a class="t-collapse btn-color fa fa-chevron-down" href="javascript:;"></a>
						                                    <a class="t-close btn-color fa fa-times" href="javascript:;"></a>
					                                    </div>
					                                </div>
					                                <div class="card-body ">
                                                        <div class="row">
					                                       <div class="col-md-10 col-sm-10 col-10">
					                                          <header class="panel-heading panel-heading-gray custom-tab ">
																<ul class="nav nav-tabs">																	
																	<li class="nav-item"><a href="<?=base_url()?>admin/view_re_reg_student?year=A 15 - 16" <?=($_GET['year']=='A 15 - 16'?'class="active"':'');?>>Acad Session 2015-16</a>
																	</li>
																	<li class="nav-item"><a href="<?=base_url()?>admin/view_re_reg_student?year=A 2016-17" <?=($_GET['year']=='A 2016-17'?'class="active"':'');?>>Acad Session 2016-17</a>
																	</li>
																	<li class="nav-item"><a href="<?=base_url()?>admin/view_re_reg_student?year=C 2016" <?=($_GET['year']=='C 2016'?'class="active"':'');?>>Cal Session 2016</a>
																	</li>
																	<li class="nav-item"><a href="<?=base_url()?>admin/view_re_reg_student?year=C 2017" <?=($_GET['year']=='C 2017'?'class="active"':'');?>>Cal Session 2017</a>
																	</li>
																</ul>
															</header>
					                                        </div>	
					                                        <div class="col-md-2 col-sm-2 col-2">
					                                            <div class="btn-group pull-right">
					                                                <a class="btn deepPink-bgcolor  btn-outline dropdown-toggle" data-toggle="dropdown">Download
					                                                    <i class="fa fa-angle-down"></i>
					                                                </a>
					                                                <ul class="dropdown-menu pull-right">
					                                                    <li>
					                                                        <a href="<?=base_url();?>scripts/exportStudentData?center_name=0&year=<?=$year; ?>">
					                                                            <i class="fa fa-file-excel-o"></i> Export to Excel </a>
					                                                    </li>
					                                                </ul>
					                                            </div>
					                                        </div>
					                                    </div>													
					                                    <div class="table-scrollable">
					                                    <table class="table table-striped table-bordered table-hover table-checkable order-column valign-middle" id="example4">
					                                        <thead>
					                                            <tr>
																    <th> PIC</th>
																	<th> Ref No.</th>
					                                                <th> Apply</th>																	
					                                                <th> Enroll No.</th>
					                                                <th> Form</th>
					                                                <th> Student Name</th>
					                                                <th> Father Name</th>
					                                                <th> Mother Name</th>
					                                                <th> Admission Session</th>
					                                                <th> Admission Type</th>
					                                                <th> Course</th>
					                                                <th> Sub Course-Cat</th>
					                                                <th> YEAR</th>
					                                                <th> Uploaded By</th>
                                                                    <th> Action</th>					                                                
																</tr>
					                                        </thead>
					                                        <tbody>
															<?php $user_type = $this->session->userdata('user_type'); ?>
															<?php $i=1; foreach ($student_details as $key):?>
															<?php 
															 $center_details    = get_center_by_id($key->user_id);
															 $subCourse_details = get_sub_courses_by_id($key->sub_course_id);
															
											               
																	?>
																<tr class="odd gradeX">
																	
																	<td>
																	<?php if($key->image!=''){ ?>
																	<img align="left" hspace="4" vspace="4"  height="70px" src="<?=base_url();?>uploads/<?=$key->image; ?>" height="50"/>
								                                    <?php } ?>
																	</td>
																	<td><?=ucfirst($key->id);?></td>
																	<td>
																	<span class="visited" id="openReReg_<?=$key->id; ?>">
																	<?php
																		if($key->re_reg){
																		echo $key->re_reg;																	
																	?>
																		<a href="javascript:void(0)" class="sublink" onclick = "showYear('<?=$key->id; ?>')"  id="showYear"><i class="fa fa-pencil"></i> Update</a>
																		<a href="<?=base_url();?>admin/delete_re_reg/<?=$key->id; ?>" class="btn btn-danger btn-xs">																		
																			<i class="fa fa-trash-o "></i>
																		</a>
																	<?php }else{ ?>
																	   <a href="javascript:void(0)" class="sublink" onclick = "showYear('<?=$key->id; ?>')"  id="showYear"><i class="fa fa-pencil"></i> Click</a> 										
																		<?php } ?>
																	</span>
																	</td>
																	<td>
																	<span class="visited" id="openEnroll_<?=$key->id; ?>">
																	<?php
																	if ($user_type == 1) {
																		if($key->enroll_num){
																		echo $key->enroll_num;
																		?>
																		<a class="sublink"  href="javascript:void(0);"   onclick = "openEnroll('<?=$key->id; ?>')"><i class="fa fa-pencil"></i> Update</a>
																		<a class="btn btn-danger btn-xs" href="javascript:void(0);"   onclick = "deleteEnroll('<?=$key->id; ?>')"><i class="fa fa-trash-o "></i></a>
																	<?php	}else{ ?>
																	   <a class="sublink"  href="javascript:void(0);"   onclick = "openEnroll('<?=$key->id; ?>')"><i class="fa fa-pencil"></i> Edit</a>											
																		<?php }}else{ echo $key->enroll_num;} ?>
																	</span>
																	</td>
																	<td>																	
																	<?php if(isset($key->form) && $key->form=='1'){
																		$date=date_create($key->form_submited_date);
                                                                        echo date_format($date,"d-m-Y H:i");							
																	} ?>
																	</td>																	
																	<td><?=ucfirst($key->name);?></td>
																	<td><?=ucfirst($key->father_name);?></td>
																	<td><?=ucfirst($key->mother_name);?></td>
																	<td><?=ucfirst($key->admission_session);?></td>
																	<td><?=ucfirst($key->admission_type);?></td>
																	<td><?=get_courses_by_id($key->course_id);?> </td>
																	<td><?=$subCourse_details[0]['name'];?> </td>
																	<td class="left"><?=$key->year;?></td>
																	<td class="left"><?=$center_details[0]['user_name'];?></td>
																	<td>
																		<a href="<?=base_url();?>admin/print_form/<?=$key->id; ?>" class="btn btn-primary btn-xs" target="_blank">
																			<i class="fa fa-eye"></i>
																		</a>
																		<?php
																		if ($user_type == 1) {
																		?>
																		<a href="<?=base_url();?>admin/edit_student/<?=$key->id; ?>" class="btn btn-primary btn-xs">
																			<i class="fa fa-pencil"></i>
																		</a>
																		<a href="<?=base_url();?>admin/delete_student/<?=$key->id; ?>" class="btn btn-danger btn-xs">																		
																			<i class="fa fa-trash-o "></i>
																		</a>
																		<?php } ?>
																	</td>
																	</tr>
															 <?php $i++; endforeach ?>
															</tbody>
					                                    </table>
					                                    </div>
					                                </div>
					                            </div>
					                        </div>
					                    </div>
                                    </div>
                                </div>
                           
                        </div>
                    </div>
                </div>
            </div>
            <!-- end page content -->  
		<div class="modal fade" id="modal-id">
    <div class="modal-dialog">
        <div class="modal-content"> 
		<form>
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Add Enrollment</h4>
            </div>
			 <input type="hidden" name="students_id" id="students_id" value="" />
            <div class="modal-body">                
                     <div class="form-group">
                        <label for="">Enrollment No</label>
                        <input type="text" name = "enroll_no"  id = "enroll_no" maxlength="14" class="form-control" placeholder="Insert Student Enrollment No.">
                    </div>                                  
               
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" id="btn_add_inroll" onclick = "addEnrollemt()">Submit</button>
            </div> 
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->  
<div class="modal fade" id="modal-Pendency">
    <div class="modal-dialog">
        <div class="modal-content"> 
		<form>
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Add Pendency</h4>
            </div>
			  <input type="hidden" name="student_id" id="student_id" value="" />
            <div class="modal-body" style="left: 50;">                
                    <div class="form-group">
                       <input type="checkbox" class="pendency" name="pendency[]" value="10th DMC" />
						<label for="">10th DMC</label>						
                    </div> 
                    <div class="form-group">
                       <input type="checkbox" class="pendency" name="pendency[]" value="12th DMC" />
						<label for="">12th DMC</label>						
                    </div> 
					 <div class="form-group">
                       <input type="checkbox" class="pendency" name="pendency[]" value="Graduation DMC" />
						<label for="">Graduation DMC</label>						
                    </div> 
                     <div class="form-group">
                       <input type="checkbox" class="pendency" name="pendency[]" value="PG DMC" />
						<label for="">PG DMC</label>						
                    </div> 
					 <div class="form-group">
                       <input type="checkbox" class="pendency" name="pendency[]" value="Degree/Provisional" />
						<label for="">Degree/Provisional </label>						
                    </div> 
					 <div class="form-group">
                       <input type="checkbox" class="pendency" name="pendency[]" value="Photo" />
						<label for="">Photo</label>						
                    </div>
                    <div class="form-group">
                       <input type="text" class="form-control" name="pendency_other" id="pendency_other" value="" placeholder="Others" />
											
                    </div> 					
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" id="btn_add_pendency" onclick = "addPendency()">Submit</button>
            </div> 
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
 <!-- end page content -->
	<div class="modal fade" id="show-year-modal">
	<div class="modal-dialog">
		<div class="modal-content"> 
		<form>
			<div class="modal-header">
				
				<h4 class="modal-title">Select Year For Re Reg</h4>
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			</div>
			 <input type="hidden" name="students_id" id="students_id" value="" />
			<div class="modal-body">                
			<div class="form-group row <?php if(form_error('year_re_reg')){ ?>has-error<?php } ?>">
				<label class="control-label col-md-3">Year   
					<span class="required"> * </span>
				</label>
				<div class="col-md-5">
				<select class="form-control input-height" name="year_re_reg" id="year_re_reg">
					<option selected="selected" value="">Select Year</option>
					<option value="2" <?=set_select('year_re_reg', '2');?>> 2'nd Year </option>
					<option value="3" <?=set_select('year_re_reg', '3');?>>3'nd Year</option>								
				</select>                                                   
					<span class="help-block" id="re_reg_error"> <?=form_error('year_re_reg'); ?> </span>
				</div>
			</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
				<button type="button" class="btn btn-primary" id="btn_add_inroll" onclick = "addReRegYear()">Submit</button>
			</div> 
			</form>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div><!-- /.modal -->  	
<script type="text/javascript">
function openPendency(id){
	if(id!=''){		
		$('#student_id').val(id);
		var $modal = $('#modal-Pendency');		
		$modal.modal('show');
	}
}

function openEnroll(id){
	if(id!=''){
		$('#students_id').val(id);
		var $modal = $('#modal-id');		
		$modal.modal('show');
		 $(".modal-body input").val("");
	}
}
function addEnrollemt(){
	var id = $('#students_id').val().trim();
	var enroll_no = $('#enroll_no').val().trim();
	if(id!='' && enroll_no!=""){
		var NORMALSERVER = "";
		 $("#btn_add_inroll").text("");	 
		 $("#btn_add_inroll").append("<img src='/su/images/btn-loader.gif'/>");
		  $.ajax({
            type: "POST",
            url: NORMALSERVER+"add_enrollment",
            data: {student_id:id,enroll_no:enroll_no},
            dataType: "JSON",
            success: function(data) {			
			if(data.success!=null && data.success!=''){	
                $('#openEnroll_'+id).empty();			
				$('#openEnroll_'+id).append(enroll_no);
				$("#btn_add_inroll").text("Submit");	
				var $modal = $('#modal-id');
		        $modal.modal('toggle');		
			}
            },
            error: function(err) {
			$("#btn_add_inroll").text("Submit");		 
            console.log(err);
            }
        });
		
	}
}
function deleteEnroll(id){
	if(id!=''){
		var NORMALSERVER = "";
		  $("#openEnroll_"+id).text("");	 
		  $("#openEnroll_"+id).append("<img src='/su/images/btn-loader.gif'/>");
		  $.ajax({
            type: "POST",
            url: NORMALSERVER+"delete_enrollment",
            data: {student_id:id},
            dataType: "JSON",
            success: function(data) {			
			if(data.success!=null && data.success!=''){	
                $('#openEnroll_'+id).empty();			
				$('#openEnroll_'+id).append(data.message);			
			}
            },
            error: function(err) {				 
            console.log(err);
            }
        });
		
	}
}
function deletePendency(id){
	if(id!=''){
		var NORMALSERVER = "";
		  $("#openPendency_"+id).text("");	 
		  $("#openPendency_"+id).append("<img src='/su/images/btn-loader.gif'/>");
		  $.ajax({
            type: "POST",
            url: NORMALSERVER+"delete_pendency",
            data: {student_id:id},
            dataType: "JSON",
            success: function(data) {			
			if(data.success!=null && data.success!=''){	
                $('#openPendency_'+id).empty();			
				$('#openPendency_'+id).append(data.message);			
			}
            },
            error: function(err) {				 
            console.log(err);
            }
        });
		
	}
}
function checkstatus(id){
	if(id!=''){
		var form_status = '0';	
		if($("#checkstatus_"+id).prop('checked')==true){ 
			form_status = '1';
		}
		if($("#checkstatus_"+id).not(':checked').length){
			form_status = '0';
        }
		var NORMALSERVER = "";		
		 $("#loader_"+id).append("<img src='/su/images/btn-loader.gif'/>");
		  $.ajax({
            type: "POST",
            url: NORMALSERVER+"submit_form",
            data: {student_id:id,form_status:form_status},
            dataType: "JSON",
            success: function(data) {			
			if(data.success!=null && data.success!=''){	               
				$("#loader_"+id+"> img").remove();
			}
            },
            error: function(err) {
			$("#loader_"+id+"> img").remove();		 
            console.log(err);
            }
        });
		
	}
}
function addPendency(){
	var id = $('#student_id').val().trim();
	  var pendency = '';  
       $('.pendency:checked').each(function (i,e) {
        var comma = pendency.length===0?'':',';
        pendency += (comma+e.value);
       });
     var pendency_other = $('#pendency_other').val().trim();	   
	if(id!='' && (pendency!="" || pendency_other!="")){
		var NORMALSERVER = "";
		 $("#btn_add_pendency").text("");	 
		 $("#btn_add_pendency").append("<img src='/su/images/btn-loader.gif'/>");
		  $.ajax({
            type: "POST",
            url: NORMALSERVER+"add_pendency",
            data: {student_id:id,pendency:pendency,pendency_other:pendency_other},
            dataType: "JSON",
            success: function(data) {			
			if(data.success!=null && data.success!=''){	
                $('#openPendency_'+id).empty();			
				$('#openPendency_'+id).append(pendency);
				$("#btn_add_pendency").text("Submit");	
				var $modal = $('#modal-Pendency');
		        $modal.modal('toggle');		
			}
            },
            error: function(err) {
			$("#btn_add_pendency").text("Submit");		 
            console.log(err);
            }
        });
		
	}
}
    function showYear(id){
		if(id!=''){
			$('#students_id').val(id);
			var $modal = $('#show-year-modal');		
			$modal.modal('show');
			 $(".modal-body input").val("");
		}
	}
	function addReRegYear(){
		
		var id = $('#students_id').val().trim();
		var year_re_reg = $('#year_re_reg').val().trim();				
		if(year_re_reg==''){
			$('#re_reg_error').empty();			
			$('#re_reg_error').css("display", "block");		
			$('#re_reg_error').append('Please Select Year');
			return false;
		}
		if(id!='' && year_re_reg!=""){
			var NORMALSERVER = "";
			 $("#btn_add_inroll").text("");	 
			 $("#btn_add_inroll").append("<img src='/su/images/btn-loader.gif'/>");
			  $.ajax({
				type: "POST",
				url: NORMALSERVER+"add_re_reg_year",
				data: {student_id:id,year_re_reg:year_re_reg},
				dataType: "JSON",
				success: function(data) {			
				if(data.success!=null && data.success!=''){	
					$('#openReReg_'+id).empty();			
					$('#openReReg_'+id).append(year_re_reg);
					$("#btn_add_inroll").text("Submit");	
					var $modal = $('#show-year-modal');
					$modal.modal('toggle');		
				}
				},
				error: function(err) {
				$("#btn_add_inroll").text("Submit");		 
				console.log(err);
				}
			});
			
		}
	}
</script>			