/** * Retrieve the total outgoings for this event * * @since 1.3 * @return str */ public function get_total_outgoings() { if (!isset($this->outgoings)) { $this->outgoings = '0.00'; $txns = mdjm_get_event_txns($this->ID, array('post_status' => 'mdjm-expenditure')); if (!empty($txns)) { foreach ($txns as $txn) { $mdjm_txn = new MDJM_Txn($txn->ID); $this->outgoings += $mdjm_txn->price; } } } /** * Override the income for this event. * * @since 1.3 * * @param str $income The income for the event. * @param str|int $id The event ID. */ return apply_filters('get_event_outgoings', $this->outgoings, $this->ID); }
/** * Displays all event transactions within a table. * * @since 1.3.7 * @global obj $mdjm_event MDJM_Event class object * @param int $event_id * @return str */ function mdjm_do_event_txn_table($event_id) { global $mdjm_event; $event_txns = apply_filters('mdjm_event_txns', mdjm_get_event_txns($event_id, array('orderby' => 'post_status'))); $in = 0; $out = 0; ?> <table class="widefat mdjm_event_txn_list"> <thead> <tr> <th style="width: 20%"><?php _e('Date', 'mobile-dj-manager'); ?> </th> <th style="width: 20%"><?php _e('To/From', 'mobile-dj-manager'); ?> </th> <th style="width: 15%"><?php _e('In', 'mobile-dj-manager'); ?> </th> <th style="width: 15%"><?php _e('Out', 'mobile-dj-manager'); ?> </th> <th><?php _e('Details', 'mobile-dj-manager'); ?> </th> <?php do_action('mdjm_event_txn_table_head', $event_id); ?> </tr> </thead> <tbody> <?php if ($event_txns) { ?> <?php foreach ($event_txns as $event_txn) { ?> <?php $txn = new MDJM_Txn($event_txn->ID); ?> <tr class="mdjm_field_wrapper"> <td><a href="<?php echo get_edit_post_link($txn->ID); ?> "><?php echo mdjm_format_short_date($txn->post_date); ?> </a></td> <td><?php echo esc_attr(mdjm_get_txn_recipient_name($txn->ID)); ?> </td> <td> <?php if ($txn->post_status == 'mdjm-income') { ?> <?php $in += mdjm_sanitize_amount($txn->price); ?> <?php echo mdjm_currency_filter(mdjm_format_amount($txn->price)); ?> <?php } else { ?> <?php echo '–'; ?> <?php } ?> </td> <td> <?php if ($txn->post_status == 'mdjm-expenditure') { ?> <?php $out += mdjm_sanitize_amount($txn->price); ?> <?php echo mdjm_currency_filter(mdjm_format_amount($txn->price)); ?> <?php } else { ?> <?php echo '–'; ?> <?php } ?> </td> <td><?php echo $txn->get_type(); ?> </td> </tr> <?php } ?> <?php } else { ?> <tr> <td colspan="5"><?php printf(__('There are currently no transactions for this %s', 'mobile-dj-manager'), mdjm_get_label_singular(true)); ?> </td> </tr> <?php } ?> </tbody> <tfoot> <tr> <th style="width: 20%"> </th> <th style="width: 20%"> </th> <th style="width: 15%"><strong><?php echo mdjm_currency_filter(mdjm_format_amount($in)); ?> </strong></th> <th style="width: 15%"><strong><?php echo mdjm_currency_filter(mdjm_format_amount($out)); ?> </strong></th> <th><strong><?php printf(__('%s Earnings:', 'mobile-dj-manager'), mdjm_get_label_singular()); ?> <?php echo mdjm_currency_filter(mdjm_format_amount($in - $out)); ?> </strong></th> </tr> <?php do_action('mdjm_event_txn_table_foot', $event_id); ?> </tfoot> </table> <?php }