+sub href_params_new_ticket {
+ my( $self, $custnum_or_cust_main, $requestors ) = @_;
+
+ my( $custnum, $cust_main );
+ if ( ref($custnum_or_cust_main) ) {
+ $cust_main = $custnum_or_cust_main;
+ $custnum = $cust_main->custnum;
+ } else {
+ $custnum = $custnum_or_cust_main;
+ $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+ }
+
+ # explicit $requestors > config option > invoicing_list
+ $requestors = $conf->config('ticket_system-requestor')
+ if !$requestors;
+ $requestors = $cust_main->invoicing_list_emailonly_scalar
+ if (!$requestors) and defined($cust_main);
+
+ my %param = (
+ 'Queue' => ($cust_main->agent->ticketing_queueid || $default_queueid),
+ 'new-MemberOf'=> "freeside://freeside/cust_main/$custnum",
+ 'Requestors' => $requestors,
+ );
+
+ ( $self->baseurl.'Ticket/Create.html', %param );
+}
+
+sub href_new_ticket {
+ my $self = shift;
+
+ my( $base, %param ) = $self->href_params_new_ticket(@_);
+
+ my $uri = new URI $base;
+ $uri->query_form(%param);
+ $uri;
+
+}
+
+sub href_ticket {
+ my($self, $ticketnum) = @_;
+ $self->baseurl. 'Ticket/Display.html?id='.$ticketnum;
+}
+
+sub queues {
+ my($self) = @_;
+
+ my $sql = "SELECT id, Name FROM Queues WHERE Disabled = 0";
+ my $sth = $dbh->prepare($sql) or die $dbh->errstr. " preparing $sql";
+ $sth->execute() or die $sth->errstr. " executing $sql";
+
+ map { $_->[0] => $_->[1] } @{ $sth->fetchall_arrayref([]) };
+
+}
+
+sub queue {
+ my($self, $queueid) = @_;
+
+ return '' unless $queueid;
+
+ my $sql = "SELECT Name FROM Queues WHERE id = ?";
+ my $sth = $dbh->prepare($sql) or die $dbh->errstr. " preparing $sql";
+ $sth->execute($queueid) or die $sth->errstr. " executing $sql";
+
+ my $rows = $sth->fetchrow_arrayref;
+ $rows ? $rows->[0] : '';
+
+}
+
+sub baseurl {
+ #my $self = shift;
+ $external_url. '/';
+}
+
+sub _retrieve_single_value {
+ my( $self, $sql ) = @_;
+
+ warn "$me $sql" if $DEBUG;
+ my $sth = $dbh->prepare($sql) or die $dbh->errstr. "preparing $sql";
+ $sth->execute or die $sth->errstr. "executing $sql";
+
+ my $arrayref = $sth->fetchrow_arrayref;
+ $arrayref ? $arrayref->[0] : $arrayref;
+}
+
+sub transaction_creator {
+ my( $self, $transaction_id ) = @_;
+
+ my $sql = "SELECT Name FROM Transactions JOIN Users ON ".
+ "Transactions.Creator=Users.id WHERE Transactions.id = ".
+ $transaction_id;
+
+ $self->_retrieve_single_value($sql);
+}
+
+sub transaction_ticketid {
+ my( $self, $transaction_id ) = @_;
+
+ my $sql = "SELECT ObjectId FROM Transactions WHERE Transactions.id = ".
+ $transaction_id;
+
+ $self->_retrieve_single_value($sql);
+}
+
+sub transaction_subject {
+ my( $self, $transaction_id ) = @_;
+
+ my $sql = "SELECT Subject FROM Transactions JOIN Tickets ON ObjectId=".
+ "Tickets.id WHERE Transactions.id = ". $transaction_id;
+
+ $self->_retrieve_single_value($sql);
+}
+
+sub transaction_status {
+ my( $self, $transaction_id ) = @_;
+
+ my $sql = "SELECT Status FROM Transactions JOIN Tickets ON ObjectId=".
+ "Tickets.id WHERE Transactions.id = ". $transaction_id;
+
+ $self->_retrieve_single_value($sql);
+}
+
+sub access_right {
+ warn "WARNING: no access rights available w/ external RT";
+ 0;
+}
+
+sub create_ticket {
+ return 'create_ticket unimplemented w/external RT (write something w/RT::Client::REST?)';
+}
+
+sub init { } #unimplemented
+
+sub selfservice_priority { '' } #unimplemented
+