Subversion Repositories ORC

Rev

Rev 22 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22 Rev 29
Line 28... Line 28...
28
 
28
 
Line 29... Line 29...
29
use CGI qw(:standard escape escapeHTML);
29
use CGI qw(:standard escape escapeHTML);
30
 
30
 
31
sub display_upload_form  {
31
sub display_upload_form  {
32
  print $h->div ("Upload a CSV File of department shifts...");
32
  print $h->div ("Upload a CSV File of department shifts...");
33
  print $h->div ("These should be the columns: (dept, role, type, date, location, start_time, end_time, note)");
33
  print $h->div ("These should be the columns: (dept, role, type, date, location, start_time, end_time, doubletime, note)");
34
	print start_multipart_form (-action => url ()),
34
	print start_multipart_form (-action => url ()),
35
#		    "Upload File: ", br (),
35
#		    "Upload File: ", br (),
36
      $h->input ({
36
      $h->input ({
Line 109... Line 109...
109
  if ($columnlabels[0] eq "id") {
109
  if ($columnlabels[0] eq "id") {
110
    $idtrue = 1;
110
    $idtrue = 1;
111
    shift @columnlabels;
111
    shift @columnlabels;
112
  }
112
  }
Line 113... Line 113...
113
  
113
  
Line 114... Line 114...
114
  my @AcceptableColumns = qw(dept, role, type, date, location, start_time, end_time, note);
114
  my @AcceptableColumns = qw(dept, role, type, date, location, start_time, end_time, doubletime, note);
115
  
115
  
116
 
116
 
Line 117... Line 117...
117
  my $fields = join ", ", @columnlabels;
117
  my $fields = join ", ", @columnlabels;
118
  my $values = join ", ", map { '?' } 0..$#columnlabels;
118
  my $values = join ", ", map { '?' } 0..$#columnlabels;
119
  my $sth = $dbh->prepare ("insert into shift ($fields) values ($values)");
119
  my $sth = $dbh->prepare ("insert into shift ($fields) values ($values)");
120
  
120
  
121
  while (<$fh>) {
121
  while (<$fh>) {
122
    chomp;
122
    chomp;
123
    my @R = map { s/[^\x00-\x7f]//g; WebDB::trim ($_) } split /,/;
123
    my @R = map { s/[^\x00-\x7f]//g; WebDB::trim ($_) } split /,/;
124
    shift @R if $idtrue;
124
    shift @R if $idtrue;
125
    push @R, "" if (scalar @R < scalar $fields and eof);
125
    push @R, "" if (scalar @R < scalar @columnlabels and eof);
Line 126... Line 126...
126
    print "inserting: ", join (" ", @R), $h->br;
126
    print "inserting: ", join (" ", @R), $h->br;