<?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_vehicule.php';
    ?>

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

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







        <div class="modal fade" id="modal_default">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Ajout d'une marque</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <form id="myformsassuree" method="POST" class="form-horizontal" onsubmit="submitformulaireun();return false"  accept-charset="utf-8" enctype="multipart/form-data">
            <div class="modal-body">
              
              <table class="table">
                <tr>
                  <td>Nom de marque</td>
                  <td>
                    <input type="text" name="DESCRIPTION" id="DESCRIPTION" class="form-control" placeholder="Nom de la marque">     
                  </td>
                </tr>
              </table>
              
            </div>
            <div class="modal-footer justify-content-between">
              <button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
              <!-- <button type="button" class="btn btn-primary"></button> -->
              <input type="submit" value="Enregistrer" class="btn btn-primary">
            </div>
          </form>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>



      <div class="modal fade" id="modal_defaultaff">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title">Ajout de l'usage</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <form id="myformsassurees" method="POST" class="form-horizontal" onsubmit="submitformulairedeux();return false"  accept-charset="utf-8" enctype="multipart/form-data">
            <div class="modal-body">
              
              <table class="table">
                <tr>
                  <td>Usage</td>
                  <td>
                    <input type="text" name="VEHICULE_CATEGORIE_DESCR" id="VEHICULE_CATEGORIE_DESCR" class="form-control" placeholder="Usage de la voiture">     
                  </td>
                </tr>
              </table>
              
            </div>
            <div class="modal-footer justify-content-between">
              <button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
              <!-- <button type="button" class="btn btn-primary"></button> -->
              <input type="submit" value="Enregistrer" class="btn btn-primary">
            </div>
          </form>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>






      
      <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Enregistrement d'une voiture</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
              <form id="FormData" action="<?php echo base_url()?>voiture/Vehicule/save_vehicule" method="POST" enctype="multipart/form-data">
                <div class="card-body row">

                  <div class="form-group col-md-6">
                        <label for="PLAQUE_VEHICULE">
                          Plaque vehicule
                          <i class="text-danger"> *</i>
                        </label>
                        <input type="text" name="PLAQUE_VEHICULE" value="<?=$approv['PLAQUE_VEHICULE']?>" class="form-control" id="PLAQUE_VEHICULE" placeholder="Plaque vehicule">
                        <?php echo form_error('PLAQUE_VEHICULE', '<div class="text-danger">', '</div>'); ?>
                     </div>


                     <div class="form-group col-md-6">
                        <label for="PIECE_CATEGORIE_ID">
                          Numero de chassis
                          <i class="text-danger"> *</i>
                        </label>
                        
                
                        <input type="text" name="NUMERO_CHASSIS" value="<?=$approv['NUMERO_CHASSIS']?>" class="form-control" id="NUMERO_CHASSIS" placeholder="Numero Chassis">
                        
                        <?php echo form_error('NUMERO_CHASSIS', '<div class="text-danger">', '</div>'); ?>
                     </div>

                     <div class="form-group col-md-6">
                        <label for="MARQUE_ID">
                          Marque
                          <i class="text-danger"> *</i>
                          <button type="button" class="btn btn-link" data-toggle="modal" data-target="#modal_default">
                  Marque non list&eacute;e?
                </button> 
                        </label>
                        

                        <select class="form-control select" name="MARQUE_ID" id="MARQUE_ID">
                    <option value=""> </option>
                    <?php 
                    foreach ($approv['MARQUE_ID'] as $key) {
                      echo "<option value=".$key['MARQUE_ID'].">".$key['DESCRIPTION']."</option>";
                    }
                    ?>
                  </select>
                        
                        <?php echo form_error('MARQUE_ID', '<div class="text-danger">', '</div>'); ?>
                     </div>



                     <div class="form-group col-md-6">
                        <label for="MARQUE_ID">
                          Usage
                          <i class="text-danger"> *</i>
                          <button type="button" class="btn btn-link" data-toggle="modal" data-target="#modal_defaultaff">
                  Usage non list&eacute;e?
                </button> 
                        </label>
                        

                        <select class="form-control select" name="VEHICULE_CATEGORIE_ID" id="VEHICULE_CATEGORIE_ID">

                    <option value=""> </option>
                    <?php 
                    foreach ($approv['VEHICULE_CATEGORIE_ID'] as $key) {
                      echo "<option value=".$key['VEHICULE_CATEGORIE_ID'].">".$key['VEHICULE_CATEGORIE_DESCR']."</option>";
                    }
                    ?>
                  </select>
                        
                        <?php echo form_error('VEHICULE_CATEGORIE_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>
  function submitformulairedeux(val){
var VEHICULE_CATEGORIE_DESCR= $('#VEHICULE_CATEGORIE_DESCR').val();
// alert(VEHICULE_CATEGORIE_DESCR);
$.post('<?php echo base_url('voiture/Vehicule/enregistrer_usage')?>',
          {
            VEHICULE_CATEGORIE_DESCR:VEHICULE_CATEGORIE_DESCR
          },
          function(data){
            // alert(data);
            $('#VEHICULE_CATEGORIE_ID').html(data); 
            $('#VEHICULE_CATEGORIE_ID').selectpicker('refresh');
            
          });
      $('#modal_defaultaff').modal('hide');
}
</script>

<script>
  function submitformulaireun(val){
var DESCRIPTION= $('#DESCRIPTION').val();
$.post('<?php echo base_url('voiture/Vehicule/enregistrer_vehicule')?>',
          {
            DESCRIPTION:DESCRIPTION
          },
          function(data){
            $('#MARQUE_ID').html(data); 
            $('#MARQUE_ID').selectpicker('refresh');
            
          });
      $('#modal_default').modal('hide');
}
</script>
</body>
</html>
