/[informatika.old]/html/lista.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 /html/lista.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations)
Tue May 9 11:10:01 2000 UTC (24 years ago) by dpavlin
Branch: MAIN
Changes since 1.4: +8 -2 lines
pretra¾ivanje po imenu ili prezimenu osobe

1 <?
2
3 include("inc/head.inc");
4
5 if (! isset($from)) {
6 $from=0;
7 }
8
9 if (! isset($kontakt_osoba_id) || ! intval($kontakt_osoba_id)!=0) {
10 echo '<form method="post" action="'.$PHP_SELF.'?'.$QUERY_STRING.'" name="forma">
11 Odaberite Va¹e ime i prezime:
12 <select name="kontakt_osoba_id">';
13
14 $result = pg_Exec ($conn, "select id,ime,prezime from kontakt_osobe
15 where aktivna=true order by ime");
16 for ($k = 0; $k < pg_numrows($result); $k++) {
17 $row=pg_fetch_array($result,$k);
18 echo "<option value=\"$row[id]\"";
19 if ($row[id]==$kontakt_osoba_id) { echo " selected"; }
20 echo ">$row[ime] $row[prezime]</option>\n";
21 }
22 echo '</select>
23 <input type=submit value="Posebno oznaèi moje zahtjeve">
24 </form>';
25 } else {
26 $result = pg_Exec ($conn, "select ime,prezime,passwd from kontakt_osobe where aktivna=true and id=$kontakt_osoba_id");
27 $row=pg_fetch_array($result,0);
28 print "<small>Trenutno ste prijavljeni kao $row[ime] $row[prezime], ako je to krivo odaberite <a href=\"$PHP_SELF?what=relogin\">ovaj link</a>.</small>";
29 }
30
31 function option($value,$text,$current) {
32 echo "<option value=\"$value\"";
33 if (isset($current) && $current==$value || !isset($current) & $default) {
34 echo " selected";
35 }
36 echo ">$text</option>";
37 }
38
39 function checkbox($name,$current) {
40 echo "<input type=\"checkbox\" name=\"$name\"";
41 if (isset($current)) {
42 echo " checked";
43 }
44 echo ">";
45 }
46
47 if (! isset($sql_upit)) { $sql_upit="novi_na_vrh"; }
48
49 echo ' <form method="post" action="'.$PHP_SELF.'?'.$QUERY_STRING.'" name="forma2">
50 Upi¹ite ime ili prezime po kojem ¾elite pretra¾ivati:
51 <input type=text name=imepr size=40 value="'.$imepr.'">
52 <br><input type=submit value="Prika¾i">
53 slogove
54 <select name="sql_upit">
55 ';
56
57 option("","bez specijalnog odabira",$sql_upit);
58 option("samo_moji","samo za moje upite *",$sql_upit);
59 option("novi_na_vrh","noviji na poèetak popisa",$sql_upit);
60 option("order_ime","sortirano po imenu",$sql_upit);
61 option("order_prezime","sortirano po prezimenu",$sql_upit);
62
63 echo ' </select>
64 <small><i>za opcije oznaèenje zvjezdicom (*) prvo morate
65 odabrati Va¹e ime i prezime!</i></small>
66 <input type=hidden name=from value=0>';
67
68 if (isset($kontakt_osoba_id)) {
69 echo '<input type=hidden name=kontakt_osoba_id value='.$kontakt_osoba_id.'>';
70 }
71 echo '<br><small>Prika¾i status zahtjeva za:
72 ',checkbox("shell",$shell),' shell
73 ',checkbox("podesavanje",$podesavanje),' pode¹avanje
74 ',checkbox("umrezavanje",$umrezavanje),' umre¾avanje
75 </small>
76 </form>
77 ';
78
79 $on_page=50;
80
81 $conn = pg_connect("dbname=informatika user=dpavlin");
82
83 $sql_polja="osobe.id as id,osobe.ime as ime,
84 osobe.prezime as prezime,
85 org_jed.naziv||'<br><small>'||org_pod_jed.pod_naziv||'<small>' as orgjed,
86 kontakt_osobe.ime||' '||kontakt_osobe.prezime as kontakt_osoba,
87 e_mail,kontakt_osoba_id
88 ";
89 $sql_tablice="osobe,org_jed,kontakt_osobe";
90 $sql_where="org_jed.id=org_jed_id
91 and org_pod_jed.pod_id=org_pod_jed_id
92 and kontakt_osoba_id=kontakt_osobe.id
93 ";
94 $sql_order="order by id";
95
96 if (isset($sql_upit)) {
97 switch($sql_upit) {
98 case "samo_moji":
99 if (isset($kontakt_osoba_id)) {
100 $sql_where.=" and kontakt_osobe.id=$kontakt_osoba_id";
101 }
102 break;
103 case "order_ime":
104 $sql_order="order by ime";
105 break;
106 case "order_prezime":
107 $sql_order="order by prezime";
108 break;
109 case "novi_na_vrh":
110 $sql_order="order by id desc";
111 break;
112 }
113 }
114
115 if (isset($shell)) {
116 $sql_polja.=",shell";
117 }
118 if (isset($podesavanje)) {
119 $sql_polja.=",podesavanje";
120 }
121 if (isset($umrezavanje)) {
122 $sql_polja.=",umrezavanje";
123 }
124
125 if (isset($imepr) && $imepr != "") {
126 $sql_where.=" and ( upper(toczs(osobe.ime)) like upper(toczs('$imepr')) or upper(toczs(osobe.prezime)) like upper(toczs('$imepr')) )";
127 }
128
129 $sql="select $sql_polja from $sql_tablice where $sql_where $sql_order limit $on_page,$from";
130
131 # echo "<pre>$sql</pre>";
132 # echo "<pre>$sql_where</pre>";
133 $result = pg_Exec ($conn, "$sql");
134
135 echo "<table border=1>
136 <tr>
137 <th>br</th>
138 <th>ime i prezime</th>
139 <th>organizacijska jedinica</th>
140 <th>status zahtjeva</th>
141 <th>kontakt osoba</th>
142 </tr>
143 ";
144
145 function print_bool($val) {
146 if ($val == 't') {
147 print "da";
148 } elseif ($val == 'f') {
149 print "ne";
150 } else {
151 print "nepoznato";
152 }
153 }
154
155 for ($k = 0; $k < pg_numrows($result); $k++) {
156 $row=pg_fetch_array($result,$k);
157 if ($k % 2 != 0) {
158 print "<tr>";
159 } else {
160 print '<tr bgcolor="#f0f0f0">';
161 }
162 print "<td>";
163 if ($row[kontakt_osoba_id]==$kontakt_osoba_id) {
164 print "<a href=\"osoba.php?what=select-osoba&id=$row[id]\">$row[id]</a>";
165 } else {
166 print "$row[id]";
167 }
168 print "</td><td>$row[ime] $row[prezime]</td>
169 <td>$row[orgjed]</td><td>";
170
171 $result1 = pg_Exec ($conn, "select datum,opis from status,status_tip where status.status_tip_id=status_tip.id and osoba_id=$row[id]");
172 for ($l = 0; $l < pg_numrows($result1); $l++) {
173 $row1=pg_fetch_array($result1,$l);
174 print "<small>$row1[datum]</small> $row1[opis]<br>";
175 }
176 print "</td><td><a href=\"mailto:$row[e_mail]\">$row[kontakt_osoba]</a><small>";
177
178
179 if (isset($shell)) {
180 print "<br>shell: ";
181 print_bool($row[shell]);
182 }
183 if (isset($podesavanje)) {
184 print "<br>pode¹avanje: ";
185 print_bool($row[podesavanje]);
186 }
187 if (isset($umrezavanje)) {
188 print "<br>umre¾avanje: ";
189 print_bool($row[umrezavanje]);
190 }
191 print "</small></td></tr>";
192 }
193
194
195 echo "</table>";
196
197 echo "<p><small>Druge stranice: <tt>";
198
199 if ($from >= $on_page) {
200 echo "<a href=$PHP_SELF?from=".($from-$on_page)."&sql_upit=$sql_upit>-</a>&nbsp;";
201 } else {
202 echo "&nbsp;&nbsp;";
203 }
204
205 if (pg_numrows($result) >= $on_page) {
206 echo "<a href=$PHP_SELF?from=".($from+$on_page)."&sql_upit=$sql_upit>+</a>&nbsp;";
207 } else {
208 echo "&nbsp;&nbsp;";
209 }
210
211 echo '</tt></small>
212
213 <p>Povratak na <a href="index.php">poèetnu stranicu</a>...
214
215 ';
216
217 include("inc/footer.inc");
218 ?>

  ViewVC Help
Powered by ViewVC 1.1.26