/**
  * Get the Export Data
  *
  * @access	public
  * @since	1.4
  * @return	arr		$data	The data for the CSV file
  */
 public function get_data()
 {
     $data = array();
     // Export all transactions
     $offset = 30 * ($this->step - 1);
     $txn_args = array('post_type' => 'mdjm-transaction', 'posts_per_page' => 30, 'offset' => $offset, 'paged' => $this->step, 'post_status' => array('mdjm-income', 'mdjm-expenditure'), 'order' => 'ASC', 'orderby' => 'date');
     if (!empty($this->start) || !empty($this->end)) {
         $txn_args['date_query'] = array(array('after' => date('Y-n-d 00:00:00', strtotime($this->start)), 'before' => date('Y-n-d 23:59:59', strtotime($this->end)), 'inclusive' => true));
     }
     if (!empty($this->status) && is_array($this->status)) {
         $meta_query = array();
         foreach ($this->status as $txn_status) {
             $meta_query[] = array('key' => '_mdjm_txn_status', 'value' => $txn_status);
         }
         $txn_args['meta_query'] = array('relation' => 'OR', $meta_query);
     }
     $all_txns = get_posts($txn_args);
     if ($all_txns) {
         $i = 0;
         $income = 0;
         $expense = 0;
         foreach ($all_txns as $txn) {
             $mdjm_txn = new MDJM_Txn($txn->ID);
             $data[$i]['id'] = $mdjm_txn->ID;
             $data[$i]['date'] = date('d-M-Y', strtotime($mdjm_txn->post_date));
             $data[$i]['status'] = $mdjm_txn->payment_status;
             $data[$i]['income'] = 'mdjm-income' == $mdjm_txn->post_status ? mdjm_format_amount($mdjm_txn->price) : '';
             $data[$i]['expense'] = 'mdjm-expenditure' == $mdjm_txn->post_status ? mdjm_format_amount($mdjm_txn->price) : '';
             $data[$i]['to_from'] = mdjm_get_txn_recipient_name($mdjm_txn->ID);
             $data[$i]['type'] = $mdjm_txn->get_type();
             $data[$i]['source'] = $mdjm_txn->get_method();
             $data[$i]['gateway'] = $mdjm_txn->get_gateway();
             $data[$i]['event'] = !empty($mdjm_txn->post_parent) ? mdjm_get_event_contract_id($mdjm_txn->post_parent) : '';
             if ('mdjm-income' == $mdjm_txn->post_status) {
                 $income += $mdjm_txn->price;
             } else {
                 $expense += $mdjm_txn->price;
             }
             $i++;
         }
         $data = apply_filters('mdjm_export_get_data', $data);
         $data = apply_filters('mdjm_export_get_data_' . $this->export_type, $data);
         return $data;
     }
     return false;
 }
예제 #2
0
/**
 * Define the data to be displayed in each of the custom columns for the Transaction post types
 *
 * @since	0.9
 * @param	str		$column_name	The name of the column to display
 * @param	int		$post_id		The current post ID
 * @return
 */
function mdjm_transaction_posts_custom_column($column_name, $post_id)
{
    switch ($column_name) {
        // Details
        case 'detail':
            $trans_types = get_the_terms($post_id, 'transaction-types');
            if (is_array($trans_types)) {
                foreach ($trans_types as $key => $trans_type) {
                    $trans_types[$key] = $trans_type->name;
                }
                echo implode("<br/>", $trans_types);
            }
            break;
            // Date
        // Date
        case 'txn_date':
            echo get_post_time('d M Y');
            break;
            // Direction
        // Direction
        case 'direction':
            if ('mdjm-income' == get_post_status($post_id)) {
                echo '<span style="color:green">' . __('In', 'mobile-dj-manager') . '</span>';
            } else {
                echo '<span style="color:red">&nbsp;&nbsp;&nbsp;&nbsp;' . __('Out', 'mobile-dj-manager') . '</span>';
            }
            break;
            // Source
        // Source
        case 'payee':
            echo mdjm_get_txn_recipient_name($post_id);
            break;
            // Event
        // Event
        case 'event':
            $parent = wp_get_post_parent_id($post_id);
            if (!empty($parent)) {
                printf('<a href="%s">%s</a>', admin_url("/post.php?post={$parent}&action=edit"), mdjm_get_option('') . $parent);
            } else {
                echo __('N/A', 'mobile-dj-manager');
            }
            break;
            // Value
        // Value
        case 'txn_value':
            echo mdjm_currency_filter(mdjm_format_amount(get_post_meta($post_id, '_mdjm_txn_total', true)));
            break;
            // Status
        // Status
        case 'txn_status':
            echo get_post_meta($post_id, '_mdjm_txn_status', true);
            break;
    }
    // switch
}
예제 #3
0
/**
 * 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 '&ndash;';
                ?>
                        <?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 '&ndash;';
                ?>
                        <?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%">&nbsp;</th>
            <th style="width: 20%">&nbsp;</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 
}