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(); |
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: $!"; |
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 |
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>) { |
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--/) { |
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 |
|
} |