98cf0d3d by Marty Penner

Temporary fix for unpaid invoices; added 'Bill To' area on unpaid invoices based…

… on user profile preference
1 parent d3c957d0
......@@ -40,6 +40,10 @@ Tools\import('HTML');
Vars::$validation->errors = Array();
});
function fix_unpaid() {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'fix_unpaid.php');
}
function display_users() {
/*
global $wpdb;
......@@ -1499,6 +1503,7 @@ HTML;
add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user');
add_submenu_page('cbv_users','New User', 'Awaiting Validation',CAPABILITY,'cbv_users_signups',__NAMESPACE__ . '\signups');
add_submenu_page('cbv_users', 'Merge Users', 'Merge Users', CAPABILITY, 'cbv_users_merge', __NAMESPACE__ . '\merge_users');
add_submenu_page('cbv_users', 'Fix Unpaid', 'Fix Unpaid', CAPABILITY, 'cbv_users_fix_unpaid', __NAMESPACE__ . '\fix_unpaid');
}
public static function admin_init() {
......
......@@ -94,7 +94,6 @@ use WP_User;
$html .= '<div style="border:1px solid #777;padding:20px;position:relative;" id="viewable-port">';
$status = get_post_meta($invoice->ID,'trans_status',true);
$html .= '<p>
<img src="/wp-content/themes/cbv/assets/images/logo.gif" width="114" height="92" /></p><p>
......@@ -248,14 +247,42 @@ use WP_User;
//}
$html .= '</p>';
//if ($status != "credit" && $invoice->payment['bt_address'] != "" && $invoice->payment['bt_card_holder'] != "") {
$html .= (!empty($invoice->payment['bt_card_holder'])) ? '<h3>BILLED TO:</h3>' : "";
$html .= (!empty($invoice->payment['bt_card_holder'])) ? $invoice->payment['bt_card_holder']."<br />" : "";
$html .= (!empty($invoice->payment['bt_address'])) ? $invoice->payment['bt_address']." ".$invoice->payment['bt_address2'] . "<br />" : "";
$html .= (!empty($invoice->payment['bt_city'])) ? $invoice->payment['bt_city'].", " .$invoice->payment['bt_province']."<br />" : "";
$html .= (!empty($invoice->payment['bt_country'])) ? $invoice->payment['bt_country']."&nbsp;&nbsp;".$invoice->payment['bt_postal']."<br /><br />" : "";
$html .= (!empty($invoice->payment['bt_card_type'])) ? "Paid using: <strong>".CBV\get_payment_string($invoice->payment['bt_card_type'])."</strong>&nbsp;&nbsp;" . $invoice->payment['bt_card_number'] : "";
//}
// Loop through each of the payment items
foreach ($invoice->payment as $key => $item) {
// Skip any fields that don't start with 'bt_'
if (substr($key, 0, 3) != 'bt_') {
continue;
}
}
if ($status == 'unpaid') {
// Get the user's profile preference
$preference = strtolower($user->profile_preference);
// Build the 'Bill To:' info array
$user_fields = array('address', 'address2', 'city', 'province', 'country', 'postal');
$bill_to = array();
foreach ($user_fields as $field) {
// Use the preference to get the user's address info
$bill_to[$field] = get_user_meta($user->ID, "{$preference}_{$field}", TRUE);
}
// Finish it off with first and last name
$bill_to['first_name'] = get_user_meta($user->ID, 'first_name', TRUE);
$bill_to['last_name'] = get_user_meta($user->ID, 'last_name', TRUE);
// Now build the html
$html .= '<h3>BILL TO:</h3>';
$html .= "{$bill_to['first_name']} {$bill_to['last_name']}<br />";
$html .= "{$bill_to['address']}<br />{$bill_to['address2']}<br />";
$html .= "{$bill_to['city']}, {$bill_to['province']}<br />";
$html .= "{$bill_to['country']} {$bill_to['postal']}";
} else {
$html .= (!empty($invoice->payment['bt_card_holder'])) ? '<h3>BILLED TO:</h3>' : "";
$html .= (!empty($invoice->payment['bt_card_holder'])) ? $invoice->payment['bt_card_holder']."<br />" : "";
$html .= (!empty($invoice->payment['bt_address'])) ? $invoice->payment['bt_address']." ".$invoice->payment['bt_address2'] . "<br />" : "";
$html .= (!empty($invoice->payment['bt_city'])) ? $invoice->payment['bt_city'].", " .$invoice->payment['bt_province']."<br />" : "";
$html .= (!empty($invoice->payment['bt_country'])) ? $invoice->payment['bt_country']."&nbsp;&nbsp;".$invoice->payment['bt_postal']."<br /><br />" : "";
$html .= (!empty($invoice->payment['bt_card_type'])) ? "Paid using: <strong>".CBV\get_payment_string($invoice->payment['bt_card_type'])."</strong>&nbsp;&nbsp;" . $invoice->payment['bt_card_number'] : "";
}
//if ($status != "credit") {
$html .= '<p>GST/HST# R108075334</p>';
......