Oktatási naptár (4)

 

A negyedik és egyben utolsó lépésként a naptár látványát véglegesítjük:

 

 

Íme, a teljes kód:

 

http://gorbem.hu/PH/Naptar4.php

 

<?php

            include("hconfig.php");

            $honap = array("", "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December");

            $hnap = array("", "H", "K", "S", "C", "P", "S", "V");

            $ma = getdate();

            $aev = $ma[year];

            $ho = $ma[mon];

            $nap = $ma[mday];

            $ev1 = $aev;

            if ( $ho < 8 ){$ev1--;}

            $ev2 = $ev1+1;

            $enap = $ev1."-08-01";

            $unap = $ev2."-07-31";

            $ered = mysql_query("SELECT * FROM tanev");

            $sszam = mysql_num_rows($ered);

            $sszam = $sszam+0;

            if ( $sszam == 0 ){mysql_query("INSERT INTO tanev SET id=''");}

            else{

                  $ered = mysql_query("SELECT * FROM tanev");

                  $sor = mysql_fetch_object($ered);

                  $elso = $sor->Elso;

                  $oszieu = $sor->OsziEU; $osziue = $sor->OsziUE;

                  $telieu = $sor->TeliEU; $teliue = $sor->TeliUE;

                  $tavaszeu = $sor->TavaszEU;  $tavaszue = $sor->TavaszUE;

                  $utolso = $sor->Utolso; $husveth = $sor->HusvetH; $punkh = $sor->PunkH;

                  $irer1 = $sor->IrEr1; $irer2 = $sor->IrEr2;

                  $irer3 = $sor->IrEr3; $irer4 = $sor->IrEr4;

                  $irer5 = $sor->IrEr5; $igaz1 = $sor->Igaz1;

                  $igaz2 = $sor->Igaz2; $igaz3 = $sor->Igaz3;

                  $rendk1 = $sor->Rendk1; $rendk2 = $sor->Rendk2; $rendk3 = $sor->Rendk3;

            }

?>

<html>

<head>

<title>Oktatási naptár</title>

</head>

<body bgcolor="#eeeeee">

<center>

<h2>A tanév rendjét meghatározó időpontok:</h2>

<form name="" action="" method="POST">

<table border=1 bordercolor="white" cellpadding=0 cellspacing=0 bgcolor="#eeeeee">

<tr>

<td valign="top">

<table border=1 bordercolor="white" cellpadding=0 cellspacing=0 bgcolor="#eeeeee">

<tr><th colspan=2>Tanítási napok:</th></tr>

<tr><td align="right">A tanév első:</td>

<td><input type="text" name="elso" size="7" <?php print "value=\"$elso\"" ?>></td></tr>

<tr><td align="right">az őszi szünet előtti utolsó:</td>

<td><input type="text" name="oszieu" size="7" <?php print "value=\"$oszieu\"" ?>></td></tr>

<tr><td align="right">az őszi szünet utáni első:</td>

<td><input type="text" name="osziue" size="7" <?php print "value=\"$osziue\"" ?>></td></tr>

<tr><td align="right">a téli szünet előtti utolsó:</td>

<td><input type="text" name="telieu" size="7" <?php print "value=\"$telieu\"" ?>></td></tr>

<tr><td align="right">a téli szünet utáni első:</td>

<td><input type="text" name="teliue" size="7" <?php print "value=\"$teliue\"" ?>></td></tr>

<tr><td align="right">a tavaszi szünet előtti utolsó:</td>

<td><input type="text" name="tavaszeu" size="7" <?php print "value=\"$tavaszeu\"" ?>></td></tr>

<tr><td align="right">a tavaszi szünet utáni első:</td>

<td><input type="text" name="tavaszue" size="7" <?php print "value=\"$tavaszue\"" ?>></td></tr>

<tr><td align="right">a tanév utolsó tanítási napja:</td>

<td><input type="text" name="utolso" size="7" <?php print "value=\"$utolso\"" ?>></td></tr>

<tr><th colspan=2>Ünnepnapok:</th></tr>

<tr><td align="right">Húsvét hétfő:</td>

<td><input type="text" name="husveth" size="7" <?php print "value=\"$husveth\"" ?>></td></tr>

<tr><td align="right">Pünkösd hétfő:</td>

<td><input type="text" name="punkh" size="7" <?php print "value=\"$punkh\"" ?>></td></tr>

<tr><td colspan=2 height="26">&nbsp;</td></tr>

</table>

</td>

<td>

<table border=1 bordercolor="white" cellpadding=0 cellspacing=0 bgcolor="#eeeeee">

<tr><th colspan=2>Tanítás nélküli munkanapok:</th></tr>

<tr><td align="right">Írásbeli érettségi 1.napja:</td>

<td><input type="text" name="irer1" size="7" <?php print "value=\"$irer1\"" ?>></td></tr>

<tr><td align="right">Írásbeli érettségi 2.napja:</td>

<td><input type="text" name="irer2" size="7" <?php print "value=\"$irer2\"" ?>></td></tr>

<tr><td align="right">Írásbeli rettségi 3.napja:</td>

<td><input type="text" name="irer3" size="7" <?php print "value=\"$irer3\"" ?>></td></tr>

<tr><td align="right">Írásbeli érettségi 4.napja:</td>

<td><input type="text" name="irer4" size="7" <?php print "value=\"$irer4\"" ?>></td></tr>

<tr><td align="right">Írásbeli érettségi 5.napja:</td>

<td><input type="text" name="irer5" size="7" <?php print "value=\"$irer5\"" ?>></td></tr>

<tr><td align="right">1. igazgatói tanítási szünet:</td>

<td><input type="text" name="igaz1" size="7" <?php print "value=\"$igaz1\"" ?>></td></tr>

<tr><td align="right">2. igazgatói tanítási szünet:</td>

<td><input type="text" name="igaz2" size="7" <?php print "value=\"$igaz2\"" ?>></td></tr>

<tr><td align="right">3. igazgatói tanítási szünet:</td>

<td><input type="text" name="igaz3" size="7" <?php print "value=\"$igaz3\"" ?>></td></tr>

<tr><th colspan=2>Rendkívüli tanítási napok:</th></tr>

<tr><td align="right">1. rendkívüli tanítási nap:</td>

<td><input type="text" name="rendk1" size="7" <?php print "value=\"$rendk1\"" ?>></td></tr>

<tr><td align="right">2. rendkívüli tanítási nap:</td>

<td><input type="text" name="rendk2" size="7" <?php print "value=\"$rendk2\"" ?>></td></tr>

<tr><td align="right">3. rendkívüli tanítási nap:</td>

<td><input type="text" name="rendk3" size="7" <?php print "value=\"$rendk3\"" ?>></td></tr>

</table>

</td>

</tr>

</table>

<br />

<input type="submit" name="mentes" value="Az adatok mentése" />

</form>

<h2><u><b>Oktatási naptár: <?php print "$ev1-$ev2."; ?></u></b></h2>

<font size="2" face="Courier New">

<?php

            if ( isset($_POST['mentes']) ){

                  $elso = $_POST['elso'];

                  $oszieu = $_POST['oszieu'];  $osziue = $_POST['osziue'];

                  $telieu = $_POST['telieu']; $teliue = $_POST['teliue'];

                  $tavaszeu = $_POST['tavaszeu']; $tavaszue = $_POST['tavaszue'];

                  $utolso = $_POST['utolso']; $husveth = $_POST['husveth']; $punkh = $_POST['punkh'];

                  $irer1 = $_POST['irer1']; $irer2 = $_POST['irer2'];

                  $irer3 = $_POST['irer3']; $irer4 = $_POST['irer4'];

                  $irer5 = $_POST['irer5']; $igaz1 = $_POST['igaz1'];

                  $igaz2 = $_POST['igaz2']; $igaz3 = $_POST['igaz3'];

                  $rendk1 = $_POST['rendk1']; $rendk2 = $_POST['rendk2']; $rendk3 = $_POST['rendk3'];

                  mysql_query("UPDATE tanev SET Elso='$elso', OsziEU='$oszieu', OsziUE='$osziue', TeliEU='$telieu', TeliUE='$teliue', TavaszEU='$tavaszeu', TavaszUE='$tavaszue', Utolso='$utolso', HusvetH='$husveth', PunkH='$punkh', IrEr1='$irer1', IrEr2='$irer2', IrEr3='$irer3', IrEr4='$irer4', IrEr5='$irer5', Igaz1='$igaz1', Igaz2='$igaz2', Igaz3='$igaz3', Rendk1='$rendk1', Rendk2='$rendk2', Rendk3='$rendk3'");

                  mysql_query("TRUNCATE TABLE naptar");

                  for ($ev=$ev1; $ev<=$ev2; $ev++){

                        for ($ho=1; $ho<13; $ho++){

                             for ($nap=1; $nap<32; $nap++){

                                   if ( checkdate($ho, $nap, $ev) ){

                                         $datum = "";

                                         if ( $nap>9 && $ho>9){$datum = $datum.$ev."-".$ho."-".$nap;}

                                         elseif ( $nap<10 && $ho>9 ){$datum = $datum.$ev."-".$ho."-0".$nap;}

                                         elseif ( $nap>9 && $ho<10 ){$datum = $datum.$ev."-0".$ho."-".$nap;}

                                         elseif ( $nap<10 && $ho<10 ){$datum = $datum.$ev."-0".$ho."-0".$nap;}

                                         if ( ($datum >= $enap) && ($datum <= $unap) ){

                                               $d = mktime(0,0,0,$ho,$nap,$ev);

                                               $n = strftime("%u","$d");

                                               $t = $n;

                                               if ( $n>5 ){$t = '0';}

                                               mysql_query("INSERT INTO naptar (id,Datum,HNap,TNap) VALUES ('', '$datum', '$n', '$t')");

                                         }

                                   }

                             }

                        }

                  }

                  mysql_query("UPDATE naptar SET TNap=0 WHERE ((Datum>='$enap') AND (Datum<'$elso')) OR ((Datum>'$oszieu') AND (Datum<'$osziue')) OR ((Datum>'$telieu') AND (Datum<'$teliue')) OR ((Datum>'$tavaszeu') AND (Datum<'$tavaszue')) OR ((Datum>'$utolso') AND (Datum<='$unap'))");

                  $okt23 = $ev1."-10-23";

                  $mindsz = $ev1."-11-01";

                  $marc15 = $ev2."-03-15";

                  $maj01 = $ev2."-05-01";

                  mysql_query("UPDATE naptar SET TNap=0 WHERE (Datum='$okt23') OR (Datum='$mindsz') OR (Datum='$marc15') OR (Datum='$maj01')");

                  mysql_query("UPDATE naptar SET TNap=0 WHERE (Datum='$husveth') OR (Datum='$punkh')");

                  mysql_query("UPDATE naptar SET TNap=0 WHERE (Datum='$irer1') OR (Datum='$irer2') OR (Datum='$irer3') OR (Datum='$irer4') OR (Datum='$irer5')");

                  mysql_query("UPDATE naptar SET TNap=0 WHERE (Datum='$igaz1') OR (Datum='$igaz2') OR (Datum='$igaz3')");

                  mysql_query("UPDATE naptar SET TNap=6 WHERE (Datum='$rendk1') OR (Datum='$rendk2') OR (Datum='$rendk3')");

                  header("location: Naptar4.php");

            }

            print "<table border=1 bordercolor=\"black\" cellpadding=0 cellspacing=0>\n";

            print "<tr>";

            for ($ev=$ev1; $ev<=$ev2; $ev++){

                  for ($ho=1; $ho<13; $ho++){

                        if ( (($ev == $ev1) && ($ho > 7)) || (($ev == $ev2) && ($ho < 8)) ){

                             print "<td>";

                             print "<table border=1 bordercolor=\"#ffffff\" cellpadding=0 cellspacing=0>\n";

                             print "<tr>";

                             if ( $ho == 8 ){print "<th colspan=\"7\">$ev1. $honap[$ho]</th>";}

                             elseif( $ho == 1 ){print "<th colspan=\"7\">$ev2. $honap[$ho]</th>";}

                             else{print "<th colspan=\"7\">$honap[$ho]</th>";}

                             print "</tr>";

                             print "<tr>";

                             print "<th>H</th><th>K</th><th>S</th><th>C</th><th>P</th><th>S</th><th>V</th>";

                             print "</tr>";

                             print "<tr>";

                             $tszn = 0;

                             $het = 1;

                             $kezd = TRUE;

                             for ($nap=1; $nap<32; $nap++){

                                   if ( checkdate($ho, $nap, $ev) ){

                                         $datum = $ev."-".$ho."-".$nap;

                                         $ered = mysql_query("SELECT * FROM naptar WHERE Datum='$datum'");

                                         $sor = mysql_fetch_object($ered);

                                         $hn = $sor->HNap;

                                         $tn = $sor->TNap;

                                         $hn = $hn+0;

                                         $tn = $tn+0;

                                         if ( checkdate($ho, $nap, $ev) ){

                                               if ( $kezd ){for ($i=0; $i<$hn-1; $i++){print "<td>&nbsp;</td>";}$kezd = FALSE;}

                                               if ( ($tn == 0) && ($hn<6) ){

                                                     print "<td align=\"right\" bgcolor=\"#eeeeee\">$nap</td>";

                                               }

                                               if ( ($tn == 0) && ($hn == 6) ){

                                                     print "<td align=\"right\" bgcolor=\"#dddddd\">$nap</td>";

                                               }

                                               if ( ($tn == 0) && ($hn == 7) ){

                                                     print "<td align=\"right\" bgcolor=\"#cccccc\">$nap</td>";

                                               }

                                               if ( $tn>0 ){print "<td align=\"right\" bgcolor=\"#88ff88\"><b>$nap</b></td>";$tnsz++;}

                                               if ( $hn == 7 ){$het++; print "</tr>";}

                                         }

                                   }

                             }

                             if ( $hn == 7){$het--;}

                             for ($i=$hn; $i<7; $i++){print "<td>&nbsp;</td>";}

                             if ( $het < 6 ){print "<tr>";for ($i=0; $i<7; $i++){print "<td>&nbsp;</td>";}print "</tr>";}

                             print "</tr>";

                             print "</table>";

                             print "</td>";

                        }

                        if ( ($ho == 11) || ($ho == 3) || ($ho == 7) ){print "</tr>";}

                  }

            }

            print "</tr>";

            print "</table>";

            print "</font>";

            print "<h3>A tanítási napok száma: $tnsz</h3>";

?>

</center>

</body>

</html>