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

Diff of /print/izvjestaj.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by dpavlin, Thu Apr 27 10:57:11 2000 UTC revision 1.8 by dpavlin, Tue Jun 27 11:15:32 2000 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  my $debug=1;  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);  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;
# Line 19  if (! $debug) { Line 21  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 {  } else {
24  open(HTML,"> /tmp/debug$$.html") || die "html: $!";  open(HTML,"> /tmp/debug.html") || die "html: $!";
25  open(MAIL,"> /tmp/debug$$.mail") || die "sendmail: $!";  open(MAIL,"> /tmp/debug.mail") || die "sendmail: $!";
26  }  }
27    
28  print HTML '  print HTML '
# Line 35  Subject: otvoreni računi za e-mail Line 37  Subject: otvoreni računi za e-mail
37    
38  ';  ';
39    
40  my $dbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr;  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();  $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");  my $sth = $dbh->prepare("select id from last_print order by id desc limit 1,1");
# Line 51  $sth->execute() || die $sth->errstr(); Line 67  $sth->execute() || die $sth->errstr();
67  my @osoba_id_za_print;  my @osoba_id_za_print;
68    
69  while (my ($osoba_id,$status_tip_id) = $sth->fetchrow_array() ) {  while (my ($osoba_id,$status_tip_id) = $sth->fetchrow_array() ) {
70          if ($status_tip_id == 5) {      # print          if ($status_tip_id == 5 || $status_tip_id == 8 ) { # print/umrežavanje
71                  push @osoba_id_za_print,$osoba_id;                  push @osoba_id_za_print,$osoba_id;
72          }          }
73  }  }
74    
75  print MAIL "Otvorenih računa: ",$#osoba_id_za_print+1,"  print MAIL "
76  Datum i vrijeme generiranja izvještaja: $currdate  Datum i vrijeme generiranja izvještaja: $currdate
77    
78  Izvještaj se nalazi i na  Izvještaj za štampanje se nalazi na
79  http://support.pliva.hr/$html_file  http://support.pliva.hr/$html_file
80  (npr. za ispis na štampaču)  sa potpunim podacima o umrežavanju, lokaciji računala i osobe
81    
82  ";  ";
83  print HTML "Otvorenih računa: ",$#osoba_id_za_print+1,"  print HTML "
84  <br>Datum i vrijeme generiranja izvještaja: $currdate<p>";  <br>Datum i vrijeme generiranja izvještaja: $currdate<p>";
85    
86  $sth = $dbh->prepare("  $sth = $dbh->prepare("
87          select osobe.id,ime,prezime,tel,lokacije.naziv,          select osobe.id,ime,prezime,tel,lokacije.naziv,
88                  org_jed.naziv,org_pod_jed.pod_naziv,                  org_jed.naziv,org_pod_jed.pod_naziv,
89                  lok_racunala,objekt,kat,soba,z_rac                  lok_racunala,objekt,kat,soba,z_rac,umrezavanje,
90                    kontakt_osobe.e_mail,podesavanje
91          from osobe          from osobe
92          where osobe.id in (".join(",",@osoba_id_za_print).")          where osobe.id in (".join(",",@osoba_id_za_print).")
93                  and lokacija_id=lokacije.id and org_jed_id=org_jed.id                  and lokacija_id=lokacije.id and org_jed_id=org_jed.id
94                  and org_pod_jed_id=org_pod_jed.pod_id                  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          order by lokacije.naziv,org_jed.naziv
98          ") || die $dbh->errstr();          ") || die $dbh->errstr();
99  $sth->execute() || die $sth->errstr();  $sth->execute() || die $sth->errstr();
100    
101  my $rbr=1;  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");  printf MAIL ("%3s %4s %-20s %4s %-30s %-20s\n","rbr","id","ime i prezime","tel","lokacija","org.jed");
105  print HTML '<table border=1>  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>  <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() ) {  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]");          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          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]) {
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><a href=\"http://support.pliva.hr/obavijest.php?id=$arr[0]\">$arr[0]</a></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 $sth2 = $dbh->prepare("select count(status_tip_id) from status
130                            where osoba_id = $arr[0] and status_tip_id=8") ||
131                                    die $dbh->errstr();
132                    $sth2->execute() || die $sth2->errstr();
133                    my ($nr_of_status8) = $sth2->fetchrow_array();
134                            
135                    if ($nr_of_status8 > 0) {
136                            $mreza='<i>umrežavanje obavljeno</i>';
137                    } else {
138                            $mreza='<b>potrebno umrežavanje</b>';
139                    }
140            }
141            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";
142          $rbr++;          $rbr++;
143            if ($rbr % 2 == 0) {
144                    $bgcol=' bgcolor=#eeeeee';
145            } else {
146                    $bgcol='';
147            }
148  }  }
149    
150  $sth->finish;  $sth->finish;
# Line 102  print HTML ' Line 157  print HTML '
157  close(HTML);  close(HTML);
158  close(MAIL);  close(MAIL);
159    
160    $dbh->disconnect;
161    
162    foreach my $email_ko (keys %mail4ko) {
163            if (! $debug) {
164                    open(MAIL,"|/usr/lib/sendmail $email_ko") || die "sendmail: $!";
165            } else {
166                    open(MAIL,">> /tmp/debug.komail") || die "sendmail: $!";
167            }
168    
169            print MAIL 'From: PlivaNet Core Support Team <pcst@pliva.hr>
170    Subject: otvoreni računi za e-mail
171    
172    Obavještavamo Vas da su otvoreni korisnički računi na intranet poslužitelju
173    za slijedeće osobe:
174    ';
175            foreach my $ime_pr (split(/\t/,$mail4ko{$email_ko})) {
176                    print MAIL "\t$ime_pr\n";
177            }
178            print MAIL '
179    Vaši korisnici dobiti će pristupno ime (login) i lozinku (password) internom
180    poštom, a djelatnici odjela Informatika IC će izvršiti podešavanje korisničkog
181    računala.';
182    
183            close(MAIL);
184    }
185    
186    print "Printanje zahtjeva za print za IC:\n./print.pl ",join(",",@za_ic),"\n";

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.26