<?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 ( $_POST['name']);
            $code =                  htmlspecialchars ( $_POST['code']);
            $symbol =               htmlspecialchars ( $_POST['symbol']);
            $sql = 'INSERT INTO acccurrency (date,name,code,symbol,updated,uid) VALUES(:date,:name,:code,:symbol,:updated,:uid )';
            $conn->prepare($sql)->execute(['date' => $today,'name' => $name,'code' => $code,'symbol' =>$symbol,'updated'=>$date,'uid' => $uid    ]);
            header("location:currency.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/smenu.php');   ?>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">


<!-- Main content -->

  <section class="content container-fluid"> 
        <div class="box box-default box-xs">
            <div class="box-body">
                <div class="row">
                    <form class="form-horizontal add_form "  action="" method="post"  >
                        <div class="col-sm-12">                       
                            <div class="col-md-12"><legend> <i class="fa fa-plus"></i> Add Currency </legend></div>              
                            <div class="col-sm-4"> 
                                <label > Currency  Name  </label>  
                                    <input type="text"  name="name" value="" autocomplete="off" class="form-control"   required=""   > 
                            </div> 
                                                                                    
                            <div class="col-md-4">
                                <label > Currency Code  </label>                          
                                <input type="text" class="form-control" name="code" required="" autocomplete="off" >
                            </div>                                             
                            <div class="col-md-4">
                                <label > Currency Symbol  </label>                          
                                <input type="text" class="form-control" name="symbol" required="" autocomplete="off" >
                            </div>                                             
                                                                         
                        </div>                           
                   
                        
                        <!-- submit button -->
                        <div class="form-group">                              
                            <div class="col-sm-offset-4 col-sm-10" style="padding-top:0.5rem;">
                                    <button type="submit"  name="submit" class="btn btn-success col-md-3">  <i class="fa fa-dollar"></i>  Add Currency  </button> </div>
                        </div> 
                    </form>               
                </div>
            </div>
        </div>
                                
    </section>

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

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

</body>
</html>