/[health_html]/inc/pgKnjiznica-adresar.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /inc/pgKnjiznica-adresar.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Fri Sep 28 23:34:37 2001 UTC (17 years, 7 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
Added some new pages to PLIVAmed. Some bugfixes.

1 <?php
2 include("inc/conn.php");
3 include_once("inc/search.php");
4 function MyCmp1($a, $b) { return MyCompare($a["naziv"], $b["naziv"]); }
5 function MyCmp2($a, $b) { return MyCompare($a["l"], $b["l"]); }
6 $fields = array(
7 "naziv" => array("dbname" => "naziv", "caption" => "Naziv ustanove"),
8 "zupanija" => array("dbname" => "zupanija", "caption" => "®upanija"),
9 "opcina" => array("dbname" => "opcina", "caption" => "Opæina"),
10 "posta" => array("dbname" => "posta", "caption" => "Po¹tanski broj"),
11 "mjesto" => array("dbname" => "mjesto", "caption" => "Mjesto"),
12 "adresa" => array("dbname" => "adresa", "caption" => "Adresa"),
13 "telefon" => array("dbname" => "telefon", "caption" => "Telefon")
14 );
15 if (!$id) {
16 list($srch, $qry_1, $qry_2) = Search($fields, array("naziv", "zupanija", "opcina", "posta", "mjesto", "adresa", "telefon"), array(), "naziv");
17 # Win1250 -> ISO8859-2
18 if ($qry_1) $qry_1 = strtr($qry_1, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
19 if ($qry_2) $qry_2 = strtr($qry_2, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
20 $tpl->assign("index", $index);
21 $tpl->assign("srch", ($qry_1 || $qry_2) ? true : false);
22 $tpl->assign("SEARCH", $srch);
23 }
24 $letters = Slova();
25 if (!$id && ($index || ($qry_1 || $qry_2))) {
26 $prvo_slovo = "UPPER(SUBSTRING(naziv FROM 1 FOR 1))";
27 $sql = "SELECT ustanova_id, $prvo_slovo AS prvo_slovo, naziv, mjesto FROM ustanove";
28 $uvjet = array();
29 if ($index && $index != 1) {
30 if ($index == '@') for ($i = 0; $i < count($letters); $i++) array_push($uvjet, "($prvo_slovo <> '".$letters[$i]."')");
31 else array_push($uvjet, "($prvo_slovo = '".MyUpper($index)."')");
32 }
33 if ($qry_1) array_push($uvjet, "($qry_1)");
34 $uvjet = implode(" AND ", $uvjet);
35 if ($uvjet) $sql .= " WHERE $uvjet";
36 $sql .= " ORDER BY prvo_slovo, naziv";
37 $sth = $dbh->prepare($sql);
38 if (!$sth) error("Cannot prepare query: \"$sql\"");
39 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
40 $slova = array();
41 $ustanove = array();
42 unset($staro_slovo);
43 while ($row = $sth->fetchrow_array()) {
44 list($id2, $fl, $naziv, $mjesto) = $row;
45 if (!isset($staro_slovo)) $staro_slovo = $fl;
46 if (!($qry_1 || $qry_2) && $staro_slovo != $fl) {
47 usort($ustanove, "MyCmp1");
48 array_push($slova, array("l" => $staro_slovo, "ustanove" => $ustanove));
49 $staro_slovo = $fl;
50 $ustanove = array();
51 }
52 array_push($ustanove, array("id" => $id2, "naziv" => MyEscape($naziv), "mjesto" => MyEscape($mjesto)));
53 }
54 $sth->finish();
55 if (count($ustanove) > 0) {
56 usort($ustanove, "MyCmp1");
57 array_push($slova, array("l" => $staro_slovo, "ustanove" => $ustanove));
58 }
59 usort($slova, "MyCmp2");
60 $records = 0;
61 for ($i = 0; $i < count($slova); $i++) $records += count($slova[$i]["ustanove"]);
62 $tpl->assign("records", $records);
63 $tpl->assign("slova", $slova);
64 $tpl->assign("stype", $stype);
65 }
66 if ($id) {
67 $sql = "SELECT naziv, zupanija, posta, adresa, mjesto, telefon, opcina, www, email FROM ustanove WHERE (ustanova_id = $id)";
68 $sth = $dbh->prepare($sql);
69 if (!$sth) error("Cannot prepare query: \"$sql\"");
70 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
71 $row = $sth->fetchrow_array();
72 $sth->finish();
73 list($naziv, $zup, $posta, $adr, $mj, $tel, $opc, $www, $email) = $row;
74 $tpl->assign("naziv", MyEscape($naziv));
75 $tpl->assign("adresa", MyEscape($adr));
76 $tpl->assign("posta", MyEscape($posta));
77 $tpl->assign("mjesto", MyEscape($mj));
78 $tpl->assign("zupanija", MyEscape($zup));
79 $tpl->assign("telefon", MyEscape($tel));
80 $tpl->assign("opcina", MyEscape($opc));
81 $tpl->assign("www", MyEscape($www));
82 $tpl->assign("email", MyEscape($email));
83 }
84 $tpl->assign("letters", $letters);
85 $tpl->assign("ID", $id);
86 $dbh->disconnect();
87 ?>

  ViewVC Help
Powered by ViewVC 1.1.26