config.php introduced
[www.energie.vellum.cz.git] / index.php
1 <?php $cvs_id='$Id$';
2
3         $detect_js=true;
4         $head='
5 <script type="text/javascript" src="objednavka.js"></script>
6 ';
7         include("common.php");
8
9         $head_css="
10 .tab-bold  { font-weight: bold; }
11 .post-type { font-family: monospace; }
12 .nowrap    { white-space: nowrap; }
13 .centered  { text-align: center; }
14 ";
15         heading();
16 ?>
17 <h1 class="centered"><img src="img/eap-title.png" <?php print(img_size(522,60)); ?> alt="Teplo &amp; Peníze" /></h1>
18 <p>&nbsp;</p>
19 <?php
20
21 function title_table_month($year,$month,$month_last)
22 {
23         $month_full=month_full($year,$month,$month_last);
24         $base="img/eap-$year-$month_full";
25         $name=        "$year/$month_full";
26         print("<a href=\"${base}.jpg\">"
27                         ."<img src=\"${base}s.jpg\" ".img_size(98,138)." alt=\"titulní stránka $name\" /></a><br />\n"
28                         ."<a href=\"obsah.php?year=$year&month=$month\">obsah $name</a>"
29                         );
30 }
31
32 db_connect();
33 $result=db_query("select year,month,month_last from $tb_obsah order by year,month");
34 $split=6;
35 $year=0;
36 $month=-$split;
37 $fin_split="";
38 $fin_year="";
39 while ($row=mysql_fetch_array($result)) {
40         $row["month"     ]--;
41         $row["month_last"]--;
42
43         if ($row["year"]!=$year) {
44                 print($fin_split.$fin_year);
45
46                 $year=$row["year"];
47                 print("<table border=\"0\" width=\"100%\"><tr><td align=\"center\"><table border=\"1\" cellpadding=\"5\">\n"
48                                 ."<tr><th colspan=\"$split\">Roèník $year (<a href=\"obsah.php?year=$year\">obsahy èísel</a>)</td></tr>\n"
49                                 );
50                 $fin_year="</table></td></tr></table>\n";
51                 $month=-$split;
52                 }
53         if ($month && floor($row["month"]/$split)!=floor($month/$split)) {
54                 print($fin_split."<tr>");
55                 $fin_split="</tr>";
56                 $month=$row["month"]-($row["month"]%$split)-1;
57                 }
58         while ($month+1<$row["month"]) {
59                 print("<td></td>");
60                 $month++;
61                 }
62         print("<td align=\"center\""
63                         .($row["month_last"]!=$row["month"] ? " colspan=\"".($row["month_last"]+1-$row["month"])."\"" : "")
64                         .">");
65         title_table_month($year,$row["month"]+1,$row["month_last"]+1);
66         print("</td>");
67         $month=$row["month_last"];
68         }
69 mysql_free_result($result);
70 print($fin_split.$fin_year);
71 ?>
72
73 <p>&nbsp;</p>
74
75 <h2>Objednávka</h2>
76 <form action="objednavka.php<?php print($have_js); ?>" method="post">
77 <table border="0" width="100%">
78 <tr><td align="center"><table border="1" width="90%">
79         <tr><td align="center"><table border="0">
80 <?php
81         function tab_left($name)
82         { print("<td>Objednávám(e)</td><td><input type=\"text\" name=\"$name\" size=\"2\" onkeyup=\"sum_price(this)\" onchange=\"sum_price(this)\" /> (krát)</td>\n"); }
83 ?>
84         <tr class="tab-bold"><?php tab_left("want_phys_2001"); ?><td>pøedplatné na rok 2001 za zvýhodnìnou cenu 360Kè</td></tr>
85         <tr><?php                  tab_left("want_phys_2000"); ?><td>roèník 2000 za cenu 150 Kè</td></tr>
86 <?php
87
88         if (!($f=fopen("objednavka.js","r")))
89                 fatal("Nepodaøilo se naèíst seznam dostupného zbo¾í");
90         while (($s=fgets($f,0x1000))) {
91                 if (!($s=trim($s)))
92                         break;
93                 if (!(ereg("^want_price\\[ *'cd_([^']*)'\\]=([0-9]*);\$",$s,$o_matched)))
94                         continue;
95                 $o_year =$o_matched[1];
96                 $o_price=$o_matched[2];
97                 print("<tr>");
98                 tab_left("want_cd_$o_year");
99                 print("<td>roèník $o_year na CD za cenu $o_price Kè</td></tr>\n");
100                 }
101         fclose($f);
102         if ($have_js) {
103                 ?>
104         <tr><td colspan="3"><hr /></td></tr>
105         <tr><td colspan="3">Celková cena: <input type="text" name="price" value="0" size="5" readonly="readonly" /> Kè</td></tr>
106                 <?php
107                 }
108 ?>
109 </table></td></tr>
110 <?php
111
112 function print_addr($title,$pfx,$ico)
113 {
114         ?>
115         <tr><td align="center"><table border="0">
116                 <colgroup width="0*" span="3" />
117                 <tr><td colspan="3" align="center" class="tab-bold"><?php print($title); ?></td></tr>
118                 <tr><td class="nowrap">Název firmy / Jméno:</td><td colspan="2"><input type="text" name="<?php print("${pfx}name"); ?>"    size="60" /></td></tr>
119                 <tr><td valign="top">Adresa:</td><td colspan="2"><table border="0">
120                         <colgroup width="0*" span="3" />
121                         <tr><td>Ulice:</td><td colspan="2"><input type="text" name="<?php print("${pfx}ulice"); ?>" size="60" /></td></tr>
122                         <tr><td>Mìsto:</td><td            ><input type="text" name="<?php print("${pfx}mesto"); ?>" size="30" /></td>
123                                 <td>PSÈ:                         <input type="text" name="<?php print("${pfx}psc"); ?>" size="5" maxlength="5" /></td></tr>
124                         </table></td></tr>
125         <?php
126         if ($ico) {
127         ?>
128                 <tr><td>IÈO:</td><td              ><input type="text" name="<?php print("${pfx}ico"); ?>" size="20" /></td>
129                         <td>DIÈ:           <input type="text" name="<?php print("${pfx}dic"); ?>" size="20" /></td></tr>
130         <?php
131                 }
132         ?>
133                 <tr><td class="nowrap">Kontaktní osoba:</td    ><td colspan="2"><input type="text" name="<?php print("${pfx}contact"); ?>" size="60" /></td></tr>
134                 <tr><td>Telefon:</td><td><input type="text" name="<?php print("${pfx}tel"); ?>" size="25" /></td>
135                         <td>Fax: <input type="text" name="<?php print("${pfx}fax"); ?>" size="25" /></td></tr>
136                 <tr><td>e-mail:</td             ><td colspan="2"><input type="text" name="<?php print("${pfx}mail"); ?>"    size="40" /></td></tr>
137         </table></td></tr>
138         <?php
139 }
140
141 print_addr("Adresa pro vystavení a zaslání faktury"          ,"addr1_",true);
142 print_addr("Adresa pro zasílaní èasopisu (jen pokud se li¹í)","addr2_",false);
143
144 ?>
145 <tr><td><table border="0">
146 <tr><td align="center" class="tab-bold">Jiné sdélení redakci</td></tr>
147 <tr><td><textarea name="comments" rows="5" cols="100"></textarea></td></tr>
148 </table></td></tr>
149 <tr><td align="center"><input type="submit" value="Ode¹li závaznou objednávku" onclick="return(validate(this.form))" /></td></tr>
150 </table></td></tr>
151 </table></form>
152
153 <?php
154         footer();
155 ?>