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