diff options
Diffstat (limited to 'httemplate/edit')
-rw-r--r-- | httemplate/edit/cable_provider.html | 20 | ||||
-rw-r--r-- | httemplate/edit/cust_main/bottomfixup.js | 21 | ||||
-rw-r--r-- | httemplate/edit/cust_main/top_misc.html | 7 | ||||
-rw-r--r-- | httemplate/edit/elements/edit.html | 1 | ||||
-rw-r--r-- | httemplate/edit/invoice_conf.html | 296 | ||||
-rw-r--r-- | httemplate/edit/process/cable_provider.html | 10 | ||||
-rw-r--r-- | httemplate/edit/process/invoice_conf.html | 21 |
7 files changed, 366 insertions, 10 deletions
diff --git a/httemplate/edit/cable_provider.html b/httemplate/edit/cable_provider.html new file mode 100644 index 000000000..9a911ccfa --- /dev/null +++ b/httemplate/edit/cable_provider.html @@ -0,0 +1,20 @@ +<& elements/edit.html, + 'name_singular' => 'Provider', + 'table' => 'cable_provider', + 'fields' => [ + 'provider', + { field=>'disabled', type=>'checkbox', value=>'Y', }, + ], + 'labels' => { + 'providernum' => 'Provider', + 'provider' => 'Provider', + 'disabled' => 'Disabled', + }, + 'viewall_dir' => 'browse', +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/cust_main/bottomfixup.js b/httemplate/edit/cust_main/bottomfixup.js index 9e18fa0df..ecfcb3cbc 100644 --- a/httemplate/edit/cust_main/bottomfixup.js +++ b/httemplate/edit/cust_main/bottomfixup.js @@ -10,17 +10,20 @@ my @fixups = ('copy_payby_fields', 'standardize_locations'); push @fixups, 'confirm_censustract' if $conf->exists('cust_main-require_censustract'); -# currently doesn't work; disable to avoid problems -#push @fixups, 'check_unique' -# if $conf->exists('cust_main-check_unique') and !$opt{'custnum'}; +my $uniqueness = $conf->config('cust_main-check_unique'); +push @fixups, 'check_unique' + if $uniqueness and !$opt{'custnum'}; push @fixups, 'do_submit'; # always last </%init> - var fixups = <% encode_json(\@fixups) %>; var fixup_position; var running = false; +<&| /elements/onload.js &> +submit_abort(); +</&> + %# state machine to deal with all the asynchronous stuff we're doing %# call this after each fixup on success: function submit_continue() { @@ -132,10 +135,14 @@ function set_censustract(tract, year) { } function check_unique() { - var search_hash = new Object; -% foreach ($conf->config('cust_main-check_unique')) { - search_hash['<% $_ %>'] = document.CustomerForm.elements['<% $_ %>'].value; + var search_hash = {}; +% if ($uniqueness eq 'address') { + search_hash['address'] = [ + document.CustomerForm.elements['bill_address1'].value, + document.CustomerForm.elements['ship_address1'].value + ]; % } +%# no other options yet %# supported in IE8+, Firefox 3.5+, WebKit, Opera 10.5+ duplicates_form(JSON.stringify(search_hash), confirm_unique); diff --git a/httemplate/edit/cust_main/top_misc.html b/httemplate/edit/cust_main/top_misc.html index ebd9b927c..e25506f52 100644 --- a/httemplate/edit/cust_main/top_misc.html +++ b/httemplate/edit/cust_main/top_misc.html @@ -154,9 +154,10 @@ % } else { - <& /elements/tr-select-part_referral.html, - 'curr_value' => $refnum - &> + <& /elements/tr-select-part_referral.html, + 'curr_value' => $refnum, + 'label' => "<B>${r}".emt('Advertising source')."</B>" + &> % } diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 060281115..6c965326b 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -338,6 +338,7 @@ Example: % qw( width height config ), #htmlarea % qw( alt_format ), #select-cust_location % qw( classnum ), # select-inventory_item +% qw( aligned ), # columnstart % ; % % #select-table diff --git a/httemplate/edit/invoice_conf.html b/httemplate/edit/invoice_conf.html new file mode 100644 index 000000000..b7b3a4ebc --- /dev/null +++ b/httemplate/edit/invoice_conf.html @@ -0,0 +1,296 @@ +<& elements/edit.html, + 'body_etc' => $body_etc, + 'name_singular' => 'invoice configuration', + 'table' => 'invoice_conf', + 'viewall_dir' => 'browse', + 'fields' => \@fields, + 'labels' => \%labels, + 'new_callback' => \&new_callback, + 'edit_callback' => \&edit_callback, + 'error_callback' => \&error_callback, + 'html_init' => \&html_init, + 'html_table_bottom' => \&html_table_bottom, + 'html_bottom' => '</DIV>', # close tablebreak-tabs +&> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +# ??? +die "access denied" + unless $curuser->access_right([ 'Edit templates', 'Edit global templates' ]); + +my $body_etc = ''; +$body_etc = q!onload="document.getElementById('locale').onchange()"! + if $cgi->param('locale') eq 'new'; + +my $modenum = $cgi->param('modenum'); +my $mode = $modenum ? qsearchs('invoice_mode', { modenum => $modenum }) : ''; + +my %textarea = (type => 'textarea', rows => 10, cols => 40); +my @fields = ( + { field => 'modenum', type => 'hidden' }, + { field => 'agentnum', + type => 'select-agent', + }, + { field => 'modename', size=>60, }, + { type => 'tablebreak-tabs', + include_opt_callback => \&menubar_opt_callback, + }, + { field => 'locale', type => 'hidden' }, + { field => 'notice_name', size=>60, }, + { field => 'subject', size=>60, }, + { field => 'lpr', size=>60, }, + + { type => 'columnstart', aligned => 1 }, + { type => 'title', value => '<BR>' }, + map ( { +{ type => 'justtitle', value => $_ } } + 'Notes', + 'Footer', + 'Summary header', + 'Return address', + 'Coupon', + 'Small footer', + 'Top margin', + 'Header separation', + 'Address separation', + 'Text height', + 'Coupon height', + 'Footer separation', + ), + + { type => 'columnnext' }, + { type => 'title', value => 'LaTeX' }, + { field => 'latexnotes', %textarea }, + { field => 'latexfooter', %textarea }, + { field => 'latexsummary', %textarea }, + { field => 'latexreturnaddress', %textarea }, + { field => 'latexcoupon', %textarea }, + { field => 'latexsmallfooter', %textarea }, + { field => 'latextopmargin', size => 16 }, + { field => 'latexheadsep', size => 16 }, + { field => 'latexaddresssep', size => 16 }, + { field => 'latextextheight', size => 16 }, + { field => 'latexextracouponspace', size => 16 }, + { field => 'latexcouponfootsep', size => 16 }, + # are these still used? + #{ field => 'latexcouponamountenclosedsep', size => 16 }, + #{ field => 'latexverticalreturnaddress', type => 'checkbox' }, + #{ field => 'latexcouponaddcompanytoaddress',type => 'checkbox' }, + # logo -- implement if someone really needs it... + + { type => 'columnnext' }, + { type => 'title', value => 'HTML' }, + { field => 'htmlnotes', %textarea }, #htmlarea? + { field => 'htmlfooter', %textarea }, + { field => 'htmlsummary', %textarea }, + { field => 'htmlreturnaddress', %textarea }, + # logo + + { type => 'columnend' }, +); + +my %labels = ( + 'confnum' => 'Configuration', + 'locale' => 'Locale', + 'agentnum' => 'Agent', + 'modename' => 'Mode name', + 'notice_name' => 'Notice name', + 'subject' => 'Email Subject: header', + 'lpr' => 'Alternate lpr command', + + map { $_ => '' } (qw( + latexnotes + latexfooter + latexsummary + latexreturnaddress + latexcoupon + latexsmallfooter + latextopmargin + latexheadsep + latexaddresssep + latextextheight + latexextracouponspace + latexcouponfootsep + htmlnotes + htmlfooter + htmlsummary + htmlreturnaddress + logo_png + logo_eps + ) ), + +); + +sub get_invoice_mode { # because we can't quite use agent_virt here + my $modenum = shift; + qsearchs({ + 'table' => 'invoice_mode', + 'hashref' => { 'modenum' => $modenum }, + 'extra_sql' => ' AND '. + $FS::CurrentUser::CurrentUser->agentnums_sql( + 'null_right' => 'Edit global templates', + 'viewall_right' => 'Edit global templates' ), + }); +}; + +sub error_callback { + my ($cgi, $object) = @_; + foreach (qw(modename agentnum)) { + $object->set($_, $cgi->param($_)); + } + if ($object->confnum) { + return edit_callback(@_); + } else { + return new_callback(@_); + } +} + +sub new_callback { + my ($cgi, $object, $fields_arrayref, $opt_hashref) = @_; + my $modenum; + if ( $cgi->param('locale') =~ /^(\w+)$/ ) { + $object->set('locale' => $1); + } + + if ( $cgi->param('modenum') =~ /^(\d+)$/ ) { + $modenum = $1; # we're adding a locale to an existing mode + $object->set('modenum' => $modenum); + my $invoice_mode = get_invoice_mode($modenum) + or die "invoice mode $modenum not found"; + + $object->set('modename', $invoice_mode->modename); + $object->set('agentnum', $invoice_mode->agentnum); + + # also, need to select a locale + # make a list of available locales + my %existing_locales = map { $_->locale } + qsearch('invoice_conf', { modenum => $modenum }); + + my @locales = grep { !exists($existing_locales{$_}) } + FS::Conf->new->config('available-locales'); + my %labels; + foreach (@locales) { + my %info = FS::Locales->locale_info($_); + $labels{$_} = $info{'label'}; + } + unshift @locales, 'new'; + $labels{'new'} = 'Select language'; + + # insert a field def + my $i = 0; + $i++ until ( $fields_arrayref->[$i]->{'field'} eq 'locale' ); + my $locale_field = $fields_arrayref->[$i]; + + my $onchange_locale = "document.getElementById('submit').disabled = + (this.options[this.selectedIndex].value == 'new');"; + + %$locale_field = ( + field => 'locale', + type => 'select', + options => \@locales, + labels => \%labels, + curr_value => 'new', + onchange => $onchange_locale, + ); + + } # otherwise it's a completely new mode, so the locale is default + +} + +sub edit_callback { + # massive false laziness with msg_template UI + my ($cgi, $object, $fields_arrayref, $opt_hashref) = @_; + + # a little different here in that we treat the content object + # as "primary" (this is edit/invoice_conf.html, etc.) + # so all we need from the invoice_mode is its name + # (and agent identity) + my $modenum = $object->modenum; + my $invoice_mode = get_invoice_mode($modenum) + or die "invoice mode $modenum not found"; + $object->set('modename', $invoice_mode->modename); + $object->set('agentnum', $invoice_mode->agentnum); + +} + +sub menubar_opt_callback { + my $object = shift; + my $modenum = $object->modenum or return; + my (@tabs, @options, %labels); + my $display_new = 0; + my $selected = ''; + foreach my $l ('', FS::Conf->new->config('available-locales')) { + my $invoice_conf = + qsearchs('invoice_conf', { modenum => $modenum, locale => $l }); + if ( $invoice_conf ) { + my %info = FS::Locales->locale_info($l) if $l; + my $label = $info{'label'} || mt('Default'); + push @tabs, $label, $invoice_conf->confnum; + $selected = $label if $object->locale eq $l; + } + else { + $display_new = 1; # there is at least one unused locale left + } + } + push @tabs, mt('New'), "modenum=$modenum;locale=new" if $display_new; + $selected = mt('New') if $object->locale eq 'new'; + $selected ||= mt('Default'); + ( + 'url_base' => $cgi->url() . '?', + 'selected' => $selected, + 'tabs' => \@tabs + ); +} + +sub html_init { +q! +<STYLE> +.fstabcontainer th { vertical-align: middle; text-align: center } +</STYLE> +! +} + +sub html_table_bottom { + my $object = shift; + my $locale = ''; + my $modenum = ''; + + if ($object->locale =~ /^(\w+)$/) { + $locale = $1; + } + if ($object->modenum =~ /^(\d+)$/) { + $modenum = $1; + } + my $html; + my $show_delete = 1; + # don't allow the default locale to be removed unless it's the last one + # in the mode + $show_delete = 0 if ( + $locale eq 'new' or + $modenum eq '' or + ($locale eq '' and + FS::invoice_conf->count("modenum = $modenum and locale is not null") > 0 + ) + ); + + if ( $show_delete ) { + # set up a delete link + my $confnum = $object->confnum; + my $url = $p."misc/delete-invoice_conf.html?$confnum"; + my $link = qq!<A HREF="javascript:areyousure('$url','Really delete this configuration?')">! . + 'Delete this configuration' . + '</A>'; + $html = qq!<TR><TD></TD> + <TD STYLE="font-style: italic; font-size: small">$link</TD></TR> + <SCRIPT TYPE="text/javascript"> + function areyousure(url, message) { + if (confirm(message)) window.location.href = url; + } + </SCRIPT> + !; + } + $html; +} + +</%init> diff --git a/httemplate/edit/process/cable_provider.html b/httemplate/edit/process/cable_provider.html new file mode 100644 index 000000000..ecffaf692 --- /dev/null +++ b/httemplate/edit/process/cable_provider.html @@ -0,0 +1,10 @@ +<& elements/process.html, + 'table' => 'cable_provider', + 'viewall_dir' => 'browse', +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/process/invoice_conf.html b/httemplate/edit/process/invoice_conf.html new file mode 100644 index 000000000..1d45e126f --- /dev/null +++ b/httemplate/edit/process/invoice_conf.html @@ -0,0 +1,21 @@ +<& elements/process.html, + 'table' => 'invoice_conf', + 'viewall_dir' => 'browse', + 'fields' => [ FS::invoice_conf->fields, 'modename', 'agentnum' ], + 'precheck_callback' => \&precheck_callback, +&> +<%init> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right(['Edit templates','Edit global templates']); + +sub precheck_callback { + my $cgi = shift; + $cgi->param('locale') =~ /^(\w*)$/; + my $locale = $1; + return mt('Language required') if $locale eq 'new'; # the user didn't choose + die "unknown locale $locale" if ( $locale and + !FS::Locales->locale_info($locale) ); +} +# invoice_conf itself knows to create/update invoice_mode if necessary, +# so nothing special here +</%init> |