From eb4ff7f73c5d4bdf74a3472448b5a195598ff4cd Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 1 Aug 2007 22:26:52 +0000 Subject: event refactor, landing on HEAD! --- httemplate/edit/access_group.html | 122 +++-- httemplate/edit/agent.cgi | 114 ++--- httemplate/edit/cust_main.cgi | 3 +- httemplate/edit/elements/edit.html | 630 ++++++++++++++++++------- httemplate/edit/invoice_logo.html | 136 ++++++ httemplate/edit/invoice_template.html | 80 ++++ httemplate/edit/part_bill_event.cgi | 18 +- httemplate/edit/part_event.html | 642 ++++++++++++++++++++++++++ httemplate/edit/part_pkg.cgi | 7 +- httemplate/edit/part_referral.html | 9 +- httemplate/edit/process/access_group.html | 1 + httemplate/edit/process/elements/process.html | 312 ++++++++----- httemplate/edit/process/invoice_logo.html | 26 ++ httemplate/edit/process/invoice_template.html | 15 + httemplate/edit/process/part_event.html | 86 ++++ httemplate/edit/process/quick-cust_pkg.cgi | 26 +- httemplate/edit/reason.html | 4 +- 17 files changed, 1820 insertions(+), 411 deletions(-) create mode 100644 httemplate/edit/invoice_logo.html create mode 100644 httemplate/edit/invoice_template.html create mode 100644 httemplate/edit/part_event.html create mode 100644 httemplate/edit/process/invoice_logo.html create mode 100644 httemplate/edit/process/invoice_template.html create mode 100644 httemplate/edit/process/part_event.html (limited to 'httemplate/edit') diff --git a/httemplate/edit/access_group.html b/httemplate/edit/access_group.html index d447512c2..4686a627a 100644 --- a/httemplate/edit/access_group.html +++ b/httemplate/edit/access_group.html @@ -1,46 +1,80 @@ <% include( 'elements/edit.html', - 'name' => 'Internal Access Group', - 'table' => 'access_group', - 'labels' => { - 'groupnum' => 'Group number', - 'groupname' => 'Group name', - }, - - 'viewall_dir' => 'browse', - - 'html_bottom' => - sub { - my $access_group = shift; - - "
Group virtualized to customers of agents:
". - ntable("#cccccc",2). - ''. - include( '/elements/checkboxes-table.html', - 'source_obj' => $access_group, - 'link_table' => 'access_groupagent', - 'target_table' => 'agent', - 'name_col' => 'agent', - 'target_link' => $p.'edit/agent.cgi?', - 'disable-able' => 1, - ). - ''. - - "
Group rights:
". - ntable("#cccccc",2). - ''. - include( '/elements/checkboxes-table-name.html', - 'source_obj' => $access_group, - 'link_table' => 'access_right', - 'link_static' => { 'righttype' => - 'FS::access_group', - }, - 'num_col' => 'rightobjnum', - 'name_col' => 'rightname', - 'names_list' => [ FS::AccessRight->rights() ], - ). - '' - - ; - }, - ) + 'name' => 'Internal Access Group', + 'table' => 'access_group', + 'labels' => { + 'groupnum' => 'Group number', + 'groupname' => 'Group name', + }, + + 'viewall_dir' => 'browse', + + 'html_bottom' => $html_bottom_sub, + ) %> +<%once> + +tie my %rights, 'Tie::IxHash', FS::AccessRight->rights_info; + + +<%init> + +my $html_bottom_sub = sub { + my $access_group = shift; + + #some false laziness w/browse/access_group.html + my $columns = 3; + my $count = 0; + + '
'. + 'Group limited to these agent(s)
'. + 'Employees in this group will only see customers of the selected agents in the system and reports.
'. + ntable("#cccccc",2). + ''. + include( '/elements/checkboxes-table.html', + 'source_obj' => $access_group, + 'link_table' => 'access_groupagent', + 'target_table' => 'agent', + 'name_col' => 'agent', + 'target_link' => $p.'edit/agent.cgi?', + 'disable-able' => 1, + ). + ''. + + '
Group access rights
'. + include('/elements/table-grid.html', bgcolor=>'#cccccc' ). + ''. join( '', map { + ''. + ''. + '
'. $_. '
'. + include( '/elements/checkboxes-table-name.html', + 'source_obj' => $access_group, + 'link_table' => 'access_right', + 'link_static' => { 'righttype' => + 'FS::access_group', + }, + 'num_col' => 'rightobjnum', + 'name_col' => 'rightname', + 'names_list' => [ map { + my $rn = + ref($_) ? $_->{'rightname'} : $_; + my %hash = (); + $hash{'note'} = ' *' + if ref($_) && $_->{'global'}; + $hash{'desc'} = $_->{'desc'} + if ref($_) && $_->{'desc'}; + [ $rn => \%hash ]; + } + @{ $rights{$_} } + ], + ). + '
'. + '
'. + ( ++$count % $columns ? '' : '') + + } keys %rights ). ''. + + '* Global rights. These rights provide access to global data which is shared among all agents. Their use is not recommended for groups which are limited to a subset of agents.
'; + +}; + + diff --git a/httemplate/edit/agent.cgi b/httemplate/edit/agent.cgi index 5992bfae0..830862ff8 100755 --- a/httemplate/edit/agent.cgi +++ b/httemplate/edit/agent.cgi @@ -1,25 +1,3 @@ -% -% -%my $agent; -%if ( $cgi->param('error') ) { -% $agent = new FS::agent ( { -% map { $_, scalar($cgi->param($_)) } fields('agent') -% } ); -%} elsif ( $cgi->keywords ) { -% my($query) = $cgi->keywords; -% $query =~ /^(\d+)$/; -% $agent = qsearchs( 'agent', { 'agentnum' => $1 } ); -%} else { #adding -% $agent = new FS::agent {}; -%} -%my $action = $agent->agentnum ? 'Edit' : 'Add'; -%my $hashref = $agent->hashref; -% -%my $conf = new FS::Conf; -% -% - - <% include("/elements/header.html","$action Agent", menubar( 'Main Menu' => $p, 'View all agents' => $p. 'browse/agent.cgi', @@ -31,43 +9,42 @@
- -Agent #<% $hashref->{agentnum} ? $hashref->{agentnum} : "(NEW)" %> + +Agent #<% $agent->agentnum ? $agent->agentnum : "(NEW)" %> <% &ntable("#cccccc", 2, '') %> - - Agent - - + + Agent + + Agent type - +% foreach my $agent_type (qsearch('agent_type',{})) { -
- - +
+"> + + + +<% include('/elements/footer.html') %> + +<%init> + +my $agent; +if ( $cgi->param('error') ) { + $agent = new FS::agent ( { + map { $_, scalar($cgi->param($_)) } fields('agent') + } ); +} elsif ( $cgi->keywords ) { + my($query) = $cgi->keywords; + $query =~ /^(\d+)$/; + $agent = qsearchs( 'agent', { 'agentnum' => $1 } ); +} else { #adding + $agent = new FS::agent {}; +} +my $action = $agent->agentnum ? 'Edit' : 'Add'; + +my $conf = new FS::Conf; + + + + diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 0a7a8c031..d13732afa 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -122,7 +122,8 @@ -<% include('/elements/tr-select-agent.html', $cust_main->agentnum, +<% include('/elements/tr-select-agent.html', + 'curr_value' => $cust_main->agentnum, 'label' => "${r}Agent", 'empty_label' => 'Select agent', ) diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 17c5ad3eb..d7d55a257 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -1,214 +1,406 @@ -% -% -% # options example... -% # -% # 'name' => -% # 'table' => -% # #? 'primary_key' => #required when the dbdef doesn't know...??? -% # 'labels' => { -% # 'column' => 'Label', -% # } -% # -% # listref - each item is a literal column name (or method) or hashref -% # or (notyet) coderef -% # if not specified all columns (except for the primary key) will be editable -% # 'fields' => [ -% # 'columname', -% # { 'field' => 'another_columname', -% # 'type' => 'text', #text -% # #checkbox -% # #select -% # #hidden - hidden value from object -% # #fixed - display fixed value from here -% # #fixedhidden - hidden value from here -% # 'value' => 'Y', #for checkbox, fixed, fixedhidden -% # }, -% # ] -% # -% # 'menubar' => '', #menubar arrayref -% # -% # #run when re-displaying with an error -% # 'error_callback' => sub { my( $cgi, $object ) = @_; }, -% # -% # #run when editing -% # 'edit_callback' => sub { my( $cgi, $object ) = @_; }, -% # -% # # returns a hashref for the new object -% # 'new_hashref_callback' -% # -% # #run when adding -% # 'new_callback' => sub { my( $cgi, $object ) = @_; }, -% # -% # #XXX describe -% # 'field_callback' => sub { }, -% # -% # #string or coderef of additional HTML to add before -% # 'html_table_bottom' => '', -% # -% # 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' -% # -% # 'html_bottom' => '', #string -% # 'html_bottom' => sub { -% # my $object = shift; -% # # ... -% # "html_string"; -% # }, -% # -% # # overrides default popurl(1)."process/$table.html" -% # 'post_url' => popurl(1).'process/something', -% -% my(%opt) = @_; -% -% #false laziness w/process.html -% my $table = $opt{'table'}; -% my $class = "FS::$table"; -% my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || -% my $fields = $opt{'fields'} -% #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; -% || [ grep { $_ ne $pkey } fields($table) ]; -% #my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields; -% -% my $object; -% if ( $cgi->param('error') ) { -% -% $object = $class->new( { -% map { $_ => scalar($cgi->param($_)) } fields($table) -% }); -% -% &{$opt{'error_callback'}}($cgi, $object) -% if $opt{'error_callback'}; -% -% } elsif ( $cgi->keywords || $cgi->param($pkey) ) { #editing -% -% my $value; -% if ( $cgi->param($pkey) ) { -% $value = $cgi->param($pkey) -% } else { -% my( $query ) = $cgi->keywords; -% $value = $query; -% } -% $value =~ /^(\d+)$/ or die "unparsable $pkey"; -% $object = qsearchs( $table, { $pkey => $1 } ); -% warn "$table $pkey => $1" -% if $opt{'debug'}; -% -% &{$opt{'edit_callback'}}($cgi, $object) -% if $opt{'edit_callback'}; -% -% } else { #adding -% -% my $hashref = $opt{'new_hashref_callback'} -% ? &{$opt{'new_hashref_callback'}} -% : {}; -% -% $object = $class->new( $hashref ); -% -% &{$opt{'new_callback'}}($cgi, $object) -% if $opt{'new_callback'}; -% -% } -% -% my $action = $object->$pkey() ? 'Edit' : 'Add'; -% -% my $title = "$action $opt{'name'}"; -% -% my $viewall_url = $p . ( $opt{'viewall_dir'} || 'search' ) . "/$table.html"; -% $viewall_url = $opt{'viewall_url'} if $opt{'viewall_url'}; -% -% my @menubar = (); -% if ( $opt{'menubar'} ) { -% @menubar = @{ $opt{'menubar'} }; -% } else { -% @menubar = ( -% 'Main menu' => $p, #eventually get rid of this when the ACL/UI update is done -% #eventually use Lingua::bs to pluralize -% "View all $opt{'name'}s" => $viewall_url, -% ); -% } -% -% +<%doc> + +Example: + + include( 'elements/edit.html', + 'name' => + 'table' => + #? 'primary_key' => #required when the dbdef doesn't know...??? + 'labels' => { + 'column' => 'Label', + } + + listref - each item is a literal column name (or method) or hashref + or (notyet) coderef + if not specified all columns (except for the primary key) will be editable + 'fields' => [ + 'columname', + { 'field' => 'another_columname', + 'type' => 'text', #text + #money + #checkbox + #select + #selectlayers + #title + #hidden - hidden value from object + #fixed - display fixed value from here + #fixedhidden - hidden value from here + 'value' => 'Y', #for checkbox, title, fixed, fixedhidden + 'disabled' => 0, + 'onchange' => 'javascript_function', + 'm2name_table' => 'table_name', #only tested w/ + # selectlayers so far + # might work w/select + # dunno others + 'm2name_namecol' => 'name_column', # + 'm2name_label' => 'Label', # + 'm2name_new_default' => \@table_name_objects, #default + #m2name + #objects for + #new records + 'm2name_error_callback' => sub { my($cgi, $object) = @_; }, + 'm2name_remove_warnings' => \%warnings, #hashref of warning + #messages for + #m2name removal + 'm2name_new_js' => 'function_name', #javascript function + #called on spawned rows + #(one arg: new_element) + 'm2name_remove_js' => 'function_name', #js function called + #when a row is + #deleted + #(three args: + # value, text, + # 'no_match') + #layer_fields & layer_values_callback only for selectlayer + 'layer_fields' => [ + 'fieldname' => 'Label', + 'another_field' => { + label=>'Label', + type =>'text', #text, money + }, + ], + 'layer_values_callback' => + sub { + my( $cgi, $object ) = @_; + { 'layer' => { 'fieldname' => 'current_value', + 'fieldname2' => 'field2value', + ... + }, + 'layer2' => { 'l2fieldname' => 'l2value', + ... + }, + ... + }; + }, + }, + ] + + 'menubar' => '', #menubar arrayref + + #agent virtualization + 'agent_virt' => 1, + 'agent_null_right' => 'Access Right Name', + + #run when re-displaying with an error + 'error_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; }, + + #run when editing + 'edit_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; }, + + # returns a hashref for the new object + 'new_hashref_callback' + + #run when adding + 'new_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; }, + + #XXX describe + 'field_callback' => sub { }, + + #string or coderef of additional HTML to add before + 'html_table_bottom' => '', + + 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' + + 'html_bottom' => '', #string + 'html_bottom' => sub { + my $object = shift; + # ... + "html_string"; + }, + + # overrides default popurl(1)."process/$table.html" + 'post_url' => popurl(1).'process/something', + ); + + + <% include("/elements/header.html", $title, include( '/elements/menubar.html', @menubar ) ) %> -% if ( $cgi->param('error') ) { +% if ( $cgi->param('error') ) { Error: <% $cgi->param('error') %>

% } % my $url = $opt{'post_url'} || popurl(1)."process/$table.html"; -
+ + + <% ( $opt{labels} && exists $opt{labels}->{$pkey} ) ? $opt{labels}->{$pkey} : $pkey %> #<% $object->$pkey() || "(NEW)" %> -<% ntable("#cccccc",2) %> +%# <% ntable("#cccccc",0) %> + + +% my $g_row = 0; % foreach my $f ( map { ref($_) ? $_ : {'field'=>$_} } % @$fields % ) { % -% &{ $opt{'field_callback'} }( $f ) -% if $opt{'field_callback'}; +% &{ $opt{'field_callback'} }( $f ) +% if $opt{'field_callback'}; +% +% my $field = $f->{'field'}; +% my $type = $f->{'type'} ||= 'text'; +% +% my $label = ( $opt{labels} && exists $opt{labels}->{$field} ) +% ? $opt{labels}->{$field} +% : $field; +% +% my $onchange = $f->{'onchange'}; +% +% my $layer_values = {}; +% if ( $f->{'layer_values_callback'} && ! $f->{'m2name_table'} ) { +% $layer_values = &{ $f->{'layer_values_callback'} }( $cgi, $object ); +% } +% warn "layer values: ". Dumper($layer_values) +% if $opt{'debug'}; +% +% my %include_common = ( +% #checkbox, title +% #& deprecated weird value hashref used only by reason.html +% 'value' => $f->{'value'}, +% +% #select(-*) +% 'options' => $f->{'options'}, +% 'labels' => $f->{'labels'}, +% 'multiple' => $f->{'multiple'}, +% 'disable_empty' => $f->{'disable_empty'}, +% #select-reason +% 'reason_class' => $f->{'reason_class'}, % -% my $field = $f->{'field'}; -% my $type = $f->{'type'} ||= 'text'; +% #selectlayers +% 'layer_fields' => $f->{'layer_fields'}, +% 'layer_values' => $layer_values, +% 'html_between' => $f->{'html_between'}, +% ); % +% my $layer_prefix_on = ''; % +% my $include_sub = sub { +% my %opt = @_; +% +% my $fieldnum = delete $opt{'fieldnum'}; +% +% my $include = $type; +% $include = "input-$include" if $include =~ /^(text|money)$/; +% $include = "tr-$include" unless $include eq 'hidden'; +% +% $include_common{'layer_prefix'} = "$field$fieldnum." +% if $layer_prefix_on; +% +% my @include = +% ( "/elements/$include.html", +% 'field' => "$field$fieldnum", +% 'id' => "$field$fieldnum", #separate? +% 'label_id' => $field."_label$fieldnum", #don't want field0_label0... +% %include_common, +% %opt, +% ); +% @include; +% }; +% +% $g_row++; +% $g_row++ if $type eq 'title'; +% +% my $fieldnum = ''; +% my $curr_value = ''; +% if ( $f->{'m2name_table'} ) { #XXX test this for all types of fields +% my $table = $f->{'m2name_table'}; +% my $col = $f->{'m2name_namecol'}; +% $fieldnum = 0; +% $layer_prefix_on = 1; +% #print out the fields for the existing m2names +% my @existing = (); +% if ( $mode eq 'error' ) { +% @existing = &{ $f->{'m2name_error_callback'} }( $cgi, $object ); +% } elsif ( $object->$pkey() ) { # $mode eq 'edit' +% @existing = $object->$table(); +% } elsif ( $f->{'m2name_new_default'} ) { # && $mode eq 'new' +% @existing = @{ $f->{'m2name_new_default'} }; +% } +% foreach my $name_obj ( @existing ) { +% +% my $ex_label = ' '. ($f->{'m2name_label'} || $field ). ' '; +% +% if ( $f->{'layer_values_callback'} ) { +% my %switches = ( 'mode' => $mode ); +% $layer_values = +% &{ $f->{'layer_values_callback'} }( $cgi, $name_obj, \%switches ); +% } +% warn "layer values: ". Dumper($layer_values) +% if $opt{'debug'}; +% +% my @existing = &{ $include_sub }( +% 'label' => $ex_label, +% 'fieldnum' => $fieldnum, +% 'curr_value' => $name_obj->$col(), +% 'onchange' => $onchange, +% 'layer_values' => $layer_values, +% 'cell_style' => ( $fieldnum ? 'border-top:1px solid black' : '' ), +% ); + + <% include( @existing ) %> +% $fieldnum++; +% $g_row++; +% } +% #$field .= $fieldnum; +% $onchange .= "\nspawn_$field(what);"; +% } else { +% $curr_value = $object->$field(); +% } +% +% my @include = &{ $include_sub }( +% 'label' => $label, +% 'fieldnum' => $fieldnum, +% 'curr_value' => $curr_value, +% 'onchange' => $onchange, +% 'cell_style' => ( $fieldnum ? 'border-top:1px solid black' : '' ), +% ); - + <% include( @include ) %> - +% if ( $f->{'m2name_table'} ) { -% if ( $type eq 'fixed' ) { + + +% } % } @@ -226,9 +418,105 @@
-"> +"> <% include("/elements/footer.html") %> +<%init> + +my(%opt) = @_; + +my $curuser = $FS::CurrentUser::CurrentUser; + +#false laziness w/process.html +my $table = $opt{'table'}; +my $class = "FS::$table"; +my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || +my $fields = $opt{'fields'} + #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; + || [ grep { $_ ne $pkey } fields($table) ]; +#my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields; + +if ( $cgi->param('redirect') ) { + my $session = $cgi->param('redirect'); + my $pref = $curuser->option("redirect$session"); + die "unknown redirect session $session\n" unless length($pref); + $cgi = new CGI($pref); +} + +my $object; +my $mode; +if ( $cgi->param('error') ) { + + $mode = 'error'; + + + $object = $class->new( { + map { $_ => scalar($cgi->param($_)) } fields($table) + }); + + &{$opt{'error_callback'}}($cgi, $object, $fields) + if $opt{'error_callback'}; + +} elsif ( $cgi->keywords || $cgi->param($pkey) ) { #editing + + $mode = 'edit'; + + my $value; + if ( $cgi->param($pkey) ) { + $value = $cgi->param($pkey) + } else { + my( $query ) = $cgi->keywords; + $value = $query; + } + $value =~ /^(\d+)$/ or die "unparsable $pkey"; + $object = qsearchs({ + 'table' => $table, + 'hashref' => { $pkey => $1 }, + 'extra_sql' => ( $opt{'agent_virt'} + ? ' AND '. $curuser->agentnums_sql( + 'null_right' => $opt{'agent_null_right'} + ) + : '' + ), + }); + warn "$table $pkey => $1" + if $opt{'debug'}; + + &{$opt{'edit_callback'}}($cgi, $object, $fields) + if $opt{'edit_callback'}; + +} else { #adding + + $mode = 'new'; + + my $hashref = $opt{'new_hashref_callback'} + ? &{$opt{'new_hashref_callback'}} + : {}; + + $object = $class->new( $hashref ); + + &{$opt{'new_callback'}}($cgi, $object, $fields) + if $opt{'new_callback'}; + +} + +my $action = $object->$pkey() ? 'Edit' : 'Add'; + +my $title = "$action $opt{'name'}"; + +my $viewall_url = $p . ( $opt{'viewall_dir'} || 'search' ) . "/$table.html"; +$viewall_url = $opt{'viewall_url'} if $opt{'viewall_url'}; + +my @menubar = (); +if ( $opt{'menubar'} ) { + @menubar = @{ $opt{'menubar'} }; +} else { + @menubar = ( + #eventually use Lingua::bs to pluralize + "View all $opt{'name'}s" => $viewall_url, + ); +} + diff --git a/httemplate/edit/invoice_logo.html b/httemplate/edit/invoice_logo.html new file mode 100644 index 000000000..0c45e4b20 --- /dev/null +++ b/httemplate/edit/invoice_logo.html @@ -0,0 +1,136 @@ +<% include("/elements/header.html", "Edit $type2desc{$type} invoice logo", + menubar( + 'View all invoice templates' => $p.'browse/invoice_template.html' + ) + ) +%> + +% if ( $error ) { + Error: <% $error %> +

+% } + +% if ( $cgi->param('msg') ) { + <% $cgi->param('msg') |h %> +

+% } + +% if ( $mode eq 'upload' ) { + + +% } elsif ( $mode eq 'preview' ) { + + +% } + + + + +<% include('/elements/table-grid.html') %> + + + + + + + + + + + + + + + +
- <% ( $opt{labels} && exists $opt{labels}->{$field} ) - ? $opt{labels}->{$field} - : $field - %> -
Current logoNew logo preview
+ +% if ( $type eq 'png' ) { + + + +% } elsif ( $type eq 'eps' ) { + + EPS preview not yet supported + +% } + + + +% if ( $mode eq 'upload' ) { + + Upload new logo (PNG format): +
+ +% } elsif ( $mode eq 'preview' ) { + + + +% } + +
+ +% if ( $mode eq 'preview' ) { +
+ +% } + + + +<% include("/elements/footer.html") %> + +<%once> + +my %type2desc = ( + 'png' => 'online', + 'eps' => 'Print/PDF (typeset)', +); + + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $conf = new FS::Conf; + +my $type = $cgi->param('type'); + +$cgi->param('name') =~ /^([^\.\/]*)$/ or die "illegal name"; +my $name = $1; + +$cgi->param('mode') =~ /^(\w*)$/ or die "illegal mode"; +my $mode = $1 || 'upload'; + +my $error = ''; +my $session = ''; +if ( $mode eq 'preview' ) { + + my $fh = $cgi->upload('new_logo'); + + if ( defined $fh ) { + + local $/; + my $logo_data = <$fh>; + + $session = int(rand(4294967296)); #XXX + my $pref = new FS::access_user_pref({ + 'usernum' => $FS::CurrentUser::CurrentUser->usernum, + 'prefname' => "logo_preview$session", + 'prefvalue' => encode_base64($logo_data), + 'expiration' => time + 3600, #1h? 1m? + }); + my $pref_error = $pref->insert; + if ( $pref_error ) { + die "FATAL: couldn't set preview cookie: $pref_error\n"; + } + + } else { + + $mode = 'upload'; + $error = 'No file uploaded'; + + } + +} + + diff --git a/httemplate/edit/invoice_template.html b/httemplate/edit/invoice_template.html new file mode 100644 index 000000000..851ab5ecf --- /dev/null +++ b/httemplate/edit/invoice_template.html @@ -0,0 +1,80 @@ +<% include("/elements/header.html", "Edit $type2desc{$type} invoice template", + menubar( + 'View all invoice templates' => $p.'browse/invoice_template.html' + ) + ) +%> + +
+ + +% if ( $type eq 'html' ) { + +% #init + + +% #editor + + +% } else { + + + +% } + +

+ + +
+ +<% include("/elements/footer.html") %> + +<%once> + +my %type2desc = ( + 'html' => 'HTML', + 'latex' => 'Print/PDF (typeset)', + 'text' => 'Plaintext', +); + +my %type2base = ( + 'html' => 'invoice_html', + 'latex' => 'invoice_latex', + 'text' => 'invoice_template', +); + + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $type = $cgi->param('type'); +my $name = $cgi->param('name'); +my $suffix = $cgi->param('suffix'); + +#XXX type handling, just testing this out for now + +my $conf = new FS::Conf; + +my $value = length($name) + ? join("\n", $conf->config_orbase($type2base{$type}.$suffix, $name) ) + : join("\n", $conf->config($type2base{$type}.$suffix) ); + +my $confname = length($name) + ? $type2base{$type}.$suffix. '_'. $name + : $type2base{$type}.$suffix; + + diff --git a/httemplate/edit/part_bill_event.cgi b/httemplate/edit/part_bill_event.cgi index 0921a9577..ff0e0a334 100755 --- a/httemplate/edit/part_bill_event.cgi +++ b/httemplate/edit/part_bill_event.cgi @@ -504,7 +504,14 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %>
-<% include('/elements/tr-select-reason.html', 'creason', 'C', $creason, $newcreasonT, $newcreason) %> +<% include('/elements/tr-select-reason.html', + 'field' => 'creason', + 'reason_class' => 'C', + 'curr_value' => $creason, + 'init_type' => $newcreasonT, + 'init_newreason' => $newcreason + ) +%>
@@ -512,7 +519,14 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %>
-<% include('/elements/tr-select-reason.html', 'sreason', 'S', $sreason, $newsreasonT, $newsreason) %> +<% include('/elements/tr-select-reason.html', + 'field' => 'sreason', + 'reason_class' => 'S', + 'curr_value' => $sreason, + 'init_type' => $newsreasonT, + 'init_newreason' => $newsreason + ) +%>
diff --git a/httemplate/edit/part_event.html b/httemplate/edit/part_event.html new file mode 100644 index 000000000..c94da615d --- /dev/null +++ b/httemplate/edit/part_event.html @@ -0,0 +1,642 @@ +<% include( 'elements/edit.html', + 'name' => 'Billing event definition', + 'table' => 'part_event', + 'fields' => [ + 'event', + { field => 'eventtable', + type => 'select', + options => [ FS::part_event->eventtables ], + labels => $eventtable_labels, + onchange => 'eventtable_changed', + }, + { field => 'agentnum', + type => 'select-agent', + disable_empty => $disable_empty_agent, + }, + { field => 'check_freq', + type => 'select', + options => [ '1d', '1m' ], + labels => $check_freq_labels, + }, + { field => 'disabled', + type => 'checkbox', + value => 'Y', + }, + { type => 'title', + value => 'Event Conditions', + }, + { field => 'conditionname', + type => 'selectlayers', + options => [ keys %all_conditions ], + labels => \%condition_labels, + onchange => 'condition_changed(what);', + layer_fields => \%condition_fields, + layer_values_callback => $condition_layer_values, + html_between => n_a('action'), + m2name_table => 'part_event_condition', + m2name_namecol => 'conditionname', + m2name_label => 'Condition', + m2name_new_default => \@implicit_condition_objs, + m2name_error_callback => + $condition_error_callback, + m2name_remove_warnings => + \%condition_remove_warnings, + m2name_new_js => 'condition_repop', + m2name_remove_js => 'condition_add', + }, + { type => 'title', + value => 'Event Action', + }, + { field => 'action', + type => 'selectlayers', + options => [ keys %all_actions ], + labels => \%action_labels, + onchange => 'action_changed(what);', + layer_fields => \%action_fields, + layer_values_callback => $action_layer_values, + html_between => n_a('action'), + }, + + ], + 'labels' => { + 'eventpart' => 'Event', + 'event' => 'Event name', + 'eventtable' => 'Type', + 'agentnum' => 'Agent', + 'check_freq' => 'Check frequency', + 'disabled' => 'Disable event', + + 'conditionname' => 'Add new condition', + #'weight', + 'action' => 'Action', + }, + 'viewall_dir' => 'browse', + 'new_callback' => sub { #start empty for new events only + my( $cgi, $object, $fields_listref ) = @_; + unshift @{ $fields_listref->[1]{'options'} }, ''; + }, + 'error_callback' => $error_callback, + + 'agent_virt' => 1, + 'agent_null_right' => 'Edit global billing events', + ) +%> + +<%once> + +#misc (eventtable, check_freq) + +my $eventtable_labels = FS::part_event->eventtable_labels; +$eventtable_labels->{''} = '** Select type **'; + +my $check_freq_labels = FS::part_event->check_freq_labels; + +#conditions + +tie my %all_conditions, 'Tie::IxHash', + '' => { 'description' => '*** Select new condition ***', }, + FS::part_event_condition->conditions(); + +my %condition_labels = map { $_ => $all_conditions{$_}->{'description'} } + keys %all_conditions; + +#my %condition_fields = map { $_ => $all_conditions{$_}->{option_fields} } +# keys %all_conditions; +my %condition_fields = map { my $c = $_; + tie my %opts, 'Tie::IxHash', + @{ $all_conditions{$c}->{'option_fields'} || []}; + %opts = ( map { ( "$c.$_" => $opts{$_} ); } + keys %opts + ); + ( $c => [ %opts ] ); + } + keys %all_conditions; + +my @implicit_conditions = sort { $all_conditions{$a}->{'implicit_flag'} <=> + $all_conditions{$b}->{'implicit_flag'} + } + grep { $all_conditions{$_}->{'implicit_flag'} } + keys %all_conditions; + +my @implicit_condition_objs = map { + new FS::part_event_condition { + 'conditionname' => $_, + }; + } + @implicit_conditions; + +my %condition_remove_warnings = + map { ( $_ => $all_conditions{$_}->{'remove_warning'} ); } + grep { $all_conditions{$_}->{'remove_warning'} } + keys %all_conditions; + +#actions + +tie my %all_actions, 'Tie::IxHash', + '' => { 'description' => '*** Select event action ***', }, + FS::part_event->actions(); + +my %action_labels = map { $_ => $all_actions{$_}->{'description'} } + keys %all_actions; + +#my %action_fields = map { $_ => $all_actions{$_}->{option_fields} } +# keys %all_actions; +my %action_fields = map { my $action = $_; + tie my %opts, 'Tie::IxHash', + @{ $all_actions{$action}->{option_fields} || [] }; + %opts = ( map { ( "$action.$_" => $opts{$_} ); } + keys %opts + ); + ( $action => [ %opts ] ); + } + keys %all_actions; + +#subs + +sub n_a { + my $t = shift; + + return sub { + my $field = shift; + qq( '; + }; +} + +my $action_layer_values = sub { + my( $cgi, $part_event ) = @_; + my $action = $cgi->param('action') || $part_event->action; + return {} unless $action; + scalar( #force hashref + { + #map { $_ => { $part_event->options } } + # keys %action_fields + map { my $action = $_; + my %fields = @{ $action_fields{$action} }; + my %obj_opts = $part_event->options; + %obj_opts = map { ( "$action.$_" => $obj_opts{$_} ); } + keys %obj_opts; + my %opts = + map { #false laziness w/process/part_event.html + my $option = $_; + my $value = scalar($cgi->param($_)) || $obj_opts{$_}; + + if ( $option =~ /^(.*)\.reasonnum$/ && $value == -1 ) { + $value = { + 'typenum' => scalar( $cgi->param( "new${option}T" ) ), + 'reason' => scalar( $cgi->param( "new${option}" ) ), + }; + } + + ( $option => $value ); + + } + keys %fields; + ( $action => \%opts ); + } + keys %action_fields + } + ); +}; + +tie my %cgi_conditions, 'Tie::IxHash'; + +my $error_callback = sub { + my( $cgi, $object, $fields_listref ) = @_; + + my @cond_params = grep /^conditionname\d+$/, $cgi->param; + + %cgi_conditions = map { + my $param = $_; + my $conditionname = $cgi->param($param); + $conditionname => { + map { + + my $cgi_key = $_; + $cgi_key =~ /^$param\.$conditionname\.(.*)$/ or die 'wtf!'; + my $key = $1; + #my $value = $cgi->param($_); + + #my $info = $all_conditions->{$conditionname} + my %cond_opts = + @{ $all_conditions{$conditionname}->{'option_fields'} || []}; + my $info = $cond_opts{$key}; + + my $value; + #false laziness w/process/part_event.html + if ( $info->{'type'} =~ /^(select|checkbox)-?multiple$/ + or $info->{'type'} =~ /^select/ && $info->{'multiple'} ) { + $value = { map { $_ => 1 } $cgi->param($cgi_key) }; + } elsif ( $info->{'type'} eq 'freq' ) { + $value = $cgi->param($cgi_key). $cgi->param($cgi_key.'_units'); + } else { + $value = $cgi->param($cgi_key); + } + + $key => $value; + + } grep /^$param\.$conditionname\./, $cgi->param + }; + } grep $cgi->param($_), grep /^conditionname\d+$/, $cgi->param; + +}; + +my $condition_error_callback = sub { + map { + new FS::part_event_condition { 'conditionname' => $_, }; + } keys %cgi_conditions; +}; + +my $condition_layer_values = sub { + #m2name_table option causes this to be + # part_event_condition instead of part_event + my ( $cgi, $part_event_condition, $switches ) = @_; + scalar( #force hashref + { + #map { $_ => { $part_event_condition->options } } + # keys %condition_fields + map { my $conditionname = $_; + my %opts = $switches->{'mode'} eq 'error' + ? %{ $cgi_conditions{$conditionname} || {} } + : $part_event_condition->options; + %opts = ( + map { ( "$conditionname.$_" => $opts{$_} ); } + keys %opts + ); + ( $conditionname => \%opts ); + } + keys %condition_fields + } + ); +}; + + + +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Edit billing events') + || $curuser->access_right('Edit global billing events'); + +my $disable_empty_agent= ! $curuser->access_right('Edit global billing events'); + +%cgi_conditions = (); +my $use_cgi_conditions = 0; + +my $JS_DEBUG = 0; + + diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index bdd3f304a..90e328d4b 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -89,7 +89,10 @@ Package information - <% include( '/elements/tr-select-pkg_class.html', $part_pkg->classnum ) %> + <% include( '/elements/tr-select-pkg_class.html', + 'curr_value' => $part_pkg->classnum, + ) + %> Promotional code @@ -290,7 +293,7 @@ Reseller information % 'form_action' => 'process/part_pkg.cgi', % 'form_elements' => \@form_elements, % 'form_text' => [ qw(pkg comment promo_code clone pkgnum pkgpart), -% qw(pay_weight credit_weight), +% qw(pay_weight credit_weight), #keys(%weight), % @fixups, % ], % 'form_checkbox' => [ qw(setuptax recurtax disabled) ], diff --git a/httemplate/edit/part_referral.html b/httemplate/edit/part_referral.html index 7ce52174d..f4572c067 100755 --- a/httemplate/edit/part_referral.html +++ b/httemplate/edit/part_referral.html @@ -1,9 +1,12 @@ <% include( 'elements/edit.html', 'name' => 'Advertising source', 'table' => 'part_referral', - 'fields' => [ 'referral' ], - 'labels' => { 'referral' => 'Advertising source' }, + 'fields' => [ 'referral', + { field=>'agentnum', type=>'select-agent', }, + ], + 'labels' => { 'referral' => 'Advertising source', + 'agentnum' => 'Agent', + }, 'viewall_dir' => 'browse', - 'html_table_bottom' => include('/elements/tr-select-agent.html'), ) %> diff --git a/httemplate/edit/process/access_group.html b/httemplate/edit/process/access_group.html index c80311586..581b50f9e 100644 --- a/httemplate/edit/process/access_group.html +++ b/httemplate/edit/process/access_group.html @@ -10,6 +10,7 @@ 'num_col' => 'rightobjnum', 'name_col' => 'rightname', 'names_list' => [ FS::AccessRight->rights() ], + 'param_style' => 'link_table.value checkboxes', }, ) %> diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html index e388c678b..19d3fbef1 100644 --- a/httemplate/edit/process/elements/process.html +++ b/httemplate/edit/process/elements/process.html @@ -1,111 +1,203 @@ -% -% -% # options example... -% # -% ### -% ##req -% ## -% # -% # 'table' => -% # -% # #? 'primary_key' => #required when the dbdef doesn't know...??? -% # #? 'fields' => [] -% # -% ### -% ##opt -% ### -% # -% # 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' -% # OR -% # 'redirect' => 'view/table.cgi?', # value of primary key is appended -% # -% # 'error_redirect' => popurl(2).'edit/table.cgi?', #query string appended -% # -% # 'edit_ext' => 'html', #defaults to 'html', you might want 'cgi' while the -% # #naming is still inconsistent -% # -% # 'copy_on_empty' => [ 'old_field_name', 'another_old_field', ... ], -% # -% # 'clear_on_error' => [ 'form_field1', 'form_field2', ... ], -% # -% # 'process_m2m' => { 'link_table' => 'link_table_name', -% # 'target_table' => 'target_table_name', -% # }, -% # 'process_m2name' => { 'link_table' => 'link_table_name', -% # 'link_static' => { 'column' => 'value' }, -% # 'num_col' => 'column', #if column name is different in -% # #link_table than source_table -% # 'name_col' => 'name_column', -% # 'names_list' => [ 'list', 'names' ], -% # }, -% -% my(%opt) = @_; -% -% #false laziness w/edit.html -% my $table = $opt{'table'}; -% my $class = "FS::$table"; -% my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || -% my $fields = $opt{'fields'} -% #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; -% || [ fields($table) ]; -% -% my $pkeyvalue = $cgi->param($pkey); -% -% my $old = qsearchs( $table, { $pkey => $pkeyvalue } ) if $pkeyvalue; -% -% my $new = $class->new( { -% map { -% $_, scalar($cgi->param($_)); -% } @$fields -% } ); -% -% if ($old && exists($opt{'copy_on_empty'})) { -% foreach my $field (@{$opt{'copy_on_empty'}}) { -% $new->set($field, $old->get($field)) -% unless scalar($cgi->param($field)); -% } -% } -% -% my $error; -% if ( $pkeyvalue ) { -% $error = $new->replace($old); -% } else { -% $error = $new->insert; -% $pkeyvalue = $new->getfield($pkey); -% } -% -% if ( !$error && $opt{'process_m2m'} ) { -% $error = $new->process_m2m( %{ $opt{'process_m2m'} }, -% 'params' => scalar($cgi->Vars), -% ); -% } -% -% if ( !$error && $opt{'process_m2name'} ) { -% $error = $new->process_m2name( %{ $opt{'process_m2name'} }, -% 'params' => scalar($cgi->Vars), -% ); -% } -% -% # XXX print?!?! -% -% if ( $error ) { -% $cgi->param('error', $error); -% if (scalar(@{$opt{'clear_on_error'}})) { -% foreach my $field (@{$opt{'clear_on_error'}}) { -% $cgi->param($field, '') -% } -% } -% my $edit_ext = $opt{'edit_ext'} || 'html'; -% my $url = $opt{'error_redirect'} || popurl(2)."$table.$edit_ext?"; -% print $cgi->redirect($url. $cgi->query_string ); -% } elsif ( $opt{'redirect'} ) { -% print $cgi->redirect( $opt{'redirect'}. $pkeyvalue ); -% } else { -% print $cgi->redirect( popurl(3). -% ( $opt{'viewall_dir'} || 'search' ). -% "/$table.html" -% ); -% } -% -% +<%doc> +Example: + + include( 'elements/process.html', + + ### + # required + ### + + 'table' => 'tablename', + + #? 'primary_key' => #required when the dbdef doesn't know...??? + #? 'fields' => [] #"" + + ### + # optional + ### + + 'viewall_dir' => '', #'search' or 'browse', defaults to 'search' + OR + 'redirect' => 'view/table.cgi?', # value of primary key is appended + + 'error_redirect' => popurl(2).'edit/table.cgi?', #query string appended + + 'edit_ext' => 'html', #defaults to 'html', you might want 'cgi' while the + #naming is still inconsistent + + 'copy_on_empty' => [ 'old_field_name', 'another_old_field', ... ], + + 'clear_on_error' => [ 'form_field1', 'form_field2', ... ], + + 'process_m2m' => { 'link_table' => 'link_table_name', + 'target_table' => 'target_table_name', + }, + 'process_m2name' => { 'link_table' => 'link_table_name', + 'link_static' => { 'column' => 'value' }, + 'num_col' => 'column', #if column name is different in + #link_table than source_table + 'name_col' => 'name_column', + 'names_list' => [ 'list', 'names' ], + + 'param_style' => 'link_table.value checkboxes', + #or# + 'param_style' => 'name_colN values', + + + }, + + #supplies arguments to insert() and replace() + # for use with tables that are FS::option_Common + 'args_callback' => sub { my( $cgi, $object ) = @_; }, + + 'debug' => 1, #turns on debugging output + + #agent virtualization + 'agent_virt' => 1, + 'agent_null_right' => 'Access Right Name', + + ) + + +<%once> + + my $me = 'process.html:'; + + +<%init> + +my(%opt) = @_; + +my $curuser = $FS::CurrentUser::CurrentUser; + +#false laziness w/edit.html +my $table = $opt{'table'}; +my $class = "FS::$table"; +my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} || +my $fields = $opt{'fields'} + #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ]; + || [ fields($table) ]; + +my $pkeyvalue = $cgi->param($pkey); + +my $old = ''; +if ( $pkeyvalue ) { + $old = qsearchs({ + 'table' => $table, + 'hashref' => { $pkey => $pkeyvalue }, + 'extra_sql' => ( $opt{'agent_virt'} + ? ' AND '. $curuser->agentnums_sql( + 'null_right' => $opt{'agent_null_right'} + ) + : '' + ), + }); +} + +my %hash = map { $_ => scalar($cgi->param($_)) } @$fields; + +my $new = $class->new( \%hash ); + +if ( $opt{'agent_virt'} ) { + die "illegal agentnum" + unless $curuser->agentnums_href->{$new->agentnum} + or $opt{'agent_null_right'} + && ! $new->agentnum + && $curuser->access_right($opt{'agent_null_right'}); +} + +if ($old && exists($opt{'copy_on_empty'})) { + foreach my $field (@{$opt{'copy_on_empty'}}) { + $new->set($field, $old->get($field)) + unless scalar($cgi->param($field)); + } +} + +my $error = $new->check; + +my @args = (); +if ( !$error && $opt{'args_callback'} ) { + @args = &{ $opt{'args_callback'} }( $cgi, $new ); +} + +if ( !$error && $opt{'debug'} ) { + warn "$me updating record in $table table using $class class\n"; + warn Dumper(\%hash); + warn "with args: \n". Dumper(\@args) if @args; +} + +if ( !$error ) { + if ( $pkeyvalue ) { + $error = $new->replace($old, @args); + } else { + $error = $new->insert(@args); + $pkeyvalue = $new->getfield($pkey); + } +} + +if ( !$error && $opt{'process_m2m'} ) { + + if ( $opt{'debug'} ) { + warn "$me processing m2m:\n". Dumper( %{ $opt{'process_m2m'} }, + 'params' => scalar($cgi->Vars), + ); + } + + $error = $new->process_m2m( %{ $opt{'process_m2m'} }, + 'params' => scalar($cgi->Vars), + ); +} + +if ( !$error && $opt{'process_m2name'} ) { + + if ( $opt{'debug'} ) { + warn "$me processing m2name:\n". Dumper( %{ $opt{'process_m2name'} }, + 'params' => scalar($cgi->Vars), + ); + } + + $error = $new->process_m2name( %{ $opt{'process_m2name'} }, + 'params' => scalar($cgi->Vars), + ); +} + +# XXX print?!?! + +if ( $error ) { + $cgi->param('error', $error); + if ( $opt{'clear_on_error'} && scalar(@{$opt{'clear_on_error'}}) ) { + foreach my $field (@{$opt{'clear_on_error'}}) { + $cgi->param($field, '') + } + } + my $edit_ext = $opt{'edit_ext'} || 'html'; + my $url = $opt{'error_redirect'} || popurl(2)."$table.$edit_ext"; + if ( length($cgi->query_string) > 1920 ) { #stupid IE 2083 URL limit + + my $session = int(rand(4294967296)); #XXX + my $pref = new FS::access_user_pref({ + 'usernum' => $FS::CurrentUser::CurrentUser->usernum, + 'prefname' => "redirect$session", + 'prefvalue' => $cgi->query_string, + 'expiration' => time + 3600, #1h? 1m? + }); + my $pref_error = $pref->insert; + if ( $pref_error ) { + die "FATAL: couldn't even set redirect cookie: $pref_error". + " attempting to set redirect$session to ". $cgi->query_string."\n"; + } + print $cgi->redirect("$url?redirect=$session"); + } else { + print $cgi->redirect("$url?". $cgi->query_string ); + } +} elsif ( $opt{'redirect'} ) { + print $cgi->redirect( $opt{'redirect'}. $pkeyvalue ); +} else { + print $cgi->redirect( popurl(3). + ( $opt{'viewall_dir'} || 'search' ). + "/$table.html" + ); +} + + diff --git a/httemplate/edit/process/invoice_logo.html b/httemplate/edit/process/invoice_logo.html new file mode 100644 index 000000000..d641a9959 --- /dev/null +++ b/httemplate/edit/process/invoice_logo.html @@ -0,0 +1,26 @@ +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Configuration'); + +my $conf = new FS::Conf; + +$cgi->param('type') =~ /^(png|eps)$/ or die "illegal type"; +my $type = $1; + +$cgi->param('name') =~ /^([^\.\/]*)$/ or die "illegal name"; +my $tname = my $name = $1; +$tname = "_$tname" if length($tname); + +$cgi->param('preview_session') =~ /^(\w*)$/ or die "illegal preview_session"; +my $session = $1; +my $data = decode_base64( $curuser->option("logo_preview$session") ); + +$conf->set("logo$name.$type", $data); + +$cgi->redirect(popurl(3). "edit/invoice_logo.html?type=$type;name=$name;msg=Logo%20changed"); + + + diff --git a/httemplate/edit/process/invoice_template.html b/httemplate/edit/process/invoice_template.html new file mode 100644 index 000000000..6c9371ad1 --- /dev/null +++ b/httemplate/edit/process/invoice_template.html @@ -0,0 +1,15 @@ +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $conf = new FS::Conf; + +my $confname = $cgi->param('confname'); +my $value = $cgi->param('value'); + +$conf->set($confname, $value); + +$cgi->redirect(popurl(3). 'browse/invoice_template.html'); + + diff --git a/httemplate/edit/process/part_event.html b/httemplate/edit/process/part_event.html new file mode 100644 index 000000000..428025fd1 --- /dev/null +++ b/httemplate/edit/process/part_event.html @@ -0,0 +1,86 @@ +<% include( 'elements/process.html', + #'debug' => 1, + 'table' => 'part_event', + 'viewall_dir' => 'browse', + 'process_m2name' => + { + 'link_table' => 'part_event_condition', + 'num_col' => 'eventpart', + 'name_col' => 'conditionname', + 'names_list' => [ FS::part_event_condition->all_conditionnames() ], + 'param_style' => 'name_colN values', + 'args_callback' => sub { # FS/FS/m2name_Common.pm + my( $object, $prefix, $params, $listref ) = @_; + #warn "$object $prefix $params $listref\n"; + + my $cond = $object->conditionname; + + my %option_fields = $object->option_fields; + + push @$listref, map { + my $field = $_; + + my $cgi_field = "$prefix$cond.$field"; + + my $value = $params->{$cgi_field}; + + my $info = $option_fields{$_}; + $info = { label=>$info, type=>'text' } + unless ref($info); + + if ( $info->{'type'} =~ + /^(select|checkbox)-?multiple$/ + or $info->{'type'} =~ /^select/ + && $info->{'multiple'} + ) + { + #special processing for compound fields + $value = { map { $_ => 1 } + split(/\0/, $value) + }; + } elsif ( $info->{'type'} eq 'freq' ) { + $value .= $params->{$cgi_field.'_units'}; + } + + #warn "value of $cgi_field is $value\n"; + + ( $field => $value ); + } + keys %option_fields; + }, + }, + + 'args_callback' => sub { + + my( $cgi, $object ) = @_; + + my $prefix = $object->action.'.'; + + map { my $option = $_; + #my $value = scalar( $cgi->param( "$prefix$option" ) ); + my $value = join(',', $cgi->param( "$prefix$option" ) ); + + if ( $option eq 'reasonnum' && $value == -1 ) { + $value = { + 'typenum' => scalar( $cgi->param( "new$prefix${option}T" ) ), + 'reason' => scalar( $cgi->param( "new$prefix${option}" ) ), + }; + } + + ( $option => $value ); + } + @{ $object->option_fields_listref }; + + }, + + 'agent_virt' => 1, + 'agent_null_right' => 'Edit global billing events', +) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Edit billing events') + || $FS::CurrentUser::CurrentUser->access_right('Edit global billing events'); + + diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 7afc9f2bb..66d02e307 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -1,5 +1,3 @@ -% -% %#untaint custnum %$cgi->param('custnum') =~ /^(\d+)$/ % or die 'illegal custnum '. $cgi->param('custnum'); @@ -9,19 +7,21 @@ %my $pkgpart = $1; % %my @cust_pkg = (); -%my $error = FS::cust_pkg::order($custnum, [ $pkgpart ], [], \@cust_pkg, ); +%my $error = FS::cust_pkg::order($custnum, [ $pkgpart ], [], \@cust_pkg, [ $cgi->param('refnum') ] ); % %if ($error) { -% - - -% -% eidiot($error); +% $cgi->param('error', $error); +% print $cgi->redirect(popurl(2). 'misc/order_pkg.html?'. $cgi->query_string ); %} else { -% print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum". -% "#cust_pkg". $cust_pkg[0]->pkgnum ); -%} -% -% +% my $frag = "cust_pkg". $cust_pkg[0]->pkgnum; +<% header('Package ordered') %> + + + +%} diff --git a/httemplate/edit/reason.html b/httemplate/edit/reason.html index 7c0722cea..c652a0820 100644 --- a/httemplate/edit/reason.html +++ b/httemplate/edit/reason.html @@ -25,6 +25,8 @@ 'fields' => [ { 'field' => 'reason_type', 'type' => 'select', + #XXX use something more sane than a hashref + #then fix tr-select.html 'value' => { 'vcolumn' => 'typenum', 'ccolumn' => 'type', 'values' => \@types, @@ -32,7 +34,7 @@ }, 'reason', { 'field' => 'class', - 'type' => 'fixedhidden', + 'type' => 'hidden', 'value' => $class, }, { 'field' => 'disabled', -- cgit v1.2.1