/[health_html]/inc/pgKnjiznica-vademecum.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

Annotation of /inc/pgKnjiznica-vademecum.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Wed Sep 26 13:04:28 2001 UTC (17 years, 9 months ago) by ravilov
Branch: MAIN
Changes since 1.2: +10 -19 lines
Added some missing files, and some missing features...

1 ravilov 1.1 <?php
2 ravilov 1.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 lijeka"),
8     "generik" => array("dbname" => "generik", "caption" => "Generièko ime"),
9 ravilov 1.3 "atk" => array("dbname" => "atc.opis || ' ' || atc.atc_id", "caption" => "ATK"),
10 ravilov 1.2 "tekst" => array("dbname" => "tekst", "caption" => "Opis")
11     );
12     if (!$id) {
13 ravilov 1.3 list($srch, $qry_1, $qry_2) = Search($fields, array("naziv", "generik", "atk", "sif_atk", "tekst"), array(), "naziv");
14 ravilov 1.2 # Win1250 -> ISO8859-2
15     if ($qry_1) $qry_1 = strtr($qry_1, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
16     if ($qry_2) $qry_2 = strtr($qry_2, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
17     $tpl->assign("index", $index);
18     $tpl->assign("srch", ($qry_1 || $qry_2) ? true : false);
19     $tpl->assign("SEARCH", $srch);
20     }
21     $letters = Slova();
22     if (!$id && ($index || ($qry_1 || $qry_2))) {
23     $prvo_slovo = "UPPER(SUBSTRING(naziv FROM 1 FOR 1))";
24 ravilov 1.3 $sql = "SELECT DISTINCT vad_id, $prvo_slovo AS prvo_slovo, naziv FROM vademecum, atc";
25     $uvjet = array("(atc.atc_id = vademecum.sif_atk)");
26 ravilov 1.2 if ($index && $index != 1) {
27     if ($index == '@') for ($i = 0; $i < count($letters); $i++) array_push($uvjet, "($prvo_slovo <> '".$letters[$i]."')");
28     else array_push($uvjet, "($prvo_slovo = '".MyUpper($index)."')");
29     }
30     if ($qry_1) array_push($uvjet, "($qry_1)");
31     $uvjet = implode(" AND ", $uvjet);
32     if ($uvjet) $sql .= " WHERE $uvjet";
33     $sql .= " ORDER BY prvo_slovo, naziv";
34     $sth = $dbh->prepare($sql);
35     if (!$sth) error("Cannot prepare query: \"$sql\"");
36     if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
37     $slova = array();
38     $lijekovi = array();
39     unset($staro_slovo);
40     while ($row = $sth->fetchrow_array()) {
41 ravilov 1.3 list($id2, $fl, $naziv) = $row;
42 ravilov 1.2 if (!isset($staro_slovo)) $staro_slovo = $fl;
43     if (!($qry_1 || $qry_2) && $staro_slovo != $fl) {
44     usort($lijekovi, "MyCmp1");
45     array_push($slova, array("l" => $staro_slovo, "lijekovi" => $lijekovi));
46     $staro_slovo = $fl;
47     $lijekovi = array();
48     }
49     array_push($lijekovi, array("id" => $id2, "naziv" => MyEscape($naziv), "mjesto" => MyEscape($mjesto)));
50     }
51     $sth->finish();
52     if (isset($staro_slovo)) {
53     usort($lijekovi, "MyCmp1");
54     array_push($slova, array("l" => $staro_slovo, "lijekovi" => $lijekovi));
55     }
56     usort($slova, "MyCmp2");
57     $records = 0;
58     for ($i = 0; $i < count($slova); $i++) $records += count($slova[$i]["lijekovi"]);
59     $tpl->assign("records", $records);
60     $tpl->assign("slova", $slova);
61     $tpl->assign("stype", $stype);
62     }
63     if ($id) {
64 ravilov 1.3 $sql = "SELECT naziv, generik, tekst, slika, slika_alt, atc.opis, atc.atc_id FROM vademecum, atc WHERE (vad_id = $id) AND (atc.atc_id = vademecum.sif_atk)";
65 ravilov 1.2 $sth = $dbh->prepare($sql);
66     if (!$sth) error("Cannot prepare query: \"$sql\"");
67     if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
68     $row = $sth->fetchrow_array();
69     $sth->finish();
70 ravilov 1.3 list($naziv, $gen, $tekst, $pic, $pic_alt, $atk, $sif_atk) = $row;
71 ravilov 1.2 $tpl->assign("naziv", MyEscape($naziv));
72     $tpl->assign("generik", MyEscape($gen));
73 ravilov 1.3 $tpl->assign("atk", MyEscape($atk));
74     $tpl->assign("sif_atk", MyEscape($sif_atk));
75     $tpl->assign("tekst", ParseNewline(MyEscape($tekst), false));
76 ravilov 1.2 $tpl->assign("pic", MyEscape($pic));
77     $tpl->assign("pic_alt", MyEscape($pic_alt));
78     }
79     $tpl->assign("letters", $letters);
80     $tpl->assign("ID", $id);
81     $dbh->disconnect();
82 ravilov 1.1 ?>

  ViewVC Help
Powered by ViewVC 1.1.26