A
download table_horaire.php
Language: PHP
License: GPL
Copyright: (C) 2001, 2002 Bertand Pallie, Loc Dayot Mairie de Pierrefitte (93)
LOC: 337
Project Info
epnadmin
Server: Savannah NonGNU
Type: cvs
...epnadmin\epnadmin\epnadmin\
   6cartes.inc.php
   add_message.sh
   add_message_file.sh
   animateur.php
   ...eurs-disponibilites.php
   animateurs-horaires.php
   animateurs.inc.php
   autoeval.js
   barcode.inc.php
   basdepage.inc.php
   camembert.inc.php
   cartes.inc.php
   common.initial.sql
   config.php
   configuration.php
   constantes.inc.php
   courriel.php
   dateheure.inc.php
   debug.inc.php
   domaines.php
   en.lang.inc.php
   entete.inc.php
   epnadmin.css
   epnadminv.css
   exemple.sql
   fonctions.inc.php
   footer.inc.php
   fr.initial.sql
   fr.lang.inc.php
   header.inc.php
   horaires.php
   i25object.inc.php
   image.inc.php
   index.php
   initial.sql
   initiations.inc.php
   initiations.php
   inscription_session.php
   localisations.php
   logiciels.php
   materiels.php
   menu2.js
   mysql.inc.php
   parcours.inc.php
   parcours.php
   positionnement.php
   prets.php
   print.php
   questions.php
   remove_message.sh
   reservations.inc.php
   reservations.php
   session.php
   sessions.inc.php
   siteweb.inc.php
   siteweb.php
   stats.php
   structure.sql
   structures.inc.php
   structures.php
   table_horaire.php
   table_horaire_session.php
   tableaux.inc.php
   tarifs.php
   themes.php
   usagers.inc.php
   usagers.php
   usages.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
<?php
/*
    Copyright (C) 2001, 2002 Bertand Pallie, Loc Dayot Mairie de Pierrefitte (93)

    EPNadmin - Version 0.7

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://epnadmin.pierrefitte93.fr/
*/

require_once("header.inc.php"); 
require_once("constantes.inc.php");             // dfinition des constantes
if (!defined("FCT_UTILISATIONS"))
{
  echo $fctnonactive;
  exit;
}

//require_once("fonctions.inc.php");              // concernant des fonctions transversales inclassables
require_once("mysql.inc.php");                  // concernant mysql
//require_once("sessions.inc.php");             // concernant les sessions et initiations
require_once("usagers.inc.php");              // concernant la gestion des usagers
require_once("reservations.inc.php");         // concernant les rservations des postes en accs individuel par des usagers
require_once("tableaux.inc.php");             // Concernant l'affichage transpos d'un tableau
//require_once("siteweb.inc.php");              // concernant les pages perso des usagers et les sites web des structures
require_once("dateheure.inc.php");            // concernant la manipulation des heures et des dates, formulaire, conversion...
require_once("structures.inc.php");           // concernant les structures
//require_once("initiations.inc.php");          // concernant les initiations et les thmes
//require_once("parcours.inc.php");             // concernant les parcours des usagers et leur positionnement

$ptitr=$stablehoraire;
$titr = $stitretablehoraire;
$datemaj="30 juillet 2003";
define("COULEUR", COULEUR_UTILISATIONS);
require("entete.inc.php");

// Fonction qui les disponibilits des postes en accs individuel.
function AfficheDisponibilitsPostes($lieuv, $datev, $usagev, $combienv, $sens, $operation)
{
global $is_ident, $id_usager, $id_structure, $info, $programmer, $deprogrammer,
       $unitehoraire, $stableahorairepaslieuouvert, $stablehorairepasdepostedispo,
	$couleurtarif;

  // Construction de la requte.
  $req = "SELECT DISTINCT structures.ville AS ville,
                          structures.structure AS structure,
                          localisations.salle AS salle,
                          localisations.id AS id_localisation,
                          structures.id AS id_structure
            FROM localisations
            LEFT JOIN structures ON structures.id=localisations.id_structure
            LEFT JOIN calendrier ON calendrier.id_localisation=localisations.id
            WHERE ((\"$lieuv\"=\"*\") OR
                   (CONCAT(\"V\",ville)=\"$lieuv\") OR
                   (CONCAT(\"S\",id_structure)=\"$lieuv\") OR
                   (CONCAT(\"L\",id_localisation)=\"$lieuv\"))
              AND (calendrier.date=\"$datev\")
              AND (ouverture=\"accs individuels\")
          ORDER BY structures.ville, structures.structure, localisations.salle";
  $res = executeRequete($req);

  $unlieu=false;
  // On va avoir une ligne par structure
  while ($reponse = fetch_object($res))
  {  // Il y a sans doute des accs individuels possibles.
     // Regardons si c'est chez nous
   if (($reponse->id_structure==$id_structure && UTILISATIONS_MOI>="r")
         || UTILISATIONS_AUTRES>="r" || $is_ident!="structure")
   {
     $unlieu=true;
     echo "<hr>\n";
     echo cadre_debut(localisation($reponse->id_localisation, TRUE));
     //echo "<h3>$reponse->salle de $reponse->structure  $reponse->ville</h3>\n";

     // Affichage des disponibilits en fonction du calendrier et des rservations
     // L, il faudrait afficher le planning de la salle concerne.
     // on a id_localisation et on sait qu'il y a une ouverture. Vrifier disponibilit.

     // on regarde les horaires d'ouverture
     $req1 = "SELECT * FROM calendrier
                     WHERE date=\"$datev\"
                       AND id_localisation=\"$reponse->id_localisation\"
											 AND ouverture=\"accs individuels\"
                     ORDER BY debut";
     $res1 = executeRequete($req1);
     $ntranche=0;
     while ($tranchehoraireouverture = fetch_object($res1))
     {  // il y a des crneaux d'ouverture, alors on regarde s'il y a dj des rservations
        // debug("ouvert");
        $tranche[$ntranche]=array( "debut" => $tranchehoraireouverture->debut,
                                   "fin" => $tranchehoraireouverture->fin);
        $ntranche++;
     }
     $minhoraire=date("H:00:00", strtotime($tranche[0]["debut"]));
     $maxhoraire=$tranche[$ntranche-1]["fin"];
     free_result($res1);

     echo "<table align=center border=1>\n";

     $i=0;  // indice des lignes
     $j=0;  // indicie des colonnes

     // Ligne des horaires
     $tableau[$i][$j]["contenu"]="";
     $j++;
     //echo "<tr><td></td>";
     $nbcolparheure = 60/$unitehoraire;
     for ($heure=$minhoraire;
          $heure<$maxhoraire;
          $heure=date("H:i:00", strtotime("+ 1 hour", strtotime($heure)))
          )
     {
         $tableau[$i][$j]["param"]= " colspan=$nbcolparheure";
         $tableau[$i][$j]["contenu"]= date("H", strtotime($heure))."h - ".
						date("H", strtotime("+ 1 hour", strtotime($heure)))."h";
         $j++;
     }
     $i++; $j=0;
     //echo "</tr>\n";

     // Ensuite, une ligne par ordinateur
     $req2 = "SELECT *
               FROM materiels
               WHERE (type=\"Unit centrale\")
                 AND (id_localisation=\"$reponse->id_localisation\")
                 AND ((reservable=\" deux\") OR (reservable=\"$combienv\"))
                 AND (usages NOT LIKE '%$usagev%')
               ORDER BY reservable";
     //debug($req2);
     $res2 = executeRequete($req2);
     $unposte=false;
     while ($poste = fetch_object($res2))
     {
       $unposte=true;
       if (PARC_AUTRES>="r")
         $tableau[$i][$j]["contenu"]="<a href=\"materiels.php?id_materiel=$poste->id\">$poste->materiel</a> ($poste->specificite)";
       else
         $tableau[$i][$j]["contenu"]="$poste->materiel ($poste->specificite)";

       $j++;
       // Il va falloir construire la ligne des horaires en tenant compte des horaires et des rservations
       $heure=$minhoraire;
       while ($heure<$maxhoraire)
       {
         // On regarde tout d'abord si on est dans les horaires d'ouverture
         $req3 = "SELECT * FROM calendrier
                      WHERE date=\"$datev\"
                      AND id_localisation=\"$reponse->id_localisation\"
											AND ouverture=\"accs individuels\"
                      AND debut<=\"$heure\" AND \"$heure\"<fin";
         $res3 = executeRequete($req3);
         if (!($tranchehoraireouverture = fetch_object($res3)))
         {
           $tableau[$i][$j]["param"]=" bgcolor=\"#828282\"";
           $j++;
           //echo "<td bgcolor=\"#828282\"></td>\n";
           // on passe au crneau suivant
           $heure=date("H:i:00", strtotime("+".$unitehoraire." minutes", strtotime($heure)));
         }
         else
         {   // C'est ouvert...
           // on regarde si le poste n'est pas dj rserv
           $req3 = "SELECT * FROM utilisation_postes
                    WHERE date=\"$datev\" AND id_materiel=\"$poste->id\"
                      AND (debut<=\"$heure\" AND \"$heure\"<fin)
                      AND (etat<>\"annule\" AND etat<>\"non tenue\")";
           $res3 = executeRequete($req3);
           if (! ($reservation = fetch_object($res3)))
           {     // pas de rservation
             // On regarde s'il est encore temps
             if (strtotime($datev." ".$heure) >= strtotime("+ 1 hour")  || ($is_ident=="structure" && UTILISATIONS>"~"))
             {
               if (UTILISATIONS_AUTRES>="w" || UTILISATIONS_MOI>="w")
                 $tableau[$i][$j]["contenu"]="<a href=\"reservations.php?operation=3&id_materiel=$poste->id&datev=$datev&debutv=$heure&usagev=$usagev\">
                     $programmer</a>";
               else
                 $tableau[$i][$j]["contenu"]="libre";
               $tableau[$i][$j]["param"]=" align=center valign=middle bgColor=\"".COULEUR_UTILISATIONS."\"";
             }
             else
               $tableau[$i][$j]["param"]=" bgcolor=\"#B3B3B3\"";
             $j++;
             $heure=date("H:i:00", strtotime("+".$unitehoraire." minutes", strtotime($heure)));
           }
           else // le poste est rserv  cette heure l.
           {
             $nbminres=60*(date("H",strtotime($reservation->fin))-date("H",strtotime($reservation->debut)))
                        + (date("i",strtotime($reservation->fin))-date("i",strtotime($reservation->debut)));
             $nbuniteres = $nbminres / $unitehoraire;
             $tableau[$i][$j]["param"]=" colspan=$nbuniteres align=center valign=middle bgcolor=\"#B3B3B3\"";
             // est-on admin ?
             if (UTILISATIONS_AUTRES>="r")
             { // oui, on est administrateur
               if (USAGERS>="~")
                 $usager=trouveusager($reservation->id_usager);
               $tableau[$i][$j]["contenu"]="";
               if (CREDITS>="~" && $usager->credit_acces_individuel<="01:00:00")
                  $tableau[$i][$j]["contenu"].="<table><tr><td bgcolor=\"".$couleurtarif[$usager->id_tarif]."\">";

               if (USAGERS_AUTRES>="r")
                  $tableau[$i][$j]["contenu"].="<a href=\"usagers.php?id_usager=$usager->id\">
                                            $usager->prenom $usager->nom</a>";
               else
                  $tableau[$i][$j]["contenu"].=$reservation->usager;

               if (CREDITS>="~" && $usager->credit_acces_individuel<="01:00:00")
                  $tableau[$i][$j]["contenu"].="</td></tr></table>";

               if (USAGERS>="~" && $reservation->id_usager2!="0" && $reservation->id_usager2!="")
               { // il sera accompagn
                 $tableau[$i][$j]["contenu"].=" (avec ";
                 $usager=trouveUsager($reservation->id_usager2);

                 if (USAGERS_AUTRES>="r")
                   $tableau[$i][$j]["contenu"].="<a href=\"usagers.php?id_usager=$usager->id\">$usager->prenom $usager->nom</a>)";
                 else
                   $tableau[$i][$j]["contenu"].="usager)";
               }
               if (USAGES>="~")
               {
                 $usage=trouveUsage($reservation->id_usage);
                 $tableau[$i][$j]["contenu"].=" ($usage->nom)";
               }
               if (UTILISATIONS_AUTRES>="r")
                 $tableau[$i][$j]["contenu"].=" <a href=\"reservations.php?id_utilisation=$reservation->id\">$info</a>";
               if (UTILISATIONS_AUTRES>="w")
                 $tableau[$i][$j]["contenu"].=" <a href=\"reservations.php?operation=2&id_utilisation=$reservation->id\">$deprogrammer</a>";
             }
             else
                if ($reservation->id_usager==$id_usager) // Il faut regarder qui est l'usager
                { // c'est justement moi qui ai rserv
                  $tableau[$i][$j]["contenu"]="rserv par moi";
                  if ($reservation->id_usager2!="0" && $reservation->id_usager2!="")
                  { // je serai accompagn
                    $tableau[$i][$j]["contenu"]=" (avec ";
                    $usage=trouveUsager($reservation->id_usager2);
                    $tableau[$i][$j]["contenu"].="$usager->prenom $usager->nom)";
                  }
                  else
                    $tableau[$i][$j]["contenu"].=" (seul)";
                  if (USAGES>="~")
                  {
                    $usage=trouveUsage($reservation->id_usage);
                    $tableau[$i][$j]["contenu"].=" pour $usage->nom";
                  }
                  if (UTILISATIONS_MOI>="w")
                    $tableau[$i][$j]["contenu"].=" <a href=\"reservations.php?operation=2&id_utilisation=$reservation->id\">$deprogrammer</a>";
                }
                else
                  $tableau[$i][$j]["contenu"]="rserv";
             $j++;
             $heure=date("H:i:00", strtotime("+".$nbminres." minutes", strtotime($heure)));
           }
         } // fin de if c'est ouvert
         free_result($res3);
       } // while $heure

       $i++; $j=0;
     } // while poste
     free_result($res2);

     /*if ($sens=="normal")
       $sens="transpos"; //normal ou transpos";
     else
       $sens="normal"; */
     Affiche_tableau($tableau, $sens);
     unset($tableau);
     echo "</table>\n";

     if (!$unposte)
        echo "<p align=center>$stablehorairepasdepostedispo</p>\n";

     echo cadre_fin();
   } // on est usager ou chez nous
  } // while reponse;
  free_result($res);

  if (!$unlieu)
     echo "<p align=center>$stableahorairepaslieuouvert</p>\n";

}

// Formulaire requete de choix
function formChoixUsage($usagev, $id_materiel="")
{
   if ($id_materiel=="")
      $req = "SELECT * FROM usages ORDER BY nom";
   else
   {
      $req = "SELECT * FROM materiels WHERE id=$id_materiel";
      $res = executeRequete($req);
      $mat = fetch_object($res);
      $listeusagesimpossibles=$mat->usages;
      $req = "SELECT * FROM usages WHERE id NOT IN ($listeusagesimpossibles) ORDER BY nom";
   }
   $res = executeRequete($req);
   echo "   <td><select name=\"usagev\">\n<option></option>";
   while ($usage=fetch_object($res))
   {
      echo "<option value=\"$usage->id\"";
      if ($usagev==$usage->id) echo " SELECTED";
      echo ">$usage->nom</option>";
   }
   echo "   </select></td>\n";
}

// Formulaire requete de choix
function ChoixCombien($combienv)
{
   echo "<td><select name=\"combienv\">\n
         <option value=\"oui\"";
   if ($combienv!=" deux") echo " selected"; echo ">non, tout seul</option>
         <option value=\" deux\"";
   if ($combienv==" deux") echo " selected"; echo ">oui, accompagn(e) d'un(e) autre usager</option>
         </select></td>\n";
}
/*
function formChoixDateUsage($datev, $usagev, $operation)
{
global $idu, $PHP_SELF;
   echo "<form name=\"formdateusage\" method=\"post\" action=\"$PHP_SELF?$idu\"><table border=0>
         <input type=\"hidden\" name=\"operation\" value=\"$operation\">
         <tr><td><a href=\"$PHP_SELF?operation=$operation&usagev=$usagev&datev=".date("Y-m-d",strtotime("-1 day",strtotime($datev)))."&$idu\">&lt;&lt;</a></td>\n";
   choixDate($date);
   echo "   <td><a href=\"$PHP_SELF?operation=$operation&usagev=$usagev&datev=".date("Y-m-d",strtotime("+1 day",strtotime($datev)))."&$idu\">&gt;&gt;</a></td>";
   formChoixUsage($usagev);
   echo "   <td>&nbsp;&nbsp;<input type=\"submit\" name=\"Afficher\" value=\"Afficher\"></td></tr></table></form>\n";
}
*/
function formChoixLieuDateUsage($lieuv, $datev, $usagev, $combienv, $sens, $operation)
{
global $idu, $PHP_SELF, $scriteredeselection, $sDisposition, $sUsage, $sAccompagne, $srechdisponibilite;
  echo cadre_debut($scriteredeselection);
   echo "<form name=\"formlieudateusage\" method=\"post\" action=\"$PHP_SELF\">
          <input type=\"hidden\" name=\"operation\" value=\"$operation\">
          <table border=1 align=center>";
   echo " <tr>
            <td>Lieu</td>
						<td>";  Choix_lieu($lieuv); echo "</td>\n";

   echo "   <td rowspan=\"4\">$sDisposition<br>"; choixSensTableau($sens);
   echo "   </td>
	        </tr>
			    <tr>
					  <td>Date</td>
            <td>
					    <table>
						    <tr>
  							  <td>
                    <a href=\"$PHP_SELF?operation=$operation&usagev=$usagev&datev=".date("Y-m-d",strtotime("-1 day",strtotime($datev)))."&lieuv=$lieuv&sens=$sens\">&lt;&lt;</a>
                  </td>";
   choixJour($datev);
   echo "         <td>
                    <a href=\"$PHP_SELF?operation=$operation&usagev=$usagev&datev=".date("Y-m-d",strtotime("+1 day",strtotime($datev)))."&lieuv=$lieuv&sens=$sens\">&gt;&gt;</a>
                  </td>
		  					</tr>
			  			</table>
			      </td>\n";

   echo " </tr>
	        <tr>
					  <td>$sUsage</td>";  formChoixUsage($usagev);
   echo " </tr>
	        <tr>
					  <td>$sAccompagne</td>";  choixCombien($combienv);
   echo " </tr>
	        <tr>
					  <td align=center colspan=3>
              <input type=\"submit\" name=\"Recherche disponibilits\" value=\"$srechdisponibilite\">
			      </td>
			    </tr>
					</table></form>\n";
  echo cadre_fin();
}

// Dbut du contenu de la page

if($datev=="")
   $datev = date("Y-m-d");
if ($usagev=="" && UTILISATIONS_AUTRES>="r")
  $usagev=1;
if ($lieuv=="" && UTILISATIONS_AUTRES>="r")
  $lieuv="*";
if ($combienv=="" && UTILISATIONS_AUTRES>="r")
  $combienv="oui";


if ($operation==1 || UTILISATIONS_AUTRES>="r")
{ // affichage du planning des postes du jour
   if ($usagev!="")
   {
      formChoixLieuDateUsage($lieuv, $datev, $usagev, $combienv, $sens, 1);
      AfficheDisponibilitsPostes($lieuv, $datev, $usagev, $combienv, $sens, 1);
      echo "<hr>\n";
      formChoixLieuDateUsage($lieuv, $datev, $usagev, $combienv, $sens, 1);
   }
   else
    formChoixLieuDateUsage($lieuv, $datev, $usagev, $combienv, $sens, 1);
}
else
{ // Choix de la date et de l'usage
   echo "<hr>\n";

  // Vrification que l'usager peut encore rserver un poste...
  $longmaxi=resteCredit($id_usager, "reservable");
  //debug("longmaxi : $longmaxi");
  // rduire par le nombre de rservations dj effectues
  $req = "SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(fin)-TIME_TO_SEC(debut))) AS nbheure
           FROM utilisation_postes
           WHERE id_usager=\"$id_usager\" AND (date>CURRENT_DATE OR (date=CURRENT_DATE AND fin>=CURRENT_TIME))
                 AND etat<>'annule'";
  $res = executeRequete($req);
  if ($dejareserve=fetch_object($res))
  { // s'il y une rponse, c'est qu'il y a dj des rservations.
    // retrancher $dejareserve  $longmaxi
    $longmaxi = $longmaxi - h2min($dejareserve->nbheure);
  }
  //debug($longmaxi);
  if ($longmaxi==0)  // le 20h, c'est pour traiter les heures ngatives
  {
     echo "<p>$screditepuise</p>\n";
  }
  else
    formChoixLieuDateUsage($lieuv, $datev, $usagev, $combienv, $sens, 1);

   // Affichage de toutes les rservations  venir pour l'usager.
   //echo "<hr>\n";
   //affiche_utilisations($id_usager);
} // if

require("basdepage.inc.php");
echo "</body></html>\n";
require("footer.inc.php");
?>

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us