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

 $select = $conn->prepare("SELECT * FROM adcompanydef");
 $select->execute(); while($data=$select->fetch()){ extract($data); }  

// update sacco details 
if (filter_has_var(INPUT_POST, "submit")) 
         try{
               $id =       1 ; //      htmlspecialchars ( strtoupper($_POST['cid']));
               $com =             htmlspecialchars ( strtoupper($_POST['company']));
               $cur =             htmlspecialchars ( strtoupper($_POST['currency']));
               $tim =             htmlspecialchars ( strtoupper($_POST['timezone']));
               $fil =             htmlspecialchars ( strtoupper($_POST['filesize']));
          
                $sql = "UPDATE adcompanydef SET company=?,currency=?, timezone=? ,filesize=?  WHERE id=?";
                $conn->prepare($sql)->execute([$com, $cur, $tim,$fil, $id]);
       

             
              header("location:adcompanydef.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="box box-success box-xs">
                <div class="box-body">
                    <div class="row">
                        <form class="form-horizontal"  action="" method="post"  enctype="multipart/form-data"  >
                            <div class="col-md-12" style=" ">
                               <div class="col-md-12"> <legend> <i class="fa fa-cog"></i> Update company setting </legend> </div>
                                <div class="col-md-3">
                                    <label> Select Default Company </label>
                                        <select class="form-control  js-example-basic-single   "  required="" name="company" style="width:100%" >
                                        <?php $stmt = $conn->prepare("SELECT * FROM adcompany  ");
                                            $stmt->execute(); foreach ($stmt as $row) {?>
                                        
                                        <option value="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></option> <?php } ?>
                                        </select>
                                    </div>
                                <div class="col-md-3">
                                    <label> Select Default Currency </label>
                                        <select class="form-control  js-example-basic-single   "  required="" name="currency" style="width:100%" >
                                        <?php $stmt = $conn->prepare("SELECT * FROM acccurrency  ");
                                            $stmt->execute(); foreach ($stmt as $row) {?>
                                        
                                        <option value="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></option> <?php } ?>
                                        </select>
                                    </div>
                                    <div class="col-md-3">
                                    <label> Select Default timezone </label>
                                        <select class="form-control  js-example-basic-single   "  required="" name="timezone" style="width:100%" >
                                        <option value='Africa/Nairobi'> Africa/Nairobi  </option>
                                        <option value='Africa/Dar_es_Salaam'> Africa/Dar_es_Salaam  </option>
                                        
                                        </select>
                                    </div>
                                    <div class="col-md-3">
                                       <label> Max file size  </label>
                                        <input type="text" class="form-control" name="filesize" required="" autocomplete="off" >
                                    </div>

                                <div class="form-group"  >
                                    <div class="col-sm-offset-4 col-sm-10"  style="margin-top:20px;" >
                                        <button type="submit"   name="submit" class="btn btn-success col-md-5">  <i class="fa fa-cog fa-lg " ></i> update company Settings  </button>
                                    </div>
                                </div>

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

        </section>


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

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



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



</html>