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

Annotation of /oznaci.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu Apr 20 09:26:38 2000 UTC (22 years, 9 months ago) by dpavlin
Branch: MAIN
File MIME type: text/plain
ručno označavanje zahtjeva

1 dpavlin 1.1 #!/usr/local/bin/perl -w
2    
3     # Dobrica Pavlinusic <dpavlin@pliva.hr>
4     # 2000-04-18 DbP oznaĆØi dupli zahtjev
5     # 2000-04-20 DbP opƦe oznaĆØivanje statusa
6    
7     use DBI;
8     use strict;
9    
10     $|++;
11    
12     my ($osoba_id,$status,$status_tip_id,$sth);
13    
14     my $host = "host=support.pliva.hr;";
15    
16     open(WHO,"who am i |") || die "who am i? $!"; # osf-ism
17     my $db_user=<WHO>;
18     close(WHO);
19     if (! defined($db_user)) {
20     $db_user="user=dpavlin;"; $host=""; # works on localhost
21     } else {
22     $db_user=~s/\s.+$//g;
23     $db_user="user=$db_user;";
24     }
25    
26    
27     my $dbh = DBI->connect("DBI:Pg:dbname=informatika;${host}${db_user}","","") || die $DBI::errstr;
28    
29     if (defined($ARGV[0]) && defined($ARGV[1])) {
30     $osoba_id = shift @ARGV;
31     $status = shift @ARGV;
32     $sth = $dbh->prepare("select ime,prezime from osobe where id=$osoba_id");
33     $sth->execute() || die $sth->errstr();
34     if (my ($ime,$prezime) = $sth->fetchrow_array()) {
35     print "Dodajem status korisniku $ime $prezime (id: $osoba_id)\n";
36     } else {
37     die "ne mogu naƦi osobu sa id-jem zahtjeva $osoba_id !";
38     }
39     } else {
40     print STDERR "trebam ID osobe i status kao argument!\n\n";
41     print STDERR "MoguƦi statusi:\n\n";
42     $sth = $dbh->prepare("select opis from status_tip");
43     $sth->execute() || die $sth->errstr();
44     while (my $status = $sth->fetchrow_array()) { print "$status\n"; }
45     exit 1;
46     }
47    
48     $sth = $dbh->prepare("select id from status_tip where opis like '$status'");
49     $sth->execute() || die $sth->errstr();
50     if (! (($status_tip_id) = $sth->fetchrow_array())) {
51     die "ne mogu pronaƦi status broj $status...";
52     } else {
53     print "\tdodajem status $status ($status_tip_id)\n";
54     }
55    
56     $dbh->do("insert into status (osoba_id,kontakt_osoba_id,datum,status_tip_id) values ($osoba_id,3,'now'::datetime,$status_tip_id)");
57    

  ViewVC Help
Powered by ViewVC 1.1.26