[freeside-commits] freeside/httemplate/edit access_group.html, 1.3, 1.4 agent.cgi, 1.15, 1.16 cust_main.cgi, 1.78, 1.79 invoice_logo.html, NONE, 1.1 invoice_template.html, NONE, 1.1 part_bill_event.cgi, 1.38, 1.39 part_event.html, NONE, 1.1 part_pkg.cgi, 1.69, 1.70 part_referral.html, 1.2, 1.3 reason.html, 1.2, 1.3
Ivan,,,
ivan at wavetail.420.am
Wed Aug 1 15:25:07 PDT 2007
- Previous message: [freeside-commits] freeside/httemplate/edit/elements edit.html, 1.11, 1.12
- Next message: [freeside-commits] freeside/httemplate/edit/process access_group.html, 1.3, 1.4 invoice_logo.html, NONE, 1.1 invoice_template.html, NONE, 1.1 part_event.html, NONE, 1.1 quick-cust_pkg.cgi, 1.9, 1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/edit
In directory wavetail:/tmp/cvs-serv23435/httemplate/edit
Modified Files:
access_group.html agent.cgi cust_main.cgi part_bill_event.cgi
part_pkg.cgi part_referral.html reason.html
Added Files:
invoice_logo.html invoice_template.html part_event.html
Log Message:
event refactor, landing on HEAD!
Index: cust_main.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/cust_main.cgi,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- cust_main.cgi 6 Apr 2007 19:38:09 -0000 1.78
+++ cust_main.cgi 1 Aug 2007 22:25:03 -0000 1.79
@@ -122,7 +122,8 @@
<!-- agent -->
-<% include('/elements/tr-select-agent.html', $cust_main->agentnum,
+<% include('/elements/tr-select-agent.html',
+ 'curr_value' => $cust_main->agentnum,
'label' => "<B>${r}Agent</B>",
'empty_label' => 'Select agent',
)
Index: access_group.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/access_group.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- access_group.html 23 Aug 2006 22:25:37 -0000 1.3
+++ access_group.html 1 Aug 2007 22:25:02 -0000 1.4
@@ -1,46 +1,80 @@
<% include( 'elements/edit.html',
- 'name' => 'Internal Access Group',
- 'table' => 'access_group',
- 'labels' => {
- 'groupnum' => 'Group number',
- 'groupname' => 'Group name',
- },
+ 'name' => 'Internal Access Group',
+ 'table' => 'access_group',
+ 'labels' => {
+ 'groupnum' => 'Group number',
+ 'groupname' => 'Group name',
+ },
- 'viewall_dir' => 'browse',
+ 'viewall_dir' => 'browse',
- 'html_bottom' =>
- sub {
- my $access_group = shift;
+ 'html_bottom' => $html_bottom_sub,
+ )
+%>
+<%once>
- "<BR>Group virtualized to customers of agents:<BR>".
- ntable("#cccccc",2).
- '<TR><TD>'.
- 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,
- ).
- '</TR></TD></TABLE>'.
+tie my %rights, 'Tie::IxHash', FS::AccessRight->rights_info;
- "<BR>Group rights:<BR>".
- ntable("#cccccc",2).
- '<TR><TD>'.
- 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() ],
- ).
- '</TR></TD></TABLE>'
+</%once>
+<%init>
- ;
- },
- )
-%>
+my $html_bottom_sub = sub {
+ my $access_group = shift;
+
+ #some false laziness w/browse/access_group.html
+ my $columns = 3;
+ my $count = 0;
+
+ '<BR>'.
+ '<FONT SIZE="+1">Group limited to these agent(s)</FONT><BR>'.
+ 'Employees in this group will only see customers of the selected agents in the system and reports.<BR>'.
+ ntable("#cccccc",2).
+ '<TR><TD>'.
+ 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,
+ ).
+ '</TD></TR></TABLE>'.
+
+ '<BR><FONT SIZE="+1">Group access rights</FONT><BR>'.
+ include('/elements/table-grid.html', bgcolor=>'#cccccc' ).
+ '<TR>'. join( '', map {
+ '<TD CLASS="inv" VALIGN="top"><TABLE BGCOLOR="#cccccc" WIDTH=100%>'.
+ '<TR><TH BGCOLOR="#dcdcdc">'. $_. '</TH></TR>'.
+ '<TR><TD>'.
+ 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{$_} }
+ ],
+ ).
+ '<BR>'.
+ '</TD></TR></TABLE></TD>'.
+ ( ++$count % $columns ? '' : '</TR><TR>')
+
+ } keys %rights ). '</TR></TABLE>'.
+
+ '* 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.<BR>';
+
+};
+
+</%init>
--- NEW FILE: invoice_logo.html ---
<% include("/elements/header.html", "Edit $type2desc{$type} invoice logo",
menubar(
'View all invoice templates' => $p.'browse/invoice_template.html'
)
)
%>
% if ( $error ) {
<FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
<BR><BR>
% }
% if ( $cgi->param('msg') ) {
<FONT SIZE="+1"><B><% $cgi->param('msg') |h %></B></FONT>
<BR><BR>
% }
% if ( $mode eq 'upload' ) {
<FORM ACTION="invoice_logo.html" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="mode" VALUE="preview">
% } elsif ( $mode eq 'preview' ) {
<FORM ACTION="process/invoice_logo.html" METHOD="POST">
<INPUT TYPE="hidden" NAME="preview_session" VALUE="<% $session %>">
% }
<INPUT TYPE="hidden" NAME="type" VALUE="<% $type %>">
<INPUT TYPE="hidden" NAME="name" VALUE="<% $name %>">
<% include('/elements/table-grid.html') %>
<TR>
<TH CLASS="grid" BGCOLOR="#cccccc">Current logo</TH>
<TH CLASS="grid" BGCOLOR="#cccccc">New logo preview</TH>
</TR>
<TR>
<TD CLASS="grid" BGCOLOR="#ffffff">
% if ( $type eq 'png' ) {
<IMG SRC="<% $p %>view/logo.cgi?type=png;name=<% $name %>">
% } elsif ( $type eq 'eps' ) {
<i>EPS preview not yet supported</i>
% }
</TD>
<TD CLASS="grid" BGCOLOR="#ffffff">
% if ( $mode eq 'upload' ) {
Upload new logo (PNG format): <INPUT TYPE="file" NAME="new_logo">
<BR><INPUT TYPE="submit" NAME="submit" VALUE="Upload">
% } elsif ( $mode eq 'preview' ) {
<IMG SRC="<% $p %>view/logo.cgi?type=png;preview_session=<% $session %>">
% }
</TD>
</TR>
</TABLE>
% if ( $mode eq 'preview' ) {
<BR>
<INPUT TYPE="submit" NAME="submit" VALUE="Change logo">
% }
</FORM>
<% include("/elements/footer.html") %>
<%once>
my %type2desc = (
'png' => 'online',
'eps' => 'Print/PDF (typeset)',
);
</%once>
<%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';
}
}
</%init>
Index: agent.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/agent.cgi,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- agent.cgi 1 Jul 2007 00:36:59 -0000 1.15
+++ agent.cgi 1 Aug 2007 22:25:02 -0000 1.16
@@ -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 @@
<FORM ACTION="<%popurl(1)%>process/agent.cgi" METHOD=POST>
-<INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $hashref->{agentnum} %>">
-Agent #<% $hashref->{agentnum} ? $hashref->{agentnum} : "(NEW)" %>
+<INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agent->agentnum %>">
+Agent #<% $agent->agentnum ? $agent->agentnum : "(NEW)" %>
<% &ntable("#cccccc", 2, '') %>
-<TR>
- <TH ALIGN="right">Agent</TH>
- <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<% $hashref->{agent} %>"></TD>
-</TR>
+ <TR>
+ <TH ALIGN="right">Agent</TH>
+ <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<% $agent->agent %>"></TD>
+ </TR>
<TR>
<TH ALIGN="right">Agent type</TH>
- <TD><SELECT NAME="typenum" SIZE=1>
-% foreach my $agent_type (qsearch('agent_type',{})) {
+ <TD>
+ <SELECT NAME="typenum" SIZE=1>
+% foreach my $agent_type (qsearch('agent_type',{})) {
- <OPTION VALUE="<% $agent_type->typenum %>"<% ( $hashref->{typenum} && ( $hashref->{typenum} == $agent_type->typenum ) ) ? ' SELECTED' : '' %>>
+ <OPTION VALUE="<% $agent_type->typenum %>"<% ( $agent->typenum && ( $agent->typenum == $agent_type->typenum ) ) ? ' SELECTED' : '' %>>
<% $agent_type->getfield('typenum') %>: <% $agent_type->getfield('atype') %>
-% }
-
+% }
- </SELECT></TD>
+ </SELECT>
+ </TD>
</TR>
-
+
<TR>
<TD ALIGN="right">Disable</TD>
- <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>></TD>
- </TR>
-
- <TR>
- <TD ALIGN="right"><!--Frequency--></TD>
- <TD><INPUT TYPE="hidden" NAME="freq" VALUE="<% $hashref->{freq} %>"></TD>
+ <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $agent->disabled eq 'Y' ? ' CHECKED' : '' %>></TD>
</TR>
+
+ <% include('/elements/tr-select-invoice_template.html',
+ 'label' => 'Invoice template',
+ 'field' => 'invoice_template',
+ 'curr_value' => $agent->invoice_template,
+ )
+ %>
- <TR>
- <TD ALIGN="right"><!--Program--></TD>
- <TD><INPUT TYPE="hidden" NAME="prog" VALUE="<% $hashref->{prog} %>"></TD>
- </TR>
% if ( $conf->config('ticket_system') ) {
% my $default_queueid = $conf->config('ticket_system-default_queueid');
% my $default_queue = FS::TicketSystem->queue($default_queueid);
@@ -92,24 +69,33 @@
</TR>
% }
-
- <TR>
- <TD ALIGN="right">(DEPRECATED) Agent interface username</TD>
- <TD>
- <INPUT TYPE="text" NAME="username" VALUE="<% $hashref->{username} %>">
- </TD>
- </TR>
-
- <TR>
- <TD ALIGN="right">(DEPRECATED) Agent interface password</TD>
- <TD>
- <INPUT TYPE="text" NAME="_password" VALUE="<% $hashref->{_password} %>">
- </TD>
- </TR>
-
</TABLE>
-<BR><INPUT TYPE="submit" VALUE="<% $hashref->{agentnum} ? "Apply changes" : "Add agent" %>">
- </FORM>
- </BODY>
-</HTML>
+<BR>
+<INPUT TYPE="submit" VALUE="<% $agent->agentnum ? "Apply changes" : "Add agent" %>">
+
+</FORM>
+
+<% 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;
+
+</%init>
+
+
Index: reason.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/reason.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- reason.html 23 Oct 2006 04:21:03 -0000 1.2
+++ reason.html 1 Aug 2007 22:25:03 -0000 1.3
@@ -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',
Index: part_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/part_pkg.cgi,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- part_pkg.cgi 12 Apr 2007 03:16:43 -0000 1.69
+++ part_pkg.cgi 1 Aug 2007 22:25:03 -0000 1.70
@@ -89,7 +89,10 @@
<INPUT TYPE="text" NAME="comment" SIZE=32 VALUE="<%$part_pkg->comment%>">
</TD>
</TR>
- <% include( '/elements/tr-select-pkg_class.html', $part_pkg->classnum ) %>
+ <% include( '/elements/tr-select-pkg_class.html',
+ 'curr_value' => $part_pkg->classnum,
+ )
+ %>
<TR>
<TD ALIGN="right">Promotional code</TD>
<TD>
@@ -290,7 +293,7 @@
% '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) ],
--- NEW FILE: invoice_template.html ---
<% include("/elements/header.html", "Edit $type2desc{$type} invoice template",
menubar(
'View all invoice templates' => $p.'browse/invoice_template.html'
)
)
%>
<FORM ACTION="process/invoice_template.html" METHOD="POST">
<INPUT TYPE="hidden" NAME="confname" VALUE="<% $confname %>">
% if ( $type eq 'html' ) {
% #init
<SCRIPT TYPE="text/javascript" src="<% $p %>elements/fckeditor/fckeditor.js">
</SCRIPT>
% #editor
<SCRIPT TYPE="text/javascript">
var oFCKeditor = new FCKeditor('value');
oFCKeditor.Value = <% $value |js_string %>;
oFCKeditor.BasePath = '<% $p %>elements/fckeditor/';
oFCKeditor.Config['SkinPath'] = '<% $p %>elements/fckeditor/editor/skins/silver/';
oFCKeditor.Height = '800';
oFCKeditor.Config['StartupFocus'] = true;
oFCKeditor.Create();
</SCRIPT>
% } else {
<TEXTAREA NAME="value" ROWS=30 COLS=80 WRAP="off"><%$value |h %></TEXTAREA>
% }
<BR><BR>
<INPUT TYPE="submit" VALUE="Change template">
</FORM>
<% 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',
);
</%once>
<%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;
</%init>
Index: part_referral.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/part_referral.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- part_referral.html 23 Aug 2006 22:25:37 -0000 1.2
+++ part_referral.html 1 Aug 2007 22:25:03 -0000 1.3
@@ -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'),
)
%>
--- NEW FILE: part_event.html ---
<% 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',
)
%>
<SCRIPT TYPE="text/javascript">
window.onload = function () { eventtable_changed(document.getElementById('eventtable')) };
var notonload = 0;
function eventtable_changed(what) {
% if ( $JS_DEBUG ) {
alert('eventtable_changed called on ' + what );
% }
var eventtable = what.options[what.selectedIndex].value;
var eventdesc = what.options[what.selectedIndex].text;
//remove the ** Select type **
if ( what.options[0].value == '' && notonload++ > 0 ) {
what.options[0] = null;
}
////
// XXX gray out conditions that can't apply?
////
////
// update condition selects
////
for ( var cnum=0; document.getElementById('conditionname'+cnum); cnum++ ) {
var cond_id = 'conditionname' + cnum;
var cond_select = document.getElementById(cond_id);
% if ( $JS_DEBUG ) {
alert('updating ' + cond_id);
% }
// save off the current value
var conditionname = cond_select.options[cond_select.selectedIndex].value;
var cond_desc = cond_select.options[cond_select.selectedIndex].text;
var seen_condition = condition_repop(cond_select);
var warning = document.getElementById(cond_id + '_warning');
% if ( $JS_DEBUG ) {
alert('turning off warning; setting style.display of '+ cond_id +
'_warning (' + warning + ') to none');
% }
warning.style.display = 'none';
if ( ! seen_condition && conditionname != '') {
// add the current (not valid) condition back
opt(cond_select, conditionname, cond_desc, true );
if ( true <% @implicit_conditions
? ( ' && '. join(' && ', map { "conditionname != '$_'" }
@implicit_conditions
)
)
: ''
%> ) {
// turn on a warning and gray out the condition row
% if ( $JS_DEBUG ) {
alert('turning on warning; setting style.display of '+ cond_id +
'_warning (' + warning + ') to none');
% }
warning.innerHTML = 'Not applicable to ' + eventdesc + ' events';
warning.style.display = '';
}
}
}
////
// update action select
////
// save off the current value first!!
var action = what.form.action.options[what.form.action.selectedIndex].value;
var a_desc = what.form.action.options[what.form.action.selectedIndex].text;
var seen_action = false;
// blank the current action select
for ( var i = what.form.action.length; i >= 0; i-- )
what.form.action.options[i] = null;
if ( action == '' ) {
opt(what.form.action, action, a_desc, true );
}
// repopulate it
% foreach my $eventtable ( FS::part_event->eventtables ) {
% tie my %actions, 'Tie::IxHash', FS::part_event->actions($eventtable);
% #use Data::Dumper; warn Dumper(%actions);
if ( eventtable == '<% $eventtable %>' ) {
% foreach my $action ( keys %actions ) {
% ( my $description = $actions{$action}->{'description'} ) =~ s/'/\\'/g;
var sel = false;
if ( action == '<% $action %>' ) {
seen_action = true;
sel = true;
}
opt( what.form.action, '<% $action %>', '<% $description %>', sel );
% }
}
% }
// by default, turn off warnings and enable the submit button
var warning = document.getElementById('action_warning');
warning.style.display = 'none';
var submit_button = document.getElementById('submit');
submit_button.disabled = '';
if ( ! seen_action && action != '' ) {
// add the current (not valid) action back
opt( what.form.action, action, a_desc, true );
// turn on a warning and disable the submit button
//warning.innerHTML = a_desc + ' event not available as a ' +
warning.innerHTML = 'Not available as a ' + eventdesc + ' action';
warning.style.display = '';
submit_button.disabled = 'disabled';
}
}
function opt(what,value,text,selected) {
var optionName = new Option(text, value, false, selected);
var length = what.length;
what.options[length] = optionName;
}
function action_changed(what) {
// remove '** Select new **'
if ( what.options[0].value == '' ) {
what.options[0] = null;
}
// remove the warning, remove the invalid action, enable the submit button
var warning = document.getElementById('action_warning');
if ( warning.style.display == '' ) {
warning.style.display = 'none';
what.options[what.length-1] = null;
document.getElementById('submit').disabled = '';
}
}
function condition_changed(what) {
// remove '** Select new **'
if ( what.options[0].value == '' ) {
what.options[0] = null;
}
var previousValue = what.getAttribute('previousValue');
var previousText = what.getAttribute('previousText');
var value = what.options[what.selectedIndex].value;
var text = what.options[what.selectedIndex].text;
% foreach my $value ( keys %condition_remove_warnings ) {
if ( previousValue == '<% $value %>' ) {
if ( !confirm( <% $condition_remove_warnings{$value} |js_string %> ) ) {
for ( var i=0; i < what.length; i++ ) {
if ( what.options[i].value == previousValue ) {
what.selectedIndex = i;
}
}
return false;
}
}
% }
//alert(previous + ' changed to ' + value);
var field_regex = /(\d+)$/;
var match = field_regex.exec(what.name);
if ( !match ) {
alert(what.name + " didn't match?!");
return;
}
//add the previous condition *back* to all the other selects...
condition_add(previousValue, previousText, match[1]);
what.setAttribute('previousValue', value);
what.setAttribute('previousText', text);
// remove the new condition from all other selects
condition_remove(value, match[1]);
}
function condition_avail(check_cond, curnum) {
for ( var cnum=0; document.getElementById('conditionname'+cnum); cnum++ ) {
if ( cnum == curnum ) continue;
var cond_id = 'conditionname' + cnum;
var cond_select = document.getElementById(cond_id);
//alert("checking " + cond_id + " (" + cond_select.disabled + ")");
if ( cond_select.disabled ) continue;
// the current value
var conditionname = cond_select.options[cond_select.selectedIndex].value;
if ( check_cond == conditionname ) return false;
}
return true;
}
function condition_remove(remove_cond, curnum) {
if ( remove_cond.length == 0 ) return;
for ( var cnum=0; document.getElementById('conditionname'+cnum); cnum++ ) {
if ( cnum == curnum ) continue;
var cond_id = 'conditionname' + cnum;
var cond_select = document.getElementById(cond_id);
//for ( var i = cond_select.length; i >= 0; i-- ) {
for ( var i=0; i < cond_select.length; i++ ) {
if ( cond_select.options[i].value == remove_cond ) {
cond_select.options[i] = null;
}
}
}
}
function condition_add(add_condname, add_conddesc, curnum) {
if ( add_condname.length == 0 ) return;
var eventtable_el = document.getElementById('eventtable');
var eventtable = eventtable_el.options[eventtable_el.selectedIndex].value;
var in_eventtable = false;
% foreach my $eventtable ( FS::part_event->eventtables ) {
% tie my %conditions, 'Tie::IxHash',
% FS::part_event_condition->conditions($eventtable);
if ( eventtable == '<% $eventtable %>' ) {
% foreach my $conditionname ( keys %conditions ) {
% my $description = $conditions{$conditionname}->{'description'};
% $description =~ s/'/\\'/g;
if ( add_condname == '<% $conditionname %>' ) {
in_eventtable = true;
}
% }
}
% }
if ( ! in_eventtable ) return;
for ( var cnum=0; document.getElementById('conditionname'+cnum); cnum++ ) {
if ( cnum == curnum ) continue;
var cond_id = 'conditionname' + cnum;
var cond_select = document.getElementById(cond_id);
if ( cond_select.disabled ) continue;
//alert("adding " + add_condname + " to " + cond_id);
opt(cond_select, add_condname, add_conddesc, false );
cond_select.parentNode.parentNode.style.display = '';
}
}
function condition_repop(cond_select) {
var eventtable_el = document.getElementById('eventtable');
var eventtable = eventtable_el.options[eventtable_el.selectedIndex].value;
// save off the current value
var conditionname = cond_select.options[cond_select.selectedIndex].value;
var cond_desc = cond_select.options[cond_select.selectedIndex].text;
var seen_condition = false;
if ( cond_select.disabled ) return false; //skip deleted conditions
var field_regex = /(\d+)$/;
var match = field_regex.exec(cond_select.name);
if ( !match ) {
alert(what.name + " didn't match?!");
return;
}
var cnum = match[1];
// blank the current condition select
for ( var i = cond_select.length; i >= 0; i-- )
cond_select.options[i] = null;
if ( conditionname == '' ) {
opt(cond_select, conditionname, cond_desc, true );
}
// repopulate it
% foreach my $eventtable ( FS::part_event->eventtables ) {
% tie my %conditions, 'Tie::IxHash',
% FS::part_event_condition->conditions($eventtable);
if ( eventtable == '<% $eventtable %>' ) {
% foreach my $conditionname ( keys %conditions ) {
% my $description = $conditions{$conditionname}->{'description'};
% $description =~ s/'/\\'/g;
var sel = false;
if ( conditionname == '<% $conditionname %>' ) {
seen_condition = true;
sel = true;
}
if ( condition_avail("<% $conditionname %>", cnum) ) {
opt(cond_select, '<% $conditionname %>', '<% $description %>', sel);
}
% }
}
% }
if ( cond_select.length > 1 || cond_select.length == 1 && cond_select.options[0].value.length > 0 ) {
cond_select.parentNode.parentNode.style.display = '';
} else {
cond_select.parentNode.parentNode.style.display = 'none';
}
return seen_condition;
}
</SCRIPT>
<%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( <FONT ID="${field}_warning" STYLE="display:none" COLOR="#FF0000">).
"Party Party Join us Join us".
'</FONT>';
};
}
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
}
);
};
</%once>
<%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;
</%init>
Index: part_bill_event.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/part_bill_event.cgi,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- part_bill_event.cgi 15 Feb 2007 00:49:26 -0000 1.38
+++ part_bill_event.cgi 1 Aug 2007 22:25:03 -0000 1.39
@@ -504,7 +504,14 @@
<TABLE BGCOLOR="#cccccc" BORDER=0 WIDTH="100%">
<TR><TD>
<TABLE BORDER=0 id="Ctable" style="display:<% $currentreasonclass eq 'C' ? 'inline' : 'none' %>">
-<% 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
+ )
+%>
</TABLE>
</TR></TD>
</TABLE>
@@ -512,7 +519,14 @@
<TABLE BGCOLOR="#cccccc" BORDER=0 WIDTH="100%">
<TR><TD>
<TABLE BORDER=0 id="Stable" style="display:<% $currentreasonclass eq 'S' ? 'inline' : 'none' %>">
-<% 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
+ )
+%>
</TABLE>
</TR></TD>
</TABLE>
- Previous message: [freeside-commits] freeside/httemplate/edit/elements edit.html, 1.11, 1.12
- Next message: [freeside-commits] freeside/httemplate/edit/process access_group.html, 1.3, 1.4 invoice_logo.html, NONE, 1.1 invoice_template.html, NONE, 1.1 part_event.html, NONE, 1.1 quick-cust_pkg.cgi, 1.9, 1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list