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

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

revision 1.1 by dpavlin, Wed Apr 12 08:10:24 2000 UTC revision 1.6 by dpavlin, Mon Jun 12 07:03:57 2000 UTC
# Line 31  $dbh->do("set datestyle = 'german'") || Line 31  $dbh->do("set datestyle = 'german'") ||
31    
32  my $sth;  my $sth;
33    
34    open(WHO,"who am i |") || die "who am i? $!";
35    my $db_user=<WHO>;
36    chomp $db_user;
37    $db_user=~s/\s.+$//g;   # OSF obriši sve iza logina
38    $db_user=~s/^[^!]+!//g; # Linux obriši hostname
39    close(WHO);
40    
41    open(HOSTNAME,"hostname |") || die "hostname: $!";
42    my $hostname=<HOSTNAME>;
43    chomp $hostname;
44    close(HOSTNAME);
45    
46    $sth = $dbh->prepare("select ko_id from unix2ko where login='$db_user' and host='$hostname'") || die $dbh->errstr();
47    $sth->execute() || die $sth->errstr();
48    my ($ko_id)=$sth->fetchrow_array;
49    die "Ne mogu naći odgovarajuću kontakt osobu u tablici unix2ko!\n\tlogin=$db_user host=$hostname\n" if (!defined($ko_id));
50    
51    print "kontakt_osoba_id (koja je pokrenula skriptu): $ko_id\n" if ($debug);
52    
53  #$sth = $dbh->prepare("select id from kontakt_osobe where e_mail like '%hana%'") || die $dbh->errstr();  #$sth = $dbh->prepare("select id from kontakt_osobe where e_mail like '%hana%'") || die $dbh->errstr();
54  #$sth->execute() || die $sth->errstr();  #$sth->execute() || die $sth->errstr();
55  #($kontakt_osoba_id) = $sth->fetchrow_array();  #($kontakt_osoba_id) = $sth->fetchrow_array();
# Line 44  my $sql; Line 63  my $sql;
63  if (! defined($print_only_id)) {  if (! defined($print_only_id)) {
64          $sql="select osoba_id,max(status_tip_id) from status where osoba_id > $last_print_id group by osoba_id";          $sql="select osoba_id,max(status_tip_id) from status where osoba_id > $last_print_id group by osoba_id";
65  } else {  } else {
66          $sql="select osoba_id,status_tip_id from status where osoba_id=$print_only_id and status_tip_id=3";          $sql="select osoba_id,status_tip_id from status where osoba_id in ($print_only_id) and status_tip_id=3";
67  }  }
68    
69  $sth = $dbh->prepare("$sql") || die "$sql ",$dbh->errstr();  $sth = $dbh->prepare("$sql") || die "$sql ",$dbh->errstr();
70  $sth->execute() || die "$sql ",$sth->errstr();  $sth->execute() || die "$sql ",$sth->errstr();
71    
72  #my $out_tex="out.tex";  #my $out_tex="out.tex";
73  my $out_tex="$0-out-$$.tex";  my $out_tex="out-$$.tex";
74    
75  open(IN,"obavjest.tex") || die "obavjest.tex: $!";  open(IN,"obavjest.tex") || die "obavjest.tex: $!";
76  open(OUT,"> $out_tex") || die "$out_tex: $!";  open(OUT,"> $out_tex") || die "$out_tex: $!";
# Line 78  $sth = $dbh->prepare(" Line 97  $sth = $dbh->prepare("
97          select osobe.id,ime,prezime,tel,lokacije.naziv,          select osobe.id,ime,prezime,tel,lokacije.naziv,
98                  org_jed.naziv,org_pod_jed.pod_naziv,                  org_jed.naziv,org_pod_jed.pod_naziv,
99                  lok_racunala,login,passwd,alias,sifra,                  lok_racunala,login,passwd,alias,sifra,
100                  objekt,kat,soba,z_rac,kontakt_osoba_id                  objekt,kat,soba,z_rac,kontakt_osoba_id,umrezavanje
101          from osobe,racuni,e_mail          from osobe,racuni,e_mail
102          where osobe.id in (".join(",",@osoba_id_za_print).")          where osobe.id in (".join(",",@osoba_id_za_print).")
103                  and lokacija_id=lokacije.id and org_jed_id=org_jed.id                  and lokacija_id=lokacije.id and org_jed_id=org_jed.id
# Line 91  $sth->execute() || die $sth->errstr(); Line 110  $sth->execute() || die $sth->errstr();
110  while (my @arr = $sth->fetchrow_array() ) {  while (my @arr = $sth->fetchrow_array() ) {
111          print join("|",@arr),"\n";          print join("|",@arr),"\n";
112    
113          $dbh->do("insert into status (osoba_id,kontakt_osoba_id,datum,status_tip_id) values ($arr[0],3,'now'::datetime,5)") if (!$debug);          if (!$debug) {
114                    $dbh->do("insert into status (osoba_id,kontakt_osoba_id,datum,status_tip_id) values ($arr[0],$ko_id,'now'::datetime,5)") || die $dbh->errstr();
115            }
116    
117          seek(IN,$begin_pos,0);          seek(IN,$begin_pos,0);
118          while(<IN>) {          while(<IN>) {
# Line 133  while (my @arr = $sth->fetchrow_array() Line 154  while (my @arr = $sth->fetchrow_array()
154                  s/--zrac--/$arr[15]/g;                  s/--zrac--/$arr[15]/g;
155                  my $ean=sprintf("2%06d%05d",$arr[11],$arr[0]);                  my $ean=sprintf("2%06d%05d",$arr[11],$arr[0]);
156                  s/--ean--/$ean/g;                  s/--ean--/$ean/g;
157                    
158                    if ($arr[17] == 1) {    
159                            s/--umrezavanje--/\\bf{Potrebno je umrežavanje}/gi;
160                    } else {
161                            s/--umrezavanje--/{\\small Računalo je umreženo}/gi;
162                    }
163            
164                  print OUT $_;                  print OUT $_;
165    
166                  if (/^%--insert_status--/) {                  if (/^%--insert_status--/) {
# Line 172  $out_no_ext=~s/\.tex//; Line 200  $out_no_ext=~s/\.tex//;
200  my $path=$0;  my $path=$0;
201  $path=~s/\/[^\/]+//g;  $path=~s/\/[^\/]+//g;
202    
203  system "$path/codean.pl $out_no_ext.tex $out_no_ext.tex2 && mv $out_no_ext.tex2 $out_no_ext.tex && latex $out_no_ext.tex && dvips $out_no_ext.dvi && lpr $out_no_ext.ps";  if (!$debug) {
204            system "$path/codean.pl $out_no_ext.tex $out_no_ext.tex2 && mv $out_no_ext.tex2 $out_no_ext.tex && latex $out_no_ext.tex && dvips $out_no_ext.dvi && lpr $out_no_ext.ps";
205    } else {
206            system "$path/codean.pl $out_no_ext.tex $out_no_ext.tex2 && mv $out_no_ext.tex2 $out_no_ext.tex && latex $out_no_ext.tex && dvips $out_no_ext.dvi";
207    
208    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.26