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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations)
Fri Jul 26 07:45:25 2002 UTC (16 years, 11 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +3 -1 lines
bugic ispravljen

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 edukacije WHERE (sifra=$del) AND (sif_radnika='$sifra') AND (sif_qualification=1)");
27 if (!$DBH->errstr && $edit == $del) unset($edit);
28 }
29 $warning = 0;
30 if ($update || $p != $page) {
31 if ($obr_ust || $smjer || $zvanje || $st_spreme || $vr_spreme || $dat_od || $dat_do) {
32 if (!$warning) {
33 if ($dat_od) {
34 $dt = DateCheck($dat_od);
35 if ($dt) $datum_od = ComposeDate($dt);
36 else $warning = 1;
37 } else $warning = 2;
38 }
39 if (!$warning) {
40 if ($dat_do) {
41 $dt = DateCheck($dat_do);
42 if ($dt) $datum_do = ComposeDate($dt);
43 else $warning = 3;
44 } #else $warning = 4;
45 }
46 if (!$warning) {
47 if (!$st_spreme) $warning = 5;
48 }
49 if (!$warning) {
50 if (!$vr_spreme) $warning = 6;
51 }
52 if (!$warning) {
53 $smjer = ISO_Win($smjer);
54 $zvanje = ISO_Win($zvanje);
55 $sif = DBQuery("SELECT sif_str_spreme FROM strucne_spreme WHERE (language='$language') AND (stupanj='$st_spreme') AND (sif_vrsta_str_spreme=$vr_spreme)");
56 $sif = $sif[0][0];
57 if (!$sif) $sif = 0;
58 if ($edit) {
59 DBQuery("UPDATE edukacije SET sif_ustanove=$obr_ust,naziv='$smjer',titula='$zvanje',sif_strucna_sprema=$sif,datum_upisa='$datum_od',datum_zavrsetka=".($datum_do?"'$datum_do'":"NULL")." WHERE (sif_radnika='$sifra') AND (sifra=$edit) AND (sif_qualification=1)");
60 } else {
61 $_id = DBQuery("SELECT max(sifra)+1 AS id FROM edukacije WHERE (sif_radnika='$sifra')");
62 $_id = $_id[0][0];
63 DBQuery("INSERT INTO edukacije (sifra,sif_radnika,sif_ustanove,naziv,titula,sif_strucna_sprema,datum_upisa,datum_zavrsetka,sif_qualification) VALUES ('$_id','$sifra',$obr_ust,'$smjer','$zvanje',$sif,'$datum_od',".($datum_do?"'$datum_do'":"NULL").",1)");
64 }
65 }
66 } else if ($edit)
67 DBQuery("DELETE FROM edukacije WHERE (sifra=$edit) AND (sif_radnika='$sifra') AND (sif_qualification=1)");
68 if ($p != $page && !$warning && !$DBH->errstr) {
69 DBClose();
70 Header("Location: $pages[$p]".Params($p));
71 exit;
72 }
73 }
74 if (($new || $update) && !$warning && !$DBH->errstr) {
75 unset($edit, $obr_ust, $smjer, $zvanje, $st_spreme, $vr_spreme);
76 unset($dat_od, $dat_od_d, $dat_od_m, $dat_od_g);
77 unset($dat_do, $dat_do_d, $dat_do_m, $dat_do_g);
78 }
79 include("inc/util.php");
80 $rows = DBQuery("SELECT sifra,naziv,grad FROM ustanove WHERE (language='$language') AND (naziv||grad <> '') AND (obrazovna)");
81 $ustanove = array();
82 for ($i = 0; $i < count($rows); $i++) {
83 list($sif, $naz, $grad) = $rows[$i];
84 if ($grad) $naz = "$naz, $grad";
85 array_push($ustanove, array("id" => $sif,
86 "name" => HTML_Escape(Win_ISO($naz))));
87 }
88 usort($ustanove, "sort_name");
89 $rows = DBQuery("SELECT DISTINCT stupanj FROM strucne_spreme WHERE (language='$language')");
90 $sss = array();
91 for ($i = 0; $i < count($rows); $i++) {
92 list($naz) = $rows[$i];
93 $naz = Win_ISO($naz);
94 array_push($sss, array("id" => $naz,
95 "name" => HTML_Escape(Win_ISO($naz))));
96 }
97 usort($sss, "sort_name");
98 $rows = DBQuery("SELECT sifra,opis FROM vrsta_strucne_spreme WHERE (language='$language') AND (opis<>'')");
99 $vss = array();
100 for ($i = 0; $i < count($rows); $i++) {
101 list($sif, $naz) = $rows[$i];
102 array_push($vss, array("id" => $sif,
103 "name" => HTML_Escape(Win_ISO($naz))));
104 }
105 usort($vss, "sort_name");
106 $rows = DBQuery("SELECT edukacije.sifra,sif_ustanove,naziv,titula,stupanj,sif_vrsta_str_spreme,datum_upisa,datum_zavrsetka FROM edukacije,strucne_spreme WHERE (sif_radnika='$sifra') AND (sif_qualification=1) AND (strucne_spreme.sif_str_spreme=edukacije.sif_strucna_sprema)");
107 $vars = array();
108 $fnd = false;
109 for ($i = 0; $i < count($rows); $i++) {
110 list($id, $ust, $sm, $zv, $st, $vr, $od, $do) = $rows[$i];
111 $od = ParseDate($od);
112 $do = ParseDate($do);
113 $ust2 = "";
114 for ($j = 0; $j < count($ustanove); $j++) {
115 if ($ustanove[$j]["id"] == $ust) {
116 $ust2 = $ustanove[$j]["name"];
117 break;
118 }
119 }
120 $sm = HTML_Escape(Win_ISO($sm));
121 $zv = HTML_Escape(Win_ISO($zv));
122 $st = HTML_Escape(Win_ISO($st));
123 $vr2 = "";
124 for ($j = 0; $j < count($vss); $j++) {
125 if ($vss[$j]["id"] == $vr) {
126 $vr2 = $vss[$j]["name"];
127 break;
128 }
129 }
130 $ust2 = nl2br($ust2);
131 $sm2 = nl2br($sm);
132 $zv2 = nl2br($zv);
133 $st2 = nl2br($st);
134 $vr2 = nl2br($vr2);
135 nepoznato($ust2);
136 nepoznato($sm2);
137 nepoznato($zv2);
138 nepoznato($st2);
139 nepoznato($vr2);
140 array_push($vars, array(
141 "id" => $id,
142 "link" => $PHP_SELF.Params($page, array("edit" => $id)),
143 "ustanova" => $ust2,
144 "smjer" => $sm2,
145 "zvanje" => $zv2,
146 "sss" => $st2,
147 "vss" => $vr2,
148 "od_d" => $od["mday"], "od_m" => $od["mon"], "od_g" => $od["year"],
149 "do_d" => $do["mday"], "do_m" => $do["mon"], "do_g" => $do["year"]
150 ));
151 if ($edit && $edit == $id) {
152 if (!$warning && !$DBH->errstr) {
153 $obr_ust = $ust;
154 $smjer = $sm;
155 $zvanje = $zv;
156 $st_spreme = $st;
157 $vr_spreme = $vr;
158 list($dat_od_d, $dat_od_m, $dat_od_g) =
159 array($od["mday"], $od["mon"], $od["year"]);
160 list($dat_do_d, $dat_do_m, $dat_do_g) =
161 array($do["mday"], $do["mon"], $do["year"]);
162 }
163 $fnd = true;
164 }
165 }
166 if (!$fnd) unset($edit);
167 DBClose();
168 $tpl = new MySmarty($page, $edit ? array("edit" => $edit) : array());
169 $tpl->assign("vars", $vars);
170 $tpl->assign("edit", $edit);
171 $tpl->assign("ou", $ustanove);
172 $tpl->assign("sss", $sss);
173 $tpl->assign("vss", $vss);
174 $tpl->assign("obr_ust", $obr_ust);
175 $tpl->assign("smjer", $smjer);
176 $tpl->assign("zvanje", $zvanje);
177 $tpl->assign("st_spreme", $st_spreme);
178 $tpl->assign("vr_spreme", $vr_spreme);
179 if ($dat_od_d && $dat_od_m && $dat_od_g) {
180 $tpl->assign("dat_od_d", $dat_od_d);
181 $tpl->assign("dat_od_m", $dat_od_m);
182 $tpl->assign("dat_od_g", $dat_od_g);
183 } else $tpl->assign("dat_od", $dat_od);
184 if ($dat_do_d && $dat_do_m && $dat_do_g) {
185 $tpl->assign("dat_do_d", $dat_do_d);
186 $tpl->assign("dat_do_m", $dat_do_m);
187 $tpl->assign("dat_do_g", $dat_do_g);
188 } else $tpl->assign("dat_do", $dat_do);
189 $tpl->assign("warning", $warning);
190 $tpl->show();
191 ?>

  ViewVC Help
Powered by ViewVC 1.1.26