-small svc_dsl UI and flow changes, RT7111
authorlevinse <levinse>
Tue, 7 Dec 2010 19:04:43 +0000 (19:04 +0000)
committerlevinse <levinse>
Tue, 7 Dec 2010 19:04:43 +0000 (19:04 +0000)
-finish basic qualifications, except prospect support, RT7111

14 files changed:
FS/FS/AccessRight.pm
FS/FS/Conf.pm
FS/FS/geocode_Mixin.pm
FS/FS/part_export/ikano.pm
FS/FS/qual.pm
httemplate/edit/process/qual.cgi
httemplate/edit/svc_dsl.cgi
httemplate/misc/qual.html
httemplate/search/qual.cgi [new file with mode: 0755]
httemplate/view/cust_main/packages.html
httemplate/view/cust_main/qual_link.html
httemplate/view/elements/svc_Common.html
httemplate/view/qual.cgi
httemplate/view/svc_dsl.cgi

index 8dbc22b..adb4a06 100644 (file)
@@ -143,6 +143,7 @@ tie my %rights, 'Tie::IxHash',
     'Add on-the-fly suspend reason', #NEW
     'Edit customer package invoice details', #NEW
     'Edit customer package comments', #NEW
+    'Qualify service', #NEW
   ],
   
   ###
index 08bdedd..f5b2451 100644 (file)
@@ -4067,6 +4067,13 @@ and customer address. Include units.',
     'description' => 'Default the "Continue recurring billing while suspended" flag to on for new package definitions.',
     'type'        => 'checkbox',
   },
+  
+  {
+    'key'         => 'qual-alt-address-format',
+    'section'     => 'UI',
+    'description' => 'Enable the alternate address format (location type, number, and kind) on qualifications',
+    'type'        => 'checkbox',
+  },
 
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
index d784b57..08e7b86 100644 (file)
@@ -88,7 +88,7 @@ sub location_label {
   my $prefix = $self->has_ship_address ? 'ship_' : '';
 
   my $notfirst = 0;
-  foreach (qw ( address1 address2 ) ) {
+  foreach (qw ( address1 address2 location_type location_number ) ) {
     my $method = "$prefix$_";
     $line .= ($notfirst ? $separator : ''). &$escape($self->$method)
       if $self->$method;
index d371582..d7203af 100644 (file)
@@ -324,6 +324,8 @@ sub qual_html {
                && $optionvalue ne '' );
     }
 
+    # XXX: eventually perhaps this should return both the packages a link to
+    # order each package and go to the svc prov with the prequal id filled in
     my $list = "<B>Qualifying Packages:</B><UL>";
     my @part_pkgs = qsearch( 'part_pkg', { 'disabled' => '' } );
     foreach my $part_pkg ( @part_pkgs ) {
index 4859b77..1bc3397 100644 (file)
@@ -127,6 +127,15 @@ sub check {
   $self->SUPER::check;
 }
 
+sub export {
+    my $self = shift;
+    if ( $self->exportnum ) {
+       return qsearchs('part_export', { exportnum => $self->exportnum } )
+               or die 'invalid exportnum';
+    }
+    '';
+}
+
 sub location {
     my $self = shift;
     if ( $self->locationnum ) {
index 78e8770..789834e 100644 (file)
@@ -16,7 +16,7 @@
 my $curuser = $FS::CurrentUser::CurrentUser;
 
 die "access denied"
-  unless $curuser->access_right('Order customer package'); # XXX: fix me
+  unless $curuser->access_right('Qualify service');
 
 $cgi->param('custnum') =~ /^(\d+)$/
   or die 'illegal custnum '. $cgi->param('custnum');
index 79aeb1a..7493d98 100644 (file)
@@ -92,11 +92,8 @@ my $new_cb = sub {
 
        my $export = @exports[0];               
        if($export->exporttype eq 'ikano') {
-           $cgi->param('vendor_qual_id') =~ /^(\d+)$/ 
-               or die 'unparsable vendor_qual_id';
-           my $vendor_qual_id = $1;
-
-           die "no start date set on customer package" if !$cust_pkg->start_date;
+           my $ddd = $cust_pkg->start_date;
+           $ddd = time unless $ddd;
 
            my @addl_fields = ( 
                { field => 'loop_type',
@@ -108,17 +105,15 @@ my $new_cb = sub {
                'password', 
                { field => 'isp_chg', type => 'checkbox', },
                'isp_prev',
-               { field => 'vendor_qual_id', 
-                 type => 'fixed', 
-                 value => $vendor_qual_id,  },
+               'vendor_qual_id',
                { field => 'vendor_order_type', 
                  type => 'hidden', 
                  value => 'NEW' },
                { field => 'desired_due_date',
                  type => 'fixed',
                  formatted_value => 
-                   time2str($date_format,$cust_pkg->start_date),
-                 value => $cust_pkg->start_date
+                   time2str($date_format,$ddd),
+                 value => $ddd
                },
            );
            push @fields, @addl_fields;
index 7796342..298b10a 100644 (file)
@@ -39,7 +39,7 @@
 <% include('/elements/tr-select-cust_location.html',
              'cgi'       => $cgi,
              'cust_main' => $cust_main,
-            'alt_format' => 1, # XXX: use a config option
+            'alt_format' => $conf->exists('qual-alt-address-format') ? 1 : 0,
             'is_optional' => 1,
             'no_bold' => 1,
           )
@@ -57,7 +57,7 @@
 my $curuser = $FS::CurrentUser::CurrentUser;
 
 die "access denied"
-  unless $curuser->access_right('Order customer package'); # XXX: fix this
+  unless $curuser->access_right('Qualify service'); 
 
 my $conf = new FS::Conf;
 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
diff --git a/httemplate/search/qual.cgi b/httemplate/search/qual.cgi
new file mode 100755 (executable)
index 0000000..58e0114
--- /dev/null
@@ -0,0 +1,78 @@
+<% include( 'elements/search.html',
+                 'title'         => 'Qualifications',
+                'name_singular' => 'qualification',
+                'query'         => { 'table'     => 'qual',
+                                     'hashref'   => $hashref,
+                                     'extra_sql' => $extra_sql,
+                                      'order_by'  => 'ORDER BY qualnum DESC',
+                                   },
+                'count_query'   => "$count_query $extra_sql",
+                'header'        => [ 'Qualification',
+                                     'Status',
+                                     'Customer or Prospect',
+                                     'Service Telephone Number',
+                                     'Address',
+                                     'Qualified Using',
+                                     'Vendor Qualification #',
+                                    ],
+                'align'         => 'rcccccc',
+                'fields'        => [ 'qualnum',
+                                     sub {
+                                       my $self = shift;
+                                       $self->status_long;
+                                     },
+                                     sub {
+                                         my $self = shift;
+                                         my $cust_or_prospect = $self->cust_or_prospect;
+                                         return $cust_or_prospect->name 
+                                           if $cust_or_prospect->get('custnum');
+                                         return "Prospect #".$cust_or_prospect->prospectnum
+                                           if $cust_or_prospect->get('prospectnum');
+                                         '';
+                                     },
+                                     'phonenum',
+                                     sub {
+                                       my $self = shift;
+                                       my %location_hash = $self->location;
+                                       # ugh...
+                                       if ( %location_hash ) {
+                                           my $loc = new FS::cust_location(\%location_hash); 
+                                           return $loc->location_label;
+                                       }
+                                       '';
+                                     },
+                                     sub {
+                                         my $self = shift;
+                                         my $export = $self->export;
+                                         my $result = '(manual)';
+                                         $result = $export->exportname if $export;
+                                         $result;
+                                     },
+                                     'vendor_qual_id',
+                                   ],
+                'links'         => [
+                                     [ "${p}view/qual.cgi?qualnum=", 'qualnum' ],
+                                     '',
+                                     '',
+                                     '',
+                                     '',
+                                     '',
+                                     '',
+                                   ],
+      )
+%>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Qualify service');
+
+my $hashref = {};
+my $count_query = 'SELECT COUNT(*) FROM qual';
+
+my $extra_sql = '';
+if ( $cgi->param('custnum') && $cgi->param('custnum') =~ /^(\d+)$/ ) {
+    $extra_sql = " where custnum = $1 or locationnum in "
+           . " (select locationnum from cust_location where custnum = $1)";
+}
+
+</%init>
index 04c47aa..ed4ca60 100755 (executable)
@@ -1,8 +1,9 @@
 % my $s = 0;
 
-% # XXX: add qual access right
+% if ( $curuser->access_right('Qualify service') ) { 
   <% $s++ ? ' | ' : '' %>
   <% include('qual_link.html', $cust_main) %>
+% }
 
 % if ( $curuser->access_right('Order customer package') ) { 
   <% $s++ ? ' | ' : '' %>
@@ -60,7 +61,11 @@ Current packages
 
     </TD>
     <TD ALIGN="right">
-      <A HREF="<%$p%>search/report_cust_pkg.html?custnum=<% $cust_main->custnum %>">Package reports</A><BR>
+      <A HREF="<%$p%>search/report_cust_pkg.html?custnum=<% $cust_main->custnum %>">Package reports</A>
+% if ( $curuser->access_right('Qualify service') ) { 
+    | <A HREF="<%$p%>search/qual.cgi?custnum=<% $cust_main->custnum %>">View Qualifications</A>
+% }
+      <BR>
       Service reports:
         <A HREF="<%$p%>search/report_svc_acct.html?custnum=<% $cust_main->custnum %>">accounts</A><BR>
       Usage reports:
index 077142c..b8dfaf9 100644 (file)
@@ -1,7 +1,7 @@
 <% include( '/elements/popup_link-cust_main.html',
               'action'      => $p. 'misc/qual.html',
-              'label'       => 'Service&nbsp;Qualification',
-              'actionlabel' => 'Service Qualification',
+              'label'       => 'New&nbsp;Qualification',
+              'actionlabel' => 'New Qualification',
               'color'       => '#333399',
               'cust_main'   => $cust_main,
               'closetext'   => 'Close',
index e3b8da4..de49b50 100644 (file)
@@ -53,11 +53,9 @@ Service #<B><% $svcnum %></B>
 % my $url = $opt{'edit_url'} || $p. 'edit/'. $opt{'table'}. '.cgi?';
 | <A HREF="<%$url%><%$svcnum%>">Edit this <% $label %></A>
 
-% unless ( $opt{'disable_unprovision'} ) {
 | <A HREF="javascript:areyousure('<%$p.'misc/unprovision.cgi?'.$svcnum%>')">
 Unprovision this Service</A>
 <BR>
-% }
 
 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
 
index f967269..ebdc5cf 100644 (file)
@@ -1,6 +1,6 @@
 <% include("/elements/header.html","View Qualification") %>
 
-% if ( $cust_or_prospect->custnum ) {
+% if ( $cust_or_prospect->get('custnum') ) {
 
   <% include( '/elements/small_custview.html', $cust_or_prospect->custnum, '', 1,
      "${p}view/cust_main.cgi") %>
@@ -28,7 +28,8 @@
 
 <%init>
 
-# XXX: add access right for quals?
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Qualify service');
 
 my $qualnum;
 if ( $cgi->param('qualnum') ) {
@@ -48,18 +49,12 @@ if ( %location_hash ) {
     $cust_location = new FS::cust_location(\%location_hash);
     $location_line = $cust_location->location_label;
 }
-# XXX: geocode_Mixin location_label doesn't currently have the new cust_location fields - add them
 
 my $location_kind;
-$location_kind = "Residential" if $cust_location->location_kind eq 'R';
-$location_kind = "Business" if $cust_location->location_kind eq 'B';
+$location_kind = "Residential" if $cust_location->get('location_kind') eq 'R';
+$location_kind = "Business" if $cust_location->get('location_kind') eq 'B';
 
 my $cust_or_prospect = $qual->cust_or_prospect;
-
-my $export;
-if ( $qual->exportnum ) {
-    $export = qsearchs('part_export', { exportnum => $qual->exportnum } )
-               or die 'invalid exportnum';
-}
+my $export = $qual->export;
 
 </%init>
index 7bbdca1..ade1350 100644 (file)
@@ -36,7 +36,6 @@ my $svc_cb = sub {
     return if ( scalar(@exports) == 0 );
 
     my $export = @exports[0];
-    $opt->{'disable_unprovision'} = 1;
 
     @fields = ( 'phonenum',
            { field => 'loop_type',