function cp_prepare_transaction_entry($order_vals) { global $wpdb; if (is_array($order_vals)) { if (isset($order_vals['post_id'])) { $trdata['ad_id'] = $order_vals['post_id']; } $trdata['payment_type'] = $order_vals['cp_payment_method']; $trdata['payment_status'] = 'Pending'; $trdata['txn_id'] = $order_vals['oid']; $trdata['transaction_subject'] = $order_vals['oid']; $trdata['custom'] = $order_vals['oid']; $trdata['item_name'] = $order_vals['item_name']; $trdata['item_number'] = $order_vals['item_number']; $trdata['mc_gross'] = $order_vals['item_amount']; $trdata['mc_currency'] = get_option('cp_curr_pay_type'); if (isset($order_vals['user_id'])) { $the_user = get_userdata($order_vals['user_id']); } else { $orders = get_user_orders('', $order_vals['oid']); if (!empty($orders)) { $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); } } if ($the_user) { $trdata['first_name'] = $the_user->first_name; $trdata['last_name'] = $the_user->last_name; $trdata['payer_email'] = $the_user->user_email; } return $trdata; } else { return false; } }
function order() { switch ($_SERVER['REQUEST_METHOD']) { case 'GET': $order_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; if ($order_id > 0) { $r_data = get_order_detail($order_id, $user_id); } else { $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 1; $r_data = get_user_orders($user_id, $limit, $page); } // $record_count = $db->getOne("SELECT COUNT(*) FROM " .$ecs->table('order_info'). " WHERE user_id = '$user_id'"); return $r_data; break; case 'DELETE': $order_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $user_id = $_SESSION['user_id']; if (cancel_order($order_id, $user_id)) { $r_data = 'Cancle Order Success!'; } else { $r_data = 'Cancle Order Failed!'; } return $r_data; break; default: return 'This API can not support ' . $_SERVER['REQUEST_METHOD'] . ' method'; break; } }
function appthemes_process_membership_order($current_user, $order) { //if order ID matches pending membership id suffix, then process the order by extendning the date and setting the ID if (isset($current_user->active_membership_pack)) { $user_active_pack_id = get_pack_id($current_user->active_membership_pack); } else { $user_active_pack_id = false; } if (isset($current_user->membership_expires)) { $user_active_pack_expiration = $current_user->membership_expires; } else { $user_active_pack_expiration = strtotime(current_time('mysql')); } if ($order['total_cost'] == 0 || $order['order_id'] == $_REQUEST['oid'] || $order['order_id'] == $_REQUEST['custom'] || $order['order_id'] == $_REQUEST['invoice']) { //update the user profile to current order pack_id taking it off "pending" status and setup the membership object update_user_meta($current_user->ID, 'active_membership_pack', $order['pack_id']); $membership = get_pack($order['pack_id']); //extend membership if its still active, so long as its not free (otherwise free extentions could be infinite) $expires_in_days = appthemes_seconds_to_days(strtotime($user_active_pack_expiration) - strtotime(current_time('mysql'))); $purchase = $order['pack_duration'] . ' ' . __('days', 'appthemes'); if ($expires_in_days > 0 && $order['total_cost'] > 0 && $order['pack_id'] == $user_active_pack_id) { $updated_expires_date = appthemes_mysql_date($user_active_pack_expiration, $order['pack_duration']); } else { $updated_expires_date = appthemes_mysql_date(current_time('mysql'), $order['pack_duration']); } update_user_meta($current_user->ID, 'membership_expires', $updated_expires_date); $order['updated_expires_date'] = $updated_expires_date; delete_option($order['option_order_id']); //return the order information in case its needed return $order; } else { //get orders of the user $the_order = get_user_orders($current_user->ID, $order['order_id']); return false; } }
public function orders($user_id, $size = 10, $start = 0) { include_once ROOT_PATH . 'includes/lib_transaction.php'; $orders = get_user_orders($user_id, $size, $start); return $orders; }
$order['option_order_id'] = 'cp_order_' . $current_user->ID . '_' . $_POST['oid']; $order['pack_type'] = 'membership'; $order['total_cost'] = $total_cost; //Check for coupon and use to to reduce total price and total number of coupon uses left if (isset($_POST['cp_coupon_code'])) { $order['cp_coupon_code'] = $_POST['cp_coupon_code']; //incriment coupon code count only if total ad price was not zero if (cp_check_coupon_discount($order['cp_coupon_code'])) { cp_use_coupon($order['cp_coupon_code']); //TODO - handle discounting of total cost } } $order = array_merge($order, (array) $membership); //save the order for use when payment is completed if (add_option($order['option_order_id'], $order)) { $cp_user_orders = get_user_orders($current_user->ID); if (isset($cp_user_orders) && $cp_user_orders) { $cp_user_recent_order = $cp_user_orders[0]; } } else { $order_already_exists = true; } include_once TEMPLATEPATH . '/includes/forms/step3-membership.php'; } else { // create a unique ID for this new ad order // uniqid requires a param for php 4.3 or earlier. added for 3.0.1 if (empty($cp_user_recent_order)) { $order_id = uniqid(rand(10, 1000), false); } else { $order_id = get_order_id($cp_user_recent_order); }
} elseif ($action == 'order_list') { include_once ROOT_PATH . 'include/lib_transaction.php'; $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $record_count = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('order_info') . " WHERE user_id = '{$user_id}'"); $pager = get_pager('user.php', array('act' => $action), $record_count, $page); $orders = get_user_orders($user_id, $pager['size'], $pager['start']); $merge = get_user_merge($user_id); $smarty->assign('merge', $merge); $smarty->assign('pager', $pager); $smarty->assign('orders', $orders); $smarty->display('user_transaction.dwt'); } elseif ($action == 'async_order_list') { include_once ROOT_PATH . 'include/lib_transaction.php'; $start = $_POST['last']; $limit = $_POST['amount']; $orders = get_user_orders($user_id, $limit, $start); if (is_array($orders)) { foreach ($orders as $vo) { //获取订单第一个商品的图片 $img = $db->getOne("SELECT g.goods_thumb FROM " . $ecs->table('order_goods') . " as og left join " . $ecs->table('goods') . " g on og.goods_id = g.goods_id WHERE og.order_id = " . $vo['order_id'] . " limit 1"); $tracking = $vo['shipping_id'] > 0 ? '<a href="user.php?act=order_tracking&order_id=' . $vo['order_id'] . '" class="c-btn3">订单跟踪</a>' : ''; $asyList[] = array('order_status' => '订单状态:' . $vo['order_status'], 'order_handler' => $vo['handler'], 'order_content' => '<a href="user.php?act=order_detail&order_id=' . $vo['order_id'] . '"><table width="100%" border="0" cellpadding="5" cellspacing="0" class="ectouch_table_no_border"> <tr> <td><img src="' . $config['site_url'] . $img . '" width="50" height="50" /></td> <td>订单编号:' . $vo['order_sn'] . '<br> 订单金额:' . $vo['total_fee'] . '<br> 下单时间:' . $vo['order_time'] . '</td> <td style="position:relative"><span class="new-arr"></span></td> </tr> </table></a>', 'order_tracking' => $tracking); }
function cp_transactions() { global $wpdb; // check to prevent php "notice: undefined index" msg when php strict warnings is on if (isset($_GET['action'])) { $theswitch = $_GET['action']; } else { $theswitch = ''; } switch ($theswitch) { // mark transaction as paid case 'setPaid': $update = "UPDATE " . $wpdb->prefix . "cp_order_info SET payment_status = 'Completed' WHERE id = '" . $_GET['id'] . "'"; $wpdb->query($update); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Updating transaction entry.....', 'appthemes'); ?> <br /><br /><img src="<?php echo bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // mark transaction as unpaid // mark transaction as unpaid case 'unsetPaid': $update = "UPDATE " . $wpdb->prefix . "cp_order_info SET payment_status = 'Pending' WHERE id = '" . $_GET['id'] . "'"; $wpdb->query($update); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Updating transaction entry.....', 'appthemes'); ?> <br /><br /><img src="<?php echo bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // delete transaction entry // delete transaction entry case 'delete': $delete = "DELETE FROM " . $wpdb->prefix . "cp_order_info WHERE id = '" . $_GET['id'] . "'"; $wpdb->query($delete); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Deleting transaction entry.....', 'appthemes'); ?> <br /><br /><img src="<?php echo bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // activate membership, update transaction entry // activate membership, update transaction entry case 'activateMembership': include_once TEMPLATEPATH . '/includes/forms/step-functions.php'; $orders = get_user_orders('', $_GET['oid']); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); //activate membership $order_processed = appthemes_process_membership_order($the_user, $storedOrder); //send email to user if ($order_processed) { cp_owner_activated_membership_email($the_user, $order_processed); } //update transaction entry $update = "UPDATE " . $wpdb->prefix . "cp_order_info SET payment_status = 'Completed' WHERE custom = '" . $_GET['oid'] . "'"; $wpdb->query($update); } ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Activating membership plan.....', 'appthemes'); ?> <br /><br /><img src="<?php echo bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // show the table of all transactions // show the table of all transactions default: ?> <div class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Order Transactions', 'appthemes'); ?> </h2> <?php cp_admin_info_box(); ?> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Payer Name', 'appthemes'); ?> </th> <th scope="col" style="text-align: center;"><?php _e('Payer Status', 'appthemes'); ?> </th> <th scope="col"><?php _e('Ad Title', 'appthemes'); ?> </th> <th scope="col"><?php _e('Item Description', 'appthemes'); ?> </th> <th scope="col" style="width:125px;"><?php _e('Transaction ID', 'appthemes'); ?> </th> <th scope="col"><?php _e('Payment Type', 'appthemes'); ?> </th> <th scope="col"><?php _e('Payment Status', 'appthemes'); ?> </th> <th scope="col"><?php _e('Total Amount', 'appthemes'); ?> </th> <th scope="col" style="width:150px;"><?php _e('Date Paid', 'appthemes'); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', 'appthemes'); ?> </th> </tr> </thead> <?php // must be higher than personal edition so let's query the db $sql = "SELECT o.*, p.post_title " . "FROM " . $wpdb->prefix . "cp_order_info o, {$wpdb->posts} p " . "WHERE o.ad_id = p.id " . "ORDER BY o.id desc"; $results = $wpdb->get_results($sql); if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i; ?> .</td> <td><strong><?php echo $result->first_name; ?> <?php echo $result->last_name; ?> </strong><br /><a href="mailto:<?php echo $result->payer_email; ?> "><?php echo $result->payer_email; ?> </a></td> <td style="text-align: center;"> <?php if ($result->payer_status == 'verified') { ?> <img src="<?php bloginfo('template_directory'); ?> /images/paypal_verified.gif" alt="" title="" /><br /><?php } ?> <?php echo ucfirst($result->payer_status); ?> </td> <td><a href="post.php?action=edit&post=<?php echo $result->ad_id; ?> "><?php echo $result->post_title; ?> </a></td> <td><?php echo $result->item_name; ?> </td> <td><?php echo $result->txn_id; ?> </td> <td><?php echo ucfirst($result->payment_type); ?> </td> <td><?php echo ucfirst($result->payment_status); ?> </td> <td><?php echo $result->mc_gross; ?> <?php echo $result->mc_currency; ?> </td> <td><?php echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->payment_date); ?> </td> <td style="text-align:center"> <?php echo '<a onclick="return confirmBeforeDelete();" href="?page=transactions&action=delete&id=' . $result->id . '" title="' . __('Delete', 'appthemes') . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="' . __('Delete', 'appthemes') . '" /></a> '; if (strtolower($result->payment_status) == 'completed') { echo '<br /><a href="?page=transactions&action=unsetPaid&id=' . $result->id . '" title="' . __('Mark as Unpaid', 'appthemes') . '">' . __('Unmark Paid', 'appthemes') . '</a>'; } else { echo '<br /><a href="?page=transactions&action=setPaid&id=' . $result->id . '" title="' . __('Mark as Paid', 'appthemes') . '">' . __('Mark Paid', 'appthemes') . '</a>'; } ?> </td> </tr> <?php $i++; } // end for each ?> </tbody> <?php } else { ?> <tr> <td> </td><td colspan="10"><?php _e('No transactions found.', 'appthemes'); ?> </td> </tr> <?php } // end $results ?> </table> <!-- this is ok --> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Membership Orders', 'appthemes'); ?> </h2> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Payer Name', 'appthemes'); ?> </th> <th scope="col" style="text-align: center;"><?php _e('Payer Status', 'appthemes'); ?> </th> <th scope="col"><?php _e('Item Description', 'appthemes'); ?> </th> <th scope="col" style="width:125px;"><?php _e('Transaction ID', 'appthemes'); ?> </th> <th scope="col"><?php _e('Payment Type', 'appthemes'); ?> </th> <th scope="col"><?php _e('Payment Status', 'appthemes'); ?> </th> <th scope="col"><?php _e('Total Amount', 'appthemes'); ?> </th> <th scope="col" style="width:150px;"><?php _e('Date Paid', 'appthemes'); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', 'appthemes'); ?> </th> </tr> </thead> <?php // seperate table for membership orders $sql = "SELECT * " . "FROM " . $wpdb->prefix . "cp_order_info " . "WHERE ad_id = 0 " . "ORDER BY id desc"; $results = $wpdb->get_results($sql); if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i; ?> .</td> <?php $payer = get_user_by('email', $result->payer_email); ?> <?php //TODO - LOOKUP CUSTOMER BY PAYPAL EMAIL CUSTOM PROFILE FIELD ?> <td><strong><?php echo $result->first_name; ?> <?php echo $result->last_name; ?> </strong><br /><a href="<?php if (isset($payer->ID) && $payer) { echo get_bloginfo('url') . '/wp-admin/user-edit.php?user_id=' . $payer->ID; } else { echo 'mailto:' . $result->payer_email; } ?> "><?php echo $result->payer_email; ?> </a></td> <td style="text-align: center;"> <?php if ($result->payer_status == 'verified') { ?> <img src="<?php bloginfo('template_directory'); ?> /images/paypal_verified.gif" alt="" title="" /><br /><?php } ?> <?php echo ucfirst($result->payer_status); ?> </td> <td><?php echo $result->item_name; ?> </td> <td><?php echo $result->txn_id; ?> </td> <td><?php echo ucfirst($result->payment_type); ?> </td> <td><?php echo ucfirst($result->payment_status); ?> </td> <td><?php echo $result->mc_gross; ?> <?php echo $result->mc_currency; ?> </td> <td><?php echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->payment_date); ?> </td> <td style="text-align:center"> <?php echo '<a onclick="return confirmBeforeDelete();" href="?page=transactions&action=delete&id=' . $result->id . '" title="' . __('Delete', 'appthemes') . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="' . __('Delete', 'appthemes') . '" /></a> '; if (strtolower($result->payment_status) == 'completed') { echo '<br /><a href="?page=transactions&action=unsetPaid&id=' . $result->id . '" title="' . __('Mark as Unpaid', 'appthemes') . '">' . __('Unmark Paid', 'appthemes') . '</a>'; } else { echo '<br /><a href="?page=transactions&action=setPaid&id=' . $result->id . '" title="' . __('Mark as Paid', 'appthemes') . '">' . __('Mark Paid', 'appthemes') . '</a>'; } ?> </td> </tr> <?php $i++; } // end for each ?> </tbody> <?php } else { ?> <tr> <td> </td><td colspan="9"><?php _e('No transactions found.', 'appthemes'); ?> </td> </tr> <?php } // end $results ?> </table> <!-- this is ok --> </div><!-- end wrap --> <?php } // endswitch ?> <script type="text/javascript"> /* <![CDATA[ */ function confirmBeforeDelete() { return confirm("<?php _e('WARNING: Are you sure you want to delete this transaction entry?? (This cannot be undone)', 'appthemes'); ?> "); } /* ]]> */ </script> <?php }
function cp_handle_ipn_response($_POST) { global $wpdb; //step functions required to process orders include_once "wp-load.php"; include_once TEMPLATEPATH . '/includes/forms/step-functions.php'; // make sure the ad unique trans id (stored in invoice var) is included if (!empty($_POST['txn_type']) && !empty($_POST['invoice'])) { // process the ad based on the paypal response switch (strtolower($_POST['payment_status'])) { // payment was made so we can approve the ad case 'completed': $pid = trim($_POST['invoice']); //attempt to process membership order first $orders = get_user_orders('', $pid); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); if (get_option('cp_paypal_ipn_debug') == 'true' && !empty($orders)) { wp_mail(get_option('admin_email'), 'PayPal IPN Attempting to Activate Memebership', print_r($orders, true) . PHP_EOL . print_r($order, true) . PHP_EOL . print_r($_REQUEST, true)); } $order_processed = appthemes_process_membership_order($the_user, $storedOrder); } if ($order_processed) { //admin email confirmation //TODO - move into wordpress options panel and allow customization wp_mail(get_option('admin_email'), 'PayPal IPN Activated Memebership', __('A membership order has been completed. Check to make sure this is a valid order by comparing this messages Paypal Transaction ID to the respective ID in the Paypal payment receipt email.', 'appthemes') . PHP_EOL . __('Order ID: ', 'appthemes') . print_r($orders, true) . PHP_EOL . __('User ID: ', 'appthemes') . print_r($user_id, true) . PHP_EOL . __('User Login: '******'appthemes') . print_r($the_user->user_login, true) . PHP_EOL . __('Pack Name: ', 'appthemes') . print_r(stripslashes($storedOrder['pack_name']), true) . PHP_EOL . __('Total Cost: ', 'appthemes') . print_r($storedOrder['total_cost'], true) . PHP_EOL . __('Paypal Transaction ID: ', 'appthemes') . print_r($_POST['txn_id'], true) . PHP_EOL); break; } $sql = $wpdb->prepare("SELECT p.ID, p.post_status\r\n FROM {$wpdb->posts} p, {$wpdb->postmeta} m\r\n WHERE p.ID = m.post_id\r\n AND p.post_status <> 'publish'\r\n AND m.meta_key = 'cp_sys_ad_conf_id'\r\n AND m.meta_value = %s\r\n ", $pid); $newadid = $wpdb->get_row($sql); // if the ad is found, then publish it if ($newadid) { $the_ad = array(); $the_ad['ID'] = $newadid->ID; $the_ad['post_status'] = 'publish'; $ad_id = wp_update_post($the_ad); // now we need to update the ad expiration date so they get the full length of time // sometimes they didn't pay for the ad right away or they are renewing // first get the ad duration and first see if ad packs are being used // if so, get the length of time in days otherwise use the default // prune period defined on the CP settings page $ad_length = get_post_meta($ad_id, 'cp_sys_ad_duration', true); if (isset($ad_length)) { $ad_length = $ad_length; } else { $ad_length = get_option('cp_prun_period'); } // set the ad listing expiration date $ad_expire_date = date_i18n('m/d/Y H:i:s', strtotime('+' . $ad_length . ' days')); // don't localize the word 'days' //now update the expiration date on the ad update_post_meta($ad_id, 'cp_sys_expire_date', $ad_expire_date); } break; case 'pending': // send an email if payment is pending wp_mail(get_option('admin_email'), 'PayPal IPN - payment pending', "" . print_r($_POST, true)); break; // payment failed so don't approve the ad // payment failed so don't approve the ad case 'denied': case 'expired': case 'failed': case 'voided': // send an email if payment didn't work wp_mail(get_option('admin_email'), 'PayPal IPN - payment failed', "" . print_r($_POST, true)); break; } // regardless of what happens, log the transaction if (file_exists(TEMPLATEPATH . '/includes/gateways/process.php')) { include_once TEMPLATEPATH . '/includes/gateways/process.php'; } } }
* was randomly generated during the ad submission. It is stored in * the cp_sys_ad_conf_id custom field. If this page is loaded and no * matching ad id is found or the ad is already published then * show an error message instead of doing any db updates * * @package ClassiPress * @author AppThemes * @version 3.0 * */ // if not logged in, redirect to login page auth_redirect_login(); //otherwise load step functions file with functions required to process the order include_once TEMPLATEPATH . '/includes/forms/step-functions.php'; global $wpdb, $current_user; $order = get_user_orders($current_user->ID, $_REQUEST['oid']); //if the order was found by OID, setup the order details into the $order variable if (isset($order) && $order) { $order = get_option($order); } //make sure the order sent from payment gateway is logged in the database and that the current user created it if (isset($order['order_id']) && $order['order_id'] == $_REQUEST['oid'] && $order['user_id'] == $current_user->ID) { $order_processed = appthemes_process_membership_order($current_user, $order); //send email to user if ($order_processed) { cp_owner_activated_membership_email($current_user, $order_processed); } } else { $order_processed = false; // check and make sure this transaction hasn't already been added $sql = "SELECT * " . "FROM {$wpdb->cp_order_info} " . "WHERE custom = '" . $wpdb->escape(appthemes_clean($_REQUEST['oid'])) . "' LIMIT 1";
$last_name = ""; } if (!($phone_number = portal_get_user_meta($page_id, "phone_number"))) { $phone_number = ""; } if (!($telegram = portal_get_user_meta($page_id, "telegram_account"))) { $telegram = ""; } if (!$public_viewer) { $tickets = get_user_tickets($real_user->ID, 10); } else { $tickets = array(); } $departments = array(0 => "فروش", 1 => "پشتیبانی فنی", 2 => "بررسی سفارشات"); $pending_orders = get_user_pending_orders($page_id, 10); $orders = get_user_orders($page_id, 10); $register_date_obj = new DateTime($real_user->user_registered); $register_date = $register_date_obj->format("Y/m/d H:i:s"); $can_change_user_name = portal_get_user_meta($page_id, "username-change"); ?> <html> <head> <title>مدیریت · اطلاعات کاربر</title> <meta charset="UTF-8"> <link rel="stylesheet" href="../stylesheets/signin.css"> <!-- New Stylesheet --> <?php include '../template/ui.php';
/** * Processes membership activation on order activation. * * @param object $order */ function cp_payments_handle_membership_activated($order) { // include all the functions needed for this action require_once get_template_directory() . '/includes/forms/step-functions.php'; foreach ($order->get_items(CP_ITEM_MEMBERSHIP) as $item) { $user = get_user_by('id', $order->get_author()); $membership_orders = get_user_orders($user->ID, false); if (empty($membership_orders)) { continue; } $order_id = get_order_id($membership_orders[0]); $stored_order = get_option($membership_orders[0]); $order_processed = appthemes_process_membership_order($user, $stored_order); if ($order_processed) { cp_owner_activated_membership_email($user, $order_processed); } } }
/** * This script is the landing page after payment has been processed * by PayPal or other gateways. It is expecting a unique ad id which * was randomly generated during the ad submission. It is stored in * the cp_sys_ad_conf_id custom field. If this page is loaded and no * matching ad id is found or the ad is already published then * show an error message instead of doing any db updates * * @package ClassiPress * @author AppThemes * @version 3.0 * */ global $wpdb, $current_user; $oid = isset($_REQUEST['oid']) ? appthemes_clean($_REQUEST['oid']) : false; $order = get_user_orders($current_user->ID, $oid); //if the order was found by OID, setup the order details into the $order variable if (isset($order) && $order) { $order = get_option($order); } //make sure the order sent from payment gateway is logged in the database and that the current user created it if (isset($order['order_id']) && $order['order_id'] == $oid && $order['user_id'] == $current_user->ID) { $order_processed = appthemes_process_membership_order($current_user, $order); //send email to user if ($order_processed) { cp_owner_activated_membership_email($current_user, $order_processed); } } else { $order_processed = false; // check and make sure this transaction hasn't already been added $sql = "SELECT * FROM {$wpdb->cp_order_info} WHERE custom = '%s' LIMIT 1";
function cp_dashboard_paypal_button($the_id) { global $wpdb, $current_user; $current_user = wp_get_current_user(); $pack = get_pack($the_id); // figure out the number of days this ad was listed for if (get_post_meta($the_id, 'cp_sys_ad_duration', true)) { $prun_period = get_post_meta($the_id, 'cp_sys_ad_duration', true); } else { $prun_period = get_option('cp_prun_period'); } //setup variables depending on the purchase type if (isset($pack->pack_name) && stristr($pack->pack_status, 'membership')) { //get any existing orders $cp_user_orders = get_user_orders($current_user->ID); if (isset($cp_user_orders) && $cp_user_orders) { $cp_user_recent_order = $cp_user_orders[0]; } else { $oid = uniqid(rand(10, 1000), false); $order = array(); $order['user_id'] = $current_user->ID; $order['order_id'] = $oid; $order['option_order_id'] = 'cp_order_' . $current_user->ID . '_' . $oid; $order['pack_type'] = 'membership'; $order['total_cost'] = $pack->pack_membership_price; $order = array_merge($order, (array) $pack); if (add_option($order['option_order_id'], $order)) { $cp_user_orders = get_user_orders($current_user->ID); if (isset($cp_user_orders) && $cp_user_orders) { $cp_user_recent_order = $cp_user_orders[0]; } } } $item_name = sprintf(__('Membership on %s for %s days', 'appthemes'), get_bloginfo('name'), $pack->pack_duration); $item_number = stripslashes($pack->pack_name); $custom = get_order_id($cp_user_recent_order); $amount = $pack->pack_membership_price; $notify_url = get_bloginfo('url') . '/index.php?invoice=' . $custom; $return = CP_MEMBERSHIP_PURCHASE_CONFIRM_URL . '?oid=' . $custom; $cbt = __('Click here to complete your purchase on', 'appthemes') . ' ' . get_bloginfo('name'); } else { //by default we assume its an ad posting $item_name = sprintf(__('Classified ad listing on %s for %s days', 'appthemes'), get_bloginfo('name'), $prun_period); $item_number = get_post_meta($the_id, 'cp_sys_ad_conf_id', true); $custom = get_post_meta($the_id, 'cp_sys_ad_conf_id', true); $amount = get_post_meta($the_id, 'cp_sys_total_ad_cost', true); $notify_url = get_bloginfo('url') . '/index.php?invoice=' . get_post_meta($the_id, 'cp_sys_ad_conf_id', true) . '&aid=' . $the_id; $return = CP_ADD_NEW_CONFIRM_URL . '?pid=' . get_post_meta($the_id, 'cp_sys_ad_conf_id', true) . '&aid=' . $the_id; $cbt = __('Click here to publish your ad on', 'appthemes') . ' ' . get_bloginfo('name'); } ?> <form name="paymentform" action="<?php if (get_option('cp_paypal_sandbox') == 'true') { echo 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } else { echo 'https://www.paypal.com/cgi-bin/webscr'; } ?> " method="post"> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="charset" value="utf-8" /> <input type="hidden" name="business" value="<?php echo get_option('cp_paypal_email'); ?> " /> <input type="hidden" name="item_name" value="<?php echo esc_attr($item_name); ?> " /> <input type="hidden" name="item_number" value="<?php echo esc_attr($item_number); ?> " /> <input type="hidden" name="amount" value="<?php echo esc_attr($amount); ?> " /> <input type="hidden" name="no_shipping" value="1" /> <input type="hidden" name="no_note" value="1" /> <input type="hidden" name="custom" value="<?php echo esc_attr($custom); ?> " /> <input type="hidden" name="cancel_return" value="<?php echo home_url(); ?> " /> <input type="hidden" name="return" value="<?php echo esc_attr($return); ?> " /> <input type="hidden" name="rm" value="2" /> <input type="hidden" name="cbt" value="<?php echo esc_attr($cbt); ?> " /> <input type="hidden" name="currency_code" value="<?php echo esc_attr(get_option('cp_curr_pay_type')); ?> " /> <?php if (get_option('cp_enable_paypal_ipn') == 'yes') { ?> <input type="hidden" name="notify_url" value="<?php echo esc_attr($notify_url); ?> " /> <?php if (get_option('cp_paypal_sandbox') == 'true') { ?> <input type="hidden" name="test_ipn" value="1" /> <?php } ?> <?php } ?> <?php if (get_option('cp_paypal_logo_url')) { ?> <input type="hidden" name="cpp_header_image" value="<?php echo esc_attr(get_option('cp_paypal_logo_url')); ?> " /> <?php } ?> <input type="image" src="<?php bloginfo('template_directory'); ?> /images/paypal.png" name="submit" /> </form> <?php }
<body> <?php if ($user_level == 10) { defined("FUNCTIONSOFADMIN") || define("FUNCTIONSOFADMIN", true); require_once "admin_funcs.php"; include '../template/header.php'; } else { defined("FUNCTIONSOFUSERS") || define("FUNCTIONSOFUSERS", true); require_once "user_funcs.php"; include "../template/header-user.php"; defined("RSSCLASS") || define("RSSCLASS", true); require_once "../__Classes/class.RssReader.php"; $tickets = get_user_tickets($user->ID, 10); $order = get_user_orders($user->ID, 1); } if ($user_level == 10) { ?> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="yekan success-text"> <i class="fa fa-comments"></i> تیکت های پشتیبانی </h4> </div> <div class="panel-body"> <div class="row"> <div class="col-lg-3 col-md-6"> <div class="panel panel-primary">
/** * Process membership order * * @param array */ public static function process_membership_order($order_info) { $file = get_template_directory() . '/includes/forms/step-functions.php'; if (is_readable($file)) { include_once $file; /* * Abracadabra */ $txn_id = $order_info['txn_id']; /* * First we retrieve user orders by the transaction id * @see https://bitbucket.org/Pronamic/classipress/src/bc1334736c6e/includes/theme-functions.php?at=3.2.1#cl-2488 */ $orders = get_user_orders('', $txn_id); $order = get_option($orders); /* * Get the user ID from the orders * @see https://bitbucket.org/Pronamic/classipress/src/bc1334736c6e/includes/theme-functions.php?at=3.2.1#cl-2476 */ $user_id = get_order_userid($orders); /* * Get user data * @see http://codex.wordpress.org/Function_Reference/get_userdata */ $userdata = get_userdata($user_id); // @see https://bitbucket.org/Pronamic/classipress/src/bc1334736c6e/includes/forms/step-functions.php?at=3.2.1#cl-895 $order_processed = appthemes_process_membership_order($userdata, $order); if ($order_processed) { // @see https://bitbucket.org/Pronamic/classipress/src/bc1334736c6e/includes/theme-emails.php?at=3.2.1#cl-563 cp_owner_activated_membership_email($userdata, $order_processed); } } }
function cp_bank_owner_new_membership_email($oid) { $orders = get_user_orders('', $oid); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); $membership_order_id = stripslashes($order_id); $membership_pack_id = stripslashes($storedOrder['pack_id']); $membership_pack_name = stripslashes($storedOrder['pack_name']); $membership_user_email = stripslashes($the_user->user_email); $membership_user_login = stripslashes($the_user->user_login); $membership_total_cost = stripslashes($storedOrder['total_cost']); $siteurl = trailingslashit(get_option('home')); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $mailto = $membership_user_email; $subject = sprintf(__('Your Membership Purchase on %s', 'appthemes'), $blogname); $headers = 'From: ' . sprintf(__('%s Admin', 'appthemes'), $blogname) . ' <' . get_option('admin_email') . '>' . "\r\n"; $message = sprintf(__('Hi %s,', 'appthemes'), $membership_user_login) . "\r\n\r\n"; $message .= __('Thank you for your membership order! Your membership has been submitted and will not be valid on our site until you pay for it.', 'appthemes') . "\r\n\r\n"; $message .= __('Please include the following details when sending the bank transfer. Once your transfer has been verified, we will then activate your membership.') . "\r\n\r\n"; $message .= __('Details for Payment', 'appthemes') . "\r\n"; $message .= __('-----------------') . "\r\n"; $message .= __('Transaction ID: ', 'appthemes') . $membership_pack_name . "\r\n"; $message .= __('Reference #: ', 'appthemes') . $oid . "\r\n"; $message .= __('Total Amount: ', 'appthemes') . $membership_total_cost . " (" . get_option('cp_curr_pay_type') . ")\r\n"; $message .= __('-----------------') . "\r\n\r\n"; $message .= __('Bank Transfer Instructions', 'appthemes') . "\r\n"; $message .= __('-----------------') . "\r\n"; $message .= strip_tags(appthemes_br2nl(stripslashes(get_option('cp_bank_instructions')))) . "\r\n"; $message .= __('-----------------') . "\r\n\r\n"; $message .= __('For questions or problems, please contact us directly at', 'appthemes') . " " . get_option('admin_email') . "\r\n\r\n\r\n\r\n"; $message .= __('Regards,', 'appthemes') . "\r\n\r\n"; $message .= sprintf(__('Your %s Team', 'appthemes'), $blogname) . "\r\n"; $message .= $siteurl . "\r\n\r\n\r\n\r\n"; // ok let's send the email wp_mail($mailto, $subject, $message, $headers); } }
$smarty->assign('pagebar', $pagebar); /* 订单状态 */ $_LANG['os'][OS_UNCONFIRMED] = '未确认'; $_LANG['os'][OS_CONFIRMED] = '已确认'; $_LANG['os'][OS_CANCELED] = '已取消'; $_LANG['os'][OS_INVALID] = '无效'; $_LANG['os'][OS_RETURNED] = '退货'; $_LANG['ss'][SS_UNSHIPPED] = '未发货'; $_LANG['ss'][SS_SHIPPED] = '已发货'; $_LANG['ss'][SS_RECEIVED] = '收货确认'; $_LANG['ps'][PS_UNPAYED] = '未付款'; $_LANG['ps'][PS_PAYING] = '付款中'; $_LANG['ps'][PS_PAYED] = '已付款'; $_LANG['confirm_cancel'] = '您确认要取消该订单吗?取消后此订单将视为无效订单'; $_LANG['cancel'] = '取消订单'; $orders = get_user_orders($_SESSION['user_id'], $page_num, $page_num * ($page - 1)); if (!empty($orders)) { foreach ($orders as $key => $val) { $orders[$key]['total_fee'] = encode_output($val['total_fee']); } } //$merge = get_user_merge($_SESSION['user_id']); $smarty->assign('orders', $orders); } $smarty->display('order_list.wml'); } else { if ($_SESSION['user_id'] > 0) { show_user_center(); } else { $smarty->display('login.wml'); }
function cp_handle_ipn_response() { global $wpdb; //step functions required to process orders include_once "wp-load.php"; include_once TEMPLATEPATH . '/includes/forms/step-functions.php'; // make sure the ad unique trans id (stored in invoice var) is included if (!empty($_POST['txn_id']) && !empty($_REQUEST['invoice'])) { $request_data = stripslashes_deep($_REQUEST); // process the ad based on the paypal response switch (strtolower($_POST['payment_status'])) { // payment was made so we can approve the ad case 'completed': $pid = trim($_REQUEST['invoice']); //attempt to process membership order first $orders = get_user_orders('', $pid); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); if (get_option('cp_paypal_ipn_debug') == 'true' && !empty($orders)) { wp_mail(get_option('admin_email'), __('PayPal IPN Attempting to Activate Membership', APP_TD), print_r($orders, true) . PHP_EOL . print_r($order, true) . PHP_EOL . print_r($request_data, true)); } $order_processed = appthemes_process_membership_order($the_user, $storedOrder); } if ($order_processed) { //send email to user cp_owner_activated_membership_email($the_user, $order_processed); //admin email confirmation //TODO - move into wordpress options panel and allow customization wp_mail(get_option('admin_email'), __('PayPal IPN Activated Membership', APP_TD), __('A membership order has been completed. Check to make sure this is a valid order by comparing this messages Paypal Transaction ID to the respective ID in the Paypal payment receipt email.', APP_TD) . PHP_EOL . __('Order ID: ', APP_TD) . print_r($orders, true) . PHP_EOL . __('User ID: ', APP_TD) . print_r($user_id, true) . PHP_EOL . __('User Login: '******'Pack Name: ', APP_TD) . print_r(stripslashes($storedOrder['pack_name']), true) . PHP_EOL . __('Total Cost: ', APP_TD) . print_r($storedOrder['total_cost'], true) . PHP_EOL . __('Paypal Transaction ID: ', APP_TD) . print_r($_POST['txn_id'], true) . PHP_EOL); break; } $sql = $wpdb->prepare("SELECT p.ID, p.post_status\n\t\t\t\t\tFROM {$wpdb->posts} p, {$wpdb->postmeta} m\n\t\t\t\t\tWHERE p.ID = m.post_id\n\t\t\t\t\tAND p.post_status <> 'publish'\n\t\t\t\t\tAND m.meta_key = 'cp_sys_ad_conf_id'\n\t\t\t\t\tAND m.meta_value = %s\n\t\t\t\t\t", $pid); $newadid = $wpdb->get_row($sql); // if the ad is found, then publish it if ($newadid) { $the_ad = array(); $the_ad['ID'] = $newadid->ID; $the_ad['post_status'] = 'publish'; $ad_id = wp_update_post($the_ad); // now we need to update the ad expiration date so they get the full length of time // sometimes they didn't pay for the ad right away or they are renewing // first get the ad duration and first see if ad packs are being used // if so, get the length of time in days otherwise use the default // prune period defined on the CP settings page $ad_length = get_post_meta($ad_id, 'cp_sys_ad_duration', true); if (isset($ad_length)) { $ad_length = $ad_length; } else { $ad_length = get_option('cp_prun_period'); } // set the ad listing expiration date $ad_expire_date = date_i18n('m/d/Y H:i:s', strtotime('+' . $ad_length . ' days')); // don't localize the word 'days' //now update the expiration date on the ad update_post_meta($ad_id, 'cp_sys_expire_date', $ad_expire_date); } break; case 'pending': // send an email if payment is pending $mailto = get_option('admin_email'); $subject = __('PayPal IPN - payment pending', APP_TD); $headers = 'From: ' . __('ClassiPress Admin', APP_TD) . ' <' . get_option('admin_email') . '>' . "\r\n"; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = __('Dear Admin,', APP_TD) . "\r\n\r\n"; $message .= sprintf(__('The following payment is pending on your %s website.', APP_TD), $blogname) . "\r\n\r\n"; $message .= __('Payment Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= __('Payer PayPal address: ', APP_TD) . $_POST['payer_email'] . "\r\n"; $message .= __('Transaction ID: ', APP_TD) . $_POST['txn_id'] . "\r\n"; $message .= __('Payer first name: ', APP_TD) . $_POST['first_name'] . "\r\n"; $message .= __('Payer last name: ', APP_TD) . $_POST['last_name'] . "\r\n"; $message .= __('Payment type: ', APP_TD) . $_POST['payment_type'] . "\r\n"; $message .= __('Amount: ', APP_TD) . html_entity_decode(cp_display_price($_POST['mc_gross'], $_POST['mc_currency'], false), ENT_QUOTES, 'UTF-8') . "\r\n\r\n"; $message .= __('Full Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= print_r($request_data, true) . "\r\n"; wp_mail($mailto, $subject, $message, $headers); break; // payment failed so don't approve the ad // payment failed so don't approve the ad case 'denied': case 'expired': case 'failed': case 'voided': // send an email if payment didn't work $mailto = get_option('admin_email'); $subject = __('PayPal IPN - payment failed', APP_TD); $headers = 'From: ' . __('ClassiPress Admin', APP_TD) . ' <' . get_option('admin_email') . '>' . "\r\n"; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = __('Dear Admin,', APP_TD) . "\r\n\r\n"; $message .= sprintf(__('The following payment has failed on your %s website.', APP_TD), $blogname) . "\r\n\r\n"; $message .= __('Payment Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= __('Payer PayPal address: ', APP_TD) . $_POST['payer_email'] . "\r\n"; $message .= __('Transaction ID: ', APP_TD) . $_POST['txn_id'] . "\r\n"; $message .= __('Payer first name: ', APP_TD) . $_POST['first_name'] . "\r\n"; $message .= __('Payer last name: ', APP_TD) . $_POST['last_name'] . "\r\n"; $message .= __('Payment type: ', APP_TD) . $_POST['payment_type'] . "\r\n"; $message .= __('Amount: ', APP_TD) . html_entity_decode(cp_display_price($_POST['mc_gross'], $_POST['mc_currency'], false), ENT_QUOTES, 'UTF-8') . "\r\n\r\n"; $message .= __('Full Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= print_r($request_data, true) . "\r\n"; wp_mail($mailto, $subject, $message, $headers); break; case 'refunded': case 'reversed': case 'chargeback': // send an email if payment was refunded $mailto = get_option('admin_email'); $subject = __('PayPal IPN - payment refunded/reversed', APP_TD); $headers = 'From: ' . __('ClassiPress Admin', APP_TD) . ' <' . get_option('admin_email') . '>' . "\r\n"; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = __('Dear Admin,', APP_TD) . "\r\n\r\n"; $message .= sprintf(__('The following payment has been marked as refunded on your %s website.', APP_TD), $blogname) . "\r\n\r\n"; $message .= __('Payment Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= __('Payer PayPal address: ', APP_TD) . $_POST['payer_email'] . "\r\n"; $message .= __('Transaction ID: ', APP_TD) . $_POST['txn_id'] . "\r\n"; $message .= __('Payer first name: ', APP_TD) . $_POST['first_name'] . "\r\n"; $message .= __('Payer last name: ', APP_TD) . $_POST['last_name'] . "\r\n"; $message .= __('Payment type: ', APP_TD) . $_POST['payment_type'] . "\r\n"; $message .= __('Reason code: ', APP_TD) . $_POST['reason_code'] . "\r\n"; $message .= __('Amount: ', APP_TD) . html_entity_decode(cp_display_price($_POST['mc_gross'], $_POST['mc_currency'], false), ENT_QUOTES, 'UTF-8') . "\r\n\r\n"; $message .= __('Full Details', APP_TD) . "\r\n"; $message .= __('-----------------', APP_TD) . "\r\n"; $message .= print_r($request_data, true) . "\r\n"; wp_mail($mailto, $subject, $message, $headers); break; } // regardless of what happens, log the transaction if (file_exists(TEMPLATEPATH . '/includes/gateways/process.php')) { include_once TEMPLATEPATH . '/includes/gateways/process.php'; } } }
function get_last_order() { $customer_order = current(get_user_orders()); if (!$customer_order) { return; } $order = wc_get_order($customer_order); $order->populate($customer_order); return $order->get_order_number(); }
function cp_transactions() { global $wpdb, $wp_version; include_once TEMPLATEPATH . '/includes/forms/step-functions.php'; if (isset($_GET['p'])) { $page = (int) $_GET['p']; } else { $page = 1; } $per_page = 10; $start = $per_page * $page - $per_page; // check to prevent php "notice: undefined index" msg when php strict warnings is on if (isset($_GET['action'])) { $theswitch = $_GET['action']; } else { $theswitch = ''; } switch ($theswitch) { // mark transaction as paid case 'setPaid': $wpdb->update($wpdb->cp_order_info, array('payment_status' => 'Completed'), array('id' => $_GET['id'])); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Updating transaction entry.....', APP_TD); ?> <br /><br /><img src="<?php bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // mark transaction as unpaid // mark transaction as unpaid case 'unsetPaid': $wpdb->update($wpdb->cp_order_info, array('payment_status' => 'Pending'), array('id' => $_GET['id'])); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Updating transaction entry.....', APP_TD); ?> <br /><br /><img src="<?php bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // delete transaction entry // delete transaction entry case 'delete': if (version_compare($wp_version, '3.4', '>=')) { $wpdb->delete($wpdb->cp_order_info, array('id' => $_GET['id'])); } else { $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->cp_order_info} WHERE id = %d", $_GET['id'])); } ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Deleting transaction entry.....', APP_TD); ?> <br /><br /><img src="<?php bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // activate membership, update transaction entry // activate membership, update transaction entry case 'activateMembership': $orders = get_user_orders('', $_GET['oid']); if (!empty($orders)) { $order_id = get_order_id($orders); $storedOrder = get_option($orders); $user_id = get_order_userid($orders); $the_user = get_userdata($user_id); //activate membership $order_processed = appthemes_process_membership_order($the_user, $storedOrder); //send email to user if ($order_processed) { cp_owner_activated_membership_email($the_user, $order_processed); } //update transaction entry $wpdb->update($wpdb->cp_order_info, array('payment_status' => 'Completed'), array('custom' => $_GET['oid'])); } ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Activating membership plan.....', APP_TD); ?> <br /><br /><img src="<?php bloginfo('template_directory'); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=transactions"> <?php break; // show the table of all transactions // show the table of all transactions default: ?> <div class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Order Transactions', APP_TD); ?> </h2> <?php cp_admin_info_box(); ?> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Payer Name', APP_TD); ?> </th> <th scope="col" style="text-align: center;"><?php _e('Payer Status', APP_TD); ?> </th> <th scope="col"><?php _e('Ad Title', APP_TD); ?> </th> <th scope="col"><?php _e('Item Description', APP_TD); ?> </th> <th scope="col" style="width:125px;"><?php _e('Transaction ID', APP_TD); ?> </th> <th scope="col"><?php _e('Payment Type', APP_TD); ?> </th> <th scope="col"><?php _e('Payment Status', APP_TD); ?> </th> <th scope="col"><?php _e('Total Amount', APP_TD); ?> </th> <th scope="col" style="width:150px;"><?php _e('Date Paid', APP_TD); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', APP_TD); ?> </th> </tr> </thead> <?php // must be higher than personal edition so let's query the db $sql = "SELECT SQL_CALC_FOUND_ROWS o.*, p.post_title " . "FROM {$wpdb->cp_order_info} o, {$wpdb->posts} p " . "WHERE o.ad_id = p.id " . "ORDER BY o.id DESC LIMIT {$start},{$per_page}"; $results = $wpdb->get_results($sql); $total_pages = $wpdb->get_var("SELECT FOUND_ROWS()"); $total_pages = ceil($total_pages / $per_page); if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; if ($result->user_id > 0) { $user = get_user_by('id', $result->user_id); $user_link = $user ? '( <a href="user-edit.php?user_id=' . $user->ID . '" title="' . __('Edit user', APP_TD) . '">' . $user->user_login . '</a> )<br />' : ''; } else { $user_link = ''; } ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i; ?> .</td> <td><strong><?php echo $result->first_name; ?> <?php echo $result->last_name; ?> </strong><br /><?php echo $user_link; ?> <a href="mailto:<?php echo $result->payer_email; ?> "><?php echo $result->payer_email; ?> </a></td> <td style="text-align: center;"> <?php if ($result->payer_status == 'verified') { ?> <img src="<?php bloginfo('template_directory'); ?> /images/paypal_verified.gif" alt="" title="" /><br /><?php } ?> <?php echo cp_get_status_i18n($result->payer_status); ?> </td> <td><a href="post.php?action=edit&post=<?php echo $result->ad_id; ?> "><?php echo $result->post_title; ?> </a></td> <td><?php echo $result->item_name; ?> </td> <td><?php echo $result->txn_id; ?> </td> <td><?php echo ucfirst($result->payment_type); ?> </td> <td><?php echo cp_get_status_i18n($result->payment_status); ?> </td> <td><?php cp_display_price($result->mc_gross, $result->mc_currency); ?> </td> <td><?php echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->payment_date); ?> </td> <td style="text-align:center"> <?php echo '<a onclick="return confirmBeforeDelete();" href="?page=transactions&action=delete&id=' . $result->id . '" title="' . __('Delete', APP_TD) . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="' . __('Delete', APP_TD) . '" /></a> '; if (strtolower($result->payment_status) == 'completed') { echo '<br /><a href="?page=transactions&action=unsetPaid&id=' . $result->id . '" title="' . __('Mark as Unpaid', APP_TD) . '">' . __('Unmark Paid', APP_TD) . '</a>'; } else { echo '<br /><a href="?page=transactions&action=setPaid&id=' . $result->id . '" title="' . __('Mark as Paid', APP_TD) . '">' . __('Mark Paid', APP_TD) . '</a>'; } ?> </td> </tr> <?php $i++; } // end for each ?> </tbody> <?php } else { ?> <tr> <td> </td><td colspan="10"><?php _e('No transactions found.', APP_TD); ?> </td> </tr> <?php } // end $results ?> </table> <!-- this is ok --> <div class="tablenav"> <div class="tablenav-pages alignright"> <?php if ($total_pages > 1) { echo paginate_links(array('base' => 'admin.php?page=transactions%_%', 'format' => '&p=%#%', 'prev_text' => __('« Previous', APP_TD), 'next_text' => __('Next »', APP_TD), 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5)); } ?> </div> </div> <div class="clear"></div> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Membership Orders', APP_TD); ?> </h2> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Payer Name', APP_TD); ?> </th> <th scope="col" style="text-align: center;"><?php _e('Payer Status', APP_TD); ?> </th> <th scope="col"><?php _e('Item Description', APP_TD); ?> </th> <th scope="col" style="width:125px;"><?php _e('Transaction ID', APP_TD); ?> </th> <th scope="col"><?php _e('Payment Type', APP_TD); ?> </th> <th scope="col"><?php _e('Payment Status', APP_TD); ?> </th> <th scope="col"><?php _e('Total Amount', APP_TD); ?> </th> <th scope="col" style="width:150px;"><?php _e('Date Paid', APP_TD); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', APP_TD); ?> </th> </tr> </thead> <?php // seperate table for membership orders $sql = "SELECT SQL_CALC_FOUND_ROWS * " . "FROM {$wpdb->cp_order_info} " . "WHERE ad_id = 0 " . "ORDER BY id DESC LIMIT {$start},{$per_page}"; $results = $wpdb->get_results($sql); $total_pages = $wpdb->get_var("SELECT FOUND_ROWS()"); $total_pages = ceil($total_pages / $per_page); if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; if ($result->user_id > 0) { $user = get_user_by('id', $result->user_id); $user_link = $user ? '( <a href="user-edit.php?user_id=' . $user->ID . '" title="' . __('Edit user', APP_TD) . '">' . $user->user_login . '</a> )<br />' : ''; } else { $user_link = ''; } ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i; ?> .</td> <?php $payer = get_user_by('email', $result->payer_email); ?> <?php //TODO - LOOKUP CUSTOMER BY PAYPAL EMAIL CUSTOM PROFILE FIELD ?> <td><strong><?php echo $result->first_name; ?> <?php echo $result->last_name; ?> </strong><br /><?php echo $user_link; ?> <a href="<?php if (isset($payer->ID) && $payer) { echo get_bloginfo('url') . '/wp-admin/user-edit.php?user_id=' . $payer->ID; } else { echo 'mailto:' . $result->payer_email; } ?> "><?php echo $result->payer_email; ?> </a></td> <td style="text-align: center;"> <?php if ($result->payer_status == 'verified') { ?> <img src="<?php bloginfo('template_directory'); ?> /images/paypal_verified.gif" alt="" title="" /><br /><?php } ?> <?php echo cp_get_status_i18n($result->payer_status); ?> </td> <td><?php echo $result->item_name; ?> </td> <td><?php echo $result->txn_id; ?> </td> <td><?php echo ucfirst($result->payment_type); ?> </td> <td><?php echo cp_get_status_i18n($result->payment_status); ?> </td> <td><?php cp_display_price($result->mc_gross, $result->mc_currency); ?> </td> <td><?php echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->payment_date); ?> </td> <td style="text-align:center"> <?php echo '<a onclick="return confirmBeforeDelete();" href="?page=transactions&action=delete&id=' . $result->id . '" title="' . __('Delete', APP_TD) . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="' . __('Delete', APP_TD) . '" /></a> '; if (strtolower($result->payment_status) == 'completed') { echo '<br /><a href="?page=transactions&action=unsetPaid&id=' . $result->id . '" title="' . __('Mark as Unpaid', APP_TD) . '">' . __('Unmark Paid', APP_TD) . '</a>'; } else { echo '<br /><a href="?page=transactions&action=setPaid&id=' . $result->id . '" title="' . __('Mark as Paid', APP_TD) . '">' . __('Mark Paid', APP_TD) . '</a>'; if (!empty($result->custom)) { $orders = get_user_orders('', $result->custom); } else { $orders = ''; } if (!empty($orders)) { echo '<br /><a href="?page=transactions&action=activateMembership&oid=' . $result->custom . '" title="' . __('Activate membership', APP_TD) . '">' . __('Activate membership', APP_TD) . '</a>'; } } ?> </td> </tr> <?php $i++; } // end for each ?> </tbody> <?php } else { ?> <tr> <td> </td><td colspan="9"><?php _e('No transactions found.', APP_TD); ?> </td> </tr> <?php } // end $results ?> </table> <!-- this is ok --> <div class="tablenav"> <div class="tablenav-pages alignright"> <?php if ($total_pages > 1) { echo paginate_links(array('base' => 'admin.php?page=transactions%_%', 'format' => '&p=%#%', 'prev_text' => __('« Previous', APP_TD), 'next_text' => __('Next »', APP_TD), 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5)); } ?> </div> </div> <div class="clear"></div> </div><!-- end wrap --> <?php } // endswitch ?> <script type="text/javascript"> /* <![CDATA[ */ function confirmBeforeDelete() { return confirm("<?php _e('WARNING: Are you sure you want to delete this transaction entry?? (This cannot be undone)', APP_TD); ?> "); } /* ]]> */ </script> <?php }
show_message($_LANG['edit_password_failure'], $_LANG['back_page_up'], '', 'info'); } } elseif ($action == 'act_add_bonus') { include_once ROOT_PATH . 'includes/lib_transaction.php'; $bouns_sn = isset($_POST['bonus_sn']) ? intval($_POST['bonus_sn']) : ''; if (add_bonus($user_id, $bouns_sn)) { show_message($_LANG['add_bonus_sucess'], $_LANG['back_up_page'], 'user.php?act=bonus', 'info'); } else { $err->show($_LANG['back_up_page'], 'user.php?act=bonus'); } } elseif ($action == 'order_list') { include_once ROOT_PATH . 'includes/lib_transaction.php'; $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $record_count = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('order_info') . " WHERE user_id = '{$user_id}'"); $pager = get_pager('user.php', array('act' => $action), $record_count, $page); $orders = get_user_orders($user_id, $pager['size'], $pager['start']); $merge = get_user_merge($user_id); $smarty->assign('merge', $merge); $smarty->assign('pager', $pager); $smarty->assign('orders', $orders); $smarty->display('user_transaction.dwt'); } elseif ($action == 'order_detail') { include_once ROOT_PATH . 'includes/lib_transaction.php'; include_once ROOT_PATH . 'includes/lib_payment.php'; include_once ROOT_PATH . 'includes/lib_order.php'; include_once ROOT_PATH . 'includes/lib_clips.php'; $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; /* 订单详情 */ $order = get_order_detail($order_id, $user_id); if ($order === false) { $err->show($_LANG['back_home_lnk'], './');
function order_list() { include_once ROOT_PATH . 'includes/lib_transaction.php'; $record_count = $GLOBALS['db']->getOne('SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE user_id = {$_SESSION['user_id']}"); if ($record_count > 0) { $page_num = '10'; $page = !empty($_GET['page']) ? intval($_GET['page']) : 1; $pages = ceil($record_count / $page_num); if ($page <= 0) { $page = 1; } if ($pages == 0) { $pages = 1; } if ($page > $pages) { $page = $pages; } $pagebar = get_wap_pager($record_count, $page_num, $page, 'user.php', 'page'); $GLOBALS['smarty']->assign('pagebar', $pagebar); /* 订单状态 */ $_LANG['os'][OS_UNCONFIRMED] = '未确认'; $_LANG['os'][OS_CONFIRMED] = '已确认'; $_LANG['os'][OS_SPLITED] = '已确认'; $_LANG['os'][OS_SPLITING_PART] = '已确认'; $_LANG['os'][OS_CANCELED] = '已取消'; $_LANG['os'][OS_INVALID] = '无效'; $_LANG['os'][OS_RETURNED] = '退货'; $_LANG['ss'][SS_UNSHIPPED] = '未发货'; $_LANG['ss'][SS_PREPARING] = '配货中'; $_LANG['ss'][SS_SHIPPED] = '已发货'; $_LANG['ss'][SS_RECEIVED] = '收货确认'; $_LANG['ss'][SS_SHIPPED_PART] = '已发货(部分商品)'; $_LANG['ss'][SS_SHIPPED_ING] = '配货中'; // 已分单 $_LANG['ps'][PS_UNPAYED] = '未付款'; $_LANG['ps'][PS_PAYING] = '付款中'; $_LANG['ps'][PS_PAYED] = '已付款'; $_LANG['cancel'] = '取消订单'; $_LANG['pay_money'] = '付款'; $_LANG['view_order'] = '查看订单'; $_LANG['received'] = '确认收货'; $_LANG['ss_received'] = '已完成'; $_LANG['confirm_received'] = '你确认已经收到货物了吗?'; $_LANG['confirm_cancel'] = '您确认要取消该订单吗?取消后此订单将视为无效订单'; $orders = get_user_orders($_SESSION['user_id'], $page_num, $page_num * ($page - 1)); //var_dump($orders); if (!empty($orders)) { foreach ($orders as $key => $val) { $orders[$key]['total_fee'] = encode_output($val['total_fee']); } } //$merge = get_user_merge($_SESSION['user_id']); $GLOBALS['smarty']->assign('orders', $orders); } }