Subversion Repositories VORC

Rev

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

Rev 136 Rev 153
Line 7... Line 7...
7
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
7
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
Line 8... Line 8...
8
 
8
 
9
use strict;
9
use strict;
10
use cPanelUserConfig;
10
use cPanelUserConfig;
-
 
11
use RollerCon;
11
use RollerCon;
12
use tableViewer;
12
use HTML::Tiny;
13
use HTML::Tiny;
13
use CGI qw/param header start_html url uploadInfo/;
14
use CGI qw/param header start_html url uploadInfo/;
Line 14... Line 15...
14
my $h = HTML::Tiny->new( mode => 'html' );
15
my $h = HTML::Tiny->new( mode => 'html' );
Line 106... Line 107...
106
  }	 # Form was okay;
107
  }	 # Form was okay;
Line 107... Line 108...
107
  
108
  
108
  print $h->div ("Processing file...");
109
  print $h->div ("Processing file...");
Line 109... Line 110...
109
  my $fh = upload ('uploadedfile');
110
  my $fh = upload ('uploadedfile');
110
 
111
 
Line 111... Line -...
111
  my @columnlabels = split /,/, <$fh>;
-
 
112
  @columnlabels = map { s/[^\x00-\x7f]//g; WebDB::trim ($_) } @columnlabels;
112
#  my @columnlabels = split /,/, <$fh>;
113
    
-
 
114
  my $idtrue = 0;
113
  my @columnlabels = map { s/[^\x00-\x7f]//g; WebDB::trim ($_) } split /,/, chomp <$fh>;
115
  if ($columnlabels[0] eq "id") {
114
    
Line 116... Line 115...
116
    $idtrue = 1;
115
  if ($columnlabels[0] eq "id") {
-
 
116
    error "'id' is no longer allowed as a column!";
Line -... Line 117...
-
 
117
  }
-
 
118
  
-
 
119
  my @AcceptableColumns = map { $_->[0] } @{ $dbh->selectall_arrayref("show columns from shift") };
-
 
120
  shift @AcceptableColumns; #Remove 'id' from the acceptable column list
-
 
121
  
Line 117... Line 122...
117
    shift @columnlabels;
122
  foreach (@columnlabels) {
118
  }
123
    if (notInArray($_, @AcceptableColumns)) {
119
  
124
      error "$_ isn't a valid column!";
Line -... Line 125...
-
 
125
    }
-
 
126
  }
120
  my @AcceptableColumns = qw(dept, role, type, date, location, start_time, end_time, doubletime, note, assignee_id);
127
 
121
  
128
  my $fields = join ", ", @columnlabels;
122
 
129
  my $values = join ", ", map { '?' } 0..$#columnlabels;
-
 
130
  my $sth = $dbh->prepare ("insert into shift ($fields) values ($values)");
-
 
131
  
123
  my $fields = join ", ", @columnlabels;
132
  my $validDepartment = getDepartments ();
124
  my $values = join ", ", map { '?' } 0..$#columnlabels;
133
  
125
  my $sth = $dbh->prepare ("insert into shift ($fields) values ($values)");
134
  while (<$fh>) {
126
  
-
 
-
 
135
    my %shift;
127
  while (<$fh>) {
136
    @shift{@columnlabels} = map { s/[^\x00-\x7f]//g; WebDB::trim ($_) } split /,/, chomp $_;
128
    chomp;
137
    
129
    my @R = map { s/[^\x00-\x7f]//g; WebDB::trim ($_) } split /,/;
138
    error "$shift{dept} isn't a valid Department!" unless inArray ($shift{dept}, keys %{$validDepartment});
130
    shift @R if $idtrue;
139
    $shift{type} = lc $shift{type};
Line 131... Line 140...
131
    $R[2] = lc $R[2] if $columnlabels[2] eq "type";
140
    $shift{doubletime} //= 0;