[freeside-commits] freeside/FS/FS/ClientAPI MyAccount.pm, 1.95.2.6, 1.95.2.7
Ivan,,,
ivan at wavetail.420.am
Thu Feb 11 17:37:55 PST 2010
Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory wavetail.420.am:/tmp/cvs-serv6490/FS/FS/ClientAPI
Modified Files:
Tag: FREESIDE_1_9_BRANCH
MyAccount.pm
Log Message:
add ticket creation to self-service API, RT#7007
Index: MyAccount.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MyAccount.pm,v
retrieving revision 1.95.2.6
retrieving revision 1.95.2.7
diff -u -d -r1.95.2.6 -r1.95.2.7
--- MyAccount.pm 21 Jan 2010 08:35:28 -0000 1.95.2.6
+++ MyAccount.pm 12 Feb 2010 01:37:53 -0000 1.95.2.7
@@ -1,5 +1,6 @@
package FS::ClientAPI::MyAccount;
+use 5.008; #require 5.8+ for Time::Local 1.05+
use strict;
use vars qw( $cache $DEBUG $me );
use subs qw( _cache _provision );
@@ -8,6 +9,7 @@
use Date::Format;
use Business::CreditCard;
use Time::Duration;
+use Time::Local qw(timelocal_nocheck);
use FS::UI::Web::small_custview qw(small_custview); #less doh
use FS::UI::Web;
use FS::UI::bytecount qw( display_bytecount );
@@ -29,18 +31,11 @@
use FS::payby;
use FS::acct_rt_transaction;
use HTML::Entities;
+use FS::TicketSystem;
-$DEBUG = 2;
+$DEBUG = 0;
$me = '[FS::ClientAPI::MyAccount]';
-#false laziness with FS::cust_main
-BEGIN {
- eval "use Time::Local;";
- die "Time::Local minimum version 1.05 required with Perl versions before 5.6"
- if $] < 5.006 && !defined($Time::Local::VERSION);
- eval "use Time::Local qw(timelocal_nocheck);";
-}
-
use vars qw( @cust_main_editable_fields );
@cust_main_editable_fields = qw(
first last company address1 address2 city
@@ -1654,6 +1649,42 @@
}
+sub create_ticket {
+ my $p = shift;
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
+
+ warn "$me create_ticket: initializing ticket system\n" if $DEBUG;
+ FS::TicketSystem->init();
+
+ my $conf = new FS::Conf;
+ my $queue = $conf->config('ticket_system-selfservice_queueid')
+ || $conf->config('ticket_system-default_queueid');
+
+ warn "$me create_ticket: creating ticket\n" if $DEBUG;
+ my $err_or_ticket = FS::TicketSystem->create_ticket(
+ '', #create RT session based on FS CurrentUser (fs_selfservice)
+ 'queue' => $queue,
+ 'custnum' => $custnum,
+ 'svcnum' => $session->{'svcnum'},
+ map { $_ => $p->{$_} } qw( requestor cc subject message )
+ );
+
+ if ( ref($err_or_ticket) ) {
+ warn "$me create_ticket: sucessful: ". $err_or_ticket->id. "\n"
+ if $DEBUG;
+ return { 'error' => '',
+ 'ticket_id' => $err_or_ticket->id,
+ };
+ } else {
+ warn "$me create_ticket: unsucessful: $err_or_ticket\n"
+ if $DEBUG;
+ return { 'error' => $err_or_ticket };
+ }
+
+
+}
+
#--
sub _custoragent_session_custnum {
More information about the freeside-commits
mailing list