ticket export for svc_phone, domain, broadband, RT#10363
authormark <mark>
Mon, 8 Nov 2010 20:59:54 +0000 (20:59 +0000)
committermark <mark>
Mon, 8 Nov 2010 20:59:54 +0000 (20:59 +0000)
FS/FS/msg_template.pm
FS/FS/part_export/rt_ticket.pm
httemplate/edit/msg_template.html

index 270eb1f..f0cda41 100644 (file)
@@ -166,8 +166,9 @@ Customer object (required).
 =item object
 
 Additional context object (currently, can be a cust_main, cust_pkg, 
-cust_bill, svc_acct, cust_pay, or cust_pay_pending).  If the object 
-is a svc_acct, its cust_pkg will be fetched and used for substitution.
+cust_bill, cust_pay, cust_pay_pending, or svc_(acct, phone, broadband, 
+domain) ).  If the object is a svc_*, its cust_pkg will be fetched and 
+used for substitution.
 
 As a special case, this may be an arrayref of two objects.  Both 
 objects will be available for substitution, with their field names 
@@ -281,9 +282,10 @@ sub prepare {
   ###
 
   my @to = ($opt{'to'}) || $cust_main->invoicing_list_emailonly;
-  warn "prepared msg_template with no email destination (custnum ".
-    $cust_main->custnum.")\n"
-    if !@to;
+  #warn "prepared msg_template with no email destination (custnum ".
+  #  $cust_main->custnum.")\n"
+  #  if !@to;
+  #  warning is not appropriate now that we use these for tickets
 
   my $conf = new FS::Conf;
 
@@ -368,7 +370,7 @@ sub substitutions {
     ],
     # next_bill_date
     'cust_pkg'  => [qw( 
-      pkgnum pkg pkg_label pkg_label_long
+      pkgnum pkg_label pkg_label_long
       location_label
       status statuscolor
     
@@ -376,6 +378,7 @@ sub substitutions {
       adjourn susp expire 
       labels_short
       ),
+      [ pkg               => sub { shift->part_pkg->pkg } ],
       [ cancel            => sub { shift->getfield('cancel') } ], # grrr...
       [ start_ymd         => sub { $ymd->(shift->getfield('start_date')) } ],
       [ setup_ymd         => sub { $ymd->(shift->getfield('setup')) } ],
@@ -400,6 +403,37 @@ sub substitutions {
       ),
       [ password          => sub { shift->getfield('_password') } ],
     ],
+    'svc_domain' => [qw(
+      svcnum
+      domain
+      ),
+      [ registrar         => sub {
+          my $registrar = qsearchs('registrar', 
+            { registrarnum => shift->registrarnum} );
+          $registrar ? $registrar->registrarname : ''
+        }
+      ],
+      [ catchall          => sub { 
+          my $svc_acct = qsearchs('svc_acct', { svcnum => shift->catchall });
+          $svc_acct ? $svc_acct->email : ''
+        }
+      ],
+    ],
+    'svc_phone' => [qw(
+      svcnum
+      phonenum
+      countrycode
+      domain
+      )
+    ],
+    'svc_broadband' => [qw(
+      svcnum
+      speed_up
+      speed_down
+      ip_addr
+      mac_addr
+      )
+    ],
     # for payment receipts
     'cust_pay' => [qw(
       paynum
index 13a0367..b53b7da 100644 (file)
@@ -122,19 +122,24 @@ tie my %options, 'Tie::IxHash', (
 );
 
 %info = (
-  'svc'      => [qw( svc_acct )], #others?
+  'svc'      => [qw( svc_acct svc_broadband svc_phone svc_domain )],
   'desc'     =>
-    'Create an RT ticket',
+  'Create an RT ticket',
   'options'  => \%options,
   'nodomain' => '',
-  'notes'    => <<'END'
-Create a ticket in RT.  The subject and body of the ticket 
-will be generated from a message template.
-END
+  'notes'    => ' 
+  Create a ticket in RT.  The subject and body of the ticket 
+  will be generated from a message template.'
 );
 
 sub _export_ticket {
   my( $self, $action, $svc ) = (shift, shift, shift);
+  my $conf = new FS::Conf;
+  die "rt_ticket export - no ticket system configured"
+    unless $conf->config('ticket_system');
+  
+  FS::TicketSystem->init();
+
   my $msgnum = $self->option($action.'_template');
   return if !$msgnum;
 
index be917d6..8e859e6 100644 (file)
@@ -101,6 +101,25 @@ my %substitutions = (
     '$password'       => 'Password',
     '$domain'         => 'Domain name',
   ],
+  'svc_domain' => [
+    '$svcnum'         => 'Service#',
+    '$domain'         => 'Domain name',
+    '$registrar'      => 'Registrar name',
+    '$catchall'       => 'Catchall email',
+  ],
+  'svc_phone' => [
+    '$svcnum'         => 'Service#',
+    '$phonenum'       => 'Phone number',
+    '$countrycode'    => 'Country code',
+    '$domain'         => 'Domain name'
+  ],
+  'svc_broadband' => [
+    '$svcnum'         => 'Service#',
+    '$ip_addr'        => 'IP address',
+    '$mac_addr'       => 'MAC address',
+    '$speed_up'       => 'Upstream speed',
+    '$speed_down'     => 'Downstream speed',
+  ],
   'cust_pay'  => [
     '$paynum'         => 'Payment#',
     '$paid'           => 'Amount',
@@ -124,6 +143,9 @@ tie my %sections, 'Tie::IxHash', (
 'cust_bill' => 'Invoice fields',
 'cust_pay'  => 'Payment fields',
 'svc_acct'  => 'Login service fields',
+'svc_domain'=> 'Domain service fields',
+'svc_phone' => 'Phone service fields',
+'svc_broadband' => 'Broadband service fields',
 );
 
 my $widget = new HTML::Widgets::SelectLayers(