/**
     Returns invoice status using the get_status function, then dies.
 */
 function show_invoice_status() {
   $invoice_id = intval($_REQUEST['invoice_id']);
   WPI_Functions::get_status(wpi_invoice_id_to_post_id($invoice_id));
   die();
 }
function status_meta_box($this_invoice) {
 
    
  $hidden = '';
  if (!empty($_REQUEST['wpi']['new_invoice'])) {
    $hidden = ' hidden ';
  }
  ?>
  <div id="postbox_status_and_history" class="postbox <?php echo $hidden; ?>">
    <h3 class="hndle"><?php _e("Invoice Status and History", WPI) ?></h3>
    <div class="inside" style="margin:0;padding:0;">
      <div id="submitbox" class="submitbox" style="overflow: auto; max-height: 150px;">
        <table id="wpi_enter_payments" class="form-table hidden" >
          <tr>
            <th><?php _e("Event Type", WPI) ?></th>
            <td>
  <?php echo WPI_UI::select("name=event_type&values=" . serialize(array('add_payment' => __('Receive Payment', WPI), 'add_charge' => __('Add Charge', WPI), 'do_adjustment' => __('Administrative Adjustment', WPI)))); ?>
              <span class="wpi_recurring_options"><?php _e('Note: Recurring bills cannot have administrative adjustments or additional charges, only received payments.', WPI); ?></span>
            </td>
          </tr>
          <tr>
            <th><?php _e("Event Amount", WPI) ?></th>
            <td>
              <?php echo WPI_UI::input("type=text&name=wpi_event_amount&class=wpi_money&special=autocomplete='off'"); ?>
              <span id="event_tax_holder" class="hidden">
                <b style="padding:5px;"><?php _e("Charge Tax", WPI) ?></b><?php echo WPI_UI::input("type=text&name=wpi_event_tax&class=wpi_money&special=autocomplete='off'"); ?>%
              </span>
            </td>
          </tr>
          <tr>
            <th><?php _e("Event Date & Time", WPI) ?></th>
            <td>
              <?php echo WPI_UI::input("type=text&name=wpi_event_date&class=wpi_date"); ?>
              <?php echo WPI_UI::input("type=text&name=wpi_event_time&class=wpi_time"); ?>
            </td>
          </tr>
          <tr>
            <th><?php _e("Event Note", WPI) ?></th>
            <td><?php echo WPI_UI::input("name=wpi_event_note"); ?>
            </td>
          </tr>
          <tr>
            <th>&nbsp;</th>
            <td>
              <?php wp_nonce_field('wpi_process_manual_event_nonce', 'wpi_process_manual_event_nonce'); ?>
              <input type="button" class="button" value="<?php esc_attr(_e('Process Charge / Payment', WPI)); ?>"  id="wpi_process_manual_event" />
              <input type="button" class="button" value="<?php esc_attr(_e('Cancel', WPI)); ?>" onclick="wpi_show_paycharge_box();" />
              <span class="wpi_ajax_response"></span>
            </td>
          </tr>
        </table>
        <div style="padding: 5px;">
          <table class="form-table" id="wpi_invoice_status_table">
  <?php
  
  if (!empty($this_invoice['log']) && is_array($this_invoice['log'])) {
    if (!empty($this_invoice['ID'])) {
      WPI_Functions::get_status($this_invoice['ID']);
    }
  }
  ?>
          </table>
        </div>
      </div>
      <div class="footer_functions">
        <span class="wpi_clickable" onclick="jQuery('.wpi_event_update').toggle();"><?php _e('Toggle History Detail', WPI); ?></span>
      </div>
    </div>
  </div>
<?php
  do_action('wpi_add_comments_box');
?>
  <?php } ?>