<?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">User Module</h3>
            <div class="row breadcrumbs-top d-inline-block">
              <div class="breadcrumb-wrapper col-12">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="#">Home</a>
                  </li>
                  <li class="breadcrumb-item"><a href="#">User Module</a>
                  </li>
                  <li class="breadcrumb-item active">User Module
                  </li>
                </ol>
              </div>
            </div>
          </div>
          
        </div>
        <div class="content-body"><!-- Zero configuration table -->
<section id="configuration">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h4 class="card-title">User Module</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 card-dashboard">
					<form class="form" action="<?php echo site_url('User/addUserModule'); ?>" 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</label>
										<select name="user" id="user" class="select2 form-control" required>
											<option value="">Select User</option>
											<?php  foreach($user as $row)
												{
													echo '<option value="'.$row->user_id.'">'.$row->username.'</option>';
												} 
											?>
										</select>
										<input type="hidden" class="" name="user_name" id="user_name" >
									</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>Link</th>
									</tr>
								</thead>
                                <tbody>
									<?php
									$rows = array();
									$rows1 = array();
									$m = 0;
									$n = 0;
									foreach($module as $row)
									{
										if (empty($rows[$row->module_name]))
											$rows[$row->module_name] = array();
														
										$rows[$row->module_name][] = $row;
									}
									foreach ($rows as $module_name => $sm)
									{
									?>
										<tr>
											<td rowspan="<?php echo count($sm)+1; ?>"><input type="checkbox" class="modchk" name="mod_chk[]" id="mod_chk" value="<?php echo $m; ?>" ><input type="hidden" class="" name="module[]" id="module" value="<?php echo $module_name; ?>" > <?php echo htmlentities($module_name); ?> </td>
										</tr>
									<?php
										foreach ($sm as $i => $sm)
										{
											if($i)
										?>
											<tr>
												<td><input type="checkbox" class="submodchk" name="submod_chk[]" id="submod_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; ?>" >  <?php echo $sm->sub_mod_name; ?></td>
												<td><input type="text" class="form-control" name="surl[]" id="surl" value="<?php echo $sm->module_url; ?>"  readonly ></td>
												<td><?php echo $sm->user_reference; ?></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>
<!--/ Zero configuration table -->



<!--/ Language - Comma decimal place table -->

        </div>
      </div>
    </div>
    <!-- END: Content-->

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

   <?php require('include/footer.php');?>
  <script>
	$("#user").change(function(){
        var uname = $('#user option:selected').text();
        $('#user_name').val(uname);
	});
  </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>