/[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

Annotation of /print/izvjestaj.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Thu Apr 27 12:21:29 2000 UTC (24 years ago) by dpavlin
Branch: MAIN
Changes since 1.2: +28 -7 lines
File MIME type: text/plain
bolji, detaljniji html izvje¹taji (samo onih korisnika koji su tra¾ili
pode¹avanje!)

1 dpavlin 1.1 #!/usr/local/bin/perl -w
2    
3     use strict;
4    
5 dpavlin 1.3 my $debug=0;
6 dpavlin 1.2
7 dpavlin 1.1 use DBI;
8     use POSIX qw(strftime);
9    
10 dpavlin 1.2 print STDERR "Debug mod: output je u /tmp/debug*\n" if ($debug);
11    
12 dpavlin 1.1 my $currdate = strftime "%d.%m.%Y %H:%M:%S", localtime;
13    
14     my $html_file=$currdate;
15     $html_file=~s/ /_/g;
16     $html_file="izvjestaji/$html_file.html";
17    
18 dpavlin 1.2 if (! $debug) {
19 dpavlin 1.1 open(HTML,"> $html_file") || die "html: $!";
20     open(MAIL,"|/usr/lib/sendmail biljana.gombar\@pliva.hr,izvjestaji\@support.pliva.hr") || die "sendmail: $!";
21 dpavlin 1.2 } else {
22 dpavlin 1.3 open(HTML,"> /tmp/debug.html") || die "html: $!";
23     open(MAIL,"> /tmp/debug.mail") || die "sendmail: $!";
24 dpavlin 1.2 }
25 dpavlin 1.1
26     print HTML '
27     <html>
28     <title>Danas otvoreni raèuni</title>
29     <body bgcolor="#ffffff">
30     <h1>Danas otvoreni raèuni</h1>
31     ';
32    
33     print MAIL 'From: PlivaNet Core Support Team <pcst@pliva.hr>
34     Subject: otvoreni raèuni za e-mail
35    
36     ';
37    
38     my $dbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr;
39     $dbh->do("set datestyle = 'german'") || die $dbh->errstr();
40    
41     my $sth = $dbh->prepare("select id from last_print order by id desc limit 1,1");
42     $sth->execute() || die $sth->errstr();
43     my ($print_from_id) = $sth->fetchrow_array();
44    
45     $sth = $dbh->prepare("select osoba_id,max(status_tip_id) from status
46     where osoba_id > $print_from_id
47     group by osoba_id
48     ") || die $dbh->errstr();
49     $sth->execute() || die $sth->errstr();
50    
51     my @osoba_id_za_print;
52    
53     while (my ($osoba_id,$status_tip_id) = $sth->fetchrow_array() ) {
54     if ($status_tip_id == 5) { # print
55     push @osoba_id_za_print,$osoba_id;
56     }
57     }
58    
59     print MAIL "Otvorenih raèuna: ",$#osoba_id_za_print+1,"
60     Datum i vrijeme generiranja izvje¹taja: $currdate
61    
62 dpavlin 1.3 Izvje¹taj za ¹tampanje se nalazi na
63 dpavlin 1.1 http://support.pliva.hr/$html_file
64 dpavlin 1.3 sa potpunim podacima o umre¾avanju, lokaciji raèunala i osobe
65 dpavlin 1.1
66     ";
67     print HTML "Otvorenih raèuna: ",$#osoba_id_za_print+1,"
68     <br>Datum i vrijeme generiranja izvje¹taja: $currdate<p>";
69    
70     $sth = $dbh->prepare("
71     select osobe.id,ime,prezime,tel,lokacije.naziv,
72     org_jed.naziv,org_pod_jed.pod_naziv,
73 dpavlin 1.3 lok_racunala,objekt,kat,soba,z_rac,umrezavanje
74 dpavlin 1.1 from osobe
75     where osobe.id in (".join(",",@osoba_id_za_print).")
76     and lokacija_id=lokacije.id and org_jed_id=org_jed.id
77     and org_pod_jed_id=org_pod_jed.pod_id
78 dpavlin 1.3 and podesavanje=true
79 dpavlin 1.1 order by lokacije.naziv,org_jed.naziv
80     ") || die $dbh->errstr();
81     $sth->execute() || die $sth->errstr();
82    
83     my $rbr=1;
84 dpavlin 1.3 my $lokacija='';
85 dpavlin 1.1
86     printf MAIL ("%3s %4s %-20s %4s %-30s %-20s\n","rbr","id","ime i prezime","tel","lokacija","org.jed");
87     print HTML '<table border=1>
88     <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>
89 dpavlin 1.3 <tr bgcolor="#e0e0f0"><th></th><th></th><th>lokacija raèunala, mre¾a</th><th>¾</th><th colspan=2>objekat / kat / soba</th></tr>
90 dpavlin 1.1 ';
91    
92 dpavlin 1.3 my $bgcol='';
93     my $mreza='';
94    
95 dpavlin 1.1 while (my @arr = $sth->fetchrow_array() ) {
96     printf MAIL ("%3s %4s %-20s %4s %-30s %-20s\n",$rbr,$arr[0],"$arr[1] $arr[2]",$arr[3],$arr[4],"$arr[5] $arr[6]");
97 dpavlin 1.3 if ($lokacija ne $arr[4]) {
98     $lokacija=$arr[4];
99     print HTML "<tr bgcolor=#000000><td colspan=6><font size=+1 color=#ffffff>$lokacija</font></td></tr>";
100     }
101     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";
102     if ($arr[12] == 0) {
103     $mreza='umre¾eno';
104     } else {
105     $mreza='<b>potrebno umre¾avanje</b>';
106     }
107     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";
108 dpavlin 1.1 $rbr++;
109 dpavlin 1.3 if ($rbr % 2 == 0) {
110     $bgcol=' bgcolor=#eeeeee';
111     } else {
112     $bgcol='';
113     }
114 dpavlin 1.1 }
115    
116     $sth->finish;
117    
118     print HTML '
119     </table>
120     </body>
121     ';
122    
123     close(HTML);
124     close(MAIL);
125 dpavlin 1.2

  ViewVC Help
Powered by ViewVC 1.1.26