       
      <!-- 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">Course 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="">Users</a>&nbsp;<i class="fa fa-angle-right"></i>
                                </li>
                                <li class="active">Course 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>Course 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">
														 
														</div>	
														<div class="col-md-2 col-sm-2 col-2">
															<div class="btn-group pull-right">
																<a href="<?=base_url();?>admin/slm_letter/<?=$center_uid;?>/<?=$letter_id;?>" class="btn deepPink-bgcolor  btn-outline " >View SLM Builty 
																	<i class="fa fa-angle-down"></i>
																</a>
															</div>
														</div>
													</div>													
					                                <div class="table-scrollable">
													<form id="form_sample_1" class="form-horizontal" action="<?=base_url();?>admin/update_builty" method="post">
					                                    <table class="table table-striped table-bordered table-hover table-checkable order-column valign-middle">
					                                        <thead>
					                                            <tr>					                                            	
					                                                <th width="20%"> Course Name</th>
					                                                <th width="20%"> Sub Course</th>				                                                
					                                                <th> Year</th>				                                                
					                                                <th> Total Student</th>				                                                
					                                                <th> Alloted books</th>				                                                
					                                                <th> Remaining books</th>				                                                
					                                                <th> Action</th>				                                                
																</tr>
					                                        </thead>
					                                        <tbody><?php //print_r($generated_letter); exit;?> 
															 <input type="hidden" name="center_uid" id="center_uid" value="<?=$center_uid;?>">
															 <input type="hidden" name="letter_id" id="letter_id" value="<?=$letter_id;?>">
															<?php $i=1; foreach ($generated_letter as $key):?>
																<tr class="odd gradeX">	                                                                   
																	<td class="left" style="padding-left: 16px; text-align:left"><?=get_courses_by_id($key->course_id);?></td>
																	<?php $sub_course=get_sub_courses_by_id($key->sub_course_id);?>
																	<td class="left" style="padding-left: 16px; text-align:left"><?=$sub_course[0]['name'];?></td>							
																	<td class="left" style="padding-left: 16px; text-align:left"><?=$key->year;?></td>																	
																	<td class="left" style="padding-left: 16px; text-align:left"><?=$key->total_student;?></td>																	
																	<td class="left" style="padding-left: 16px; text-align:left"><?=$key->alloted_books;?></td>																	
																	<td class="left" style="padding-left: 16px; text-align:left"><?=($key->total_student-$key->alloted_books);?></td>																	
																	<td class="left">																	
																	<?php /* <a href="javascript:void(0)" onclick = "allotBooks(<?=$center_uid; ?>,<?=$key->course_id;?>);"><label class="btn btn-primary disable-node">Allot</label></a>  
																	<a href="javascript:void(0)" onclick = "editBooks(<?=$center_uid; ?>,<?=$key->course_id;?>);"><label class="btn btn-primary disable-node">Edit</label></a> */
																	?>																	
																	<input type="text" name="alloted_books[<?=$key->course_id;?>]" id="alloted_books" placeholder="Edit" class="form-control input-height" value="<?=$key->alloted_books;?>">
																	
																	</td>																
																</tr>
															 <?php $i++; endforeach ?>															 
															  
															</tbody>
					                                    </table>
														<input type="submit" name="Update" value="Update Builty" class="btn btn-primary disable-node" style="float: right;margin: 5px;" />
														</form>
					                                    </div>
					                                </div>
					                            </div>
					                        </div>
					                    </div>
                                    </div>
                                </div>
                           
                        </div>
                    </div>
                </div>
            </div>
	<div class="modal fade" id="modal-Books">
    <div class="modal-dialog">
        <div class="modal-content"> 
		<form>
            <div class="modal-header">
			<h4 class="modal-title">Allot Books</h4>
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
			  <input type="hidden" name="course_id" id="course_id" value="" />
			  <input type="hidden" name="center_id" id="center_id" value="" />
            <div class="modal-body" style="left: 50;">                
                  <div class="form-group row">
					<label class="control-label col-md-3">Add Books
					</label>
					<div class="col-md-10">
						<div class="input-group">
						  <input type="text" class="form-control input-height" name="book_value" id="book_value" placeholder="Add Books" maxlength="4"/>
						</div>
					<span class="help-block"> </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_books" onclick = "submitBooks();">Submit</button>
            </div> 
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal --> 
            <!-- end page content -->  
<script type="text/javascript">
function allotBooks(center_id,course_id){
	if(center_id!='' && course_id!=''){		
		$('#center_id').val(center_id);
		$('#course_id').val(course_id);
		var $modal = $('#modal-Books');        
        $modal.modal('show');
	}
}
function editBooks(center_id,course_id){
	if(center_id!='' && course_id!=''){		
		$('#center_id').val(center_id);
		$('#course_id').val(course_id);
		var $modal = $('#modal-Books');        
        $modal.modal('show');
	}
}

function submitBooks(){
	var center_id = $('#center_id').val();
	var course_id = $('#course_id').val();
	var book_value = $('#book_value').val();
	if(center_id!='' && course_id !=''){		
		  $.ajax({
            type: "POST",
            url: "/admin/issue_center_books",
            data: {center_id:center_id,course_id:course_id,book_value:book_value},
            dataType: "JSON",
            success: function(data) {			
			if(data.success!=null && data.success!=''){
                var $modal = $('#modal-Books');  
				$modal.modal('hide');
			}
            },
            error: function(err) {
			var $modal = $('#modal-Books');  
			$modal.modal('hide');					 
            console.log(err);
            }
        });
		
	}
}
</script>			