2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
|
my $debug=0; |
6 |
|
|
7 |
use DBI; |
use DBI; |
8 |
use POSIX qw(strftime); |
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; |
my $currdate = strftime "%d.%m.%Y %H:%M:%S", localtime; |
15 |
|
|
16 |
my $html_file=$currdate; |
my $html_file=$currdate; |
17 |
$html_file=~s/ /_/g; |
$html_file=~s/ /_/g; |
18 |
$html_file="izvjestaji/$html_file.html"; |
$html_file="izvjestaji/$html_file.html"; |
19 |
|
|
20 |
|
if (! $debug) { |
21 |
open(HTML,"> $html_file") || die "html: $!"; |
open(HTML,"> $html_file") || die "html: $!"; |
22 |
open(MAIL,"|/usr/lib/sendmail biljana.gombar\@pliva.hr,izvjestaji\@support.pliva.hr") || die "sendmail: $!"; |
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 ' |
print HTML ' |
29 |
<html> |
<html> |
53 |
my @osoba_id_za_print; |
my @osoba_id_za_print; |
54 |
|
|
55 |
while (my ($osoba_id,$status_tip_id) = $sth->fetchrow_array() ) { |
while (my ($osoba_id,$status_tip_id) = $sth->fetchrow_array() ) { |
56 |
if ($status_tip_id == 5) { # print |
if ($status_tip_id == 5 || $status_tip_id == 8 ) { # print/umrežavanje |
57 |
push @osoba_id_za_print,$osoba_id; |
push @osoba_id_za_print,$osoba_id; |
58 |
} |
} |
59 |
} |
} |
61 |
print MAIL "Otvorenih računa: ",$#osoba_id_za_print+1," |
print MAIL "Otvorenih računa: ",$#osoba_id_za_print+1," |
62 |
Datum i vrijeme generiranja izvještaja: $currdate |
Datum i vrijeme generiranja izvještaja: $currdate |
63 |
|
|
64 |
Izvještaj se nalazi i na |
Izvještaj za štampanje se nalazi na |
65 |
http://support.pliva.hr/$html_file |
http://support.pliva.hr/$html_file |
66 |
(npr. za ispis na štampaču) |
sa potpunim podacima o umrežavanju, lokaciji računala i osobe |
67 |
|
|
68 |
"; |
"; |
69 |
print HTML "Otvorenih računa: ",$#osoba_id_za_print+1," |
print HTML "Otvorenih računa: ",$#osoba_id_za_print+1," |
72 |
$sth = $dbh->prepare(" |
$sth = $dbh->prepare(" |
73 |
select osobe.id,ime,prezime,tel,lokacije.naziv, |
select osobe.id,ime,prezime,tel,lokacije.naziv, |
74 |
org_jed.naziv,org_pod_jed.pod_naziv, |
org_jed.naziv,org_pod_jed.pod_naziv, |
75 |
lok_racunala,objekt,kat,soba,z_rac |
lok_racunala,objekt,kat,soba,z_rac,umrezavanje |
76 |
from osobe |
from osobe |
77 |
where osobe.id in (".join(",",@osoba_id_za_print).") |
where osobe.id in (".join(",",@osoba_id_za_print).") |
78 |
and lokacija_id=lokacije.id and org_jed_id=org_jed.id |
and lokacija_id=lokacije.id and org_jed_id=org_jed.id |
79 |
and org_pod_jed_id=org_pod_jed.pod_id |
and org_pod_jed_id=org_pod_jed.pod_id |
80 |
|
and podesavanje=true |
81 |
order by lokacije.naziv,org_jed.naziv |
order by lokacije.naziv,org_jed.naziv |
82 |
") || die $dbh->errstr(); |
") || die $dbh->errstr(); |
83 |
$sth->execute() || die $sth->errstr(); |
$sth->execute() || die $sth->errstr(); |
84 |
|
|
85 |
my $rbr=1; |
my $rbr=1; |
86 |
|
my $lokacija=''; |
87 |
|
|
88 |
printf MAIL ("%3s %4s %-20s %4s %-30s %-20s\n","rbr","id","ime i prezime","tel","lokacija","org.jed"); |
printf MAIL ("%3s %4s %-20s %4s %-30s %-20s\n","rbr","id","ime i prezime","tel","lokacija","org.jed"); |
89 |
print HTML '<table border=1> |
print HTML '<table border=1> |
90 |
<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> |
<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> |
91 |
|
<tr bgcolor="#e0e0f0"><th></th><th></th><th>lokacija računala, mreža</th><th>ž</th><th colspan=2>objekat / kat / soba</th></tr> |
92 |
'; |
'; |
93 |
|
|
94 |
|
my $bgcol=''; |
95 |
|
my $mreza=''; |
96 |
|
|
97 |
while (my @arr = $sth->fetchrow_array() ) { |
while (my @arr = $sth->fetchrow_array() ) { |
98 |
printf MAIL ("%3s %4s %-20s %4s %-30s %-20s\n",$rbr,$arr[0],"$arr[1] $arr[2]",$arr[3],$arr[4],"$arr[5] $arr[6]"); |
printf MAIL ("%3s %4s %-20s %4s %-30s %-20s\n",$rbr,$arr[0],"$arr[1] $arr[2]",$arr[3],$arr[4],"$arr[5] $arr[6]"); |
99 |
print HTML "<tr><td>$rbr</td><td>$arr[0]</td><td>$arr[1] $arr[2]</td><td>$arr[3]</td><td>$arr[4]</td><td>$arr[5]<br>$arr[6]</td></tr>\n"; |
if ($lokacija ne $arr[4]) { |
100 |
|
$lokacija=$arr[4]; |
101 |
|
print HTML "<tr bgcolor=#000000><td colspan=6><font size=+1 color=#ffffff>$lokacija</font></td></tr>"; |
102 |
|
} |
103 |
|
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"; |
104 |
|
if ($arr[12] == 0) { |
105 |
|
$mreza='umreženo'; |
106 |
|
} else { |
107 |
|
my $rows = $dbh->do("select max(status_tip_id) from status |
108 |
|
where osoba_id = $arr[0] and status_tip_id=8") || die $dbh->errstr(); |
109 |
|
if ($rows > 0) { |
110 |
|
$mreza='<i>umrežavanje obavljeno</i>'; |
111 |
|
} else { |
112 |
|
$mreza='<b>potrebno umrežavanje</b>'; |
113 |
|
} |
114 |
|
} |
115 |
|
print HTML "<tr$bgcol><td colspan=2> </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"; |
116 |
$rbr++; |
$rbr++; |
117 |
|
if ($rbr % 2 == 0) { |
118 |
|
$bgcol=' bgcolor=#eeeeee'; |
119 |
|
} else { |
120 |
|
$bgcol=''; |
121 |
|
} |
122 |
} |
} |
123 |
|
|
124 |
$sth->finish; |
$sth->finish; |
130 |
|
|
131 |
close(HTML); |
close(HTML); |
132 |
close(MAIL); |
close(MAIL); |
133 |
|
|