1 |
<?php |
2 |
|
3 |
include_once("find_html_file.inc"); |
4 |
|
5 |
$title.=" : VADEMECUM"; |
6 |
|
7 |
$all_local = "vse"; |
8 |
|
9 |
function fix_title($t) { |
10 |
$t=trim($t); |
11 |
if ($sp=strpos($t," ")) { |
12 |
$out=strtoupper(substr($t,0,$sp)).substr($t,$sp,strlen($t)-$sp); |
13 |
} else { |
14 |
$out=strtoupper($t); |
15 |
} |
16 |
return $out; |
17 |
} |
18 |
|
19 |
if (isset($smpc) && $smpc >= 1000 && $smpc <= 9999 && find_html_file("vade",$smpc)) { |
20 |
include_once("read_file.inc"); |
21 |
$main = read_file(find_html_file("vade",$smpc)); |
22 |
|
23 |
$sth = $dbh->prepare("select smpc,type,title from vademecum where smpc=$smpc"); |
24 |
$sth->execute(); |
25 |
if ($row=$sth->fetchrow_hash()) { |
26 |
switch ($row[type]) { |
27 |
case 'H' : |
28 |
$title.=" : ZDRAVILA "; |
29 |
break; |
30 |
case 'V' : |
31 |
$title .= " : VETERINA "; |
32 |
break; |
33 |
} |
34 |
|
35 |
$row[title]=fix_title($row[title]); |
36 |
|
37 |
$title.=" : $row[title]"; |
38 |
$smarty->assign("mtext",$row[title]); |
39 |
$smarty->assign("back_url",$PHP_SELF."?p=vade"); |
40 |
} |
41 |
} else { |
42 |
|
43 |
$sql_where=array(); |
44 |
|
45 |
if (isset($search) && $search!="" && $search!="all" && $search!=$all_local) { |
46 |
$sql_where[]="upper(title) like upper('%$search%')"; |
47 |
} |
48 |
|
49 |
if (isset($type) && $type != "") { |
50 |
$sql_where[]="upper(type)=upper('$type')"; |
51 |
} |
52 |
|
53 |
if (isset($search)) { |
54 |
|
55 |
$sql = "select distinct smpc,type,title from vademecum "; |
56 |
if ($sql_where) { |
57 |
$sql.=" where ".join(" and ",$sql_where); |
58 |
} |
59 |
$sql.=" order by title asc"; |
60 |
# print "<pre>$sql</pre>"; |
61 |
$sth = $dbh->prepare($sql); |
62 |
$sth->execute(); |
63 |
while ($row=$sth->fetchrow_hash()) { |
64 |
$row[title]=fix_title($row[title]); |
65 |
$data[]=$row; |
66 |
} |
67 |
|
68 |
if (!$data) { |
69 |
$smarty->assign("data","notfound"); |
70 |
} |
71 |
|
72 |
$smarty->assign("data",$data); |
73 |
$smarty->assign("search",$search); |
74 |
|
75 |
} else { |
76 |
$smarty->assign("search",$all_local); |
77 |
} |
78 |
|
79 |
$types = array ('', 'H', 'V'); |
80 |
$types_desc = array ('kjerkoli', 'zdravila', 'veterina'); |
81 |
|
82 |
$smarty->assign( array( |
83 |
type=>$type, |
84 |
types=>$types, |
85 |
types_desc=>$types_desc, |
86 |
title=>$title |
87 |
)); |
88 |
$main=$smarty->fetch("vade.tpl"); |
89 |
|
90 |
} |
91 |
|
92 |
?> |