<?php
  include VIEWPATH.'includes/new_header.php';
  ?>
  
<body class="hold-transition sidebar-mini">
<!-- Site wrapper -->
<div class="wrapper">
  <?php
  include VIEWPATH.'includes/new_top_menu.php';
  include VIEWPATH.'includes/new_menu_principal.php';
  ?>

  

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <?php 
    include 'includes/menu_garage.php';
    ?>

    <!-- Main content -->
    <section class="content">

      <!-- Default box -->
      <div class="card">







        



            <?php 
             if(!empty($this->session->flashdata('message')))
               echo $this->session->flashdata('message');
            ?>



      
      <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Modification d'un Garage</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
                <form role="form" action="<?=base_url('voiture/Garage/update_garage')?>" enctype="multipart/form-data" method="POST">
                <div class="card-body row">

                <div class="form-group col-lg-12">
                    <label for="exampleInputEmail1">Nom du garage <spam class="text-danger">*</spam></label>
                    <input type="text" class="form-control" id="GARAGE_NOM" name="GARAGE_NOM" value="<?php echo $approv['GARAGE_NOM']?>">
                    <input type="hidden" class="form-control" id="GARAGE_ID" name="GARAGE_ID" value="<?php echo $approv['GARAGE_ID']?>">
                    <?php echo form_error('GARAGE_NOM', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-6">
                    
                    <label for="exampleInputEmail1">Province <spam class="text-danger">*</spam> </label>
                    <select  onchange="get_commune(this.value)" class="custom-select" name="PROVINCE_ID" id="PROVINCE_ID">
                          <option value="">-- Select --</option>
                          <?php
                          foreach ($approv['province'] as $provinces) {
                            if ($provinces['PROVINCE_ID'] == $approv['PROVINCE_ID']) {
                              echo"<option value='".$provinces['PROVINCE_ID']."' selected>".$provinces['PROVINCE_NAME']."</option>";
                            }
                            else{
                              echo"<option value='".$provinces['PROVINCE_ID']."'>".$provinces['PROVINCE_NAME']."</option>";
                            }
                           
                          }
                          ?>
                        </select>
                    
                    <?php echo form_error('PROVINCE_ID', '<div class="text-danger">', '</div>'); ?>
                  </div>


                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">Commune <spam class="text-danger">*</spam> </label>
                    <select class="custom-select" name="COMMUNE_ID" id="COMMUNE_ID">
                          <option value="">-- Select --</option>
                          <?php
                          foreach ($approv['commune'] as $communes) {
                            if ($communes['COMMUNE_ID'] == $approv['COMMUNE_ID']) {
                           echo"<option value='".$communes['COMMUNE_ID']."' selected>".$communes['COMMUNE_NAME']."</option>";
                            }
                            else{
                              echo"<option value='".$communes['COMMUNE_ID']."'>".$communes['COMMUNE_NAME']."</option>";
                            }
                          }
                          ?>
                        </select>
                    
                    <?php echo form_error('COMMUNE_ID', '<div class="text-danger">', '</div>'); ?>
                  </div>

                  

                    

                    
                  
                </div>
                <!-- /.card-body -->

                <div class="card-footer">
                  <button type="submit" class="btn btn-primary btn-block">Enregistrer</button>
                </div>
              </form>
            </div>
        
        
        <!-- /.card-body -->
        <!-- <div class="card-footer">
          Footer
        </div> -->
        <!-- /.card-footer-->
      </div>
      <!-- /.card -->

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

  <?php
 include VIEWPATH.'includes/new_copy_footer.php';  
  ?>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->
<?php
  include VIEWPATH.'includes/new_script.php';
  ?>

<script>
  $(document).ready(function(){ 
    $('#message').delay(5000).hide('slow');
    });



    function get_commune(prov){
    var form= new FormData();
    form.append("prov",prov);
    $.ajax({
            url: "<?php echo base_url('voiture/Garage/get_commune/');?>"+prov,
            type: "POST",
            data: form,
            processData: false,  
            contentType: false,
            success: function(data){
            $('#COMMUNE_ID').html(data);
           
          }
    }); 

  }

  $('#sandbox-container input').datepicker({
});
</script>


  


</body>
</html>
