/[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.2 - (show annotations)
Tue Sep 25 15:38:04 2001 UTC (17 years, 10 months ago) by ravilov
Branch: MAIN
Changes since 1.1: +89 -1 lines
Major changes. Too numeruous to mention all here.

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" => "atk", "caption" => "ATK"),
10 "sif_atk" => array("dbname" => "sif_atk", "caption" => "©ifra ATK"),
11 "tekst" => array("dbname" => "tekst", "caption" => "Opis")
12 );
13 if (!$id) {
14 list($srch, $qry_1, $qry_2) = Search($fields, array("naziv", "zupanija", "opcina", "posta", "mjesto", "adresa", "telefon"), array(), "naziv");
15 # Win1250 -> ISO8859-2
16 if ($qry_1) $qry_1 = strtr($qry_1, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
17 if ($qry_2) $qry_2 = strtr($qry_2, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
18 $tpl->assign("index", $index);
19 $tpl->assign("srch", ($qry_1 || $qry_2) ? true : false);
20 $tpl->assign("SEARCH", $srch);
21 }
22 $letters = Slova();
23 if (!$id && ($index || ($qry_1 || $qry_2))) {
24 $prvo_slovo = "UPPER(SUBSTRING(naziv FROM 1 FOR 1))";
25 $sql = "SELECT vad_id, $prvo_slovo AS prvo_slovo, naziv FROM vademecum";
26 $uvjet = array();
27 if ($index && $index != 1) {
28 if ($index == '@') for ($i = 0; $i < count($letters); $i++) array_push($uvjet, "($prvo_slovo <> '".$letters[$i]."')");
29 else array_push($uvjet, "($prvo_slovo = '".MyUpper($index)."')");
30 }
31 if ($qry_1) array_push($uvjet, "($qry_1)");
32 $uvjet = implode(" AND ", $uvjet);
33 if ($uvjet) $sql .= " WHERE $uvjet";
34 $sql .= " ORDER BY prvo_slovo, naziv";
35 $sth = $dbh->prepare($sql);
36 if (!$sth) error("Cannot prepare query: \"$sql\"");
37 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
38 $slova = array();
39 $lijekovi = array();
40 unset($staro_slovo);
41 while ($row = $sth->fetchrow_array()) {
42 list($id2, $fl, $naziv, $mjesto) = $row;
43 if (!isset($staro_slovo)) $staro_slovo = $fl;
44 if (!($qry_1 || $qry_2) && $staro_slovo != $fl) {
45 usort($lijekovi, "MyCmp1");
46 array_push($slova, array("l" => $staro_slovo, "lijekovi" => $lijekovi));
47 $staro_slovo = $fl;
48 $lijekovi = array();
49 }
50 array_push($lijekovi, array("id" => $id2, "naziv" => MyEscape($naziv), "mjesto" => MyEscape($mjesto)));
51 }
52 $sth->finish();
53 if (isset($staro_slovo)) {
54 usort($lijekovi, "MyCmp1");
55 array_push($slova, array("l" => $staro_slovo, "lijekovi" => $lijekovi));
56 }
57 usort($slova, "MyCmp2");
58 $records = 0;
59 for ($i = 0; $i < count($slova); $i++) $records += count($slova[$i]["lijekovi"]);
60 $tpl->assign("records", $records);
61 $tpl->assign("slova", $slova);
62 $tpl->assign("stype", $stype);
63 }
64 if ($id) {
65 $sql = "SELECT naziv, generik, sif_atk, sif_atk_generik, tekst, slika, slika_alt FROM vademecum WHERE (vad_id = $id)";
66 $sth = $dbh->prepare($sql);
67 if (!$sth) error("Cannot prepare query: \"$sql\"");
68 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
69 $row = $sth->fetchrow_array();
70 $sth->finish();
71 list($naziv, $gen, $sast, $ob, $skup, $izd, $ind, $konind, $int, $upoz, $doz, $nus, $rok, $pic, $pic_alt) = $row;
72 $tpl->assign("naziv", MyEscape($naziv));
73 $tpl->assign("generik", MyEscape($gen));
74 $tpl->assign("sastav", MyEscape($sast));
75 $tpl->assign("pakiranje", MyEscape($ob));
76 $tpl->assign("skupina", MyEscape($skup));
77 $tpl->assign("izdavanje", MyEscape($izd));
78 $tpl->assign("indikacije", MyEscape($ind));
79 $tpl->assign("kontraindikacije", MyEscape($konind));
80 $tpl->assign("interakcije", MyEscape($int));
81 $tpl->assign("upozorenja", MyEscape($upoz));
82 $tpl->assign("doziranje", MyEscape($doz));
83 $tpl->assign("nuspojave", MyEscape($nus));
84 $tpl->assign("rok", MyEscape($rok));
85 $tpl->assign("pic", MyEscape($pic));
86 $tpl->assign("pic_alt", MyEscape($pic_alt));
87 }
88 $tpl->assign("letters", $letters);
89 $tpl->assign("ID", $id);
90 $dbh->disconnect();
91 ?>

  ViewVC Help
Powered by ViewVC 1.1.26