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


  if ($this->session->userdata('SOCAR_PROFIL_ID') == 0) {
          
          $SOCAR_ID_USER = $this->session->userdata('SOCAR_ID_USER');  
        }
        else{
          $SOCAR_ID_USER = 0;
        }

  ?>

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

    <!-- Main content -->
    <section class="content">
      <div class="row">
        
        <?php 
    include 'includes/menu_messages_small.php';
    ?>
        <!-- /.col -->
        <div class="col-md-9">
          <div class="card card-primary card-outline">
            <div class="card-header">
              <h3 class="card-title"><?php echo $title?></h3>

              
              <!-- /.card-tools -->
            </div>
            <!-- /.card-header -->
            <div class="card-body p-0">
              <div class="mailbox-read-info">
                <h5>Objet: <?php echo $message['TYPE_MESSAGE'].' de la demande de cong&eacute; # '.$message['ID_DEMANDE_CONGE'] ?> </h5>
                <h6>De: <?php echo $message['SNOM'].' '.$message['SPRENOM'] ?>
                  <span class="mailbox-read-time float-right"><?php echo $message['DATE_SYSTEME_DEMANDE'] ?></span></h6>
              </div>
              <!-- /.mailbox-read-info -->
              <div class="mailbox-controls with-border text-right">
                <div class="btn-group">

                 
                  <?php

                  if ($message['ID_EMPLOYE_DESTINATAIRE'] == $SOCAR_ID_USER) {
                    ?>
                  <a href="<?php echo base_url('conge/Messages/reply/'.$message['ID_MESSAGE_CONGE'].'')?>" class="btn btn-primary btn-sm">
                    <i class="fas fa-reply"></i> Repondre 
                  </a>
                  <?php
                  if ($message['ID_STATUS_MESSAGE'] == 1) {
                    ?>
                  <a href="<?php echo base_url('conge/Messages/readed/'.$message['ID_MESSAGE_CONGE'].'')?>" class="btn btn-primary btn-sm">
                    <i class="fa fa-envelope-open"></i> Marquer comme lu
                  </a>
                  <?php
                  }
                  }
                  ?>
          
                </div>
                <!-- /.btn-group -->
              </div>
              <!-- /.mailbox-controls -->
              <div class="mailbox-read-message">
                <?php echo $message['CORPS_MESSAGE']?>

                <br>
                <br>
                <br>
                <hr>

                <div class="form-group col-lg-12">
                  <h6>Details du conge</h6>
                  <table class="table table-striped">
                    <tr>
                      <td>Exercice</td>
                      <td><?php echo $data['EXERCICE']?></td> 
                      <td>Employ&eacute;</td>
                      <td><?php echo $data['NOM']?> <?php echo $data['PRENOM']?></td> 
                    </tr>
                    
                    <tr>
                      <td>Conge & Nb Jours Restant</td>
                      <td><?php echo $data['TYPE_CONGE']?> restant avec <?php echo $data['NB_JOURS_RESTANT']?> Jours</td> 
                      <td>Periode conge</td>
                      <td><?php echo $data['DATE_DEBUT_CONGE_DEMANDE']?> au <?php echo $data['DATE_FIN_CONGE_DEMANDE']?> (<?php echo $data['NB_JOURS_DEMANDE']?> Jours)</td> 
                    </tr>
                    
                    <tr>
                      <td>Niveau de demande</td>
                      <td><?php echo $data['NIVEAU']?></td> 
                      <td>Affectation</td>
                      <td>
                      <button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#modal-default">
                  Affectation
                </button>
                  <div class="modal fade" id="modal-default">
                  <div class="modal-dialog">
                    <div class="modal-content">
                      <div class="modal-header">
                        <h4 class="modal-title">Affectation</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                          <span aria-hidden="true">&times;</span>
                        </button>
                      </div>
                      <div class="modal-body">
                        <table class="table">
                          <tr>
                            <td>Direction</td>
                            <td><?php echo $data['DIRECTION']?></td>
                          </tr>
                          <tr>
                            <td>Service</td>
                            <td><?php echo $data['SERVICE']?></td>
                          </tr>
                          <tr>
                            <td>Status</td>
                            <td><?php echo $data['STATUS_CONGE']?></td>
                          </tr>
                          <tr>
                            <td>Section</td>
                            <td><?php echo $data['SECTION']?></td>
                          </tr>
                        </table>
                      </div>
                      <div class="modal-footer justify-content-between">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">Fermer</button>
                      </div>
                    </div>
                    <!-- /.modal-content -->
                  </div>
                  <!-- /.modal-dialog -->
                </div>
                      </td> 
                    </tr>
                    
                  </table>

                  
                </div>

                <div class="form-group col-lg-12">
                  <h6>Historique de traitement</h6>
                  <table class="table table-striped">
                    <tr>
                      <td>Date Traitement</td>
                      <td>Direction</td>
                      <td>Service</td>
                      <td>Section</td>
                      <td>Employe</td>
                      <td>Status</td>
                      <td>Commentaire</td>
                    </tr>
                    
                    <?php
                    foreach ($historique as $value) {                    
                    ?>

                    <tr>
                      <td><?php echo $value['DATE_TRAITEMENT']; ?></td>
                      <td><?php echo $value['DIRECTION']; ?></td>
                      <td><?php echo $value['SERVICE']; ?></td>
                      <td><?php echo $value['SECTION']; ?></td>
                      <td><?php echo $value['NOM']; ?> <?php echo $value['PRENOM']; ?></td>
                      <td><?php echo $value['STATUS_CONGE']; ?></td>
                      <!-- <td><?php echo $value['NIVEAU']; ?></td> -->
                      <td><?php echo $value['COMMENTAIRE']; ?></td>
                    </tr>

                    <?php
                    }
                    ?>

                  </table>
                </div>
                

              </div>
              <!-- /.mailbox-read-message -->
            </div>
            <!-- /.card-body -->
            
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <?php
 include VIEWPATH.'includes/new_copy_footer.php';  
  ?>
  

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>

<!-- ./wrapper -->
<?php
  include VIEWPATH.'includes/new_script.php';
  ?>

<!-- Page specific script -->
<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,"ordering": false,
    });
   
  });
</script>

</body>
</html>
