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

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

      <!-- Default box -->
      <div class="card">
      
      <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Enregistrement Action</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
              <form id="FormData" action="<?php echo base_url()?>document_interne/Action_Interne/add" method="POST" enctype="multipart/form-data">
                <div class="card-body row">
                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">Nom Action <spam class="text-danger">*</spam></label>
                    <input type="text" class="form-control" id="DESCRIPTION" name="DESCRIPTION" placeholder="" value="<?=set_value('DESCRIPTION')?>">
                    <?php echo form_error('DESCRIPTION', '<div class="text-danger">', '</div>'); ?>
                  </div> 
                  <div class="form-group col-lg-6">
                    <label for="exampleInputEmail1">Type doc <spam class="text-danger">*</spam></label>
                    <select class="custom-select" name="ID_TYPE_DOC_INTERNE" id="ID_TYPE_DOC_INTERNE" onchange="get_etapes(this)">
                          <option>-- Select --</option>
                          <?php
                          foreach ($type_document as $type_documents) {
                           echo"<option value='".$type_documents['ID_TYPE_DOC_INTERNE']."'>".$type_documents['DESCRIPTION']."</option>";
                          }
                          ?>
                        </select>
                    <?php echo form_error('ID_TYPE_DOC_INTERNE', '<div class="text-danger">', '</div>'); ?>
                  </div> 


                  <div class="form-group col-lg-4">
                    <label for="exampleInputEmail1">Etape Action <spam class="text-danger">*</spam></label>
                    <select class="custom-select" name="ID_ETAPE_DOC_INTERNE" id="ID_ETAPE_DOC_INTERNE"  onchange="get_next_etapes(this)">
                          <option>-- Select --</option>
                          <?php
                          foreach ($etape_interne as $etape_intern) {
                           echo"<option value='".$etape_intern['ID_ETAPE_DOC_INTERNE']."'>".$etape_intern['DESCRIPTION']."</option>";
                          }
                          ?>
                        </select>
                    <?php echo form_error('ID_ETAPE_DOC_INTERNE', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-4">
                    <label for="exampleInputEmail1">Etape suivant <spam class="text-danger">*</spam></label>
                    
                    <select class="custom-select" name="NEXT" id="NEXT">
                          <option>-- Select --</option>
                          <?php

                          foreach ($etape_interne as $etape_intern) {
                           echo"<option value='".$etape_intern['ID_ETAPE_DOC_INTERNE']."'>".$etape_intern['DESCRIPTION']."</option>";
                          }
                          ?>
                        </select>
                    <?php echo form_error('NEXT', '<div class="text-danger">', '</div>'); ?>
                  </div> 

                  <div class="form-group col-lg-4">
                    <label for="ON_PDF">Termine processus <spam class="text-danger">*</spam></label>
                    <br>
                    
                    <label class="radio-inline">
                      <input type="radio" name="IS_LAST" id="inlineRadio2" value="1"> Refus
                    </label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label class="radio-inline">
                      <input type="radio" name="IS_LAST" id="inlineRadio3" value="2"> Dernier
                    </label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label class="radio-inline">
                      <input type="radio" name="IS_LAST" id="inlineRadio3" value="0"> Continue
                    </label>


                    <?php echo form_error('IS_LAST', '<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 () {
   
    //Date picker
    $('#DATE_FERIER').datetimepicker({
        format: 'L'
    }); 
  })
 


</script>

<script type="text/javascript">
  function get_etapes(va){
 var ID_TYPE_DOC_INTERNE= $(va).val();
 $.post('<?php echo base_url('document_interne/Action_Interne/get_etapes')?>',
     {ID_TYPE_DOC_INTERNE:ID_TYPE_DOC_INTERNE},
     function(data){
       $('#ID_ETAPE_DOC_INTERNE').html(data);
     });
}
</script>

<script type="text/javascript">
  function get_next_etapes(va){
 var ID_ETAPE_DOC_INTERNE= $(va).val();
 var ID_TYPE_DOC_INTERNE= $('#ID_TYPE_DOC_INTERNE').val();
 $.post('<?php echo base_url('document_interne/Action_Interne/get_next_etapes')?>',
     {
      ID_TYPE_DOC_INTERNE:ID_TYPE_DOC_INTERNE,
      ID_ETAPE_DOC_INTERNE:ID_ETAPE_DOC_INTERNE
    },
     function(data){
       $('#NEXT').html(data);
     });
}
</script>
</body>
</html>
