<div id="grille">

  <div class="mt-2 mb-2">
    <select class="form-select text-center" name="rech_voir" id="rech_voir" onchange="javascript:grille();">
      <option value="0">voir tout</option>
      <option value="1"<?=(($rech_voir==1)?" selected":"");?>>petit matin uniquement</option>
      <option value="2"<?=(($rech_voir==2)?" selected":"");?>>journée uniquement</option>
      <option value="3"<?=(($rech_voir==3)?" selected":"");?>>Matin/midi/soir uniquement</option>
    </select>
  </div>

  <div class="text-center my-2">
    <a href="javascript:grilleToDate('<?=$dateAvant->toDateString();?>');" style="text-decoration:none;" class="px-2 border border-dark rounded icon-arrow-left"></a>
    &nbsp;
    <?php if ($aff=="j"): ?>
      <?=$date->getDay();?> - <?=$date->getMonth();?> - <?=$date->getYear();?>
    <?php elseif($aff=="s"): ?>
      Semaine du <?=$du->getDay();?>/<?=$du->getMonth();?>/<?=substr($du->getYear(),-2);?> au <?=$au->getDay();?>/<?=$au->getMonth();?>/<?=substr($au->getYear(),-2);?>
    <?php else: ?>
      <?=$mois[$date->getMonth()];?> <?=$au->getYear();?>
    <?php endif; ?>
    &nbsp;
    <a href="javascript:grilleToDate('<?=$dateApres->toDateString();?>');" style="text-decoration:none;" class="px-2 border border-dark rounded icon-arrow-right"></a>
    <?php if ($aff=="j"): ?>
      <button type="button" class="btn btn-sm btn-primary" onclick="javascript:ouvrir(600,800,100,100,'<?=base_url();?>/agenda/print_liste_jour/<?=$date->toDateString();?>',1);">imprimer</button>
    <?php endif; ?>
  </div>

  <!-- <div class="table-responsive"> -->
    <table class="table table-bordered">
      <thead class="table-light">
        <tr>
          <?php foreach ($entete as $key => $ent): ?>
            <th class="p-0" style="white-space:nowrap;">
              <div class="ag_entete_<?=(($aff=="j")?"j":"s");?>"><?=$ent['jour'];?></div>
              <?=(($aff=="j")?"&nbsp;".$ent['date']->toLocalizedString('MMM d, yyyy'):"");?>
              <?=(($aff=="s")?"<div class=\"ag_second_s\">".$ent['date']->toLocalizedString('MMM d, yyyy'):"")."</div>";?>
            </th>
          <?php endforeach; ?>
        </tr>
      </thead>
      <tbody>
        <tr>
          <?php
            $cpt=0;
            for ($i=1; $i <$firstDecal ; $i++) {
              $cpt++;
              echo "<td> - </td>" ;
            }
          ?>
          <?php foreach ($tab_jour as $key => $jour): ?>
            <?php
              $cpt++;
            ?>
            <td class="p-0" style="height:75px;<?=(($aff!="j")?"width:14.28%;":"");?><?=(($aff!="j" && $key==date('Y-m-d'))?"background-color:#f5dff7;":"");?>">
              <?php if ($aff!="j"): ?>
                <a href="javascript:jourDate('<?=$key;?>');" class="d-block h-100" style="text-decoration:none;">
                  <div class="text-end pe-1 pt-1" style="color:gray;font-size:0.7em;"><span class="border border-dark rounded px-1 text-white bg-dark"><b><?=intval(substr($key,-2));?></b></span></div>
                  <?php if ($jour): ?>
                    <div class="text-center" style="font-size:1.1em;"><b><?=count($jour);?></b></div>
                  <?php endif; ?>
                </a>
              <?php else: ?>
                <button type="button" class="btn btn-sm btn-primary icon-plus p-0 w-100 text-center" onclick="javascript:newRDV('<?=$key;?>');"></button>


                  <ul class="nav nav-tabs" id="myTab" role="tablist">
                    <li class="nav-item" role="presentation">
                      <button class="nav-link active" id="restant-tab" data-bs-toggle="tab" data-bs-target="#restant" type="button" role="tab" aria-controls="restant" aria-selected="true">
                        Restants
                      </button>
                    </li>
                    <li class="nav-item" role="presentation">
                      <button class="nav-link" id="effectuee-tab" data-bs-toggle="tab" data-bs-target="#effectuee" type="button" role="tab" aria-controls="effectuee" aria-selected="false">
                        Terminés
                      </button>
                    </li>
                  </ul>
                  <div class="tab-content" id="myTabContent">
                    <div class="tab-pane fade show active p-2" id="restant" role="tabpanel" aria-labelledby="restant-tab">


                    </div>
                    <div class="tab-pane fade p-2" id="effectuee" role="tabpanel" aria-labelledby="effectuee-tab">...</div>
                  </div>




              <?php endif; ?>
            </td>
            <?php if ($cpt%7==0): ?>
              </tr>
              <tr>
            <?php endif; ?>
          <?php endforeach; ?>
          <?php if ($firstDecal>0 && !($cpt%7==0)): ?>
            <?php
              while(!($cpt%7==0)){
                $cpt++;
                echo "<td> - </td>" ;
              }
            ?>
          <?php endif; ?>
        </tr>
      </tbody>
    </table>
  <!-- </div> -->

</div>
