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


 
if (filter_has_var(INPUT_POST, "submit")) 
try{

      $date =            htmlspecialchars (strtoupper($_POST['date']));
      $date =            date("Y-m-d", strtotime($date));
      $name =            htmlspecialchars (strtoupper($_POST['name']));
      $code=            htmlspecialchars (strtoupper($_POST['code']));
      $description =       htmlspecialchars ( strtoupper($_POST['description']));
        

$sql = 'INSERT INTO sys_roles ( date,name,code,description ) VALUES(:date,:name,:code,:desc )';
$conn->prepare($sql)->execute([ 'date' => $date,'name'=>$name, 'code' => $code, 'desc' => $description  ]);
header("location:userrole.php");

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

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

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

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

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


    <!-- Header Navbar -->
       <?php include_once('../inc/snavbar.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/smenuc.php');   ?>
     
    <!-- /.sidebar -->
  </aside>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
        <section class="content-header">
          <h1 class="listheader" >   <i class="fa fa-user-plus"></i> Add Roles    </h1>
            <ol class="breadcrumb">
            <!-- <li><a href="#"><i class="fa fa-dashboard"></i> </a></li>
            <li><a href="#"> </a></li>
            <li class="active"> </li> -->
            <li><a href="userroles.php" class="btn btn-default btn-md"> <i class="fa fa-user-plus"></i>  Listed Roles  </a></li>
            </ol>
        </section>

    <section class="content container-fluid">   
       
        <div class="box box-default box-xs">
            <div class="box-body">
                <div class="row">
                    <form class="form-horizontal"  action="" method="post" >
                       
                            <div class="col-sm-4">
                                <label>  Date </label>
                                <input type="text" class="form-control datepicker " name="date"   autocomplete="off">
                            </div>  
                            <div class="col-sm-5">
                                <label>  User name </label>
                                <input type="text" class="form-control " name="name"   autocomplete="off">
                            </div>  
                            <div class="col-sm-3">
                                <label>  User Code   </label>
                                <input type="text" class="form-control " name="code"   autocomplete="off">
                            </div>  
                            <div class="col-sm-12">
                                 <label>  User Description  </label>
                                 <textarea class="form-control " name="description" > </textarea>
                               
                            </div>  
                     
                                              

                        <div class="col-md-12">
                           <div class="form-group">                              
                            <div class="col-sm-offset-4 col-sm-10" style="padding:0.5rem;">
                                    <button type="submit"  name="submit" class="btn btn-success subbtn col-md-3">  <i class="fa fa-user-plus"></i>  Add Roles  </button> </div>
                            </div> 
                        </div>              
                     
                    </form>
                </div>
            </div>
        </div>                         
    </section>
</div>



  <!-- Main Footer -->
  <footer class="main-footer">
    <?php  include_once('../inc/sfooter.php'); ?>
  </footer>
  

</div>

<!-- REQUIRED JS SCRIPTS -->
<?php include_once('../inc/slinkjs.php') ?>
 
 
 
</body>
</html>