+ #$href =
+ #uri_escape($href);
+
+ $self->baseurl. $href;
+
+}
+
+sub href_params_new_ticket {
+ # my( $self, $custnum_or_cust_main, $requestors ) = @_;
+ # no longer takes $custnum--it must be an object
+ my ( $self, $object, $requestors ) = @_;
+ my $cust_main; # for default requestors
+ if ( $object->isa('FS::cust_main') ) {
+ $cust_main = $object;
+ }
+ elsif ( $object->isa('FS::svc_Common') ) {
+ $object = $object->cust_svc;
+ $cust_main = $object->cust_pkg->cust_main if ( $object->cust_pkg );
+ }
+ elsif ( $object->isa('FS::cust_svc') ) {
+ $cust_main = $object->cust_pkg->cust_main if ( $object->cust_pkg );
+ }
+
+ # 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 $subtype = $object->table;
+ my $pkey = $object->get($object->primary_key);
+
+ my @param = (
+ 'Queue' => ($cust_main->agent->ticketing_queueid || $default_queueid),
+ 'new-MemberOf'=> "freeside://freeside/$subtype/$pkey",
+ '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;