/[hr-web]/Patenti.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 /Patenti.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Tue Jul 23 13:08:57 2002 UTC (16 years, 11 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +7 -7 lines
mali ispravci

1 <?php
2 include("inc/global.php");
3 if (!Auth()) exit;
4 $page = CalcPage($PHP_SELF);
5 $p = $page;
6 if (isparam("wb_p")) $p--;
7 if (isparam("wb_OK")) $p++;
8 if (isparam("wb_h")) $p = $PG_HOME;
9 if (isparam("wb_o")) $p = $PG_OVERVIEW;
10 include("inc/conn.php");
11 DBOpen();
12 $del = 0;
13 reset($HTTP_GET_VARS);
14 while ($var = key($HTTP_GET_VARS)) {
15 next($HTTP_GET_VARS);
16 if (!eregi('^del_([0-9]+)$', $var, $match)) continue;
17 $del = $match[1];
18 }
19 reset($HTTP_POST_VARS);
20 while ($var = key($HTTP_POST_VARS)) {
21 next($HTTP_POST_VARS);
22 if (!eregi('^del_([0-9]+)$', $var, $match)) continue;
23 $del = $match[1];
24 }
25 if ($del) {
26 DBQuery("DELETE FROM patenti WHERE (sifra=$del) AND (sif_radnika='$sifra')");
27 if (!$DBH->errstr && $edit != $del) unset($edit);
28 }
29 YearFix($godina);
30 $warning = 0;
31 if ($update || $p != $page) {
32 if ($autori || $naziv || $godina || $zastita || $na_snazi || $drzave || $komentar) {
33 if (!$warning && !$naziv) $warning = 1;
34 if (!$warning && !$godina) $warning = 2;
35 if (!$warning && !$zastita) $warning = 3;
36 if (!$warning && ($na_snazi && !$drzave)) $warning = 4;
37 if (!$warning) {
38 $autori = ISO_Win($autori);
39 $naziv = ISO_Win($naziv);
40 $godina = ISO_Win($godina);
41 $zastita = ISO_Win($zastita);
42 $drzave = ISO_Win($drzave);
43 $komentar = ISO_Win($komentar);
44 if ($edit) DBQuery("UPDATE patenti SET autori='$autori',naziv='$naziv',godina='$godina',zastita='$zastita',na_snazi=".($na_snazi?"true":"false").",drzave='$drzave',komentar='$komentar' WHERE (sif_radnika='$sifra') AND (sifra=$edit)");
45 else DBQuery("INSERT INTO patenti (sif_radnika,autori,naziv,godina,zastita,na_snazi,drzave,komentar) VALUES ('$sifra','$autori','$naziv','$godina','$zastita',".($na_snazi?"true":"false").",'$drzave','$komentar')");
46 }
47 } else if ($edit)
48 DBQuery("DELETE FROM patenti WHERE (sifra=$edit) AND (sif_radnika='$sifra')");
49 if ($p != $page && !$warning && !$DBH->errstr) {
50 DBClose();
51 Header("Location: $pages[$p]".Params($p));
52 exit;
53 }
54 }
55 if (($new || $update) && !$warning && !$DBH->errstr)
56 unset($edit, $autori, $naziv, $godina, $zastita, $na_snazi, $drzave, $komentar);
57 $rows = DBQuery("SELECT sifra,autori,naziv,godina,zastita,na_snazi,drzave,komentar FROM patenti WHERE (sif_radnika='$sifra') ORDER BY naziv");
58 $vars = array();
59 $fnd = false;
60 for ($i = 0; $i < count($rows); $i++) {
61 list($id, $aut, $naz, $god, $zast, $ns, $drz, $kom) = $rows[$i];
62 $aut = HTML_Escape(Win_ISO($aut));
63 $naz = HTML_Escape(Win_ISO($naz));
64 $god = HTML_Escape(Win_ISO($god));
65 $zast = HTML_Escape(Win_ISO($zast));
66 $drz = HTML_Escape(Win_ISO($drz));
67 $kom = HTML_Escape(Win_ISO($kom));
68 $kom2 = nl2br($kom);
69 $naz2 = $naz;
70 $god2 = $god;
71 $zast2 = $zast;
72 $drz2 = $drz;
73 if (!$god2) $god2 = "-";
74 nepoznato($naz2);
75 nepoznato($zast2);
76 nepoznato($drz2);
77 nepoznato($kom2);
78 array_push($vars, array(
79 "id" => $id,
80 "link" => $PHP_SELF.Params($page, array("edit" => $id)),
81 "autori" => $aut,
82 "naziv" => $naz2,
83 "godina" => $god2,
84 "zastita" => $zast2,
85 "na_snazi" => ($ns[0] != "f" && $ns[0] != "F"),
86 "drzave" => $drz2,
87 "komentar" => $kom2
88 ));
89 if ($edit && $edit == $id) {
90 if (!$warning) {
91 $autori = $aut;
92 $naziv = $naz;
93 $godina = $god;
94 $zastita = $zast;
95 $na_snazi = ($ns[0] != "f" && $ns[0] != "F");
96 $drzave = $drz;
97 $komentar = $kom;
98 }
99 $fnd = true;
100 }
101 }
102 if (!$fnd) unset($edit);
103 $row = DBQuery("SELECT ime,prezime FROM osoba WHERE (sif_radnika='$sifra')");
104 list($ime, $prezime) = $row[0];
105 $ime = HTML_Escape(Win_ISO($ime));
106 $prezime = HTML_Escape(Win_ISO($prezime));
107 DBClose();
108 $tpl = new MySmarty($page, $edit ? array("edit" => $edit) : array());
109 $tpl->assign("vars", $vars);
110 $tpl->assign("edit", $edit);
111 $tpl->assign("ime", $ime);
112 $tpl->assign("prezime", $prezime);
113 $tpl->assign("autori", $autori);
114 $tpl->assign("naziv", $naziv);
115 $tpl->assign("godina", $godina);
116 $tpl->assign("zastita", $zastita);
117 $tpl->assign("na_snazi", $na_snazi);
118 $tpl->assign("drzave", $drzave);
119 $tpl->assign("komentar", $komentar);
120 $tpl->assign("warning", $warning);
121 $tpl->show();
122 ?>

  ViewVC Help
Powered by ViewVC 1.1.26