time/data/etc. unit pricing add-ons, RT#24392
[freeside.git] / httemplate / edit / part_event.html
index 6a53222..702471b 100644 (file)
                               type    => 'checkbox',
                               value   => 'Y',
                             },
+                            { field   => '_initialize',
+                              type      => 'checkbox',
+                              onchange  => '_initialize_changed',
+                              value   => 'Y',
+                            }, 
                             { type    => 'title',
                               value   => 'Event Conditions',
                             },
@@ -54,7 +59,6 @@
                               layer_values_callback => $action_layer_values,
                               html_between => n_a('action'),
                             },
-
                           ],
               'labels' => {
                             'eventpart'  => 'Event',
@@ -67,6 +71,7 @@
                             'conditionname' => 'Add new condition',
                             #'weight',
                             'action'     => 'Action',
+                            '_initialize' => 'Initialize event',
                           },
               'viewall_dir' => 'browse',
               'new_callback' => sub { #start empty for new events only
 
   }
 
+  function _initialize_changed(what) {
+    document.getElementById('disabled').disabled = what.checked;
+    if ( what.checked ) {
+%# because it's not an immediately obvious concept
+      alert('Initializing the event will treat it as "already run" on the '+
+            'current date for all existing customers.  This affects '+
+            'conditions that prevent running an event more than once.');
+    }
+  }
+
 </SCRIPT>
 <%once>
 
@@ -485,6 +500,9 @@ tie my %all_conditions, 'Tie::IxHash',
   '' => { 'description' => '*** Select new condition ***', },
   FS::part_event_condition->conditions();
 
+# *** Select new condition *** sorts to the beginning anyway
+(tied %all_conditions)->SortByValue;
+
 my %condition_labels = map { $_ => $all_conditions{$_}->{'description'} }
                            keys %all_conditions;
 
@@ -524,6 +542,8 @@ tie my %all_actions, 'Tie::IxHash',
   '' => { 'description' => '*** Select event action ***', },
   FS::part_event->actions();
 
+(tied %all_actions)->SortByValue;
+
 my %action_labels = map { $_ => $all_actions{$_}->{'description'} }
                         keys %all_actions;