1 package FS::TicketSystem;
4 use vars qw( $conf $system $AUTOLOAD );
6 use FS::UID qw( dbh driver_name );
8 FS::UID->install_callback( sub {
10 $system = $conf->config('ticket_system');
19 my $conf = new FS::Conf;
20 die "FS::TicketSystem::$AUTOLOAD called, but no ticket system configured\n"
23 eval "use FS::TicketSystem::$system;";
31 return if $system ne 'RT_Internal';
33 my ($class, %opts) = @_;
34 my ($t, $exec, @fields) = map { driver_name =~ /^mysql/i ? $_ : lc($_) }
35 (qw( ScripConditions ExecModule
36 Name Description ExecModule ApplicableTransTypes
37 Creator Created LastUpdatedBy LastUpdated));
38 my $count_sql = "SELECT COUNT(*) FROM $t WHERE $exec = 'CustomFieldChange'";
39 my $sth = dbh->prepare($count_sql) or die dbh->errstr;
40 $sth->execute or die $sth->errstr;
41 my $total = $sth->fetchrow_arrayref->[0];
44 my $insert_sql = "INSERT INTO $t (".join(',',@fields).") VALUES (".
45 "'On Custom Field Change', 'When a custom field is changed to some value',
46 'CustomFieldChange', 'Any', 1, CURRENT_DATE, 1, CURRENT_DATE )";
47 $sth = dbh->prepare($insert_sql) or die dbh->errstr;
48 $sth->execute or die $sth->errstr;