/[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

Contents of /inc/pgKnjiznica-vademecum.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Fri Sep 28 23:34:37 2001 UTC (17 years, 10 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +2 -2 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 lijeka"),
8 "generik" => array("dbname" => "generik", "caption" => "Generièko ime"),
9 "atk" => array("dbname" => "atc.opis || ' ' || atc.atc_id", "caption" => "ATK"),
10 "tekst" => array("dbname" => "tekst", "caption" => "Opis")
11 );
12 if (!$id) {
13 list($srch, $qry_1, $qry_2) = Search($fields, array("naziv", "generik", "atk", "sif_atk", "tekst"), array(), "naziv");
14 # 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 $sql = "SELECT vad_id, $prvo_slovo AS prvo_slovo, naziv FROM vademecum, atc";
25 $uvjet = array("(atc.atc_id = vademecum.sif_atk)");
26 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 list($id2, $fl, $naziv) = $row;
42 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 (count($lijekovi) > 0) {
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 $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 $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 list($naziv, $gen, $tekst, $pic, $pic_alt, $atk, $sif_atk) = $row;
71 $tpl->assign("naziv", MyEscape($naziv));
72 $tpl->assign("generik", MyEscape($gen));
73 $tpl->assign("atk", MyEscape($atk));
74 $tpl->assign("sif_atk", MyEscape($sif_atk));
75 $tpl->assign("tekst", ParseNewline(MyEscape($tekst), false));
76 $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 ?>

  ViewVC Help
Powered by ViewVC 1.1.26