/[informatika.old]/print/izvjestaj.pl
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 /print/izvjestaj.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations)
Wed May 10 11:54:54 2000 UTC (23 years, 10 months ago) by dpavlin
Branch: MAIN
Changes since 1.5: +34 -3 lines
File MIME type: text/plain
dodano mailanje kontakt osobama sa obavjesti o otvaranju

1 #!/usr/local/bin/perl -w
2
3 use strict;
4
5 my $debug=0;
6
7 use DBI;
8 use POSIX qw(strftime);
9
10 $debug++ if ($ARGV[0] eq "-d");
11
12 print STDERR "Debug mod: output je u /tmp/debug*\n" if ($debug);
13
14 my $currdate = strftime "%d.%m.%Y %H:%M:%S", localtime;
15
16 my $html_file=$currdate;
17 $html_file=~s/ /_/g;
18 $html_file="izvjestaji/$html_file.html";
19
20 if (! $debug) {
21 open(HTML,"> $html_file") || die "html: $!";
22 open(MAIL,"|/usr/lib/sendmail biljana.gombar\@pliva.hr,izvjestaji\@support.pliva.hr") || die "sendmail: $!";
23 } else {
24 open(HTML,"> /tmp/debug.html") || die "html: $!";
25 open(MAIL,"> /tmp/debug.mail") || die "sendmail: $!";
26 }
27
28 print HTML '
29 <html>
30 <title>Danas otvoreni raèuni</title>
31 <body bgcolor="#ffffff">
32 <h1>Danas otvoreni raèuni</h1>
33 ';
34
35 print MAIL 'From: PlivaNet Core Support Team <pcst@pliva.hr>
36 Subject: otvoreni raèuni za e-mail
37
38 ';
39
40 my $host = "host=support.pliva.hr;";
41
42 open(WHO,"who -m |") || die "who am i? $!";
43 my $db_user=<WHO>;
44 $db_user=~s/[^!]+!//;
45 close(WHO);
46 if (! defined($db_user)) {
47 $db_user="user=dpavlin;"; $host=""; # works on localhost
48 } else {
49 $db_user=~s/\s.+$//g;
50 $db_user="user=$db_user;";
51 }
52
53
54 my $dbh = DBI->connect("DBI:Pg:dbname=informatika;${host}${db_user}","","") || die $DBI::errstr;
55 $dbh->do("set datestyle = 'german'") || die $dbh->errstr();
56
57 my $sth = $dbh->prepare("select id from last_print order by id desc limit 1,1");
58 $sth->execute() || die $sth->errstr();
59 my ($print_from_id) = $sth->fetchrow_array();
60
61 $sth = $dbh->prepare("select osoba_id,max(status_tip_id) from status
62 where osoba_id > $print_from_id
63 group by osoba_id
64 ") || die $dbh->errstr();
65 $sth->execute() || die $sth->errstr();
66
67 my @osoba_id_za_print;
68
69 while (my ($osoba_id,$status_tip_id) = $sth->fetchrow_array() ) {
70 if ($status_tip_id == 5 || $status_tip_id == 8 ) { # print/umre¾avanje
71 push @osoba_id_za_print,$osoba_id;
72 }
73 }
74
75 print MAIL "Otvorenih raèuna: ",$#osoba_id_za_print+1,"
76 Datum i vrijeme generiranja izvje¹taja: $currdate
77
78 Izvje¹taj za ¹tampanje se nalazi na
79 http://support.pliva.hr/$html_file
80 sa potpunim podacima o umre¾avanju, lokaciji raèunala i osobe
81
82 ";
83 print HTML "Otvorenih raèuna: ",$#osoba_id_za_print+1,"
84 <br>Datum i vrijeme generiranja izvje¹taja: $currdate<p>";
85
86 $sth = $dbh->prepare("
87 select osobe.id,ime,prezime,tel,lokacije.naziv,
88 org_jed.naziv,org_pod_jed.pod_naziv,
89 lok_racunala,objekt,kat,soba,z_rac,umrezavanje,
90 kontakt_osobe.e_mail,podesavanje
91 from osobe
92 where osobe.id in (".join(",",@osoba_id_za_print).")
93 and lokacija_id=lokacije.id and org_jed_id=org_jed.id
94 and org_pod_jed_id=org_pod_jed.pod_id
95 and podesavanje=true
96 and kontakt_osobe.id=kontakt_osoba_id
97 order by lokacije.naziv,org_jed.naziv
98 ") || die $dbh->errstr();
99 $sth->execute() || die $sth->errstr();
100
101 my $rbr=1;
102 my $lokacija='';
103
104 printf MAIL ("%3s %4s %-20s %4s %-30s %-20s\n","rbr","id","ime i prezime","tel","lokacija","org.jed");
105 print HTML '<table border=1>
106 <tr bgcolor="#e0e0f0"><th>rbr</th><th>id</th><th>ime i prezime</th><th>tel</th><th>lokacija</th><th>org.jed</th></tr>
107 <tr bgcolor="#e0e0f0"><th></th><th></th><th>lokacija raèunala, mre¾a</th><th>¾</th><th colspan=2>objekat / kat / soba</th></tr>
108 ';
109
110 my $bgcol='';
111 my $mreza='';
112 my @za_ic;
113 my %mail4ko;
114
115 while (my @arr = $sth->fetchrow_array() ) {
116 push @za_ic,$arr[0];
117 $mail4ko{$arr[13]}.="\t$arr[1] $arr[2]";
118 $mail4ko{$arr[13]}.=" (bez pode¹avanja)" if ($arr[14] == 0);
119
120 printf MAIL ("%3s %4s %-20s %4s %-30s %-20s\n",$rbr,$arr[0],"$arr[1] $arr[2]",$arr[3],$arr[4],"$arr[5] $arr[6]");
121 if ($lokacija ne $arr[4]) {
122 $lokacija=$arr[4];
123 print HTML "<tr bgcolor=#000000><td colspan=6><font size=+1 color=#ffffff>$lokacija</font></td></tr>";
124 }
125 print HTML "<tr$bgcol><td>$rbr</td><td>$arr[0]</td><td>$arr[1] $arr[2]</td><td>tel: $arr[3]</td><td><small>$arr[4]</small></td><td>$arr[5]<br>$arr[6]</td></tr>\n";
126 if ($arr[12] == 0) {
127 $mreza='umre¾eno';
128 } else {
129 my $rows = $dbh->do("select max(status_tip_id) from status
130 where osoba_id = $arr[0] and status_tip_id=8") || die $dbh->errstr();
131 if ($rows > 0) {
132 $mreza='<i>umre¾avanje obavljeno</i>';
133 } else {
134 $mreza='<b>potrebno umre¾avanje</b>';
135 }
136 }
137 print HTML "<tr$bgcol><td colspan=2>&nbsp;</td><td><small>$arr[7] $mreza</small></a><td><small>¾-$arr[11]</small></td><td colspan=2><small>$arr[8] / $arr[9] / $arr[10]</small></td></tr>\n";
138 $rbr++;
139 if ($rbr % 2 == 0) {
140 $bgcol=' bgcolor=#eeeeee';
141 } else {
142 $bgcol='';
143 }
144 }
145
146 $sth->finish;
147
148 print HTML '
149 </table>
150 </body>
151 ';
152
153 close(HTML);
154 close(MAIL);
155
156 $dbh->disconnect;
157
158 foreach my $email_ko (keys %mail4ko) {
159 if (! $debug) {
160 open(MAIL,"|/usr/lib/sendmail $email_ko") || die "sendmail: $!";
161 } else {
162 open(MAIL,">> /tmp/debug.komail") || die "sendmail: $!";
163 }
164
165 print MAIL 'From: PlivaNet Core Support Team <pcst@pliva.hr>
166 Subject: otvoreni raèuni za e-mail
167
168 Obavje¹tavamo Vas da su otvoreni korisnièki raèuni na intranet poslu¾itelju
169 za slijedeæe osobe:
170 ';
171 foreach my $ime_pr (split(/\t/,$mail4ko{$email_ko})) {
172 print MAIL "\t$ime_pr\n";
173 }
174 print MAIL '
175 Va¹i korisnici dobiti æe pristupno ime (login) i lozinku (password) internom
176 po¹tom, a djelatnici odjela Informatika IC æe izvr¹iti pode¹avanje korisnièkog
177 raèunala.';
178
179 close(MAIL);
180 }
181
182 print "Printanje zahtjeva za print za IC:\n./print.pl ",join(",",@za_ic),"\n";

  ViewVC Help
Powered by ViewVC 1.1.26