1 |
<?php |
<?php |
2 |
|
include("inc/conn.php"); |
3 |
$date = getdate(); |
$date = getdate(); |
4 |
if (!isset($type)) $type = 1; |
if (!isset($type)) $type = 1; |
5 |
$tpl->assign("type", $type); |
$tpl->assign("type", $type); |
10 |
if (!isset($sort)) $sort = 2; |
if (!isset($sort)) $sort = 2; |
11 |
$tpl->assign("sort", $sort); |
$tpl->assign("sort", $sort); |
12 |
$tpl->assign("kreni", $kreni); |
$tpl->assign("kreni", $kreni); |
13 |
|
$mjeseci = array("siječanj", "veljača", "ožujak", "travanj", "svibanj", "lipanj", "srpanj", "kolovoz", "rujan", "listopad", "studeni", "prosinac"); |
14 |
|
$mj = array("siječnja", "veljače", "ožujka", "travnja", "svibnja", "lipnja", "srpnja", "kolovoza", "rujna", "listopada", "studenog", "prosinca"); |
15 |
|
$tpl->assign("mjeseci", $mjeseci); |
16 |
|
$sql = "SELECT DISTINCT godina_od, godina_do FROM kongresi"; |
17 |
|
$sth = $dbh->prepare($sql); |
18 |
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
19 |
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
20 |
$godine = array(); |
$godine = array(); |
21 |
for ($i = $date["year"] - 2; $i < $date["year"] + 3; $i++) array_push($godine, $i); |
while ($row = $sth->fetchrow_array()) { |
22 |
|
list($od, $do) = $row; |
23 |
|
$fnd = false; |
24 |
|
for ($i = 0; $i < count($godine); $i++) if ($godine[$i] == $od) $fnd = true; |
25 |
|
if (!$fnd) array_push($godine, $od); |
26 |
|
for ($i = 0; $i < count($godine); $i++) if ($godine[$i] == $do) $fnd = true; |
27 |
|
if (!$fnd) array_push($godine, $do); |
28 |
|
} |
29 |
|
$sth->finish(); |
30 |
$tpl->assign("godine", $godine); |
$tpl->assign("godine", $godine); |
31 |
if ($kreni) { |
if ($kreni) { |
32 |
// ... |
$sql = "SELECT DISTINCT kongresi.kon_id, naziv, dan_od, mjesec_od, godina_od, dan_do, mjesec_do, godina_do, mjesto, organizator, domaci, url, url_naziv, napomena FROM kongresi, kon_spec"; |
33 |
|
$uvjeti = array(); |
34 |
|
if ($type) array_push($uvjeti, "(".(($type == 1) ? "" : "NOT ")."domaci)"); |
35 |
|
if ($month) array_push($uvjeti, "(mjesec_od >= $month) AND (mjesec_do <= $month)"); |
36 |
|
if ($year) array_push($uvjeti, "(godina_od >= $year) AND (godina_do <= $year)"); |
37 |
|
if ($spec) array_push($uvjeti, "(kon_spec.spec_id = $spec) AND (kon_spec.kon_id = kongresi.kon_id)"); |
38 |
|
$uvjeti = implode(" AND ", $uvjeti); |
39 |
|
if ($uvjeti) $sql .= " WHERE $uvjeti"; |
40 |
|
if ($sort) { |
41 |
|
if ($sort == 1) $sql .= " ORDER BY naziv"; |
42 |
|
if ($sort == 2) $sql .= " ORDER BY godina_od, mjesec_od, dan_od, godina_do, mjesec_do, dan_do"; |
43 |
|
if ($sort == 3) $sql .= " ORDER BY mjesto"; |
44 |
|
if ($sort == 4) $sql .= " ORDER BY organizator"; |
45 |
|
} |
46 |
|
$sth = $dbh->prepare($sql); |
47 |
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
48 |
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
49 |
|
$dogadjanja = array(); |
50 |
|
while ($row = $sth->fetchrow_array()) { |
51 |
|
list($id, $naziv, $od, $om, $og, $dd, $dm, $dg, $mjesto, $org, $dom, $url, $title, $nap) = $row; |
52 |
|
array_push($dogadjanja, array( |
53 |
|
"naziv" => MyEscape($naziv), |
54 |
|
"od_d" => $od, "od_m" => $mj[$om - 1], "od_g" => $og, |
55 |
|
"do_d" => $dd, "do_m" => $mj[$dm - 1], "do_g" => $dg, |
56 |
|
"organizator" => MyEscape($org), |
57 |
|
"mjesto" => MyEscape($mjesto), |
58 |
|
"url" => $url, "url_title" => MyEscape($title), |
59 |
|
"domaci" => (!$dom || $dom[0] == "f" || $dom[0] == "F") ? false : true, |
60 |
|
"napomena" => LinkIt(ParseNewline(MyEscape($nap))) |
61 |
|
)); |
62 |
|
} |
63 |
|
$sth->finish(); |
64 |
|
$tpl->assign("dogadjanja", $dogadjanja); |
65 |
} |
} |
66 |
|
$dbh->disconnect(); |
67 |
?> |
?> |