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'); ...@@ -40,6 +40,10 @@ Tools\import('HTML');
40 Vars::$validation->errors = Array(); 40 Vars::$validation->errors = Array();
41 }); 41 });
42 42
43 function fix_unpaid() {
44 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'fix_unpaid.php');
45 }
46
43 function display_users() { 47 function display_users() {
44 /* 48 /*
45 global $wpdb; 49 global $wpdb;
...@@ -1499,6 +1503,7 @@ HTML; ...@@ -1499,6 +1503,7 @@ HTML;
1499 add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user'); 1503 add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user');
1500 add_submenu_page('cbv_users','New User', 'Awaiting Validation',CAPABILITY,'cbv_users_signups',__NAMESPACE__ . '\signups'); 1504 add_submenu_page('cbv_users','New User', 'Awaiting Validation',CAPABILITY,'cbv_users_signups',__NAMESPACE__ . '\signups');
1501 add_submenu_page('cbv_users', 'Merge Users', 'Merge Users', CAPABILITY, 'cbv_users_merge', __NAMESPACE__ . '\merge_users'); 1505 add_submenu_page('cbv_users', 'Merge Users', 'Merge Users', CAPABILITY, 'cbv_users_merge', __NAMESPACE__ . '\merge_users');
1506 add_submenu_page('cbv_users', 'Fix Unpaid', 'Fix Unpaid', CAPABILITY, 'cbv_users_fix_unpaid', __NAMESPACE__ . '\fix_unpaid');
1502 } 1507 }
1503 1508
1504 public static function admin_init() { 1509 public static function admin_init() {
......
...@@ -94,7 +94,6 @@ use WP_User; ...@@ -94,7 +94,6 @@ use WP_User;
94 $html .= '<div style="border:1px solid #777;padding:20px;position:relative;" id="viewable-port">'; 94 $html .= '<div style="border:1px solid #777;padding:20px;position:relative;" id="viewable-port">';
95 95
96 $status = get_post_meta($invoice->ID,'trans_status',true); 96 $status = get_post_meta($invoice->ID,'trans_status',true);
97
98 97
99 $html .= '<p> 98 $html .= '<p>
100 <img src="/wp-content/themes/cbv/assets/images/logo.gif" width="114" height="92" /></p><p> 99 <img src="/wp-content/themes/cbv/assets/images/logo.gif" width="114" height="92" /></p><p>
...@@ -248,14 +247,42 @@ use WP_User; ...@@ -248,14 +247,42 @@ use WP_User;
248 //} 247 //}
249 $html .= '</p>'; 248 $html .= '</p>';
250 249
251 //if ($status != "credit" && $invoice->payment['bt_address'] != "" && $invoice->payment['bt_card_holder'] != "") { 250 // Loop through each of the payment items
252 $html .= (!empty($invoice->payment['bt_card_holder'])) ? '<h3>BILLED TO:</h3>' : ""; 251 foreach ($invoice->payment as $key => $item) {
253 $html .= (!empty($invoice->payment['bt_card_holder'])) ? $invoice->payment['bt_card_holder']."<br />" : ""; 252 // Skip any fields that don't start with 'bt_'
254 $html .= (!empty($invoice->payment['bt_address'])) ? $invoice->payment['bt_address']." ".$invoice->payment['bt_address2'] . "<br />" : ""; 253 if (substr($key, 0, 3) != 'bt_') {
255 $html .= (!empty($invoice->payment['bt_city'])) ? $invoice->payment['bt_city'].", " .$invoice->payment['bt_province']."<br />" : ""; 254 continue;
256 $html .= (!empty($invoice->payment['bt_country'])) ? $invoice->payment['bt_country']."&nbsp;&nbsp;".$invoice->payment['bt_postal']."<br /><br />" : ""; 255 }
257 $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'] : ""; 256 }
258 //} 257 if ($status == 'unpaid') {
258 // Get the user's profile preference
259 $preference = strtolower($user->profile_preference);
260
261 // Build the 'Bill To:' info array
262 $user_fields = array('address', 'address2', 'city', 'province', 'country', 'postal');
263 $bill_to = array();
264 foreach ($user_fields as $field) {
265 // Use the preference to get the user's address info
266 $bill_to[$field] = get_user_meta($user->ID, "{$preference}_{$field}", TRUE);
267 }
268 // Finish it off with first and last name
269 $bill_to['first_name'] = get_user_meta($user->ID, 'first_name', TRUE);
270 $bill_to['last_name'] = get_user_meta($user->ID, 'last_name', TRUE);
271
272 // Now build the html
273 $html .= '<h3>BILL TO:</h3>';
274 $html .= "{$bill_to['first_name']} {$bill_to['last_name']}<br />";
275 $html .= "{$bill_to['address']}<br />{$bill_to['address2']}<br />";
276 $html .= "{$bill_to['city']}, {$bill_to['province']}<br />";
277 $html .= "{$bill_to['country']} {$bill_to['postal']}";
278 } else {
279 $html .= (!empty($invoice->payment['bt_card_holder'])) ? '<h3>BILLED TO:</h3>' : "";
280 $html .= (!empty($invoice->payment['bt_card_holder'])) ? $invoice->payment['bt_card_holder']."<br />" : "";
281 $html .= (!empty($invoice->payment['bt_address'])) ? $invoice->payment['bt_address']." ".$invoice->payment['bt_address2'] . "<br />" : "";
282 $html .= (!empty($invoice->payment['bt_city'])) ? $invoice->payment['bt_city'].", " .$invoice->payment['bt_province']."<br />" : "";
283 $html .= (!empty($invoice->payment['bt_country'])) ? $invoice->payment['bt_country']."&nbsp;&nbsp;".$invoice->payment['bt_postal']."<br /><br />" : "";
284 $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'] : "";
285 }
259 286
260 //if ($status != "credit") { 287 //if ($status != "credit") {
261 $html .= '<p>GST/HST# R108075334</p>'; 288 $html .= '<p>GST/HST# R108075334</p>';
......