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

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

 $AllowedFileTypes = ['image/png', 'image/jpeg', 'image/pjpeg', 'image/gif' ] ;
 $max_file_size = 2048 ;

 //$dir_folder = "../img/company/";



// update sacco details 
if (filter_has_var(INPUT_POST, "submit")) 
         try{
               $ACID =             htmlspecialchars ( strtoupper($_POST['CID']));
               $n =             htmlspecialchars ( strtoupper($_POST['name']));
               $p =             htmlspecialchars ( strtoupper($_POST['phone']));
               $e =             htmlspecialchars ( strtoupper($_POST['email']));
               $a =             htmlspecialchars ( strtoupper($_POST['address']));
               $l =             htmlspecialchars ( strtoupper($_POST['location']));

              //  $logo = $_FILES['logo']['name'];
              //  $folder = "images/company/".basename($logo);
              //  $filesize = $_FILES["logo"] ["size"];

// Check if logo file type allowed i.e png
// check if logo size bigger than specified
// check if logo upload ,upload the path in the database 

              //  if (in_array($_FILES["logo"]["type"], $AllowedFileTypes))
              //     {                      
              //        if($filesize < $max_file_size ) //conditions for the file
              //          	{
              //               if (move_uploaded_file($_FILES['logo']['tmp_name'], $folder))
              //                     {
              //                               $msg = "Image uploaded successfully";

                                     $sql = "UPDATE adcompany SET name=?,phone=?, email=?, address=?,location=?  WHERE id=?";
                                     $conn->prepare($sql)->execute([$n, $p, $e,$a,$l,$ACID]);
              //                     }
              //               else{ $msg = "Failed to upload image"; }
              //           }
              //       else{ $msg = " FILE SIZE TOO LARGE "; }

              //     } 
              //  else{ $msg = "UN ALLOWED TYPE "; }

             
              header("location:thecompany.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="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-home fa-lg" style="font-size:25px; color:green;"></i> ADD COMPANY DETAILS    </a></li>          
             <li class="  pull-right"><a href="#managecategories" data-toggle="tab"> <i class=" fa fa-bars" style="font-size:25px;"></i>  MANAGE FLEET  </a></li> 
            </ul>
-->
            
         <!-----   ==========------>
          <div class="tab-content"> 
            <div class=" active tab-pane" id="categories">
          
                <div class="row">
                    <div class="col-md-12">
                    
                    <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs">
                              <li class="active"><a href="#tab_1" data-toggle="tab"> <i class="fa fa-cog fa-cog" style="color:green;font-size:20px;"></i> GENERAL SETTINGS </a></li>
                              <!-- <li><a href="#tab_2" data-toggle="tab"> <i class="fa fa-key fa-lg"></i>REGISTRATION INFO </a></li> -->
                              <!-- <li><a href="#tab_3" data-toggle="tab"> <i class="fa fa-globe  fa-lg" style="color:black;"></i>   EXTRA SETTINGS</a></li> -->
                              <li><a href="#tab_4" data-toggle="tab"> <i class="fa fa-wrench  fa-lg" style="color:black;"></i>   SYSTEM SETTINGS</a></li>

                         
                        </ul>
                        
            <div class="tab-content">
    <!-- general setting ---->
                <div class="tab-pane active" id="tab_1">
                      <form class="form-horizontal"  action="" method="post"  enctype="multipart/form-data"  >
                           <div class="col-md-12" style="border:solid; margin-top:10px; margin-bottom:10px;padding-top:10px;   padding-top:10px;border-width:thin; border-color:green;">

                              <div class="col-sm-offset-1">
                                  <div class="col-md-11">   
                                          <div class="col-md-8">
                                              <label> COMPANY NAME </label>
                                              <input type="text"  name="name"  value="<?php echo"$name"; ?>"class="form-control">
                                              <input type="hidden"  name="CID"  value="<?php echo"$id"; ?>"class="form-control">
                                            </div>

                                            <div class="col-md-4">
                                                  <label> PHONE NUMBER </label>
                                                  <input type="text"  name="phone" value="<?php echo"$phone"; ?>"class="form-control ">
                                              </div>

                                             <div class="col-md-6">
                                                  <label> EMAIL </label>
                                                  <input type="text"  name="email" value="<?php echo"$email"; ?>" class="form-control ">
                                              </div>

                                              <div class="col-md-6">
                                                  <label> WEBSITE </label>
                                                  <input type="text" name="website" value="<?php echo"$website" ?>" class="form-control ">
                                              </div>                    

                                              <div class="col-md-12">
                                                  <label> POSTAL ADRESS </label>
                                                  <input type="text"  name="address" value="<?php echo"$address" ?>" class="form-control ">
                                              </div>                       

                                             <div class="col-md-12">
                                                  <label> LOCATION </label>
                                                  <input type="text"  name="location"  value="<?php echo"$location"; ?>"class="form-control ">
                                              </div>   

                                              <div class="col-md-6">
                                                  <label> LOGO </label>
                                                  <input type="file" name="logo" class="form-control  ">
                                              </div>
                                              <!-- <div class="col-md-6">
                                                  <div class="img-block">
                                                        <img  src='images/company/".$company_logo." '  alt="" title="<?php echo $company_logo; ?>" width="300" height="200" class="img-responsive" />
                                                        <p><strong><?php echo $company_logo; ?></strong></p>
                                                    </div>
                                              </div> -->

                                             <!-- submit button -->
                                              <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-home fa-lg " ></i>  UPDATE COMPANY DETAILS  </button>
                                                 </div>
                                               </div>
                                    </div>
                              </div>
                         </div>
            </form>  
        </div>
             
<!-- /. REGISTRATION DETAILS  -->
            <div class="tab-pane" id="tab_2">
            </div>
             
             
<!-- /.EXTRA setting  -->
              <div class="tab-pane" id="tab_3">
              </div>

      <!-- END EXTRA SETTINGS  -->
      <!-- ADD SYSTEM SETTINGS -->
      <div class="tab-pane" id="tab_4">
                            <form class="form-horizontal"  action="" method="post"  >
                <div class="col-md-12" style="border:solid; margin-top:10px; margin-bottom:10px;padding-top:10px;   padding-top:10px;border-width:thin; border-color:green;">

                            <div class="col-sm-offset-1">
                                  <div class="col-md-11">   
                                        

                                              <div class="col-md-6">
                                                  <label> DATE FORMAT  </label>
                                                  <input type="text" name="website"  class="form-control ">
                                              </div>                
                                              <div class="col-md-6">
                                                  <label> TIME ZONE   </label>
                                                  <input type="text" name="website"  class="form-control ">
                                              </div>                
                                             
                                              <div class="col-md-6">
                                                  <label> FORM THEME COLOR </label>
                                                  <input type="text"  name="email"  class="form-control ">
                                              </div>

                                              <div class="col-md-6">
                                                  <label> FONT   </label>
                                                  <input type="text" name="website"  class="form-control ">
                                              </div>                

                                             <!-- submit button -->
                                              <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-warning col-md-5">  <i class="fa fa-home fa-lg " ></i>  UPDATE COMPANY DETAILS  </button>
                                                 </div>
                                               </div>
                                    </div>
                              </div>
                         </div>
               </form> 
              </div>

      <!-- ADD SYSTEM SETTINGS -->


              <!-- /.tab-pane -->
            </div>
            <!-- /.tab-content -->
          </div>
          <!-- nav-tabs-custom -->
        </div>         
                         
                     
                  
                </div>     
           </div>
              

         <!--------------------- id manage categories  --------------->
  <div class="   tab-pane" id="managecategories">
        
</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/sfooter.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/slinkjs.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>