
<?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 Sub 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 Sub Permission</a>
                  </li>
                  <li class="breadcrumb-item active">Module Sub 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 Sub 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_sub_per as $key => $data) ?>

						<form class="form" action="<?php echo site_url('User/addUserSubPermission/');?>" 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>Permission</th>
										<th>Sub Permission</th>
										<th>Link</th>
									</tr>
								</thead>
                                <tbody>
									<?php
									$rows = array();
									$m = 0;
									$n = 0;
									foreach($user_sub_per as $row)
									{
										if (empty($rows[$row->sub_mod_id]))
											$rows[$row->sub_mod_id] = array();
														
										$rows[$row->sub_mod_id][] = $row;
									}
									?>
									
									<?php
									foreach ($rows as $sub_mod_id => $sm)
									//foreach(array_combine($rows,$rows1) as $sub_mod_name => $sm)
									{
									?>
										<tr>
											<?php
												$sub_mod_id = $sub_mod_id;
												$q= $this->db->query("select M.module_id,M.module_name,S.sub_mod_id,S.sub_mod_name from module M inner join sub_module S on M.module_id=S.module_id where S.sub_mod_id='$sub_mod_id'");
												foreach($q->result_array() as $row2)
												$sub_mod_name = $row2['sub_mod_name'];
												$module_name = $row2['module_name'];
											?>
											<td rowspan="<?php echo count($sm)+1; ?>" ><?php echo htmlentities($module_name); ?> </td>	
											<td rowspan="<?php echo count($sm)+1; ?>" ><?php echo htmlentities($sub_mod_name); ?> </td>
										</tr>
										
									<?php
										foreach ($sm as $i => $sm)
										{
											if($i)
										?>
											<tr>
												<td><?php echo $sm->permission_name; ?></td>
												<td><input type="checkbox" class="subperchk" name="subper_chk[]" id="subper_chk" value="<?php echo $n; ?>" ><input type="hidden" class="" name="module_id[]" id="module_id" value="<?php echo $sm->module_id; ?>" ><input type="hidden" class="" name="submodule[]" id="submodule" value="<?php echo $sm->sub_mod_id; ?>" ><input type="hidden" class="" name="permission_id[]" id="permission_id" value="<?php echo $sm->permission_id; ?>" ><input type="hidden" class="" name="subpermission_id[]" id="subpermission_id" value="<?php echo $sm->sub_permsn_id; ?>" ><input type="hidden" class="" name="user_module_id[]" id="user_module_id" value="<?php echo $sm->user_module_id; ?>" ><input type="hidden" class="" name="user_permission_id[]" id="user_permission_id" value="<?php echo $sm->user_permission_id; ?>" >
												<?php echo $sm->sub_permsn_name; ?></td>
												<td><input type="text" class="form-control" name="spurl[]" id="spurl" ></td>
											</tr>
										
										
										<?php
											$n++;
										}
										
										$m++;
										
									}
									
									?>
								</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');?>
  

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