/[corp_html]/animal_health.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 /animal_health.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Wed Mar 14 14:34:59 2001 UTC (23 years ago) by dpavlin
Branch: MAIN
Changes since 1.3: +1 -1 lines
show animals just once

1 <?php
2 require("Smarty.class.php");
3 require("conn.inc");
4
5 $smarty = new Smarty;
6
7 $smarty->assign( array ( Title=>"Pliva d.d." ) );
8
9 $section="products";
10
11 $title="Products : Animal Health";
12 $lpic="products"; $lext=".jpg";
13 $mpic="products.gif";
14 $back_url="products.php";
15
16 $sql_where=array();
17
18 $smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, Section_title=>$title ) );
19
20 $sth = $dbh->prepare("select animal,name from vet_animal");
21 $sth->execute();
22 while ($row=$sth->fetchrow_array()) {
23 $animals[]=$row[0];
24 $animals_desc[]=$row[1];
25 if (isset($GLOBALS[$row[0]])) {
26 $animal_arr[]="'$row[0]'";
27 }
28 }
29
30 if ($animal_arr) {
31 $sth = $dbh->prepare("select smpc from vet_animal_product where animal in (".implode(",",$animal_arr).")");
32 $sth->execute();
33 while ($row=$sth->fetchrow_array()) {
34 $smpc_arr[]=$row[0];
35 }
36 $sql_where[]="smpc in (".implode(",",$smpc_arr).")";
37 }
38
39 $sth = $dbh->prepare("select type,description from vet_type");
40 $sth->execute();
41 $types[]="any";
42 $types_desc[]="all types";
43 while ($row=$sth->fetchrow_array()) {
44 $types[]=$row[0];
45 $types_desc[]=$row[1];
46 }
47
48 $smarty->assign( array(
49 animals=>$animals,
50 animals_desc=>$animals_desc,
51 types=>$types,
52 types_desc=>$types_desc,
53 ));
54
55
56 if (isset($type) && $type!="any") {
57 $sql_where[]="type='$type'";
58 }
59
60 if (isset($search) && $search!="" && $search!="all") {
61 $sql_where[]=" (upper(brand) like upper('%$search%') or
62 upper(form) like upper('%$search%') or
63 upper(generic) like upper('%$search%') or
64 upper(description) like upper('%$search%') )
65 ";
66 }
67
68 if ($sql_where) {
69 $sql_where=" where ".implode(" and ",$sql_where);
70 }
71
72 if (isset($search)) {
73
74 $sth = $dbh->prepare("select distinct brand,form,composition,description,type,smpc from vet_products $sql_where order by brand asc");
75 $sth->execute();
76 while ($row=$sth->fetchrow_hash()) {
77 if ($show_animals) {
78 $sth2 = $dbh->prepare("select distinct vet_animal_product.animal,name from vet_animal_product,vet_animal where vet_animal_product.animal=vet_animal.animal and smpc=$row[smpc]");
79 $sth2->execute();
80 unset($animals);
81 while ($row2=$sth2->fetchrow_hash()) {
82 $animals[]=$row2[name];
83 }
84 $row[animals]=implode(", ",$animals);
85 }
86 $data[]=$row;
87 }
88
89 if (!$data) {
90 $smarty->assign("data","notfound");
91 }
92
93 $smarty->assign("data",$data);
94 $smarty->assign("search",$search);
95
96 } else {
97 $smarty->assign("search","all");
98 }
99
100 $smarty->assign( array(type=>"$type",
101 show_description=>$show_description,
102 show_animals=>$show_animals
103 ));
104 $main=$smarty->fetch("animal_health.tpl");
105
106 include("common.inc");
107 $smarty->assign( array(back_url=>$back_url, MAIN=>$main));
108
109 $smarty->display("index.tpl");
110 ?>

  ViewVC Help
Powered by ViewVC 1.1.26