--- print/print.pl 2000/06/12 07:03:57 1.6 +++ print/print.pl 2002/02/04 15:55:13 1.9 @@ -37,6 +37,15 @@ $db_user=~s/\s.+$//g; # OSF obriši sve iza logina $db_user=~s/^[^!]+!//g; # Linux obriši hostname close(WHO); +if ($db_user eq "") { + open(ID,"id |") || die "id: $!"; + my $foo=; chomp $foo; + if ($foo=~/uid=\d+\((\w+)\)/) { + $db_user=$1; + } else { + die "can't locate who is local user!"; + } +} open(HOSTNAME,"hostname |") || die "hostname: $!"; my $hostname=; @@ -92,17 +101,16 @@ print "Računa za insprintati: ",$#osoba_id_za_print+1,"\n"; exit if ($#osoba_id_za_print+1 == 0); - +my $server=3; $sth = $dbh->prepare(" select osobe.id,ime,prezime,tel,lokacije.naziv, - org_jed.naziv,org_pod_jed.pod_naziv, lok_racunala,login,passwd,alias,sifra, objekt,kat,soba,z_rac,kontakt_osoba_id,umrezavanje from osobe,racuni,e_mail where osobe.id in (".join(",",@osoba_id_za_print).") - and lokacija_id=lokacije.id and org_jed_id=org_jed.id - and org_pod_jed_id=org_pod_jed.pod_id - and racuni.osoba_id=osobe.id and e_mail.osoba_id=osobe.id + and lokacija_id=lokacije.id + and racuni.osoba_id=osobe.id and racuni.server_id=$server + and e_mail.osoba_id=osobe.id ") || die $dbh->errstr(); $sth->execute() || die $sth->errstr(); @@ -114,6 +122,10 @@ $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(); } + my $sth2 = $dbh->prepare("select naziv,mt from sap_osobe,sap_oj where sap_oj.sifra_oj = sap_oj and sap_sifra = $arr[11]"); + $sth2->execute() || die $sth2->errstr(); + my ($sap_org_jed,$mt) = $sth2->fetchrow_array(); + seek(IN,$begin_pos,0); while() { s/--id--/$arr[0]/g; @@ -126,8 +138,8 @@ s/--prezime--/$arr[2]/g; s/--tel--/$arr[3]/g; s/--lok--/$arr[4]/g; - s/--orgjed--/$arr[5]/g; - s/--orgpodjed--/$arr[6]/g; + s/--orgjed--/$sap_org_jed/g; + s/--mt--/$mt/g; s/--lokrac--/$arr[7]/g; s/--login--/$arr[8]/g;