continue sales person work: customer and package selection, commissions, reporting...
authorIvan Kohler <ivan@freeside.biz>
Sun, 18 Aug 2013 21:36:08 +0000 (14:36 -0700)
committerIvan Kohler <ivan@freeside.biz>
Sun, 18 Aug 2013 21:36:08 +0000 (14:36 -0700)
FS/FS/cust_pkg.pm
httemplate/misc/change_pkg.cgi
httemplate/misc/order_pkg.html

index 676757e..dedc637 100644 (file)
@@ -1840,6 +1840,7 @@ sub change {
       $hash{$date} = $self->getfield($date);
     }
   }
+
   # allow $opt->{'locationnum'} = '' to specifically set it to null
   # (i.e. customer default location)
   $opt->{'locationnum'} = $self->locationnum if !exists($opt->{'locationnum'});
@@ -1864,7 +1865,6 @@ sub change {
   }
 
   $hash{'contactnum'} = $opt->{'contactnum'} if $opt->{'contactnum'};
-  $hash{'quantity'} = $opt->{'quantity'} || $self->quantity;
 
   my $cust_pkg;
   if ( $opt->{'cust_pkg'} ) {
@@ -1881,10 +1881,11 @@ sub change {
   } else {
     # Create the new package.
     $cust_pkg = new FS::cust_pkg {
-      custnum        => $custnum,
-      pkgpart        => ( $opt->{'pkgpart'}     || $self->pkgpart      ),
-      refnum         => ( $opt->{'refnum'}      || $self->refnum       ),
-      locationnum    => ( $opt->{'locationnum'}                        ),
+      custnum     => $custnum,
+      locationnum => $opt->{'locationnum'},
+      ( map {  $_ => ( $opt->{$_} || $self->$_() )  }
+          qw( pkgpart quantity refnum salesnum )
+      ),
       %hash,
     };
     $error = $cust_pkg->insert( 'change' => 1,
@@ -2177,14 +2178,17 @@ sub change_later {
 
   return '' unless $new_pkgpart or $new_locationnum or $new_quantity; # wouldn't do anything
 
-  my %hash = (
-    'custnum'     => $self->custnum,
-    'pkgpart'     => ($opt->{'pkgpart'}     || $self->pkgpart),
-    'locationnum' => ($opt->{'locationnum'} || $self->locationnum),
-    'quantity'    => ($opt->{'quantity'}    || $self->quantity),
-    'start_date'  => $date,
-  );
-  my $new = FS::cust_pkg->new(\%hash);
+  # allow $opt->{'locationnum'} = '' to specifically set it to null
+  # (i.e. customer default location)
+  $opt->{'locationnum'} = $self->locationnum if !exists($opt->{'locationnum'});
+
+  my $new = FS::cust_pkg->new( {
+    custnum     => $self->custnum,
+    locationnum => $opt->{'locationnum'},
+    start_date  => $date,
+    map   {  $_ => ( $opt->{$_} || $self->$_() )  }
+      qw( pkgpart quantity refnum salesnum )
+  } );
   $error = $new->insert('change' => 1, 
                         'allow_pkgpart' => ($new_pkgpart ? 0 : 1));
   if ( !$error ) {
index 923be71..887fa01 100755 (executable)
@@ -6,12 +6,14 @@
 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/change-cust_pkg.html" METHOD=POST>
 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
 
+
+<FONT CLASS="fsinnerbox-title"><% mt('Package') |h %></FONT>
 <% ntable('#cccccc') %>
 
   <TR>
     <TH ALIGN="right"><% mt('Current package') |h %></TH>
     <TD COLSPAN=7>
-      <% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %>
+      <FONT STYLE="background-color:#e8e8e8"><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %></FONT>
     </TD>
   </TR>
 
                'curr_value' => $cust_pkg->quantity
   &>
 
-  <& /elements/tr-select-cust_location.html,
-               'cgi'       => $cgi,
-               'cust_main' => $cust_main,
-  &>
-
 </TABLE>
+<BR>
+
+
+<FONT CLASS="fsinnerbox-title"><% mt('Change') |h %></FONT>
+<% ntable('#cccccc') %>
 
-<TABLE>
   <TR>
-    <TD> Apply this change: </TD>
+<!--    <TD> Apply this change: </TD> -->
     <TD> <INPUT TYPE="radio" NAME="delay" VALUE="0" \
-          <% !$cgi->param('delay') ? 'CHECKED' : '' %>> now </TD>
+          <% !$cgi->param('delay') ? 'CHECKED' : '' %>> Now </TD>
     <TD> <INPUT TYPE="radio" NAME="delay" VALUE="1" \
-          <% $cgi->param('delay')  ? 'CHECKED' : '' %>> in the future
+          <% $cgi->param('delay')  ? 'CHECKED' : '' %>> In the future
       <& /elements/input-date-field.html, {
-  'name'  => 'start_date',
-  'value' => ($cgi->param('start_date') || $cust_main->next_bill_date),
+          'name'  => 'start_date',
+          'value' => ($cgi->param('start_date') || $cust_main->next_bill_date),
       } &>
     </TD>
   </TR>
 </TABLE>
+</BR>
+
+
+<FONT CLASS="fsinnerbox-title"><% mt('Location') |h %></FONT>
+<% ntable('#cccccc') %>
+
+  <& /elements/tr-select-cust_location.html,
+               'cgi'       => $cgi,
+               'cust_main' => $cust_main,
+  &>
+
+</TABLE>
+<BR>
+
 
 <& /elements/standardize_locations.html,
             'form'       => "OrderPkgForm",
             'callback'   => 'document.OrderPkgForm.submit();',
 &>
 
-<BR>
 <INPUT NAME    = "submitButton"
        TYPE    = "button"
        VALUE   = "<% mt("Change package") |h %>"
index 0573468..febe427 100644 (file)
@@ -33,7 +33,7 @@
   <FONT CLASS="fsinnerbox-title"><% mt('Sales') |h %></FONT>
 % }
 % if ( $show_sales_table ) {
-  <% ntable("#cccccc", 2) %>
+  <% ntable("#cccccc") %>
 % }
 
 <& /elements/tr-select-sales.html,
@@ -55,7 +55,7 @@
 % }
 
 <FONT CLASS="fsinnerbox-title"><% mt('Package') |h %></FONT>
-<% ntable("#cccccc", 2) %>
+<% ntable("#cccccc") %>
 
 % if ( $part_pkg ) {
     <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>">
 %
 % if ( $discount_cust_pkg || $waive_setup_fee ) {
   <FONT CLASS="fsinnerbox-title"><% mt('Discounting') |h %></FONT>
-  <% ntable("#cccccc", 2) %>
+  <% ntable("#cccccc") %>
 
 %   if ( $waive_setup_fee ) {
       <TR>
 % my $contact_title = $lock_locationnum ? 'Contact'
 %                                       : 'Contact and Location';
 <FONT CLASS="fsinnerbox-title"><% mt($contact_title) |h %></FONT>
-<% ntable("#cccccc", 2) %>
+<% ntable("#cccccc") %>
 
 <& /elements/tr-select-contact.html,
              'cgi'           => $cgi,