--- sections/vade.inc 2001/11/19 09:11:36 1.1 +++ sections/vade.inc 2001/11/21 09:16:47 1.6 @@ -4,28 +4,45 @@ $title.=" : VADEMECUM"; +$all_local = "vse"; + +function fix_title($t) { + $t=trim($t); + if ($sp=strpos($t," ")) { + $out=strtoupper(substr($t,0,$sp)).substr($t,$sp,strlen($t)-$sp); + } else { + $out=strtoupper($t); + } + return $out; +} + if (isset($smpc) && $smpc >= 1000 && $smpc <= 9999 && find_html_file("vade",$smpc)) { - $main=join('',file(find_html_file("vade",$smpc))); + include_once("read_file.inc"); + $main = read_file(find_html_file("vade",$smpc)); $sth = $dbh->prepare("select smpc,type,title from vademecum where smpc=$smpc"); $sth->execute(); if ($row=$sth->fetchrow_hash()) { switch ($row[type]) { case 'H' : - $title.=" : HUMAN "; + $title.=" : ZDRAVILA "; break; case 'V' : $title .= " : VETERINA "; break; } + + $row[title]=fix_title($row[title]); $title.=" : $row[title]"; $smarty->assign("mtext",$row[title]); + $smarty->assign("back_url",$PHP_SELF."?p=vade"); } } else { + $sql_where=array(); - if (isset($search) && $search!="" && $search!="all") { + if (isset($search) && $search!="" && $search!="all" && $search!=$all_local) { $sql_where[]="upper(title) like upper('%$search%')"; } @@ -40,10 +57,11 @@ $sql.=" where ".join(" and ",$sql_where); } $sql.=" order by title asc"; - print "
$sql
"; +# print "
$sql
"; $sth = $dbh->prepare($sql); $sth->execute(); while ($row=$sth->fetchrow_hash()) { + $row[title]=fix_title($row[title]); $data[]=$row; } @@ -55,12 +73,16 @@ $smarty->assign("search",$search); } else { - $smarty->assign("search","all"); + $smarty->assign("search",$all_local); } + $types = array ('', 'H', 'V'); + $types_desc = array ('kjerkoli', 'zdravila', 'veterina'); + $smarty->assign( array( - type=>"$type", - self=>$PHP_SELF, + type=>$type, + types=>$types, + types_desc=>$types_desc, title=>$title )); $main=$smarty->fetch("vade.tpl");