<?php  include_once('config/db.php'); include_once('config/check.php');  


 
if (filter_has_var(INPUT_POST, "submit")) 
try{
      $name =       htmlspecialchars (strtoupper($_POST['name']));
      $url =       '#';// htmlspecialchars ( $_POST['url']);
      $icon =      '<i class="fa fa-circle-o"></i>' ;   //$_POST['icon'];
      $module =       htmlspecialchars ( strtoupper($_POST['module']));
     
      $display =     0; //  htmlspecialchars ( strtoupper($_POST['display']));
     
     

$sql = 'INSERT INTO sys_sub_module (module, name,url,icon,displayno ) VALUES(:module,:name,:url ,:icon,:display )';
$conn->prepare($sql)->execute([ 'module' => $module, 'name' => $name,'url' => $url ,'icon'=>$icon ,'display' =>$display ]);
header("location:sys_submodules.php");

  } catch(Exception $e) { echo 'Message: ' .$e->getMessage();}
                  
?>

<!DOCTYPE html>
<html>
<head>
<?php include_once('inc/link.php');   ?>

</head>
<body <?php include_once('inc/nav.php');  ?>>
<div class="wrapper">

  <!-- Main Header -->
    <header class="main-header">

    <!-- Logo -->
    <?php include_once('inc/brand.php');   ?>


    <!-- Header Navbar -->
       <?php include_once('inc/navbar.php');   ?>

   
  </header>
 
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">

    <!-- sidebar: style can be found in sidebar.less -->
     <?php include_once('inc/menu.php');   ?>
     
    <!-- /.sidebar -->
  </aside>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">

<!-- Main content -->
 <section class="content container-fluid">
       
      
 <div class="row">
        <!-- /.col -->
        <div class="col-md-11">
         <div class="col-md-12">
          <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">

             
              <li class="active"><a href="#categories" data-toggle="tab" > <i class="fa fa-wrench" style="font-size:25px; color:green;"></i>  ADD UOM  </a></li>
                          
             <li class="  pull-right"><a href="#managecategories" data-toggle="tab"> <i class=" fa fa-bars" style="font-size:25px; color:green;"></i>  MANAGE/VIEW PAGES   </a></li>
             
            </ul>

    <div class="tab-content">
         <div class="active   tab-pane" id="categories">
            <form class="form-horizontal"  action="" method="post"  style="border:solid; margin-top:10px; margin-bottom:10px;padding-top:10px; padding-top:10px;border-width:thin; border-color:green;">
              <!----../ BANK NAME --->
                      <div class="col-md-12">
                         <div class="col-sm-offset-1"> 
                            <!-- Page name ,page url ,icon uses font-wesome clasess -->
                            <div class="col-md-12 ">

                                <div class="col-sm-4">
                                    <label> Module  </label>
                                      <select class="form-control   "  required="" name="module" style="width:100%" >
                                         <?php $stmt = $conn->prepare("SELECT * FROM sys_module  ");
                                           $stmt->execute(); foreach ($stmt as $row) {?>
                                                   
                                                 <option value="<?php echo $row['id']; ?>"><?php
                                                    echo $row['name']; ?></option> <?php } ?>
                                       </select> 
                                    <!-- <input type="text" class="form-control " name="name"   autocomplete="off"> -->
                                </div>  

                                <div class="col-sm-4">
                                    <label> PAGE NAME  </label>
                                    <input type="text" class="form-control " name="name"   autocomplete="off">
                                </div>                    

                                <!-- <div class="col-sm-4">
                                    <label>  PAGE URL </label>
                                    <input type="text" class="form-control " name="url"  autocomplete="off">   
                                </div> -->

                                <!-- <div class="col-sm-4">
                                    <label>  ICON (font awesome class) </label>
                                    <input type="text" class="form-control "   name="icon"  autocomplete="off">   
                                </div> -->
                            </div>

                            <!-- module ,url,icon -->
                            <div class="col-md-12 ">
                                              

                               

                                <!-- <div class="col-sm-4">
                                    <label>  display </label>
                                    <input type="text" class="form-control " name="display"  autocomplete="off">   
                                </div> -->
                            </div>
                         
                        </div>    
                    </div>
            <!-- submit button -->
                     <div class="form-group">                              
                          <div class="col-sm-offset-4 col-sm-10" style="padding:2rem;">
                                <button type="submit"  name="submit" class="btn btn-success col-md-3">  <i class="fa fa-cart-plus"></i>  Add  </button> </div>
                    </div> 
            </form>
        </div>
              

  <!---/....  MANAGE CATEGORIES ------->
  <div class="  tab-pane" id="managecategories">
        <table class="table table-hover table-condensed table-bordered " id="newsletter">
                    <thead class="thead-light ">
                         <tr class="bg-primary">
                           
                            <th style="width:40%; ">  UOM (Units of measurements)  </th>
                            <th style="width:15%; ">  CODE </th>
                            <th style="width:30 %;" > DESCRIPTION </th>
                            <th style="width:15 %;" > STATUS </th>
                          

                          </tr>
                       </thead>
                       
                    <tbody class="box-body">
                       <?php    
                      try{ 
                            $select = $conn->prepare("SELECT * FROM bel_uom ");
                            $select->execute();
                           while($data=$select->fetch()){
                        ?>

                    <tr>
                        <td> <?php echo $data['name']; ?> </td>
                        <td> <?php echo $data['code']; ?> </td>                        
                        <td> <?php echo $data['description']; ?> </td>

                        <td> 
                        <form method="post" action="uomedit"> <button  class="btn btn-success btn-block "type="submit" name="edituom" value="<?php echo $data['id']; ?>"> EDIT  </button>  </form> </td> 
            
                     <?php } } catch(PDOException $e) {echo "error:".$e->getMessage(); }?>
                   </tr>
                 </tbody>
     </table>
</div>

          
            </div>
          </div>
          <!-- /.nav-tabs-custom -->
          </div>
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->








    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!-- Main Footer -->
  <footer class="main-footer">
    <?php  include_once('inc/footer.php'); ?>
  </footer>
  
  
           <!-- .modal -->
<div class="modal fade m_top_25 " id="Mymodal">
	<div class="modal-dialog">
		<div class="modal-content">
		                                <center id="Loading_ID" class="d_none r_corners">
                                    <h4 class="m_top_20 m_bottom_20">Please wait... Processing Your Submission </h4>
                                    <img src="images/loading-bar.gif" class="img-thumbnail" alt="Loading"
                                         style="max-width:160px;">
                                </center>
                                <!--End Submission Processing -->

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


</div>



<!-- REQUIRED JS SCRIPTS -->
<?php include_once('inc/linkjs.php') ?>
 
 <script>
    
 $(document).ready(function() { 
     // $("#Loading_ID").hide();
      $("#loading").hide();
       $('#add').click(function() { 


     
           //$('#Mymodal').modal('show')
            $("#loading").show('fast');
         
           
           
           
    }); 
}); 
    
</script>
 
 

<script>
    $( document ).ready(function() {
            var table = $('#newsletter').DataTable( {
             buttons: [
               { extend: 'excel', text: ' Excel'},
                { extend: 'pdf', text: ' Download PDF'},
             ] } );
  
   table.buttons().container()
    .appendTo( $('.col-sm-6:eq(0)', table.table().container() ) );  });
</script>




</body>



</html>