<?php
$metacss = "";
$barre = "";

global $aModel;

ob_start();
?>
  <div class="row">
    <div class="col-sm-12 col-md-6">
      <div class="panel panel-info">
        <div class="panel-heading"><i class="fa fa-file-text"></i> Accueil - Informations Marchés
          <button class="btn btn-success btn-xs pull-right" id="btnAddInfo" title="Créer une info marché"><i class="fa fa-plus fa-lg"></i> Ajouter</button>
        </div>
        <div class="panel-body">
          <div class="border cm-scrollbar cm-table-w-scroll table-responsive table-800">
            <table id="tblInfos" class="table table-bordered table-striped table-fixed">
              <thead>
              <tr>
                <th class="header" scope="col" width="10%">Date</th>
                <th class="header text-center" scope="col" width="20%">Titre</th>
                <th class="header text-center" scope="col" width="30%">Texte</th>
                <th class="header text-center" scope="col" width="10%">Publié</th>
                <th class="header text-center" scope="col" width="10%">Actions</th>
              </tr>
              </thead>
              <tbody>
              <?php
              $iLines = 0;
              foreach ($aModel["infos"] as $info) {
                echo '<tr class="ligInfo">';
                echo '<td>' . affiche_date($info["date_infos"]) . '</td>';
                echo '<td>' . $info["titre_infos"] . '</td>';
                echo '<td>' . $info["text_infos"] . '</td>';
                echo '<td class="center">';
                if ($info["chk_publie"] == 1) {
                  echo 'Oui';
                } else {
                  echo 'Non';
                }
                echo '</td>';
                echo '<td class="text-center">';
                echo '<a title="Modifier cette info marchés" class="btn btn-xs btn-primary btnModInfo mr-1" data-rowid="' . $info["rowid"] . '"><i class="fa fa-pencil fa-lg"></i></a>';
                echo '<a title="Supprimer cette info marchés" class="btn btn-xs btn-danger btnSuppInfo" data-rowid="' . $info["rowid"] . '"><i class="fa fa-trash fa-lg"></i></a>';
                echo '</td>';
                echo '</tr>';
                $iLines++;
              }
              if ($iLines == 0) {
                echo '<tr><td colspan="5" class="text-center">Aucune info marchés</td></tr>';
              }
              ?>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-12 col-md-6">

    </div>
  </div>
<?php
$content = ob_get_contents();
ob_clean();

ob_start();
//! Affichage des modales
?>
  <div class="modal draggable fade" id="modalEditInfos" tabindex="-1" role="dialog" aria-labelledby="modInfosTitre" data-backdrop="static">
    <div class="modal-dialog modal-xl">
      <div class="modal-content">
        <div class="modal-header">
          <h4 class="modal-title" id="modInfosTitre"></h4>
        </div>
        <div class="modal-body">
          <div class="row">
            <div class="col-md-12">
              <form class="form-horizontal" id="frmInfo" role="form" enctype="multipart/form-data">
                <input type="hidden" name="rowid" id="inpInfoRowid" value=""/>

                <div class="form-group">
                  <label for="inpInfoDate" class="control-label col-md-2">Date :</label>
                  <div class="col-md-2"><input type="date" class="form-control" name="date_infos" id="inpInfoDate" data-default="" required="required"/></div>
                  <label for="inpInfoChkPublie" class="control-label col-md-2">Publié :</label>
                  <div class="col-md-2">
                    <div class="checkbox"><input type="checkbox" name="chk_publie" id="inpInfoChkPublie"/></div>
                  </div>
                </div>
                <div class="form-group">
                  <label for="inpInfoTitre" class="control-label col-md-2">Titre :</label>
                  <div class="col-md-6"><input type="text" class="form-control" name="titre_infos" id="inpInfoTitre" data-default="" required="required" maxlength="200"/></div>
                </div>
                <div class="form-group">
                  <label for="inpInfoText" class="control-label col-md-2">Texte :</label>
                  <div class="col-md-8">
                    <textarea class="form-control" rows="3" name="text_infos" id="inpInfoText" required="required"></textarea>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" id="btnCancelModInfo" title="Annuler la modification">Annuler</button>
          <button type="button" class="btn btn-success" id="btnSaveModInfo">Enregistrer</button>
        </div>
      </div>
    </div>
  </div>

<?php
$modal = ob_get_contents();
ob_clean();

ob_start();
?>
  <script src="/pub/res/js/jinterface.js"></script>
<?php
$jscript = ob_get_contents();
ob_end_clean();
require_once $Route->_layout;
