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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (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.5: +4 -4 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 u_plivi WHERE (id=$del) AND (sif_radnika='$sifra')");
27 if (!$DBH->errstr && $edit == $del) unset($edit);
28 }
29 $warning = 0;
30 if ($update || $p != $page) {
31 if ($radno_mjesto || $zadaci || $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 $radno_mjesto = ISO_Win($radno_mjesto);
48 $zadaci = ISO_Win($zadaci);
49 if ($edit) DBQuery("UPDATE u_plivi SET radno_mjesto='$radno_mjesto',zadaci='$zadaci',datum_od='$datum_od',datum_do=".($datum_do?"'$datum_do'":"NULL")." WHERE (sif_radnika='$sifra') AND (id=$edit)");
50 else DBQuery("INSERT INTO u_plivi (sif_radnika,radno_mjesto,zadaci,datum_od,datum_do) VALUES ('$sifra','$radno_mjesto','$zadaci','$datum_od',".($datum_do?"'$datum_do'":"NULL").")");
51 }
52 } else if ($edit)
53 DBQuery("DELETE FROM u_plivi WHERE (sif_radnika='$sifra') AND (id=$edit)");
54 if ($p != $page && !$warning && !$DBH->errstr) {
55 DBClose();
56 Header("Location: $pages[$p]".Params($p));
57 exit;
58 }
59 }
60 if (($new || $update) && !$warning && !$DBH->errstr) {
61 unset($edit, $radno_mjesto, $zadaci);
62 unset($dat_od, $dat_od_d, $dat_od_m, $dat_od_g);
63 unset($dat_do, $dat_do_d, $dat_do_m, $dat_do_g);
64 }
65 $rows = DBQuery("SELECT id,radno_mjesto,zadaci,datum_od,datum_do FROM u_plivi WHERE (sif_radnika='$sifra') ORDER BY datum_od");
66 DBClose();
67 $vars = array();
68 $fnd = false;
69 for ($i = 0; $i < count($rows); $i++) {
70 list($id, $rm, $zad, $od, $do) = $rows[$i];
71 $od = ParseDate($od);
72 $do = ParseDate($do);
73 $rm = HTML_Escape(Win_ISO($rm));
74 $zad = HTML_Escape(Win_ISO($zad));
75 $rm2 = nl2br($rm);
76 $zad2 = nl2br($zad);
77 nepoznato($rm2);
78 nepoznato($zad2);
79 array_push($vars, array(
80 "id" => $id,
81 "link" => $PHP_SELF.Params($page, array("edit" => $id)),
82 "radno_mjesto" => $rm2,
83 "zadaci" => $zad2,
84 "od_d" => $od["mday"], "od_m" => $od["mon"], "od_g" => $od["year"],
85 "do_d" => $do["mday"], "do_m" => $do["mon"], "do_g" => $do["year"]
86 ));
87 if ($edit && $edit == $id) {
88 if (!$warning) {
89 $radno_mjesto = $rm;
90 $zadaci = $zad;
91 list($dat_od_d, $dat_od_m, $dat_od_g) =
92 array($od["mday"], $od["mon"], $od["year"]);
93 list($dat_do_d, $dat_do_m, $dat_do_g) =
94 array($do["mday"], $do["mon"], $do["year"]);
95 }
96 $fnd = true;
97 }
98 }
99 if (!$fnd) unset($edit);
100 $tpl = new MySmarty($page, $edit ? array("edit" => $edit) : array());
101 $tpl->assign("vars", $vars);
102 $tpl->assign("edit", $edit);
103 $tpl->assign("radno_mjesto", $radno_mjesto);
104 $tpl->assign("zadaci", $zadaci);
105 if ($dat_od_d && $dat_od_m && $dat_od_g) {
106 $tpl->assign("dat_od_d", $dat_od_d);
107 $tpl->assign("dat_od_m", $dat_od_m);
108 $tpl->assign("dat_od_g", $dat_od_g);
109 } else $tpl->assign("dat_od", $dat_od);
110 if ($dat_do_d && $dat_do_m && $dat_do_g) {
111 $tpl->assign("dat_do_d", $dat_do_d);
112 $tpl->assign("dat_do_m", $dat_do_m);
113 $tpl->assign("dat_do_g", $dat_do_g);
114 } else $tpl->assign("dat_do", $dat_do);
115 $tpl->assign("warning", $warning);
116 $tpl->show();
117 ?>

  ViewVC Help
Powered by ViewVC 1.1.26