Subversion Repositories VORC

Rev

Rev 113 | Rev 133 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 113 Rev 128
Line 34... Line 34...
34
 
34
 
Line 35... Line 35...
35
use CGI qw(:standard escape escapeHTML);
35
use CGI qw(:standard escape escapeHTML);
36
 
36
 
37
sub display_upload_form  {
37
sub display_upload_form  {
38
  print $h->div ("Upload a CSV File of department shifts...");
38
  print $h->div ("Upload a CSV File of department shifts...");
39
  print $h->div ("These should be the columns: (dept, role, type, date, location, start_time, end_time, doubletime, note)");
39
  print $h->div ("These should be the columns: (dept, role, type, date, location, start_time, end_time, doubletime, note, assignee_id)");
40
	print start_multipart_form (-action => url ()),
40
	print start_multipart_form (-action => url ()),
41
#		    "Upload File: ", br (),
41
#		    "Upload File: ", br (),
42
      $h->input ({
42
      $h->input ({
Line 115... Line 115...
115
  if ($columnlabels[0] eq "id") {
115
  if ($columnlabels[0] eq "id") {
116
    $idtrue = 1;
116
    $idtrue = 1;
117
    shift @columnlabels;
117
    shift @columnlabels;
118
  }
118
  }
Line 119... Line 119...
119
  
119
  
Line 120... Line 120...
120
  my @AcceptableColumns = qw(dept, role, type, date, location, start_time, end_time, doubletime, note);
120
  my @AcceptableColumns = qw(dept, role, type, date, location, start_time, end_time, doubletime, note, assignee_id);
121
  
121
  
122
 
122
 
Line 129... Line 129...
129
    my @R = map { s/[^\x00-\x7f]//g; WebDB::trim ($_) } split /,/;
129
    my @R = map { s/[^\x00-\x7f]//g; WebDB::trim ($_) } split /,/;
130
    shift @R if $idtrue;
130
    shift @R if $idtrue;
131
    $R[2] = lc $R[2] if $columnlabels[2] eq "type";
131
    $R[2] = lc $R[2] if $columnlabels[2] eq "type";
132
    push @R, "" if (scalar @R < scalar @columnlabels and eof);
132
    push @R, "" if (scalar @R < scalar @columnlabels and eof);
133
    print "inserting: ", join (" ", @R), $h->br;
133
    print "inserting: ", join (" ", @R), $h->br;
134
    $sth->execute (map { defined $_ ? $_ : undef } @R) or print $sth->errstr;
134
    $sth->execute (map { $_ eq '' and $_ = undef } map { defined $_ ? $_ : undef } @R) or print $sth->errstr;
135
  }
135
  }
136
  print "DONE!", $h->br, $h->br;
136
  print "DONE!", $h->br, $h->br;
137
    
137
  
138
	$dbh->disconnect ();	 # Image was stored into database successfully.  Present confirmation
138
	$dbh->disconnect ();	 # Image was stored into database successfully.  Present confirmation
Line 139... Line 139...
139
	
139
	
140
	# Display link to main page so user can upload another image
140
	# Display link to main page so user can upload another image
141
	print $h->hr, $h->a ({ href => url }, "[Upload another file]"), $h->a ({ href => "/schedule/" }, "[Home]");
141
	print $h->hr, $h->a ({ href => url }, "[Upload another file]"), $h->a ({ href => "/schedule/" }, "[Home]");