Subversion Repositories VORC

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
180 - 1
#!/usr/bin/perl
2
 
3
use strict;
4
use cPanelUserConfig;
5
use RollerCon;
6
use WebDB;
7
use DBI;
8
 
9
my $dbh = WebDB::connect ();
10
 
11
my $add_boop = $dbh->prepare ("insert into assignment (Gid, role, RCid) values (?, ?, ?)");
12
 
13
while (my $input = <>) {
14
	my ($wbid, $MVPid, $date, $start_time, @name) = split /,/, $input;
15
	my $name = join ",", @name;
16
	$name =~ s/\s+$//;
17
 
18
#	warn "FOUND: $wbid, $MVPid, $date, $start_time, @name";
19
 
20
	# Get the RCid
21
	my ($RCid) = $dbh->selectrow_array ("select RCid from v_official where MVPid = ?", undef, $MVPid);
22
	warn "ERROR: No RCid found for MVPid [$MVPid]" and next unless $RCid;
23
 
24
	# Get the class location
25
	my ($location) = $dbh->selectrow_array ("select location from class where date = ? and start_time = ? and name = ?", undef, $date, $start_time, $name);
26
	warn "ERROR: No Location Found for [$date, $start_time, $name]" and next unless $location;
27
 
28
	# Get the class id and role id
29
	my ($class_id, $role) = $dbh->selectrow_array ("select id, concat('CLA-', max(cast(substring_index(role, '-', -1) as UNSIGNED)) +1) as role, count(role) from v_class_signup where date = ? and start_time = ? and location = ?", undef, $date, $start_time, $location);
30
	warn "ERROR: Unable to calculuate RoleID for [$date, $start_time, $location]" and next unless ($class_id and $role);
31
 
32
#	print "executing [$class_id, $role, $RCid, $wbid]\n" and next;
33
 
34
	# Add the scann
35
	$add_boop->execute ($class_id, $role, $RCid);
36
	warn "DBERROR: " .$dbh->errstr unless !$dbh->errstr;
37
}