diff options
Diffstat (limited to 'httemplate/elements')
| -rw-r--r-- | httemplate/elements/freeside.css | 2 | ||||
| -rw-r--r-- | httemplate/elements/header-full.html | 3 | ||||
| -rw-r--r-- | httemplate/elements/header-popup.html | 3 | ||||
| -rw-r--r-- | httemplate/elements/printtofit.js | 26 | ||||
| -rw-r--r-- | httemplate/elements/progress-init.html | 14 | ||||
| -rw-r--r-- | httemplate/elements/select-rt-customfield.html | 34 | ||||
| -rw-r--r-- | httemplate/elements/select-rt-queue.html | 24 | ||||
| -rw-r--r-- | httemplate/elements/select-terms.html | 5 | ||||
| -rw-r--r-- | httemplate/elements/tr-input-locale-text.html | 120 | ||||
| -rw-r--r-- | httemplate/elements/tr-select-router_block_ip.html | 2 | ||||
| -rw-r--r-- | httemplate/elements/xmlhttp.html | 2 |
11 files changed, 206 insertions, 29 deletions
diff --git a/httemplate/elements/freeside.css b/httemplate/elements/freeside.css index fb5e7d961..cc104a196 100644 --- a/httemplate/elements/freeside.css +++ b/httemplate/elements/freeside.css @@ -235,7 +235,7 @@ div.fstabcontainer { .fsinnerbox th { font-weight:normal; font-size:80%; - valign: bottom; + vertical-align: bottom; color: #666666; } diff --git a/httemplate/elements/header-full.html b/httemplate/elements/header-full.html index db38eafba..07595a539 100644 --- a/httemplate/elements/header-full.html +++ b/httemplate/elements/header-full.html @@ -47,6 +47,9 @@ Example: <link rel="stylesheet" href="<% $fsurl %>elements/jquery-ui.min.css"> <SCRIPT SRC="<% $fsurl %>elements/jquery.js"></SCRIPT> <SCRIPT SRC="<% $fsurl %>elements/jquery-ui.min.js"></SCRIPT> +% if ( $FS::CurrentUser::CurrentUser->option('printtofit') ) { + <SCRIPT SRC="<% $fsurl %>elements/printtofit.js"></SCRIPT> +% } % } <% include('init_overlib.html') |n %> <% include('rs_init_object.html') |n %> diff --git a/httemplate/elements/header-popup.html b/httemplate/elements/header-popup.html index 17593693e..6c0f80b37 100644 --- a/httemplate/elements/header-popup.html +++ b/httemplate/elements/header-popup.html @@ -30,6 +30,9 @@ Example: <META HTTP-Equiv="Expires" Content="0"> % unless ( $no_jquery ) { <SCRIPT SRC="<% $fsurl %>elements/jquery.js"></SCRIPT> +% if ( $FS::CurrentUser::CurrentUser->option('printtofit') ) { + <SCRIPT SRC="<% $fsurl %>elements/printtofit.js"></SCRIPT> +% } % } <% $head |n %> </HEAD> diff --git a/httemplate/elements/printtofit.js b/httemplate/elements/printtofit.js new file mode 100644 index 000000000..66257fca8 --- /dev/null +++ b/httemplate/elements/printtofit.js @@ -0,0 +1,26 @@ +$().ready(function() { + var beforePrint = function() { + if ($('body').width() > 0) { + // 7.5 inches * 96 DPI; maybe make the width a user pref? + var maxwidth = 7.5 * 96; + $('body').css('zoom', maxwidth / $('body').width()); + } + }; + var afterPrint = function() { + $('body').css('zoom', 1); + } + + if (window.matchMedia) { // chrome, most importantly; also IE10? + window.matchMedia('print').addListener( + function(mq) { + mq.matches ? beforePrint() : afterPrint(); + } + ); + } else { // other IE + $(window).on('beforeprint', beforePrint); + $(window).on('afterprint', afterPrint); + } + // got nothing for firefox + // https://bugzilla.mozilla.org/show_bug.cgi?id=774398 + // but firefox already has "shrink to fit" +}); diff --git a/httemplate/elements/progress-init.html b/httemplate/elements/progress-init.html index e38dde65f..0c2b8165a 100644 --- a/httemplate/elements/progress-init.html +++ b/httemplate/elements/progress-init.html @@ -98,14 +98,14 @@ function <%$key%>process () { overlib( 'Submitting job to server...', WIDTH, 444, HEIGHT, 168, CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 ); + // jQuery .serializeArray() maybe? + var copy_fields = <% encode_json(\%copy_fields) %>; var Hash = new Array(); var x = 0; var fieldName; for (var i = 0; i<document.<%$formname%>.elements.length; i++) { field = document.<%$formname%>.elements[i]; - if ( <% join(' || ', map { "(field.name.indexOf('$_') > -1)" } @$fields ) %> - ) - { + if ( <% $all_fields %> || copy_fields[ field.name ] ) { if ( field.type == 'select-multiple' ) { //alert('select-multiple ' + field.name); for (var j=0; j < field.options.length; j++) { @@ -168,6 +168,14 @@ $progress_url->query_form( %dest_info, ); +my $all_fields = 0; +my %copy_fields; +if (grep '/^ALL$/', @$fields) { + $all_fields = 1; +} else { + %copy_fields = map { $_ => 1 } @$fields; +} + #stupid safari is caching the "location" of popup iframs, and submitting them #instead of displaying them. this should prevent that. my $popup_name = 'popup-'.random_id(); diff --git a/httemplate/elements/select-rt-customfield.html b/httemplate/elements/select-rt-customfield.html index 85758d585..488accac3 100644 --- a/httemplate/elements/select-rt-customfield.html +++ b/httemplate/elements/select-rt-customfield.html @@ -1,31 +1,27 @@ -<SELECT NAME="<% $opt{name} %>"> +<SELECT NAME="<% $opt{'name'} %>"<% $opt{'multiple'} ? ' MULTIPLE' : '' %>> % while ( @fields ) { -<OPTION VALUE="<% shift @fields %>"><% shift @fields %></OPTION> +% my $value = shift @fields; +% my $label = shift @fields; +<OPTION VALUE="<% $value %>"<% $curr_value{$value} ? ' SELECTED' : '' %>><% $label %></OPTION> % } </SELECT> <%init> my %opt = @_; -my $lookuptype = $opt{lookuptype}; -my $valuetype = $opt{valuetype}; -# get a list of TimeValue-type custom fields -my $CurrentUser = RT::CurrentUser->new(); -$CurrentUser->LoadByName($FS::CurrentUser::CurrentUser->username); -die "RT not configured" unless $CurrentUser->id; -my $CFs = RT::CustomFields->new($CurrentUser); -$CFs->Limit(FIELD => 'LookupType', - OPERATOR => 'ENDSWITH', - VALUE => $lookuptype) - if $lookuptype; - -$CFs->Limit(FIELD => 'Type', - VALUE => $valuetype) - if $valuetype; +my %curr_value = map { $_ => 1 } split(', ',$opt{'curr_value'}); my @fields; push @fields, '', $opt{empty_label} if exists($opt{empty_label}); -while (my $CF = $CFs->Next) { - push @fields, $CF->Name, ($CF->Description || $CF->Name); +my $conf = new FS::Conf; + +if ($conf->config('ticket_system') eq 'RT_Internal') { + + push @fields, FS::TicketSystem->custom_fields( + lookuptype => $opt{lookuptype}, + valuetype => $opt{valuetype}, + ); + } + </%init> diff --git a/httemplate/elements/select-rt-queue.html b/httemplate/elements/select-rt-queue.html new file mode 100644 index 000000000..4ae8bc942 --- /dev/null +++ b/httemplate/elements/select-rt-queue.html @@ -0,0 +1,24 @@ +<SELECT NAME="<% $opt{'name'} %>"<% $opt{'multiple'} ? ' MULTIPLE' : '' %>> +% while ( @fields ) { +% my $value = shift @fields; +% my $label = shift @fields; +<OPTION VALUE="<% $value %>"<% $curr_value{$value} ? ' SELECTED' : '' %>><% $label %></OPTION> +% } +</SELECT> +<%init> +my %opt = @_; + +my %curr_value = map { $_ => 1 } split(', ',$opt{'curr_value'}); + +my @fields; +push @fields, '', $opt{empty_label} if exists($opt{empty_label}); + +my $conf = new FS::Conf; + +if ($conf->config('ticket_system') eq 'RT_Internal') { + + push @fields, FS::TicketSystem->queues(); + +} + +</%init> diff --git a/httemplate/elements/select-terms.html b/httemplate/elements/select-terms.html index a330df17c..eda439a4c 100644 --- a/httemplate/elements/select-terms.html +++ b/httemplate/elements/select-terms.html @@ -34,10 +34,7 @@ my $empty_label = my $empty_value = $opt{'empty_value'} || ''; -my @terms = ( emt('Payable upon receipt'), - ( map "Net $_", - 0, 3, 5, 7, 9, 10, 14, 15, 18, 20, 21, 25, 30, 45, 60, 90 ), - ); +my @terms = map emt($_), @FS::Conf::invoice_terms; my @pre_options = $opt{pre_options} ? @{ $opt{pre_options} } : (); diff --git a/httemplate/elements/tr-input-locale-text.html b/httemplate/elements/tr-input-locale-text.html new file mode 100644 index 000000000..110a8aa9b --- /dev/null +++ b/httemplate/elements/tr-input-locale-text.html @@ -0,0 +1,120 @@ +<%doc> +Usage: + +In edit/foo.html: + +<& /elements/tr-input-locale-text.html, + cgi => $cgi, # needed to preserve values in error redirect + object => $record, + field => 'myfield', + label => 'My Field', +&> + +And in edit/process/foo.html: +<& elements/process.html, + ... + process_locale => 'myfield', +&> + +'object' needs to be an FS::Record subclass instance for a table that has +a '_msgcat' localization table. For a table "foo" where "foo.myfield" +contains some customer-visible label (in the default locale), +"foo_msgcat.myfield" contains the translation of that label for a customer +locale. The foreign key in foo_msgcat must have the same name as the primary +key of foo. + +Currently only a single field can be localized this way; including this +element more than once in the form will lead to conflicts. This is how +it should work; if at some point we need to localize several fields of the +same record, we should modify this element to show multiple inputs for each +locale. + +</%doc> +<%init> + +my %opt = @_; +my $object = delete $opt{object}; +my $field = delete $opt{field}; + +# identify our locales +my $conf = FS::Conf->new; +my $default_locale = $conf->config('locale') || 'en_'; +my @locales = grep { ! /^$default_locale/ } $conf->config('available-locales'); + +my $label = delete $opt{label}; +my %labels = map { $_ => "$label—".FS::Locales->description($_) } + @locales; +@locales = sort { $labels{$a} cmp $labels{$b} } @locales; +my %curr_values; + +# where are the msgcat records? +my $msgcat_table = $object->table . '_msgcat'; +my $msgcat_pkey = dbdef->table($msgcat_table)->primary_key; +my %msgcat_pkeyvals; + +# find existing msgcat records, if any, and record their message values +# and pkeys +my $pkey = $object->primary_key; +my $pkeyval = $object->get($pkey); +if ($pkeyval) { # of course if this is a new record there won't be any + my @linked = qsearch($msgcat_table, { $pkey => $pkeyval }); + foreach (@linked) { + $curr_values{ $_->locale } = $_->get( $field ); + $msgcat_pkeyvals{ $_->locale } = $_->get( $msgcat_pkey ); + } +} + +# sticky-on-error the locale inputs +if( my $cgi = $opt{cgi} ) { + my $i = 0; + # they're named 'foomsgnum0_locale' and 'foomsgnum0_myfield' + while ( my $locale = $cgi->param($msgcat_pkey . $i . '_locale') ) { + my $value = $cgi->param($msgcat_pkey . $i . '_' . $field); + $curr_values{ $locale } = $value; + $i++; + } +} + +# compat with tr-input-text for styling +my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : ''; + +my $colspan = $opt{'colspan'} ? 'COLSPAN="'.$opt{'colspan'}.'"' : ''; + + +</%init> +% # pass through %opt on all of these to retain formatting +% # one tr, td, and input for the default locale +<& tr-input-text.html, + %opt, + 'label' => $label, + 'field' => $field +&> +% # and one for each of the others +% my $i = 0; +% foreach my $locale (@locales) { +% my $basename = $msgcat_pkey . $i; +% my $lfield = $basename . '_' . $field; +<& tr-td-label.html, + %opt, + 'id' => $lfield, # uniqueness + 'label' => $labels{$locale} +&> + <TD <% $colspan %><% $cell_style %> ID="<% $lfield %>_input0"> + <& hidden.html, + 'field' => $basename, + 'curr_value' => $msgcat_pkeyvals{$locale}, + # will be empty if this is a new record and/or new locale, that's fine + &> + <& hidden.html, + 'field' => $basename . '_locale', + 'curr_value' => $locale, + &> + <& input-text.html, + %opt, + 'field' => $lfield, + 'curr_value' => $curr_values{$locale}, + &> + </TD> +</TR> +% $i++; +% } # foreach $locale diff --git a/httemplate/elements/tr-select-router_block_ip.html b/httemplate/elements/tr-select-router_block_ip.html index ee135686c..2aa715e29 100644 --- a/httemplate/elements/tr-select-router_block_ip.html +++ b/httemplate/elements/tr-select-router_block_ip.html @@ -56,7 +56,7 @@ function clearhint_ip_addr (what) { ] &> </td></tr> -<& /elements/tr-td-label.html, label => 'IP address', required => $opt{'ip_addr_required'} &> +<& /elements/tr-td-label.html, label => ($opt{'ip_addr_label'} || 'IP address'), required => $opt{'ip_addr_required'} &> <td> % #warn Dumper \%fixed; % if ( exists $fixed{$ip_field} ) { diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html index 2f4f0d555..e70871169 100644 --- a/httemplate/elements/xmlhttp.html +++ b/httemplate/elements/xmlhttp.html @@ -44,7 +44,7 @@ my %initialized = ();#won't work if component is "preloaded"... so don't do that len = args.length - 1; } for (var i = 0; i < len; i++) - content = content + "&arg=" + escape(args[i]); + content = content + "&arg=" + encodeURIComponent(args[i]); content = content.replace( /[+]/g, '%2B'); // fix unescaped plus signs if ( '<%$method%>' == 'GET' ) { |
