X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_event.html;h=ea97391476df7bc34453895347bb2af206c817fe;hb=d9880fb208858d882d02462bba4c3c57db3b377c;hp=f68f06b9f4feafcbd89f97eb5ccc6a1257171247;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git
diff --git a/httemplate/browse/part_event.html b/httemplate/browse/part_event.html
index f68f06b9f..ea9739147 100644
--- a/httemplate/browse/part_event.html
+++ b/httemplate/browse/part_event.html
@@ -10,7 +10,7 @@
'query' => { 'select' => 'part_event.*',
'table' => 'part_event',
'addl_from' => $join_conditions,
- 'hashref' => {},
+ 'hashref' => $hashref,
'order_by' => $order_conditions,
},
'count_query' => $count_query,
@@ -22,14 +22,14 @@
'Action',
],
'fields' => [ 'eventpart',
- 'event',
+ $event_sub,
$eventtable_sub,
$check_freq_sub,
$conditions_sub,
$action_sub,
],
'links' => [ $link,
- $link,
+ '',
'',
'',
'',
@@ -40,6 +40,34 @@
%>
<%once>
+my $link = [ $p.'edit/part_event.html?', 'eventpart' ];
+
+my $event_sub = sub {
+ my $part_event = shift;
+ my $onclick = include('/elements/popup_link_onclick.html',
+ action => $p.'view/part_event-targets.html?eventpart='.
+ $part_event->eventpart,
+ actionlabel => 'Event query', #no, XSS - '.$part_event->event,
+ width => 650,
+ height => 420,
+ close_text => 'Close',
+ );
+ [#rows
+ [#subcolumns
+ {
+ 'data' => encode_entities($part_event->event),
+ 'link' => $p.'edit/part_event.html?'.$part_event->eventpart,
+ },
+ {
+ 'data' => '(query) ',
+ 'size' => '-1',
+ 'data_style' => 'b',
+ 'onclick' => $onclick,
+ },
+ ],
+ ];
+};
+
my $eventtable_labels = FS::part_event->eventtable_labels;
my $eventtable_sub = sub { $eventtable_labels->{ shift->eventtable }; };
@@ -50,14 +78,39 @@ my $conditions_sub = sub {
my $part_event = shift;
my $addl = 0;
+
[
map {
my $part_event_condition = $_;
my %options = $part_event_condition->options;
+ my $desc = $part_event_condition->description;
+
+ if ( $cgi->param('test_eventtable_num') =~ /^(\d+)$/ ) {
+
+ my $tablenum = $1;
+
+ if ( $cgi->param('eventtable') =~ /^(cust_main|cust_pkg|cust_bill)$/ ) {
+ my $eventtable = "FS::$1";
+ my $object = $eventtable->by_key($tablenum);
+
+ my $cust_event = $part_event->new_cust_event($object);
+
+ my $test = $part_event_condition->condition(
+ $object,
+ 'cust_event' => $cust_event,
+ );
+
+ my $yesno = $test ? '(yes)'
+ : '(no)';
+
+ $desc .= " $yesno";
+ }
+ }
+
[
{
- 'data' => $part_event_condition->description,
+ 'data' => $desc,
'width' => '100%',
'align' => 'center',
'colspan' => 2,
@@ -131,8 +184,6 @@ my $action_sub = sub {
};
-my $link = [ $p.'edit/part_event.html?', 'eventpart' ];
-
%once>
<%init>
@@ -140,6 +191,7 @@ die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Edit billing events')
|| $FS::CurrentUser::CurrentUser->access_right('Edit global billing events');
+
my $html_init =
#XXX better description
'Events are billing, collection or other actions triggered when certain '.
@@ -148,21 +200,35 @@ my $html_init =
qq!Add a new event!.
' or '.
'
';
-
+
+my $hashref = {};
+
my $count_query = 'SELECT COUNT(*) FROM part_event WHERE '.
$FS::CurrentUser::CurrentUser->agentnums_sql(
'null_right' => 'Edit global billing events',
'viewall_right' => 'None',
);
-my $join_conditions = FS::part_event_condition->join_conditions_sql;
+if ( $cgi->param('eventtable') =~ /^(\w+)$/ ) {
+ $hashref->{eventtable} = $1;
+ $count_query .= " AND eventtable = '$1' ";
+}
+
+my $tablenum = '';
+if ( $cgi->param('test_eventtable_num') =~ /^(\d+)$/ ) {
+ $tablenum = $1;
+}
+
+my $join_conditions = FS::part_event_condition->join_conditions_sql('', 'time' => time);
my $order_conditions = FS::part_event_condition->order_conditions_sql;
%init>