[ Index ]

PHP Cross Reference of IEUF

title

Body

[close]

/gestion/ -> parentsrelais.php (source)

   1  <?php
   2  //Vérification accès
   3  require  'inc/autorisation.inc.php';
   4  if (!Adherent() && !ParentDAdherent()) include  'inc/404.php';
   5  include  "../inclus/connect_bdi.inc.php";
   6  $lettre_atelier='B';
   7  $modif=!NonCA();
   8  ?>
   9  <!DOCTYPE html>
  10  <html lang="fr">
  11    <head>
  12      <meta content="text/html; charset=iso-8859-1" http-equiv="content-type">
  13      <title>Parents-relais</title>
  14      <style type="text/css">
  15    body{
  16     font-family: Arial,Helvetica,sans-serif;
  17     font-size: 10pt;
  18    }
  19    #coordonnes {
  20    position: absolute;  
  21    bottom: 12px;  
  22    border-width: 3px;  
  23    border-style: solid;  
  24    border-color: black;  
  25    -webkit-border-radius: 10px 10px 10px 10px;
  26    border-radius: 10px 10px 10px 10px;  
  27    padding: 5px;  
  28     font-size: 12pt;
  29  }
  30  
  31  #liste_relais {  
  32    position: absolute;  
  33    bottom: 130px;  
  34    top: 50px;  
  35    overflow: auto;  
  36    width: 97%;
  37  }
  38  #liste_relais th {
  39    font-size: 16pt;
  40  }
  41  #liste_relais td[onclick] {
  42    cursor: pointer;
  43    color: #0000cc;
  44    background-color: #fcfcff;
  45  }
  46  #liste_relais td[onclick]:hover {
  47    color: #cc0000;
  48  }
  49  #masque {
  50    background-color: #cccccc;
  51    opacity: 0.7;
  52  }
  53  #masque, #fond_saisie {
  54    position: absolute;
  55    top : 0;
  56    left : 0;
  57    width: 100%;
  58    height: 100%;
  59    visibility: hidden;
  60  }
  61  #saisie {
  62    position: static;
  63    margin-top: 200px;
  64    margin-left: auto;
  65    margin-right: auto;
  66    width: 600px;
  67    height: 300px;
  68    background-color: #222222;
  69    color: white;
  70    border-radius: 20px 20px 20px 20px;
  71    box-shadow: 20px 20px 20px #666666;
  72  }
  73  #saisie p {
  74    padding-top: 30px;
  75    font-size: 16pt;
  76    text-align: center;
  77  }
  78  </style>
  79    </head>
  80    <body>
  81      <p></p>
  82      <div id="liste_relais">
  83        <table style="width: 100%;" border="1">
  84          <tbody>
  85            <tr>
  86              <th>Date</th>
  87              <th>Nom du parent</th>
  88              <th>Téléphone</th>
  89            </tr>
  90            <?php
  91             $semaine= 7*24*3600;
  92             $id_at=0;
  93             $intitule=$lieu_gard=$lieu_mob=$mob_anim=$nom_anim=$pre_anim=$nom_pres=$pre_pres=$mob_pres=$date_deb=$date_relais=$nom=$prenom=$mobile='';
  94             $datedeb= $datefin= 0;
  95             $t_js= array("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi");
  96             $requete="SELECT id as id_at, intitule, lieu_gard, lieu_mob, date_deb, date_fin,
  97                  UNIX_TIMESTAMP(date_deb) as datedeb, UNIX_TIMESTAMP(date_fin) as datefin, jour_repet  
  98               FROM atelier
  99               WHERE lettre='$lettre_atelier' ORDER BY date_deb DESC LIMIT 1";
 100             $recherche=$mysqli->query($requete);
 101             if (($col=$recherche->fetch_assoc())) extract($col);
 102             $daterelais=0;
 103             $requete="SELECT UNIX_TIMESTAMP(date_relais) as daterelais FROM relais_parent ORDER BY date_relais DESC LIMIT 1";
 104             $recherche=$mysqli->query($requete);
 105             if (($col=$recherche->fetch_assoc())) extract($col);
 106             $daterelais= $daterelais > $datedeb ? $daterelais : $datedeb;
 107             $datefin+= (($jour_repet - date("w", $datefin) - 7) % 7)*24*3600;
 108             //echo date("d-m-Y", $daterelais)."  ".date("d-m-Y", $datefin)."<br>";
 109             if ($daterelais < $datefin){
 110               $daterelais+= (($jour_repet - date("w", $daterelais) + 7) % 7)*24*3600+12*3600;
 111               while(floor($daterelais/$semaine) <= floor($datefin/$semaine)) {
 112                 $requete="INSERT relais_parent SET date_relais='".date("Y-m-d",$daterelais)."'";
 113                 $mysqli->query($requete);
 114                 //echo "$requete <br>";
 115                 $daterelais+= $semaine;
 116                 //echo date("d-m-Y", $daterelais)." $daterelais --  $datefin ".date("d-m-Y", $datefin)."<br>";
 117              }
 118             }
 119             $requete="SELECT personne.nom as nom_anim, personne.prenom as pre_anim, personne.mobile as mob_anim FROM anime, animateur, personne
 120               WHERE anime.id_atelier=$id_at AND anime.id_animateur=animateur.id AND animateur.id_perso=personne.id";
 121             $recherche=$mysqli->query($requete);
 122             if (($col=$recherche->fetch_assoc())) extract($col);
 123             $requete="SELECT personne.nom as nom_pres, personne.prenom as pre_pres, personne.mobile as mob_pres FROM personne
 124               WHERE role='pr'";
 125             $recherche=$mysqli->query($requete);
 126             if (($col=$recherche->fetch_assoc())) extract($col);
 127             $requete="SELECT relais_parent.id as id, id_perso,
 128                  personne.nom as nom, personne.prenom as prenom, personne.mobile as mobile,
 129                  DATE_FORMAT(date_relais, '%d-%m-%Y') AS date_relais, DATE_FORMAT(date_relais, '%w') AS js, date_relais as dr
 130               FROM relais_parent LEFT JOIN personne
 131               ON id_perso=personne.id
 132               WHERE date_relais >= '$date_deb'";
 133             $recherche=$mysqli->query($requete);
 134             while (($col=$recherche->fetch_assoc())){
 135               extract($col);
 136               $date_aff=$modif
 137                       ? "<td onclick='ouvre_dialogue($id, \"$dr\", \"".$t_js[$js]." $date_relais\", \"$id_perso\");' >".$t_js[$js]." $date_relais</td>"
 138                       : "<td>".$t_js[$js]." $date_relais</td>";
 139               echo "
 140                <tr>
 141                  $date_aff
 142                  <td id='nom_$id'>$prenom $nom</td>
 143                  <td id='tel_$id'>$mobile</td>
 144                </tr>";
 145             }
 146            ?>
 147          </tbody>
 148        </table>
 149      </div>
 150      <p><br>
 151      </p>
 152      <?php
 153       echo"
 154       <div id='coordonnes'>Atelier $lettre_atelier $intitule<br>
 155        Gardien : $lieu_gard téléphone $lieu_mob<br>
 156        Animateur : $pre_anim $nom_anim téléphone $mob_anim<br>
 157        Président : $pre_pres $nom_pres téléphone $mob_pres</div>";
 158        if ($modif) {
 159      ?>
 160      <div id="masque"></div>
 161      <div id="fond_saisie">
 162        <div id="saisie">
 163          <input type="hidden" name="dr" id="dr" value="">
 164          <input type="hidden" name="id" id="id" value="">
 165          <p id="form_date"></p>
 166          <p>
 167            <select name="parent" id="parent">
 168              <option value="0"> -- Non pourvu --</option>
 169              <?php
 170              $requete="SELECT id, nom, prenom FROM personne WHERE DATE_ADD(DateNaiss, INTERVAL 18 YEAR) < NOW() OR DateNaiss is NULL ORDER BY nom";
 171              $recherche=$mysqli->query($requete);
 172              while (($col=$recherche->fetch_assoc())) {
 173                extract($col);
 174                echo "<option value='$id'>$nom $prenom</option>\n";
 175              }
 176              ?>
 177            </select>
 178          </p>
 179          <p>
 180            <button onclick="ferme_dialogue();">ABANDONNER</button>
 181            <button onclick="maj_base();">VALIDER</button>
 182          </p>
 183        </div>
 184      </div>
 185      <script>
 186        xhr= new XMLHttpRequest();
 187        function ouvre_dialogue(id, dr, date, idp) {
 188          document.getElementById("masque").style.visibility= "visible";
 189          document.getElementById("fond_saisie").style.visibility= "visible";
 190          document.getElementById("dr").value=dr;
 191          document.getElementById("id").value=id;
 192          document.getElementById("form_date").innerHTML= date;
 193        }
 194        function ferme_dialogue() {
 195          document.getElementById("masque").style.visibility= "hidden";
 196          document.getElementById("fond_saisie").style.visibility= "hidden";        
 197        }
 198        function maj_base() {
 199          var dr= document.getElementById("dr").value;
 200          var id= document.getElementById("id").value;
 201          var parent= document.getElementById("parent").value;
 202          xhr.open("POST", "maj_parentrelais.php", false);
 203          xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 204          xhr.send("id="+id+"&dr="+dr+"&pa="+parent);
 205          if(xhr.status === 200) {// Réponse OK
 206            var rep= xhr.responseText;
 207            //alert (rep);
 208            var t_rep= rep.split("\n");
 209            var id= t_rep[0];
 210            var nom= t_rep.length > 2 ? t_rep[1]+" "+t_rep[2] : "";
 211            var tel= t_rep.length > 3 ? t_rep[3] : "";
 212            document.getElementById("nom_"+id).innerHTML= nom;
 213            document.getElementById("tel_"+id).innerHTML= tel;
 214            ferme_dialogue();
 215          }
 216        }
 217      </script>
 218        <?php } ?>
 219    </body>
 220  </html>


Generated: Fri Jan 31 19:59:00 2014 Cross-referenced by PHPXref 0.7.1