From 81978af92ecdaaefeff5156d9ab3b4f99586df1c Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Tue, 3 Jul 2012 18:51:51 -0700 Subject: [PATCH 1/1] quotations, RT#16996 --- FS/FS/AccessRight.pm | 1 + FS/FS/Conf.pm | 26 +- FS/FS/Schema.pm | 46 +- FS/FS/Template_Mixin.pm | 2525 +++++++++++++++++++++ FS/FS/Upgrade.pm | 8 +- FS/FS/access_right.pm | 1 + FS/FS/cust_bill.pm | 2731 ++--------------------- FS/FS/cust_main.pm | 2 +- FS/FS/prospect_main.pm | 17 +- FS/FS/quotation.pm | 20 +- FS/MANIFEST | 8 + conf/quotation_html | 266 +++ conf/quotation_latex | 362 +++ conf/quotation_latexnotes | 8 + httemplate/edit/process/quotation.html | 2 +- httemplate/edit/quotation.html | 15 + httemplate/elements/tr-fixed-cust_main.html | 15 + httemplate/elements/tr-fixed-date.html | 13 + httemplate/elements/tr-fixed-prospect_main.html | 15 + httemplate/view/prospect_main.html | 31 + httemplate/view/quotation.html | 25 +- 21 files changed, 3518 insertions(+), 2619 deletions(-) create mode 100644 FS/FS/Template_Mixin.pm create mode 100644 conf/quotation_html create mode 100644 conf/quotation_latex create mode 100644 conf/quotation_latexnotes create mode 100644 httemplate/elements/tr-fixed-cust_main.html create mode 100644 httemplate/elements/tr-fixed-date.html create mode 100644 httemplate/elements/tr-fixed-prospect_main.html diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index eb9974adf..4de29481d 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -98,6 +98,7 @@ tie my %rights, 'Tie::IxHash', #'New contact', #'View customer contacts', #'List contacts', + 'Generate quotation', ], ### diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 8c9d56fef..7e641308b 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1197,7 +1197,15 @@ sub reason_type_options { { 'key' => 'invoice_html', 'section' => 'invoicing', - 'description' => 'Optional HTML template for invoices. See the billing documentation for details.', + 'description' => 'HTML template for invoices. See the billing documentation for details.', + + 'type' => 'textarea', + }, + + { + 'key' => 'quotation_html', + 'section' => '', + 'description' => 'HTML template for quotations.', 'type' => 'textarea', }, @@ -1245,6 +1253,13 @@ sub reason_type_options { }, { + 'key' => 'quotation_latex', + 'section' => '', + 'description' => 'LaTeX template for typeset PostScript quotations.', + 'type' => 'textarea', + }, + + { 'key' => 'invoice_latextopmargin', 'section' => 'invoicing', 'description' => 'Optional LaTeX invoice topmargin setting. Include units.', @@ -1303,6 +1318,15 @@ and customer address. Include units.', }, { + 'key' => 'quotation_latexnotes', + 'section' => '', + 'description' => 'Notes section for LaTeX typeset PostScript quotations.', + 'type' => 'textarea', + 'per_agent' => 1, + 'per_locale' => 1, + }, + + { 'key' => 'invoice_latexfooter', 'section' => 'invoicing', 'description' => 'Footer for LaTeX typeset PostScript invoices.', diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index a90c73a95..797b70549 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1054,8 +1054,50 @@ sub tables_hashref { 'index' => [ [ 'company' ], [ 'agentnum' ], [ 'disabled' ] ], }, - #eventually use for billing & ship from cust_main too - #for now, just cust_pkg locations + 'quotation' => { + 'columns' => [ + #regular fields + 'quotationnum', 'serial', '', '', '', '', + 'prospectnum', 'int', 'NULL', '', '', '', + 'custnum', 'int', 'NULL', '', '', '', + '_date', @date_type, '', '', + 'disabled', 'char', 'NULL', 1, '', '', + 'usernum', 'int', 'NULL', '', '', '', + #'total', @money_type, '', '', + #'quotation_term', 'varchar', 'NULL', $char_d, '', '', + ], + 'primary_key' => 'quotationnum', + 'unique' => [], + 'index' => [ [ 'prospectnum' ], ['custnum'], ], + }, + + 'quotation_pkg' => { + 'columns' => [ + 'quotationpkgnum', 'serial', '', '', '', '', + 'pkgpart', 'int', '', '', '', '', + 'locationnum', 'int', 'NULL', '', '', '', + 'start_date', @date_type, '', '', + 'contract_end', @date_type, '', '', + 'quantity', 'int', 'NULL', '', '', '', + 'waive_setup', 'char', 'NULL', 1, '', '', + ], + 'primary_key' => 'quotationpkgnum', + 'unique' => [], + 'index' => [ ['pkgpart'], ], + }, + + 'quotation_pkg_discount' => { + 'columns' => [ + 'quotationpkgdiscountnum', 'serial', '', '', '', '', + 'quotationpkgnum', 'int', '', '', '', '', + 'discountnum', 'int', '', '', '', '', + #'end_date', @date_type, '', '', + ], + 'primary_key' => 'quotationpkgdiscountnum', + 'unique' => [], + 'index' => [ [ 'quotationpkgnum' ], ], #[ 'discountnum' ] ], + }, + 'cust_location' => { #'location' now that its prospects too, but... 'columns' => [ 'locationnum', 'serial', '', '', '', '', diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm new file mode 100644 index 000000000..19b452e3b --- /dev/null +++ b/FS/FS/Template_Mixin.pm @@ -0,0 +1,2525 @@ +package FS::Template_Mixin; + +use strict; +use vars qw( $DEBUG $me + $money_char $date_format $rdate_format $date_format_long ); + # but NOT $conf +use vars qw( $invoice_lines @buf ); #yuck +use List::Util qw(sum); +use Date::Format; +use Date::Language; +use Text::Template 1.20; +use File::Temp 0.14; +use HTML::Entities; +use Locale::Country; +use FS::UID; +use FS::Record qw( qsearch qsearchs ); +use FS::Misc qw( generate_ps generate_pdf ); +use FS::pkg_category; +use FS::pkg_class; +use FS::L10N; + +$DEBUG = 0; +$me = '[FS::Template_Mixin]'; +FS::UID->install_callback( sub { + my $conf = new FS::Conf; #global + $money_char = $conf->config('money_char') || '$'; + $date_format = $conf->config('date_format') || '%x'; #/YY + $rdate_format = $conf->config('date_format') || '%m/%d/%Y'; #/YYYY + $date_format_long = $conf->config('date_format_long') || '%b %o, %Y'; +} ); + +=item print_text HASHREF | [ TIME [ , TEMPLATE [ , OPTION => VALUE ... ] ] ] + +Returns an text invoice, as a list of lines. + +Options can be passed as a hashref (recommended) or as a list of time, template +and then any key/value pairs for any other options. + +I