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

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

      <!-- Default box -->
      <div class="card">
      
      <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Modification d'un section</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
              <form id="FormData" action="<?php echo base_url()?>organigramme/Section/update" method="POST" enctype="multipart/form-data">
                <div class="card-body row">
                  <div class="form-group col-lg-12">
                    <label for="exampleInputEmail1">Nom du departement <spam class="text-danger">*</spam></label>
                    <input type="text" class="form-control" id="DESCRIPTION" name="DESCRIPTION" value="<?php echo $data['DESCRIPTION']?>">
                    <input type="hidden" id="ID_SECTION" name="ID_SECTION" value="<?php echo $data['ID_SECTION']?>">
                    <?php echo form_error('DESCRIPTION', '<div class="text-danger">', '</div>'); ?>
                  </div> 


                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">Direction <spam class="text-danger">*</spam></label>
                    <select class="custom-select" name="ID_DIRECTION" id="ID_DIRECTION" onchange="get_departement(this)">
                          <option>-- Select --</option>
                          <?php
                          foreach ($direction as $directions) {
                            if ($directions['ID_DIRECTION'] == $data['ID_DIRECTION']) {
                              echo"<option value='".$directions['ID_DIRECTION']."' selected>".$directions['DESCRIPTION']."</option>";
                            }
                            else{
                              echo"<option value='".$directions['ID_DIRECTION']."'>".$directions['DESCRIPTION']."</option>";
                            }
                           
                          }
                          ?>
                        </select>
                    
                    <?php echo form_error('ID_DIRECTION', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">Section <spam class="text-danger">*</spam></label>
                    <select class="custom-select" name="ID_SERVICE" id="ID_SERVICE">
                          <option>-- Select --</option>
                          <?php
                          foreach ($departement as $departements) {
                            if ($departements['ID_SERVICE'] == $data['ID_SERVICE']) {
                              echo"<option value='".$departements['ID_SERVICE']."' selected>".$departements['DESCRIPTION']."</option>";
                            }
                            else{
                              echo"<option value='".$departements['ID_SERVICE']."'>".$departements['DESCRIPTION']."</option>";
                            }
                           
                          }
                          ?>
                        </select>
                    
                    <?php echo form_error('ID_SERVICE', '<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 get_departement(va){
 var ID_DIRECTION= $(va).val();
 $.post('<?php echo base_url('organigramme/Section/get_departement')?>',
     {ID_DIRECTION:ID_DIRECTION},
     function(data){
       $('#ID_SERVICE').html(data);
     });
}
</script>
</body>
</html>