--- otvori_nove+db 2000/05/17 09:57:22 1.6 +++ otvori_nove+db 2000/05/31 13:57:49 1.7 @@ -41,11 +41,18 @@ my @mail_to; # array to main initial message to open(WHO,"who am i |") || die "who am i? $!"; my $db_user=; +chomp $db_user; $db_user=~s/\s.+$//g; close(WHO); xdebug "koristim korinika $db_user\n"; +open(HOSTNAME,"hostname |") || die "hostname: $!"; +my $hostname=; +chomp $hostname; +close(HOSTNAME); + +xdebug "koristim hostname $hostname\n"; v "/etc/aliases\n"; open(ALIAS,"/etc/aliases") || die "Can't open /etc/aliases: $!"; @@ -105,9 +112,17 @@ my $max_osoba_id=0; my $dbh = DBI->connect("DBI:Pg:dbname=informatika;host=support.pliva.hr;user=$db_user","","") || die $DBI::errstr; -my $sth = $dbh->prepare("select max(id) from last_open") || die $dbh->errstr(); + +my $sth = $dbh->prepare("select ko_id from unix2ko where login='$db_user' and host='$hostname'") || die $dbh->errstr(); +$sth->execute() || die $sth->errstr(); +my ($ko_id)=$sth->fetchrow_array; + +xdebug "upotrebljavam ID kontakt osobe: $ko_id\n"; + +$sth = $dbh->prepare("select max(id) from last_open") || die $dbh->errstr(); $sth->execute() || die $sth->errstr(); my ($last_open)=$sth->fetchrow_array; + if (! defined($open_only_id)) { $sth = $dbh->prepare("select id,ime,prezime,sifra,objekt,kat,soba,shell from view_otvori_nove where id > $last_open") || die $dbh->errstr(); } else { @@ -237,7 +252,7 @@ system "mkdir -p $dir ; mkdir $dir/bin ; \ chown -R $uid:$group_id{$group} $dir ; chmod 755 $dir" if (! $debug); - $dbh->do("insert into status (osoba_id,kontakt_osoba_id,datum,status_tip_id) values ($osoba_id,3,'now'::datetime,3)") if (! $debug); + $dbh->do("insert into status (osoba_id,kontakt_osoba_id,datum,status_tip_id) values ($osoba_id,$ko_id,'now'::datetime,3)") if (! $debug); $max_osoba_id = $osoba_id if ($max_osoba_id < $osoba_id) ; }