/** * WP eCommerce Admin AJAX functions * * These are the WPSC Admin AJAX functions * * @package wp-e-commerce * @since 3.7 * * @uses update_option() Updates option in the database given key and value * @uses wp_delete_term() Removes term from the database * @uses fetch_rss() DEPRECATED * @uses wpsc_member_dedeactivate_subscriptions() @todo docs * @uses wpsc_member_deactivate_subscriptions() @todo docs * @uses wpsc_update_purchase_log_status() Updates the status of the logs for a purchase * @uses transaction_results() Main function for creating purchase reports * @uses wpsc_find_purchlog_status_name() Finds name of given status */ function wpsc_admin_ajax() { if (!wpsc_is_store_admin()) { return; } global $wpdb; if (isset($_POST['action']) && $_POST['action'] == 'product-page-order') { $current_order = get_option('wpsc_product_page_order'); $new_order = $_POST['order']; if (isset($new_order["advanced"])) { $current_order["advanced"] = array_unique(explode(',', $new_order["advanced"])); } if (isset($new_order["side"])) { $current_order["side"] = array_unique(explode(',', $new_order["side"])); } update_option('wpsc_product_page_order', $current_order); exit(print_r($order, 1)); } if (isset($_POST['save_image_upload_state']) && $_POST['save_image_upload_state'] == 'true' && is_numeric($_POST['image_upload_state'])) { $upload_state = (int) (bool) $_POST['image_upload_state']; update_option('wpsc_use_flash_uploader', $upload_state); exit("done"); } if (isset($_POST['remove_variation_value']) && $_POST['remove_variation_value'] == "true" && is_numeric($_POST['variation_value_id'])) { $value_id = absint($_GET['variation_value_id']); echo wp_delete_term($value_id, 'wpsc-variation'); exit; } if (isset($_REQUEST['log_state']) && $_REQUEST['log_state'] == "true" && is_numeric($_POST['id']) && is_numeric($_POST['value'])) { $newvalue = $_POST['value']; if ($_REQUEST['suspend'] == 'true') { if ($_REQUEST['value'] == 1 && function_exists('wpsc_member_dedeactivate_subscriptions')) { wpsc_member_dedeactivate_subscriptions($_POST['id']); } elseif (function_exists('wpsc_member_deactivate_subscriptions')) { wpsc_member_deactivate_subscriptions($_POST['id']); } exit; } else { $log_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '%d' LIMIT 1", $_POST['id']), ARRAY_A); if ($newvalue == 2 && function_exists('wpsc_member_activate_subscriptions')) { wpsc_member_activate_subscriptions($_POST['id']); } wpsc_update_purchase_log_status($_POST['id'], $newvalue); if ($newvalue > $log_data['processed'] && $log_data['processed'] < 2) { transaction_results($log_data['sessionid'], false); } $status_name = wpsc_find_purchlog_status_name($purchase['processed']); echo "document.getElementById(\"form_group_" . absint($_POST['id']) . "_text\").innerHTML = '" . $status_name . "';\n"; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes(wpsc_currency_display(admin_display_total_price($start_timestamp, $end_timestamp))) . "';\n"; echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes(wpsc_currency_display(admin_display_total_price())) . "';\n"; exit; } } }
function wpsc_get_quarterly_summary() { (int) ($firstquarter = get_option('wpsc_first_quart')); (int) ($secondquarter = get_option('wpsc_second_quart')); (int) ($thirdquarter = get_option('wpsc_third_quart')); (int) ($fourthquarter = get_option('wpsc_fourth_quart')); (int) ($finalquarter = get_option('wpsc_final_quart')); $results[] = admin_display_total_price($thirdquarter + 1, $fourthquarter); $results[] = admin_display_total_price($secondquarter + 1, $thirdquarter); $results[] = admin_display_total_price($firstquarter + 1, $secondquarter); $results[] = admin_display_total_price($finalquarter, $firstquarter); return $results; }
function wpsc_right_now() { global $wpdb; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); $product_count = $wpdb->get_var("SELECT COUNT(*)\n\t\tFROM `" . $wpdb->posts . "` \n\t\tWHERE `post_status` = 'publish'\n\t\tAND `post_type` = 'wpsc-product'"); $group_count = count(get_terms("wpsc_product_category")); $sales_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $start_timestamp . "' AND '" . $end_timestamp . "'"); $monthtotal = wpsc_currency_display(admin_display_total_price($start_timestamp, $end_timestamp)); $overaltotal = wpsc_currency_display(admin_display_total_price()); $variation_count = count(get_terms("wpsc-variation", array('parent' => 0))); $pending_sales = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('1')"); $accept_sales = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('2' ,'3', '4')"); $theme = get_option('wpsc_selected_theme'); ?> <div class='table'> <p class='sub'><?php _e('At a Glance', 'wpsc'); ?> </p> <table style='border-top:1px solid #ececec;'> <tr class='first'> <td class='first b'> <?php echo $product_count; ?> </td> <td class='t'> <?php echo _nx('Product', 'Products', $product_count, 'dashboard widget', 'wpsc'); ?> </td> <td class='b'> <?php echo $sales_count; ?> </td> <td class='last'> <?php echo _nx('Sale', 'Sales', $sales_count, 'dashboard widget', 'wpsc'); ?> </td> </tr> <tr> <td class='first b'> <?php echo $group_count; ?> </td> <td class='t'> <?php echo _nx('Category', 'Categories', $group_count, 'dashboard widget', 'wpsc'); ?> </td> <td class='b'> <?php echo $pending_sales; ?> </td> <td class='last t waiting'> <?php echo _n('Pending sale', 'Pending sales', $pending_sales, 'wpsc'); ?> </td> </tr> <tr> <td class='first b'> <?php echo $variation_count; ?> </td> <td class='t'> <?php echo _nx('Variation', 'Variations', $variation_count, 'dashboard widget', 'wpsc'); ?> </td> <td class='b'> <?php echo $accept_sales; ?> </td> <td class='last t approved'> <?php echo _n('Closed sale', 'Closed sales', $accept_sales, 'wpsc'); ?> </td> </tr> </table> </div> <?php }
function wpsc_right_now() { global $wpdb, $nzshpcrt_imagesize_info; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); $replace_values[":productcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `active` IN ('1')"); $product_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `active` IN ('1')"); $replace_values[":productcount:"] .= " " . ($replace_values[":productcount:"] == 1 ? TXT_WPSC_PRODUCTCOUNT_SINGULAR : TXT_WPSC_PRODUCTCOUNT_PLURAL); $product_unit = $replace_values[":productcount:"] == 1 ? TXT_WPSC_PRODUCTCOUNT_SINGULAR : TXT_WPSC_PRODUCTCOUNT_PLURAL; $replace_values[":groupcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `active` IN ('1')"); $group_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `active` IN ('1')"); $replace_values[":groupcount:"] .= " " . ($replace_values[":groupcount:"] == 1 ? TXT_WPSC_GROUPCOUNT_SINGULAR : TXT_WPSC_GROUPCOUNT_PLURAL); $group_unit = $replace_values[":groupcount:"] == 1 ? TXT_WPSC_GROUPCOUNT_SINGULAR : TXT_WPSC_GROUPCOUNT_PLURAL; $replace_values[":salecount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $start_timestamp . "' AND '" . $end_timestamp . "'"); $sales_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $start_timestamp . "' AND '" . $end_timestamp . "'"); $replace_values[":salecount:"] .= " " . ($replace_values[":salecount:"] == 1 ? TXT_WPSC_SALECOUNT_SINGULAR : TXT_WPSC_SALECOUNT_PLURAL); $sales_unit = $replace_values[":salecount:"] == 1 ? TXT_WPSC_SALECOUNT_SINGULAR : TXT_WPSC_SALECOUNT_PLURAL; $replace_values[":monthtotal:"] = nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp), 1); $replace_values[":overaltotal:"] = nzshpcrt_currency_display(admin_display_total_price(), 1); $variation_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_VARIATIONS . "`"); $variation_unit = $variation_count == 1 ? TXT_WPSC_VARIATION_SINGULAR : TXT_WPSC_VARIATION_PLURAL; $replace_values[":pendingcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('1')"); $pending_sales = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('1')"); $replace_values[":pendingcount:"] .= " " . ($replace_values[":pendingcount:"] == 1 ? TXT_WPSC_PENDINGCOUNT_SINGULAR : TXT_WPSC_PENDINGCOUNT_PLURAL); $pending_sales_unit = $replace_values[":pendingcount:"] == 1 ? TXT_WPSC_PENDINGCOUNT_SINGULAR : TXT_WPSC_PENDINGCOUNT_PLURAL; $accept_sales = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('2' ,'3', '4')"); $accept_sales_unit = $accept_sales == 1 ? TXT_WPSC_PENDINGCOUNT_SINGULAR : TXT_WPSC_PENDINGCOUNT_PLURAL; $replace_values[":theme:"] = get_option('wpsc_selected_theme'); $replace_values[":versionnumber:"] = WPSC_PRESENTABLE_VERSION; if (function_exists('add_object_page')) { $output = ""; $output .= "<div id='dashboard_right_now' class='postbox'>"; $output .= "\t<h3 class='hndle'>"; $output .= "\t\t<span>" . TXT_WPSC_CURRENT_MONTH . "</span>"; $output .= "\t\t<br class='clear'/>"; $output .= "\t</h3>"; $output .= "<div class='inside'>"; $output .= "<p class='sub'>" . TXT_WPSC_AT_A_GLANCE . "</p>"; //$output.="<p class='youhave'>".TXT_WPSC_SALES_DASHBOARD."</p>"; $output .= "<div class='table'>"; $output .= "<table>"; $output .= "<tr class='first'>"; $output .= "<td class='first b'>"; $output .= "<a href='?page=wpsc-edit-products'>" . $product_count . "</a>"; $output .= "</td>"; $output .= "<td class='t'>"; $output .= ucfirst($product_unit); $output .= "</td>"; $output .= "<td class='b'>"; $output .= "<a href='?page=wpsc-sales-logs'>" . $sales_count . "</a>"; $output .= "</td>"; $output .= "<td class='last'>"; $output .= ucfirst($sales_unit); $output .= "</td>"; $output .= "</tr>"; $output .= "<tr>"; $output .= "<td class='first b'>"; $output .= "<a href='?page=wpsc-edit-groups'>" . $group_count . "</a>"; $output .= "</td>"; $output .= "<td class='t'>"; $output .= ucfirst($group_unit); $output .= "</td>"; $output .= "<td class='b'>"; $output .= "<a href='?page=wpsc-sales-logs'>" . $pending_sales . "</a>"; $output .= "</td>"; $output .= "<td class='last t waiting'>" . TXT_WPSC_PENDING . " "; $output .= ucfirst($pending_sales_unit); $output .= "</td>"; $output .= "</tr>"; $output .= "<tr>"; $output .= "<td class='first b'>"; $output .= "<a href='?page=wpsc-edit-variations'>" . $variation_count . "</a>"; $output .= "</td>"; $output .= "<td class='t'>"; $output .= ucfirst($variation_unit); $output .= "</td>"; $output .= "<td class='b'>"; $output .= "<a href='?page=wpsc-sales-logs'>" . $accept_sales . "</a>"; $output .= "</td>"; $output .= "<td class='last t approved'>" . TXT_WPSC_CLOSED . " "; $output .= ucfirst($accept_sales_unit); $output .= "</td>"; $output .= "</tr>"; $output .= "</table>"; $output .= "</div>"; $output .= "<div class='versions'>"; $output .= "<p><a class='button rbutton' href='admin.php?page=wpsc-edit-products'><strong>" . TXT_WPSC_ADD_NEW_PRODUCT . "</strong></a>" . TXT_WPSC_HERE_YOU_CAN_ADD . "</p>"; $output .= "</div>"; $output .= "</div>"; $output .= "</div>"; } else { $output = ""; $output .= "<div id='rightnow'>\n\r"; $output .= "\t<h3 class='reallynow'>\n\r"; $output .= "\t\t<a class='rbutton' href='admin.php?page=wpsc-edit-products'><strong>" . TXT_WPSC_ADD_NEW_PRODUCT . "</strong></a>\n\r"; $output .= "\t\t<span>" . _('Right Now') . "</span>\n\r"; //$output.=" <br class='clear'/>\n\r"; $output .= "\t</h3>\n\r"; $output .= "<p class='youhave'>" . TXT_WPSC_SALES_DASHBOARD . "</p>\n\r"; $output .= "\t<p class='youare'>\n\r"; $output .= "\t\t" . TXT_WPSC_YOUAREUSING . "\n\r"; //$output.=" <a class='rbutton' href='themes.php'>Change Theme</a>\n\r"; //$output.="<span id='wp-version-message'>This is WordPress version 2.6. <a class='rbutton' href='http://wordpress.org/download/'>Update to 2.6.1</a></span>\n\r"; $output .= "\t\t</p>\n\r"; $output .= "</div>\n\r"; $output .= "<br />\n\r"; $output = str_replace(array_keys($replace_values), array_values($replace_values), $output); } return $output; }
echo nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp), 1); echo " " . TXT_WPSC_ACCEPTED_PAYMENTS; ?> </p> </div> <div class='order_summary_subsection'> <strong><?php echo TXT_WPSC_TOTAL_INCOME; ?> </strong> <p id='log_total_absolute'> <?php //$total_income = $wpdb->get_results($sql,ARRAY_A); echo nzshpcrt_currency_display(admin_display_total_price(), 1); ?> </p> </div> <div class='order_summary_subsection'> <strong><?php echo TXT_WPSC_RSS_FEED_HEADER; ?> </strong> <p> <a class='product_log_rss' href='index.php?rss=true&rss_key=key&action=purchase_log'><img align='absmiddle' src='<?php echo WPSC_URL; ?>
function wpsc_admin_ajax() { global $wpdb, $user_level, $wp_rewrite; get_currentuserinfo(); if (is_numeric($_POST['catid'])) { /* fill category form */ echo nzshpcrt_getcategoryform($_POST['catid']); exit; } else { if (is_numeric($_POST['brandid'])) { /* fill brand form */ echo nzshpcrt_getbrandsform($_POST['brandid']); exit; } else { if (is_numeric($_POST['variation_id'])) { echo nzshpcrt_getvariationform($_POST['variation_id']); exit; } } } if ($_POST['action'] == 'product-page-order') { $order = $_POST['order']; if (!isset($order[0])) { $order = $order['normal']; } else { $order = $order[0]; } $order = array_unique(explode(',', $order)); update_option('wpsc_product_page_order', $order); exit(print_r($order, 1)); } if ($_POST['save_image_upload_state'] == "true" && is_numeric($_POST['image_upload_state'])) { //get_option('wpsc_image_upload_state'); $upload_state = (int) (bool) $_POST['image_upload_state']; update_option('wpsc_use_flash_uploader', $upload_state); exit("done"); } if ($_POST['remove_variation_value'] == "true" && is_numeric($_POST['variation_value_id'])) { $wpdb->query("DELETE FROM `" . WPSC_TABLE_VARIATION_VALUES_ASSOC . "` WHERE `value_id` = '" . (int) $_POST['variation_value_id'] . "'"); $wpdb->query("DELETE FROM `" . WPSC_TABLE_VARIATION_VALUES . "` WHERE `id` = '" . (int) $_POST['variation_value_id'] . "' LIMIT 1"); exit; } if ($_POST['edit_variation_value_list'] == 'true' && is_numeric($_POST['variation_id']) && is_numeric($_POST['product_id'])) { $variation_id = (int) $_POST['variation_id']; $product_id = (int) $_POST['product_id']; $variations_processor = new nzshpcrt_variations(); $variation_values = $variations_processor->falsepost_variation_values($variation_id); if (is_array($variation_values)) { //echo(print_r($variation_values,true)); $check_variation_added = $wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_VARIATION_ASSOC . "` WHERE `type` IN ('product') AND `associated_id` IN ('{$product_id}') AND `variation_id` IN ('{$variation_id}') LIMIT 1"); //exit("<pre>".print_r($variation_values,true)."<pre>"); if ($check_variation_added == null) { $variations_processor->add_to_existing_product($product_id, $variation_values); } echo $variations_processor->display_attached_variations($product_id); echo $variations_processor->variations_grid_view($product_id); } else { echo "false"; } exit; } if ($_POST['remove_form_field'] == "true" && is_numeric($_POST['form_id'])) { //exit(print_r($user,true)); if (current_user_can('level_7')) { $wpdb->query($wpdb->prepare("UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id'])); exit(' '); } } if ($_POST['hide_ecom_dashboard'] == 'true') { require_once ABSPATH . WPINC . '/rss.php'; $rss = fetch_rss('http://www.instinct.co.nz/feed/'); $rss->items = array_slice($rss->items, 0, 5); $rss_hash = sha1(serialize($rss->items)); update_option('wpsc_ecom_news_hash', $rss_hash); exit(1); } if ($_POST['remove_meta'] == 'true' && is_numeric($_POST['meta_id'])) { $meta_id = (int) $_POST['meta_id']; $selected_meta = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `id` IN('{$meta_id}') ", ARRAY_A); if ($selected_meta != null) { if ($wpdb->query("DELETE FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `id` IN('{$meta_id}') LIMIT 1")) { echo $meta_id; exit; } } echo 0; exit; } if ($_REQUEST['log_state'] == "true" && is_numeric($_POST['id']) && is_numeric($_POST['value'])) { $newvalue = $_POST['value']; if ($_REQUEST['suspend'] == 'true') { if ($_REQUEST['value'] == 1) { wpsc_member_dedeactivate_subscriptions($_POST['id']); } else { wpsc_member_deactivate_subscriptions($_POST['id']); } exit; } else { $log_data = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '" . $_POST['id'] . "' LIMIT 1", ARRAY_A); if ($newvalue == 2 && function_exists('wpsc_member_activate_subscriptions')) { wpsc_member_activate_subscriptions($_POST['id']); } $update_sql = "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . $newvalue . "' WHERE `id` = '" . $_POST['id'] . "' LIMIT 1"; $wpdb->query($update_sql); //echo("/*"); if ($newvalue > $log_data['processed'] && $log_data['processed'] < 2) { transaction_results($log_data['sessionid'], false); } //echo("*/"); $stage_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_STATUSES . "` WHERE `id`='" . $newvalue . "' AND `active`='1' LIMIT 1"; $stage_data = $wpdb->get_row($stage_sql, ARRAY_A); echo "document.getElementById(\"form_group_" . $_POST['id'] . "_text\").innerHTML = '" . $stage_data['name'] . "';\n"; echo "document.getElementById(\"form_group_" . $_POST['id'] . "_text\").style.color = '#" . $stage_data['colour'] . "';\n"; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes(nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp), 1)) . "';\n"; echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes(nzshpcrt_currency_display(admin_display_total_price(), 1)) . "';\n"; exit; } } if ($_POST['list_variation_values'] == "true") { // retrieve the forms for associating variations and their values with products $variation_processor = new nzshpcrt_variations(); $variations_selected = array(); foreach ((array) $_POST['variations'] as $variation_id => $checked) { $variations_selected[] = (int) $variation_id; } if (is_numeric($_POST['product_id']) && $_POST['product_id'] > 0) { $product_id = absint($_POST['product_id']); $selected_price = (double) $_POST['selected_price']; // variation values housekeeping $completed_variation_values = $variation_processor->edit_product_values($product_id, $_POST['edit_var_val'], $selected_price); // get all the currently associated variations from the database $associated_variations = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_VARIATION_ASSOC . "` WHERE `type` IN ('product') AND `associated_id` IN ('{$product_id}')", ARRAY_A); $variations_still_associated = array(); foreach ((array) $associated_variations as $associated_variation) { // remove variations not checked that are in the database if (array_search($associated_variation['variation_id'], $variations_selected) === false) { $wpdb->query("DELETE FROM `" . WPSC_TABLE_VARIATION_ASSOC . "` WHERE `id` = '{$associated_variation['id']}' LIMIT 1"); $wpdb->query("DELETE FROM `" . WPSC_TABLE_VARIATION_VALUES_ASSOC . "` WHERE `product_id` = '{$product_id}' AND `variation_id` = '{$associated_variation['variation_id']}' "); } else { // make an array for adding in the variations next step, for efficiency $variations_still_associated[] = $associated_variation['variation_id']; } } foreach ((array) $variations_selected as $variation_id) { // add variations not already in the database that have been checked. $variation_values = $variation_processor->falsepost_variation_values($variation_id); if (array_search($variation_id, $variations_still_associated) === false) { $variation_processor->add_to_existing_product($product_id, $variation_values); } } //echo "/* ".print_r($variation_values,true)." */\n\r"; echo "edit_variation_combinations_html = \"" . str_replace(array("\n", "\r"), array('\\n', '\\r'), addslashes($variation_processor->variations_grid_view($product_id, (array) $completed_variation_values))) . "\";\n"; } else { if (count($variations_selected) > 0) { // takes an array of variations, returns a form for adding data to those variations. if ((double) $_POST['selected_price'] > 0) { $selected_price = (double) $_POST['selected_price']; } $limited_stock = false; if ($_POST['limited_stock'] == 'true') { $limited_stock = true; } $selected_variation_values = array(); foreach ($_POST['edit_var_val'] as $variation_value_array) { //echo "/* ".print_r($variation_value_array,true)." */\n\r"; $selected_variation_values = array_merge(array_keys($variation_value_array), $selected_variation_values); } ////echo "/* ".print_r($selected_variation_values,true)." */\n\r"; echo "edit_variation_combinations_html = \"" . __('Edit Variation Set', 'wpsc') . "<br />" . str_replace(array("\n", "\r"), array('\\n', '\\r'), addslashes($variation_processor->variations_grid_view(0, (array) $variations_selected, (array) $selected_variation_values, $selected_price, $limited_stock))) . "\";\n"; } else { echo "edit_variation_combinations_html = \"\";\n"; } } exit; } if (isset($_POST['language_setting']) && ($_GET['page'] = WPSC_DIR_NAME . '/wpsc-admin/display-options.page.php')) { if ($user_level >= 7) { update_option('language_setting', $_POST['language_setting']); } } }
function wpsc_ordersummary() { ?> <div class='postbox'> <h3 class='hndle'><?php echo TXT_WPSC_ORDER_SUMMARY; ?> </h3> <div class='inside'> <div class='order_summary_subsection'> <strong><?php echo TXT_WPSC_TOTAL_THIS_MONTH; ?> </strong> <p id='log_total_month'> <?php $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); echo nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp), 1); echo " " . TXT_WPSC_ACCEPTED_PAYMENTS; ?> </p> </div> <div class='order_summary_subsection'> <strong><?php echo TXT_WPSC_TOTAL_INCOME; ?> </strong> <p id='log_total_absolute'> <?php //$total_income = $wpdb->get_results($sql,ARRAY_A); echo nzshpcrt_currency_display(admin_display_total_price(), 1); ?> </p> </div> <div class='order_summary_subsection'> <strong><?php echo TXT_WPSC_RSS_FEED_HEADER; ?> </strong> <p> <a class='product_log_rss' href='index.php?rss=true&rss_key=key&action=purchase_log'><img align='middle' src='<?php echo WPSC_URL; ?> /images/rss-icon.jpg' alt='' title='' /> <span><?php echo TXT_WPSC_RSS_FEED_LINK; ?> </span></a> <?php echo TXT_WPSC_RSS_FEED_TEXT; ?> </p> </div> <div class='order_summary_subsection'> <strong><?php echo TXT_WPSC_PLUGIN_NEWS_HEADER; ?> </strong> <p> <?php echo TXT_WPSC_PLUGIN_NEWS; ?> <br /><br /><?php echo TXT_WPSC_POWERED_BY; ?> <a href='http://www.instinct.co.nz'>Instinct</a> </p> </div> </div> <?php if (get_option('activation_state') != "true") { ?> <div class='gold-cart_pesterer'> <div> <img src='<?php echo WPSC_URL; ?> /images/gold-cart.png' alt='' title='' /><a href='http://www.instinct.co.nz/e-commerce/shop/'><?php echo TXT_WPSC_UPGRADE_TO_GOLD; ?> </a><?php echo TXT_WPSC_UNLEASH_MORE; ?> </div> </div> <?php } ?> </div> <?php }
function wpsc_ordersummary() { ?> <div class='postbox'> <h3 class='hndle'><?php echo __('Order Summary', 'wpsc'); ?> </h3> <div class='inside'> <div class='order_summary_subsection'> <strong><?php echo __('This Month', 'wpsc'); ?> </strong> <p id='log_total_month'> <?php $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); echo nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp), 1); echo " " . __('(accepted payments)', 'wpsc'); ?> </p> </div> <div class='order_summary_subsection'> <strong><?php echo __('Life Time', 'wpsc'); ?> </strong> <p id='log_total_absolute'> <?php //$total_income = $wpdb->get_results($sql,ARRAY_A); echo nzshpcrt_currency_display(admin_display_total_price(), 1); ?> </p> </div> <div class='order_summary_subsection'> <strong><?php echo __('Subscribe to your orders', 'wpsc'); ?> </strong> <p> <a class='product_log_rss' href='index.php?rss=true&rss_key=key&action=purchase_log'><img align='middle' src='<?php echo WPSC_URL; ?> /images/rss-icon.jpg' alt='' title='' /> <span><?php echo __('Subscribe to an RSS feed', 'wpsc'); ?> </span></a> <?php echo __('of your orders', 'wpsc'); ?> </p> </div> <div class='order_summary_subsection'> <strong><?php echo __('Plugin News', 'wpsc'); ?> </strong> <p> <?php echo __('The <a href="http://instinct.co.nz/blogshop/products-page/" target="_blank">WP DropShop Module</a> is the latest and most cutting edge shopping cart available online. Coupled with Grid View then your site will be the talk of street! <br/><br/>The <a href="http://instinct.co.nz/blogshop/products-page/" target="_blank">GridView Module</a> is a visual module built to enhance the way your product page looks.<br/><br/><a href="http://www.instinct.co.nz/wp-campaign-monitor/100">WP Campaign Monitor</a> is an email newsletter tool built just for WP users who want to send campaigns, track the results and manage their subscribers. The latest version integrates with e-commerce lite meaning that you will be able to send buyers email newsletters and much more. ', 'wpsc'); ?> <br /><br /><?php echo __('This shop is powered by ', 'wpsc'); ?> <a href='http://www.instinct.co.nz'>Instinct</a> </p> </div> </div> <?php if (get_option('activation_state') != "true") { ?> <div class='gold-cart_pesterer'> <div> <img src='<?php echo WPSC_URL; ?> /images/gold-cart.png' alt='' title='' /><a href='http://www.instinct.co.nz/e-commerce/shop/'><?php echo __('Upgrade to Gold', 'wpsc'); ?> </a><?php echo __(' and unleash more functionality into your shop.', 'wpsc'); ?> </div> </div> <?php } ?> </div> <?php }
function wpsc_admin_ajax() { global $wpdb; if (isset($_POST['action']) && $_POST['action'] == 'product-page-order') { $current_order = get_option('wpsc_product_page_order'); $new_order = $_POST['order']; if (isset($new_order["advanced"])) { $current_order["advanced"] = array_unique(explode(',', $new_order["advanced"])); } if (isset($new_order["side"])) { $current_order["side"] = array_unique(explode(',', $new_order["side"])); } update_option('wpsc_product_page_order', $current_order); exit(print_r($order, 1)); } if (isset($_POST['save_image_upload_state']) && $_POST['save_image_upload_state'] == 'true' && is_numeric($_POST['image_upload_state'])) { $upload_state = (int) (bool) $_POST['image_upload_state']; update_option('wpsc_use_flash_uploader', $upload_state); exit("done"); } if (isset($_POST['remove_variation_value']) && $_POST['remove_variation_value'] == "true" && is_numeric($_POST['variation_value_id'])) { $value_id = absint($_GET['variation_value_id']); echo wp_delete_term($value_id, 'wpsc-variation'); exit; } if (isset($_POST['hide_ecom_dashboard']) && $_POST['hide_ecom_dashboard'] == 'true') { require_once ABSPATH . WPINC . '/rss.php'; $rss = fetch_rss('http://www.instinct.co.nz/feed/'); $rss->items = array_slice($rss->items, 0, 5); $rss_hash = sha1(serialize($rss->items)); update_option('wpsc_ecom_news_hash', $rss_hash); exit(1); } if (isset($_POST['remove_meta']) && $_POST['remove_meta'] == 'true' && is_numeric($_POST['meta_id'])) { $meta_id = (int) $_POST['meta_id']; if (delete_meta($meta_id)) { echo $meta_id; exit; } echo 0; exit; } if (isset($_REQUEST['log_state']) && $_REQUEST['log_state'] == "true" && is_numeric($_POST['id']) && is_numeric($_POST['value'])) { $newvalue = $_POST['value']; if ($_REQUEST['suspend'] == 'true') { if ($_REQUEST['value'] == 1 && function_exists('wpsc_member_dedeactivate_subscriptions')) { wpsc_member_dedeactivate_subscriptions($_POST['id']); } elseif (function_exists('wpsc_member_deactivate_subscriptions')) { wpsc_member_deactivate_subscriptions($_POST['id']); } exit; } else { $log_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '%d' LIMIT 1", $_POST['id']), ARRAY_A); if ($newvalue == 2 && function_exists('wpsc_member_activate_subscriptions')) { wpsc_member_activate_subscriptions($_POST['id']); } $wpdb->update(WPSC_TABLE_PURCHASE_LOGS, array('processed' => $newvalue), array('id' => $_POST['id']), '%d', '%d'); if ($newvalue > $log_data['processed'] && $log_data['processed'] < 2) { transaction_results($log_data['sessionid'], false); } $status_name = wpsc_find_purchlog_status_name($purchase['processed']); echo "document.getElementById(\"form_group_" . $_POST['id'] . "_text\").innerHTML = '" . $status_name . "';\n"; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes(wpsc_currency_display(admin_display_total_price($start_timestamp, $end_timestamp))) . "';\n"; echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes(wpsc_currency_display(admin_display_total_price())) . "';\n"; exit; } } }
function wpsc_right_now($hidden = '') { global $wpdb, $nzshpcrt_imagesize_info; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); $replace_values[":productcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `active` IN ('1')"); $product_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `active` IN ('1')"); $replace_values[":productcount:"] .= " " . ($replace_values[":productcount:"] == 1 ? __('product', 'wpsc') : __('products', 'wpsc')); $product_unit = $replace_values[":productcount:"] == 1 ? __('product', 'wpsc') : __('products', 'wpsc'); $replace_values[":groupcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `active` IN ('1')"); $group_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `active` IN ('1')"); $replace_values[":groupcount:"] .= " " . ($replace_values[":groupcount:"] == 1 ? __('group', 'wpsc') : __('groups', 'wpsc')); $group_unit = $replace_values[":groupcount:"] == 1 ? __('group', 'wpsc') : __('groups', 'wpsc'); $replace_values[":salecount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $start_timestamp . "' AND '" . $end_timestamp . "'"); $sales_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $start_timestamp . "' AND '" . $end_timestamp . "'"); $replace_values[":salecount:"] .= " " . ($replace_values[":salecount:"] == 1 ? __('sale', 'wpsc') : __('sales', 'wpsc')); $sales_unit = $replace_values[":salecount:"] == 1 ? __('sale', 'wpsc') : __('sales', 'wpsc'); $replace_values[":monthtotal:"] = nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp), 1); $replace_values[":overaltotal:"] = nzshpcrt_currency_display(admin_display_total_price(), 1); $variation_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PRODUCT_VARIATIONS . "`"); $variation_unit = $variation_count == 1 ? __('variation', 'wpsc') : __('variations', 'wpsc'); $replace_values[":pendingcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('1')"); $pending_sales = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('1')"); $replace_values[":pendingcount:"] .= " " . ($replace_values[":pendingcount:"] == 1 ? __('transaction', 'wpsc') : __('transactions', 'wpsc')); $pending_sales_unit = $replace_values[":pendingcount:"] == 1 ? __('transaction', 'wpsc') : __('transactions', 'wpsc'); $accept_sales = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `processed` IN ('2' ,'3', '4')"); $accept_sales_unit = $accept_sales == 1 ? __('transaction', 'wpsc') : __('transactions', 'wpsc'); $replace_values[":theme:"] = get_option('wpsc_selected_theme'); $replace_values[":versionnumber:"] = WPSC_PRESENTABLE_VERSION; if (function_exists('add_object_page')) { $output = ""; $output .= "<div id='dashboard_right_now' class='postbox " . (array_search('dashboard_right_now', $hidden) !== false ? 'closed' : '') . "'>"; $output .= "\t<h3 class='hndle'>"; $output .= "\t\t<span>" . __('Current Month', 'wpsc') . "</span>"; $output .= "\t\t<br class='clear'/>"; $output .= "\t</h3>"; $output .= "<div class='inside'>"; $output .= "<p class='sub'>" . __('At a Glance', 'wpsc') . "</p>"; //$output.="<p class='youhave'>".__('You have <a href='admin.php?page=wpsc-edit-products'>:productcount:</a>, contained within <a href='admin.php?page=wpsc-edit-groups'>:groupcount:</a>. This month you made :salecount: and generated a total of :monthtotal: and your total sales ever is :overaltotal:. You have :pendingcount: awaiting approval.', 'wpsc')."</p>"; $output .= "<div class='table'>"; $output .= "<table>"; $output .= "<tr class='first'>"; $output .= "<td class='first b'>"; $output .= "<a href='?page=wpsc-edit-products'>" . $product_count . "</a>"; $output .= "</td>"; $output .= "<td class='t'>"; $output .= ucfirst($product_unit); $output .= "</td>"; $output .= "<td class='b'>"; $output .= "<a href='?page=wpsc-sales-logs'>" . $sales_count . "</a>"; $output .= "</td>"; $output .= "<td class='last'>"; $output .= ucfirst($sales_unit); $output .= "</td>"; $output .= "</tr>"; $output .= "<tr>"; $output .= "<td class='first b'>"; $output .= "<a href='?page=wpsc-edit-groups'>" . $group_count . "</a>"; $output .= "</td>"; $output .= "<td class='t'>"; $output .= ucfirst($group_unit); $output .= "</td>"; $output .= "<td class='b'>"; $output .= "<a href='?page=wpsc-sales-logs'>" . $pending_sales . "</a>"; $output .= "</td>"; $output .= "<td class='last t waiting'>" . __('Pending', 'wpsc') . " "; $output .= ucfirst($pending_sales_unit); $output .= "</td>"; $output .= "</tr>"; $output .= "<tr>"; $output .= "<td class='first b'>"; $output .= "<a href='?page=wpsc-edit-variations'>" . $variation_count . "</a>"; $output .= "</td>"; $output .= "<td class='t'>"; $output .= ucfirst($variation_unit); $output .= "</td>"; $output .= "<td class='b'>"; $output .= "<a href='?page=wpsc-sales-logs'>" . $accept_sales . "</a>"; $output .= "</td>"; $output .= "<td class='last t approved'>" . __('Closed', 'wpsc') . " "; $output .= ucfirst($accept_sales_unit); $output .= "</td>"; $output .= "</tr>"; $output .= "</table>"; $output .= "</div>"; $output .= "<div class='versions'>"; $output .= "<p><a class='button rbutton' href='admin.php?page=wpsc-edit-products'><strong>" . __('Add New Product', 'wpsc') . "</strong></a>" . __('Here you can add products, groups or variations', 'wpsc') . "</p>"; $output .= "</div>"; $output .= "</div>"; $output .= "</div>"; } else { $output = ""; $output .= "<div id='rightnow'>\n\r"; $output .= "\t<h3 class='reallynow'>\n\r"; $output .= "\t\t<a class='rbutton' href='admin.php?page=wpsc-edit-products'><strong>" . __('Add New Product', 'wpsc') . "</strong></a>\n\r"; $output .= "\t\t<span>" . _('Right Now') . "</span>\n\r"; //$output.=" <br class='clear'/>\n\r"; $output .= "\t</h3>\n\r"; $output .= "<p class='youhave'>" . __('You have <a href="admin.php?page=wpsc-edit-products">:productcount:</a>, contained within <a href="admin.php?page=wpsc-edit-groups">:groupcount:</a>. This month you made :salecount: and generated a total of :monthtotal: and your total sales ever is :overaltotal:. You have :pendingcount: awaiting approval.', 'wpsc') . "</p>\n\r"; $output .= "\t<p class='youare'>\n\r"; $output .= "\t\t" . __('You are using the :theme: style. This is WP e-Commerce :versionnumber:.', 'wpsc') . "\n\r"; //$output.=" <a class='rbutton' href='themes.php'>Change Theme</a>\n\r"; //$output.="<span id='wp-version-message'>This is WordPress version 2.6. <a class='rbutton' href='http://wordpress.org/download/'>Update to 2.6.1</a></span>\n\r"; $output .= "\t\t</p>\n\r"; $output .= "</div>\n\r"; $output .= "<br />\n\r"; $output = str_replace(array_keys($replace_values), array_values($replace_values), $output); } return $output; }
function wpsc_admin_latest_activity() { $user = wp_get_current_user(); if ($user->user_level > 9) { echo "<div>"; echo "<h3>" . TXT_WPSC_E_COMMERCE . "</h3>"; echo "<p>"; echo "<strong>" . TXT_WPSC_TOTAL_THIS_MONTH . "</strong><br />"; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); echo nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp), 1); echo "</p>"; echo "<p>"; echo "<strong>" . TXT_WPSC_TOTAL_INCOME . "</strong><br />"; echo nzshpcrt_currency_display(admin_display_total_price(), 1); echo "</p>"; echo "</div>"; } }
function wpsc_right_now() { global $wpdb, $nzshpcrt_imagesize_info; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); $replace_values[":productcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "product_list` WHERE `active` IN ('1')"); $replace_values[":productcount:"] .= " " . ($replace_values[":productcount:"] == 1 ? TXT_WPSC_PRODUCTCOUNT_SINGULAR : TXT_WPSC_PRODUCTCOUNT_PLURAL); $replace_values[":groupcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "product_categories` WHERE `active` IN ('1')"); $replace_values[":groupcount:"] .= " " . ($replace_values[":groupcount:"] == 1 ? TXT_WPSC_GROUPCOUNT_SINGULAR : TXT_WPSC_GROUPCOUNT_PLURAL); $replace_values[":salecount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "purchase_logs` WHERE `date` BETWEEN '" . $start_timestamp . "' AND '" . $end_timestamp . "'"); $replace_values[":salecount:"] .= " " . ($replace_values[":salecount:"] == 1 ? TXT_WPSC_SALECOUNT_SINGULAR : TXT_WPSC_SALECOUNT_PLURAL); $replace_values[":monthtotal:"] = nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp), 1); $replace_values[":overaltotal:"] = nzshpcrt_currency_display(admin_display_total_price(), 1); $replace_values[":pendingcount:"] = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "purchase_logs` WHERE `processed` IN ('1')"); $replace_values[":pendingcount:"] .= " " . ($replace_values[":pendingcount:"] == 1 ? TXT_WPSC_PENDINGCOUNT_SINGULAR : TXT_WPSC_PENDINGCOUNT_PLURAL); $replace_values[":theme:"] = get_option('wpsc_selected_theme'); $replace_values[":versionnumber:"] = WPSC_PRESENTABLE_VERSION; $output = ""; $output .= "<div id='rightnow'>\n\r"; $output .= "\t<h3 class='reallynow'>\n\r"; $output .= "\t\t<span>" . _('Right Now') . "</span>\n\r"; $output .= "\t\t<a class='rbutton' href='admin.php?page=wp-shopping-cart/display-items.php'><strong>" . TXT_WPSC_ADDNEWPRODUCT . "</strong></a>\n\r"; $output .= "\t\t<br class='clear'/>\n\r"; $output .= "\t</h3>\n\r"; $output .= "<p class='youhave'>" . TXT_WPSC_SALES_DASHBOARD . "</p>\n\r"; $output .= "\t<p class='youare'>\n\r"; $output .= "\t\t" . TXT_WPSC_YOUAREUSING . "\n\r"; //$output.=" <a class='rbutton' href='themes.php'>Change Theme</a>\n\r"; //$output.="<span id='wp-version-message'>This is WordPress version 2.6. <a class='rbutton' href='http://wordpress.org/download/'>Update to 2.6.1</a></span>\n\r"; $output .= "\t\t</p>\n\r"; $output .= "</div>\n\r"; $output .= "<br />\n\r"; $output = str_replace(array_keys($replace_values), array_values($replace_values), $output); return $output; }