<?php require('include/header.php');?>

   <?php require('include/sidenav.php');?>

   
    <!-- BEGIN: Content-->
    <div class="app-content content">
      <div class="content-overlay"></div>
      <div class="content-wrapper">
        <div class="content-header row">
          <div class="content-header-left col-md-12 col-12 mb-2 breadcrumb-new">
            <h3 class="content-header-title mb-0 d-inline-block">Module Permission</h3>
            <div class="row breadcrumbs-top d-inline-block">
              <div class="breadcrumb-wrapper col-12">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="index-2.html">Home</a>
                  </li>
                  <li class="breadcrumb-item"><a href="#">Module Permission</a>
                  </li>
                  <li class="breadcrumb-item active">Module Permission
                  </li>
                </ol>
              </div>
            </div>
          </div>
          
        </div>
        <div class="content-body"><!-- Basic form layout section start -->
<section id="basic-form-layouts">
	



	<div class="row justify-content-md-center">
		<div class="col-md-12">
			<div class="card">
				<div class="card-header">
					<h4 class="card-title" id="basic-layout-form-center">Module Permission</h4>
					<a class="heading-elements-toggle"><i class="la la-ellipsis-v font-medium-3"></i></a>
					<div class="heading-elements">
						<ul class="list-inline mb-0">
							<li><a data-action="collapse"><i class="ft-minus"></i></a></li>
							<li><a data-action="reload"><i class="ft-rotate-cw"></i></a></li>
							<li><a data-action="expand"><i class="ft-maximize"></i></a></li>
							<li><a data-action="close"><i class="ft-x"></i></a></li>
						</ul>
					</div>
				</div>
				<div class="card-content collapse show">
					<div class="card-body">

						 <?php 	foreach($user_module as $key => $data) ?>

						<form class="form" action="<?php echo site_url('User/addModulePermission/');?>" method="post">
							<div class="row justify-content-md-center">
								<div class="col-md-6">
									<div class="form-body">
										<div class="form-group">
											<label for="eventInput1">User Name</label>
											<input type="text" id="user_name" class="form-control"  name="user_name" value="<?php echo $data->username; ?>" readonly>
											<input type="hidden" id="user_id" class="form-control"  name="user_id" value="<?php echo $data->user_id; ?>">
										</div>

									</div>
								</div>
							</div>
							
							<div class="table-responsive">
                           <table class="table table-striped table-bordered zero-configuration">
								<thead>
									<tr>
										<th>Module</th>
										<th>Sub Module</th>
										<th>Status</th>
									</tr>
								</thead>
                                <tbody>
									<?php
									$rows = array();
									$rows1 = array();
									$m = 0;
									$n = 0;
									$k=0;
									foreach($user_module as $row)
									{
								?>
									<tr>
										<td><?php echo $row->module_name; ?></td>
										<td><?php echo $row->sub_mod_name; ?></td>
										<td>
											<?php if($row->status == 'Enabled') { ?>
										    <a href="#" menu-status="Disabled" um-id="<?php echo $row->user_module_id; ?>" class="btn btn-sm btn-info menu_status">Disable</a>
											<?php } else { ?>
											<a href="#" menu-status="Enabled" um-id="<?php echo $row->user_module_id; ?>" class="btn btn-sm btn-info menu_status">Enable</a>
											<?php } ?>
										</td>
									</tr>
									<?php
									}
								?>
								</tbody>
							</table>
                        </div>
							
						<div class="form-actions text-right">
								<button type="reset" class="btn btn-warning mr-1">
									<i class="ft-x"></i> Reset
								</button>
								<button type="submit" class="btn btn-primary">
									<i class="la la-check-square-o"></i> Save
								</button>
							</div>
						</form>	

					</div>
				</div>
			</div>
		</div>
	</div>

</section>
<!-- // Basic form layout section end -->
        </div>
      </div>
    </div>
    <!-- END: Content-->


   <?php //require('include/theme_customizer.php');?>

   <?php require('include/footer.php');?>
  
  <script>
	$(document).on("click",".menu_status",function(){
		var um_id=$(this).attr('um-id');
		var menu_status=$(this).attr('menu-status');
			$.ajax({
			type: "POST",
			dataType:'json',
			data : { um_id : um_id, menu_status : menu_status},
			url: "<?php echo base_url();?>index.php/User/change_menu_status",
			success: function(dataz) { 
				var data = $.trim(dataz);
				
				setInterval(function(){
						window.location.reload(true);
					}, 400);
			}
		});
	});
</script>

  </body>
  <!-- END: Body-->

<!-- Mirrored from pixinvent.com/modern-admin-clean-bootstrap-4-dashboard-html-template/html/ltr/vertical-modern-menu-template/form-layout-basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Apr 2020 09:38:02 GMT -->
</html>