[freeside-commits] branch master updated. ce200f25b9d4eebeddac0e8a9a58dbab6a54645b

Ivan ivan at 420.am
Thu Nov 6 16:49:35 PST 2014


The branch, master has been updated
       via  ce200f25b9d4eebeddac0e8a9a58dbab6a54645b (commit)
       via  b6538b4641f900da4892d8c44292befb71188822 (commit)
      from  67cef14ba963b2dab906d5e67095c8d1d3de43b5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ce200f25b9d4eebeddac0e8a9a58dbab6a54645b
Merge: b6538b4 67cef14
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Nov 6 16:49:30 2014 -0800

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit b6538b4641f900da4892d8c44292befb71188822
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Nov 6 16:48:16 2014 -0800

    delete packages from quotations, RT#30313

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index ce7efca..f70ac3c 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -220,26 +220,82 @@ Internal method - returns a filled-in template for this invoice as a scalar.
 
 See print_ps and print_pdf for methods that return PostScript and PDF output.
 
-Non optional options include 
-  format - latex, html, template
+Required options
 
-Optional options include
+=over 4
 
-template - a value used as a suffix for a configuration template.  Please 
-don't use this.
+=item format
 
-time - a value used to control the printing of overdue messages.  The
+The B<format> option is required and should be set to html, latex (print and PDF) or template (plaintext).
+
+=back
+
+Additional options
+
+=over 4
+
+=item notice_name
+
+Overrides "Invoice" as the name of the sent document.
+
+=item today
+
+Used to control the printing of overdue messages.  The
 default is now.  It isn't the date of the invoice; that's the `_date' field.
 It is specified as a UNIX timestamp; see L<perlfunc/"time">.  Also see
 L<Time::Local> and L<Date::Parse> for conversion functions.
 
-cid - 
+=item logo_file
+
+Logo file (path to temporary EPS file on the local filesystem)
+
+=item cid
+
+CID for inline (emailed) images (logo)
+
+=item locale
+
+Override customer's locale
+
+=item unsquelch_cdr
+
+Overrides any per customer cdr squelching when true
+
+=item no_number
 
-unsquelch_cdr - overrides any per customer cdr squelching when true
+Supress the (invoice, quotation, statement, etc.) number
 
-notice_name - overrides "Invoice" as the name of the sent document (templates from 10/2009 or newer required)
+=item no_date
 
-locale - override customer's locale
+Supress the date
+
+=item no_coupon
+
+Supress the payment coupon
+
+=item barcode_file
+
+Barcode file (path to temporary EPS file on the local filesystem)
+
+=item barcode_img
+
+Flag indicating the barcode image should be a link (normal HTML dipaly)
+
+=item barcode_cid
+
+Barcode CID for inline (emailed) images
+
+=item preref_callback
+
+Coderef run for each line item, code should return HTML to be displayed
+before that line item (quotations only)
+
+=item template
+
+Dprecated.  Used as a suffix for a configuration template.  Please 
+don't use this, it deprecated in favor of more flexible alternatives.
+
+=back
 
 =cut
 
@@ -1106,6 +1162,7 @@ sub print_generic {
     $options{'summary_page'} = $summarypage;
     $options{'skip_usage'} =
       scalar(@$extra_sections) && !grep{$section == $_} @$extra_sections;
+    $options{'preref_callback'} = $params{'preref_callback'};
 
     warn "$me   searching for line items\n"
       if $DEBUG > 1;
@@ -1113,7 +1170,8 @@ sub print_generic {
     foreach my $line_item ( $self->_items_pkg(%options),
                             $self->_items_fee(%options) ) {
 
-      warn "$me     adding line item $line_item\n"
+      warn "$me     adding line item ".
+           join(', ', map "$_=>".$line_item->{$_}, keys %$line_item). "\n"
         if $DEBUG > 1;
 
       $line_item->{'ref'} = $line_item->{'pkgnum'};
@@ -2541,6 +2599,9 @@ location (whichever is defined).
 multisection: a flag indicating that this is a multisection invoice,
 which does something complicated.
 
+preref_callback: coderef run for each line item, code should return HTML to be
+displayed before that line item (quotations only)
+
 Returns a list of hashrefs, each of which may contain:
 
 pkgnum, description, amount, unit_amount, quantity, pkgpart, _is_setup, and 
@@ -2661,12 +2722,18 @@ sub _items_cust_bill_pkg {
             || $discount_show_always
             || $cust_bill_pkg->recur_show_zero;
           push @b, {
+            'pkgnum'      => $cust_bill_pkg->pkgpart, #so it displays in Ref
             'description' => $description,
             'amount'      => sprintf("%.2f", $cust_bill_pkg->setup),
+            'preref_html' => ( $opt{preref_callback}
+                                 ? &{ $opt{preref_callback} }( $cust_bill_pkg )
+                                 : ''
+                             ),
           };
         }
         if ( $cust_bill_pkg->recur != 0 ) {
           push @b, {
+            'pkgnum'      => $cust_bill_pkg->pkgpart, #so it displays in Ref
             'description' => "$desc (". $cust_bill_pkg->part_pkg->freq_pretty.")",
             'amount'      => sprintf("%.2f", $cust_bill_pkg->recur),
           };
diff --git a/conf/quotation_html b/conf/quotation_html
index 68d373f..5458774 100644
--- a/conf/quotation_html
+++ b/conf/quotation_html
@@ -155,7 +155,11 @@
               $OUT .=  ( ($line->{'ref'} && $line->{'ref'} ne $lastref) ? '' : '_more' ).
                        '">'.
                        '<td align="center">'. 
-                       ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ). '</td>'.
+                         ( $line->{'ref'} ne $lastref
+                             ? $line->{'preref_html'}. $line->{'ref'}
+                             : ''
+                         ).
+                       '</td>'.
                        '<td align="left">'. $line->{'description'}. '</td>'.
                        ( $unitprices 
                            ? '<td align="left">'. $line->{'unit_amount'}. '</td>'.
diff --git a/httemplate/misc/delete-quotation_pkg.html b/httemplate/misc/delete-quotation_pkg.html
new file mode 100644
index 0000000..5a44d37
--- /dev/null
+++ b/httemplate/misc/delete-quotation_pkg.html
@@ -0,0 +1,21 @@
+% if ( $error ) {
+%   errorpage($error);
+% } else {
+<% $cgi->redirect($p. "view/quotation.html?". $quotationnum) %>
+% }
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Generate quotation'); #separate ACL for editing it later?  too silly for us yet
+
+#untaint quotationpkgnum
+my($query) = $cgi->keywords;
+$query =~ /^(\d+)$/ or die "Illegal quotationpkgnum";
+my $quotationpkgnum = $1;
+
+my $quotation_pkg = qsearchs('quotation_pkg',{'quotationpkgnum'=>$quotationpkgnum});
+my $quotationnum = $quotation_pkg->quotationnum;
+
+my $error = $quotation_pkg->delete;
+
+</%init>
diff --git a/httemplate/view/quotation.html b/httemplate/view/quotation.html
index a88acf8..ae9c4aa 100755
--- a/httemplate/view/quotation.html
+++ b/httemplate/view/quotation.html
@@ -1,5 +1,12 @@
 <& /elements/header.html, mt('Quotation View'), $menubar &>
 
+<SCRIPT TYPE="text/javascript">
+function areyousure(href, message) {
+  if (confirm(message) == true)
+    window.location.href = href;
+}
+</SCRIPT>
+
 %#XXX link to order...
 
 <%doc>
@@ -38,7 +45,7 @@ XXX resending quotations
 % } 
 
 % if ( $conf->exists('quotation_html') ) { 
-    <% join('', $quotation->print_html() ) %>
+    <% join('', $quotation->print_html( preref_callback=>$preref_callback )) %>
 % } else { 
 %   die "quotation_html config missing";
 % }
@@ -87,5 +94,17 @@ my $link = "quotationnum=$quotationnum";
 #$link .= ';template='. uri_escape($template) if $template;
 #$link .= ';notice_name='. $notice_name if $notice_name;
 
+my $preref_callback = sub {
+  areyousure_link("${p}misc/delete-quotation_pkg.html?". shift->quotationpkgnum,
+                  emt('Are you sure you want to remove this package from the quotation?'),
+                  emt('Remove this package'), #tooltip
+                  qq(<img src="${p}images/cross.png">), #link
+                 );
+};
+
+sub areyousure_link {
+    my ($url,$msg,$title,$label) = (shift,shift,shift,shift);
+    '<A HREF="javascript:areyousure(\''.$url.'\',\''.$msg.'\')" TITLE="'.$title.'">'.$label.'</A>';
+}
 
 </%init>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Template_Mixin.pm                   |   89 +++++++++++++++++++++++++----
 conf/quotation_html                       |    6 +-
 httemplate/misc/delete-quotation_pkg.html |   21 +++++++
 httemplate/view/quotation.html            |   21 ++++++-
 4 files changed, 124 insertions(+), 13 deletions(-)
 create mode 100644 httemplate/misc/delete-quotation_pkg.html




More information about the freeside-commits mailing list