user_level <= 2) { if(file_exists(WPSC_UPGRADES_DIR.'gold_cart_files/affiliates.php')) { require_once(WPSC_UPGRADES_DIR.'gold_cart_files/affiliates.php'); add_object_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 0, WPSC_URL.'/gold_cart_files/affiliates.php','affiliate_page', WPSC_URL."/images/credit_cards.png"); } else { if (function_exists('add_object_page')) { add_object_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 2, $base_page,array(), WPSC_URL."/images/credit_cards.png"); } else { add_menu_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 2, $base_page); } } } else { if (function_exists('add_object_page')) { add_object_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 2, $base_page,array(), WPSC_URL."/images/credit_cards.png"); } else { add_menu_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 2, $base_page); } } $purchase_log_page = add_submenu_page($base_page, __('Sales', 'wpsc'), __('Sales', 'wpsc'), 7, 'wpsc-sales-logs', 'wpsc_display_sales_logs'); $page_hooks[] = $purchase_log_page; //echo add_submenu_page($base_page,__("Products"), __("Products"), 7, 'wpsc-edit-products', 'wpsc_display_products_page'); $edit_products_page = add_submenu_page($base_page,__('Products', 'wpsc'),__('Products', 'wpsc'), 7, 'wpsc-edit-products', 'wpsc_display_edit_products_page'); $page_hooks[] = $edit_products_page; //echo $edit_products_page; $page_hooks[] = add_submenu_page($base_page,__('Categories', 'wpsc'), __('Categories', 'wpsc'), 7, 'wpsc-edit-groups', 'wpsc_display_groups_page'); //print_r($page_hooks); // add_submenu_page($base_page,__('Variations', 'wpsc'), __('Variations', 'wpsc'), 7, WPSC_DIR_NAME.'/display_variations.php'); $page_hooks[] = add_submenu_page($base_page,__('Variations', 'wpsc'), __('Variations', 'wpsc'), 7, 'wpsc-edit-variations', 'wpsc_display_variations_page'); foreach((array)get_option('wpsc_product_page_order') as $box) { $boxes[$box] = ucwords(str_replace("_"," ",$box)); } //exit('-->'.$help); if (function_exists('add_contextual_help')) { add_contextual_help(WPSC_DIR_NAME.'/display-log',"About this page"); add_contextual_help(WPSC_DIR_NAME.'/display-category',"About this page"); add_contextual_help(WPSC_DIR_NAME.'/display_variations',"About this page"); add_contextual_help(WPSC_DIR_NAME.'/display-coupons',"About this page"); add_contextual_help(WPSC_DIR_NAME.'/options',"General Settings
Presentation Options
Admin Options
Shipping Options
Payment Options
"); add_contextual_help(WPSC_DIR_NAME.'/display-items',"About this page"); } //exit('base page:'.$base_page); // exit($GLOBALS['wp_version']); if(IS_WPMU || $GLOBALS['wp_version'] == '3.0'){ $page_hooks[] = add_submenu_page($base_page,__('Marketing', 'wpsc'), __('Marketing', 'wpsc'), 10,'wpsc_display_coupons_page','wpsc_display_coupons_page'); }else{ $page_hooks[] = add_submenu_page($base_page,__('Marketing', 'wpsc'), __('Marketing', 'wpsc'), 7,'wpsc_display_coupons_page','wpsc_display_coupons_page'); } //add_submenu_page('themes.php', 'Marketing', 'Marketing', 7, 'my_test_screen', 'my_test_screen'); $edit_options_page = add_submenu_page($base_page,__('Settings', 'wpsc'), __('Settings', 'wpsc'), 7, 'wpsc-settings', 'wpsc_display_settings_page'); $page_hooks[] = $edit_options_page; $page_hooks[] = add_submenu_page($base_page,__('Upgrades', 'wpsc'), __('Upgrades', 'wpsc'), 7, 'wpsc-upgrades', 'wpsc_display_upgrades_page'); //$page_hooks[] = add_submenu_page($base_page,__('Upgrades (Old)', 'wpsc'), __('Upgrades (Old)', 'wpsc'), 7, 'wpsc-gold-options','wpsc_gold_shpcrt_options_page'); if(($_SESSION['wpsc_activate_debug_page'] == true) || (defined('WPSC_ADD_DEBUG_PAGE') && (constant('WPSC_ADD_DEBUG_PAGE') == true))) { $page_hooks[] = add_submenu_page($base_page,__('- Debug'), __('- Debug'), 9, 'wpsc-debug', 'wpsc_debug_page'); } $page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $base_page); do_action('wpsc_add_submenu'); } //add_action('load-'.WPSC_DIR_NAME.'/display-coupons.php', 'wpsc_admin_include_coupon_js'); // exit('
'.print_r($page_hooks, true).'
'); // Include the javascript and CSS for this page foreach($page_hooks as $page_hook) { add_action("load-$page_hook", 'wpsc_admin_include_css_and_js'); switch($page_hook) { case $edit_products_page: add_action("load-$page_hook", 'wpsc_admin_edit_products_page_js'); break; case $edit_options_page: add_action("load-$page_hook", 'wpsc_admin_include_optionspage_css_and_js'); break; case $purchase_log_page: add_action('admin_head', 'wpsc_product_log_rss_feed'); break; case 'store_page_wpsc_display_coupons_page': add_action("load-$page_hook", 'wpsc_admin_include_coupon_js'); break; } } /// some updating code is run from here, is as good a place as any, and better than some if((get_option('wpsc_trackingid_subject') == null) && (get_option('wpsc_trackingid_message') == null)) { update_option('wpsc_trackingid_subject', __('Product Tracking Email', 'wpsc')); update_option('wpsc_trackingid_message', __("Track & Trace means you may track the progress of your parcel with our online parcel tracker, just login to our website and enter the following Tracking ID to view the status of your order.\n\nTracking ID: %trackid%\n", 'wpsc')); } return; } function wpsc_product_log_rss_feed() { echo ""; } function wpsc_admin_include_coupon_js() { $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION; //exit('called'); wp_enqueue_script('wp-e-commerce-admin-parameters', $siteurl."/wp-admin/admin.php?wpsc_admin_dynamic_js=true", false, $version_identifier); wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL.'/wpsc-admin/css/settingspage.css', false, false, 'all' ); wp_enqueue_script('livequery', WPSC_URL.'/wpsc-admin/js/jquery.livequery.js', array('jquery'), '1.0.3'); wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/css/admin.css', false, $version_identifier, 'all' ); wp_enqueue_script('datepicker-ui', WPSC_URL."/js/ui.datepicker.js",array('jquery-ui-core'), $version_identifier); wp_enqueue_script('wp-e-commerce-admin_legacy', WPSC_URL.'/admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-sortable','datepicker-ui'), $version_identifier); } /** * wpsc_admin_css_and_js function, includes the wpsc_admin CSS and JS * No parameters, returns nothing */ function wpsc_admin_include_css_and_js() { $siteurl = get_option('siteurl'); if(is_ssl()) { $siteurl = str_replace("http://", "https://", $siteurl); } wp_admin_css( 'dashboard' ); wp_admin_css( 'media' ); wp_enqueue_script( 'postbox', '/wp-admin/js/postbox.js', array('jquery')); $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION; wp_enqueue_script('jCrop', WPSC_URL.'/wpsc-admin/js/jquery.Jcrop.min.js', array('jquery'), '0.9.8'); wp_enqueue_script('livequery', WPSC_URL.'/wpsc-admin/js/jquery.livequery.js', array('jquery'), '1.0.3'); wp_enqueue_script('wp-e-commerce-admin-parameters', $siteurl."/wp-admin/admin.php?wpsc_admin_dynamic_js=true", false, $version_identifier); wp_enqueue_script('wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/js/admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-sortable'), $version_identifier); wp_enqueue_script('wp-e-commerce-legacy-ajax', WPSC_URL.'/wpsc-admin/js/ajax.js', false, $version_identifier); // needs removing wp_enqueue_script('wp-e-commerce-variations', WPSC_URL.'/wpsc-admin/js/variations.js', array('jquery'), $version_identifier); wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/css/admin.css', false, $version_identifier, 'all' ); wp_enqueue_style( 'wp-e-commerce-admin-dynamic', $siteurl."/wp-admin/admin.php?wpsc_admin_dynamic_css=true" , false, $version_identifier, 'all' ); wp_localize_script( 'wp-e-commerce-tags', 'postL10n', array( 'tagsUsed' => __('Tags used on this post:'), 'add' => attribute_escape(__('Add')), 'addTag' => attribute_escape(__('Add new tag')), 'separate' => __('Separate tags with commas'), )); if(defined('WPSC_GOLD_DIR_NAME') && WPSC_GOLD_DIR_NAME != ''){ wp_enqueue_style('gold_cart', WPSC_GOLD_FILE_URL.'/gold_cart.css',false, $version_identifier, 'all'); } // Prototype breaks dragging and dropping, I need it gone wp_deregister_script('prototype'); // remove the old javascript and CSS, we want it no more, it smells bad remove_action('admin_head', 'wpsc_admin_css'); } function wpsc_admin_edit_products_page_js() { wp_enqueue_script('wp-e-commerce-tags', WPSC_URL.'/wpsc-admin/js/product_tagcloud.js', array('livequery'), $version_identifier); if ( user_can_richedit() ) { wp_enqueue_script('editor'); } wp_enqueue_script('media-upload'); wp_enqueue_style('thickbox'); wp_enqueue_script('swfupload'); wp_enqueue_script('swfupload-swfobject'); wp_enqueue_script('swfupload-queue'); wp_enqueue_script('wpsc-swfupload-handlers', WPSC_URL.'/wpsc-admin/js/wpsc-swfupload-handlers.js', false, $version_identifier); add_action( 'admin_head', 'wp_tiny_mce' ); // remove cforms timymce code from running on the products page, because it breaks tinymce for us remove_filter( 'mce_external_plugins', 'cforms_plugin'); remove_filter( 'mce_buttons', 'cforms_button'); //add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 ); wp_enqueue_script('quicktags'); do_action('wpsc_admin_edit_products_js'); } /** * wpsc_admin_include_optionspage_css_and_js function, includes the wpsc_admin CSS and JS for the specific options page * No parameters, returns nothing */ function wpsc_admin_include_optionspage_css_and_js(){ wp_enqueue_script('wp-e-commerce-js-ajax', WPSC_URL.'/js/ajax.js', false, $version_identifier); wp_enqueue_script('wp-e-commerce-js-ui-tabs', WPSC_URL.'/wpsc-admin/js/jquery-ui.js', false, $version_identifier); wp_enqueue_script('wp-e-commerce-js-dimensions', WPSC_URL.'/wpsc-admin/js/dimensions.js', false, $version_identifier); wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL.'/wpsc-admin/css/settingspage.css', false, false, 'all' ); wp_enqueue_style( 'wp-e-commerce-ui-tabs', WPSC_URL.'/wpsc-admin/css/jquery.ui.tabs.css', false, $version_identifier, 'all' ); } function wpsc_meta_boxes(){ //$pagename = 'products_page_wpsc-edit-products'; $pagename = 'store_page_wpsc-edit-products'; add_meta_box('wpsc_product_category_and_tag_forms', 'Category and Tags', 'wpsc_product_category_and_tag_forms', $pagename, 'normal', 'high'); add_meta_box('wpsc_product_price_and_stock_forms', 'Price and Stock', 'wpsc_product_price_and_stock_forms', $pagename, 'normal', 'high'); add_meta_box('wpsc_product_variation_forms', 'Variations', 'wpsc_product_variation_forms', $pagename, 'normal', 'high'); add_meta_box('wpsc_product_shipping_forms', 'Shipping', 'wpsc_product_shipping_forms', $pagename, 'normal', 'high'); add_meta_box('wpsc_product_advanced_forms', 'Advanced Settings', 'wpsc_product_advanced_forms', $pagename, 'normal', 'high'); add_meta_box('wpsc_product_download_forms', 'Product Download', 'wpsc_product_download_forms', $pagename, 'normal', 'high'); add_meta_box('wpsc_product_image_forms', 'Product Images', 'wpsc_product_image_forms', $pagename, 'normal', 'high'); } add_action('admin_menu', 'wpsc_meta_boxes'); function wpsc_admin_dynamic_js() { header('Content-Type: text/javascript'); header('Expires: '.gmdate('r',mktime(0,0,0,date('m'),(date('d')+12),date('Y'))).''); header('Cache-Control: public, must-revalidate, max-age=86400'); header('Pragma: public'); $siteurl = get_option('siteurl'); $hidden_boxes = get_option('wpsc_hidden_box'); $form_types1 = get_option('wpsc_checkout_form_fields'); $unique_names1 = Array('billingfirstname', 'billinglastname', 'billingaddress', 'billingcity', 'billingcountry', 'billingemail', 'billingphone', 'billingpostcode', 'delivertoafriend', 'shippingfirstname', 'shippinglastname', 'shippingaddress', 'shippingcity', 'shippingstate', 'shippingcountry', 'shippingpostcode'); foreach($form_types1 as $form_type) { $form_types .= ""; } $unique_names = ""; foreach($unique_names1 as $unique_name){ $unique_names.= ""; } $hidden_boxes = implode(',', (array)$hidden_boxes); echo "var base_url = '".$siteurl."';\n\r"; echo "var WPSC_URL = '". WPSC_URL."';\n\r"; echo "var WPSC_IMAGE_URL = '".WPSC_IMAGE_URL."';\n\r"; echo "var WPSC_DIR_NAME = '".WPSC_DIR_NAME."';\n\r"; echo "var WPSC_IMAGE_URL = '".WPSC_IMAGE_URL."';\n\r"; // LightBox Configuration start echo "var fileLoadingImage = '".WPSC_URL."/images/loading.gif';\n\r"; echo "var fileBottomNavCloseImage = '".WPSC_URL."/images/closelabel.gif';\n\r"; echo "var fileThickboxLoadingImage = '".WPSC_URL."/images/loadingAnimation.gif';\n\r"; echo "var resizeSpeed = 9;\n\r"; echo "var borderSize = 10;\n\r"; echo "var hidden_boxes = '".$hidden_boxes."';\n\r"; echo "var IS_WP27 = '".IS_WP27."';\n\r"; echo "var TXT_WPSC_DELETE = '".__('Delete', 'wpsc')."';\n\r"; echo "var TXT_WPSC_TEXT = '".__('Text', 'wpsc')."';\n\r"; echo "var TXT_WPSC_EMAIL = '".__('Email', 'wpsc')."';\n\r"; echo "var TXT_WPSC_COUNTRY = '".__('Country', 'wpsc')."';\n\r"; echo "var TXT_WPSC_TEXTAREA = '".__('Textarea', 'wpsc')."';\n\r"; echo "var TXT_WPSC_HEADING = '".__('Heading', 'wpsc')."';\n\r"; echo "var TXT_WPSC_COUPON = '".__('Coupon', 'wpsc')."';\n\r"; echo "var HTML_FORM_FIELD_TYPES =\" ".$form_types."; \" \n\r"; echo "var HTML_FORM_FIELD_UNIQUE_NAMES = \" ".$unique_names."; \" \n\r"; echo "var TXT_WPSC_LABEL = '".__('Label', 'wpsc')."';\n\r"; echo "var TXT_WPSC_LABEL_DESC = '".__('Label Description', 'wpsc')."';\n\r"; echo "var TXT_WPSC_ITEM_NUMBER = '".__('Item Number', 'wpsc')."';\n\r"; echo "var TXT_WPSC_LIFE_NUMBER = '".__('Life Number', 'wpsc')."';\n\r"; echo "var TXT_WPSC_PRODUCT_CODE = '".__('Product Code', 'wpsc')."';\n\r"; echo "var TXT_WPSC_PDF = '".__('PDF', 'wpsc')."';\n\r"; echo "var TXT_WPSC_AND_ABOVE = '".__(' and above', 'wpsc')."';\n\r"; echo "var TXT_WPSC_IF_PRICE_IS = '".__('If price is ', 'wpsc')."';\n\r"; echo "var TXT_WPSC_IF_WEIGHT_IS = '".__('If weight is ', 'wpsc')."';\n\r"; exit(); } if($_GET['wpsc_admin_dynamic_js'] == 'true') { add_action("admin_init", 'wpsc_admin_dynamic_js'); } function wpsc_admin_dynamic_css() { header('Content-Type: text/css'); header('Expires: '.gmdate('r',mktime(0,0,0,date('m'),(date('d')+12),date('Y'))).''); header('Cache-Control: public, must-revalidate, max-age=86400'); header('Pragma: public'); $flash = apply_filters('flash_uploader', $flash); if($flash = 1) { ?> div.flash-image-uploader { display: block; } div.browser-image-uploader { display: none; } div.flash-image-uploader { display: none; } div.browser-image-uploader { display: block; } get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."`"); /* * This is the right hand side for the past 30 days revenue on the wp dashboard */ echo "
"; echo "".__('This Month', 'wpsc')."
"; echo "

"; // calculates total amount of orders for the month $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); $sql = "SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' AND `processed` IN (2,3,4) ORDER BY `date` DESC"; $currentMonthOrders = $wpdb->get_var($sql); //calculates amount of money made for the month $currentMonthsSales = nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp),1); echo $currentMonthsSales; echo "".__('Sales', 'wpsc').""; echo "

"; echo "

"; echo ""; echo $currentMonthOrders; echo ""; echo "".__('Orders', 'wpsc').""; echo "

"; echo "

"; //echo ""; //calculates average sales amount per order for the month if($currentMonthOrders > 0){ $monthsAverage = ((int)admin_display_total_price($start_timestamp, $end_timestamp)/(int)$currentMonthOrders); echo nzshpcrt_currency_display($monthsAverage,1); } //echo ""; echo "".__('Avg Orders', 'wpsc').""; echo "

"; echo "
"; /* *This is the left side for the total life time revenue on the wp dashboard */ echo "
"; echo "".__('Life Time', 'wpsc')."
"; echo "

"; echo nzshpcrt_currency_display(admin_display_total_price(),1); echo "".__('Sales', 'wpsc').""; echo "

"; echo "

"; echo ""; echo $totalOrders; echo ""; echo "".__('Orders', 'wpsc').""; echo "

"; echo "

"; //echo ""; //calculates average sales amount per order for the month if((admin_display_total_price() > 0) && ($totalOrders > 0) ) { $totalAverage = ((int)admin_display_total_price()/(int)$totalOrders); } else { $totalAverage = 0; } echo nzshpcrt_currency_display($totalAverage,1); //echo ""; echo "".__('Avg Orders', 'wpsc').""; echo "

"; echo "
"; echo "
"; } add_action('wpsc_admin_pre_activity','wpsc_admin_latest_activity'); /* * Pre-2.7 Dashboard Information */ function wpsc_admin_dashboard_rightnow() { $user = wp_get_current_user(); if($user->user_level>9){ echo "
"; echo "

".__('e-Commerce', 'wpsc')."

"; echo "

"; do_action('wpsc_admin_pre_activity'); // wpsc_admin_latest_activity(); do_action('wpsc_admin_post_activity'); echo "

"; } } /* * Dashboard Widget for 2.7 (TRansom) */ function wpsc_dashboard_widget_setup() { global $current_user; get_currentuserinfo(); if($current_user->user_level>9) { wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/css/admin.css', false, $version_identifier, 'all' ); wp_add_dashboard_widget('wpsc_dashboard_widget', __('E-Commerce'),'wpsc_dashboard_widget'); } } /* if(file_exists(WPSC_FILE_PATH."/wpsc-admin/includes/flot_graphs.php")){ function wpsc_dashboard_quarterly_widget_setup() { wp_enqueue_script('flot', WPSC_URL.'/wpsc-admin/js/jquery.flot.pack.js', array('jquery'), '0.9.8'); wp_enqueue_script('canvas', WPSC_URL.'/wpsc-admin/js/excanvas.pack.js', array('jquery', 'flot'), '0.9.8'); wp_add_dashboard_widget('wpsc_quarterly_dashboard_widget', __('Sales by Quarter'),'wpsc_quarterly_dashboard_widget'); } function wpsc_quarterly_dashboard_widget(){ require_once(WPSC_FILE_PATH."/wpsc-admin/includes/flot_graphs.php"); $flot = new flot(); } } */ function wpsc_get_quarterly_summary(){ global $wpdb; (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_quarterly_dashboard_widget(){ if(get_option('wpsc_business_year_start') == false){ ?>
' name='add_start' />

At a Glance Revenue

01  ()

02  ()

03  ()

04  ()

user_level>9) { $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION; wp_enqueue_script('datepicker-ui', WPSC_URL."/js/ui.datepicker.js",array('jquery', 'jquery-ui-core', 'jquery-ui-sortable'), $version_identifier); wp_add_dashboard_widget('wpsc_quarterly_dashboard_widget', __('Sales by Quarter'),'wpsc_quarterly_dashboard_widget'); } } add_action('wp_dashboard_setup', 'wpsc_quarterly_setup'); function wpsc_dashboard_widget() { global $current_user; get_currentuserinfo(); if($current_user->user_level>9) { do_action('wpsc_admin_pre_activity'); do_action('wpsc_admin_post_activity'); } } /* * END - Dashboard Widget for 2.7 */ /* * Dashboard Widget Last Four Month Sales. */ function wpsc_dashboard_4months_widget(){ global $wpdb; $this_year = date("Y"); //get current year and month $this_month = date("n"); $months[] = mktime(0, 0, 0, $this_month-3, 1, $this_year); //generate unix time stamps fo 4 last months $months[] = mktime(0, 0, 0, $this_month-2, 1, $this_year); $months[] = mktime(0, 0, 0, $this_month-1, 1, $this_year); $months[] = mktime(0, 0, 0, $this_month, 1, $this_year); $prodsql = "SELECT `".WPSC_TABLE_CART_CONTENTS."`.`prodid` FROM `".WPSC_TABLE_CART_CONTENTS."` INNER JOIN `".WPSC_TABLE_PURCHASE_LOGS."` ON `".WPSC_TABLE_CART_CONTENTS."`.`purchaseid` = `".WPSC_TABLE_PURCHASE_LOGS."`.`id` WHERE `".WPSC_TABLE_PURCHASE_LOGS."`.`processed` >= 2 AND `".WPSC_TABLE_PURCHASE_LOGS."`.`date` >= ".$months[0]." GROUP BY `".WPSC_TABLE_CART_CONTENTS."`.`prodid` ORDER BY SUM(`".WPSC_TABLE_CART_CONTENTS."`.`price` * `".WPSC_TABLE_CART_CONTENTS."`.`quantity`) DESC LIMIT 4"; $products = $wpdb->get_results($prodsql,ARRAY_A); //get 4 products with top income in 4 last months. $timeranges[0]["start"]= mktime(0, 0, 0, $this_month-3, 1, $this_year); //make array of time ranges $timeranges[0]["end"]= mktime(0, 0, 0, $this_month-2, 1, $this_year); $timeranges[1]["start"]= mktime(0, 0, 0, $this_month-2, 1, $this_year); $timeranges[1]["end"]= mktime(0, 0, 0, $this_month-1, 1, $this_year); $timeranges[2]["start"]= mktime(0, 0, 0, $this_month-1, 1, $this_year); $timeranges[2]["end"]= mktime(0, 0, 0, $this_month, 1, $this_year); $timeranges[3]["start"]= mktime(0, 0, 0, $this_month, 1, $this_year); $timeranges[3]["end"]= mktime(); foreach ((array)$products as $product){ //run trough products and get each product income amounts and name foreach ($timeranges as $timerange){ //run trough time ranges of product, and get its income over each time range $prodsql = "SELECT SUM(`".WPSC_TABLE_CART_CONTENTS."`.`price` * `".WPSC_TABLE_CART_CONTENTS."`.`quantity`) AS sum FROM `".WPSC_TABLE_CART_CONTENTS."` INNER JOIN `".WPSC_TABLE_PURCHASE_LOGS."` ON `".WPSC_TABLE_CART_CONTENTS."`.`purchaseid` = `".WPSC_TABLE_PURCHASE_LOGS."`.`id` WHERE `".WPSC_TABLE_PURCHASE_LOGS."`.`processed` >= 2 AND `".WPSC_TABLE_PURCHASE_LOGS."`.`date` >= ".$timerange["start"]." AND `".WPSC_TABLE_PURCHASE_LOGS."`.`date` < ".$timerange["end"]." AND `".WPSC_TABLE_CART_CONTENTS."`.`prodid` = ".$product['prodid']." GROUP BY `".WPSC_TABLE_CART_CONTENTS."`.`prodid` LIMIT 1"; //get the amount of income that current product has generaterd over current time range $sum = $wpdb->get_results($prodsql,ARRAY_A); $sums[]=$sum[0]["sum"]; //push amount to array } $namesql = "SELECT `".WPSC_TABLE_PRODUCT_LIST."`.`name` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`id` = ".$product['prodid']; $name = $wpdb->get_results($namesql,ARRAY_A); $prod_data[]=array($sums, $name[0]["name"]); //result: array of 2: $prod_data[0] = array(income) $sums=array(); //reset array //$prod_data[1] = product name } $tablerow=1; $output.='
Last four months of sales on a per product basis:
'; foreach ($months as $mnth) { $output.=''; } $output.=''; foreach((array)$prod_data as $product) { $output.=''; $currsymbol=wpsc_get_currency_symbol(); $tablerow++; foreach ($product[0] as $amount) { $output.= ''; } $output.=''; } $output.='
At a Glance' . date("M", $mnth) . '
' . $tablerow . ' ' . $product[1] . '' . $currsymbol . number_format(absint($amount),2) . '
'; echo $output; } function wpsc_dashboard_4months_widget_setup() { global $current_user; get_currentuserinfo(); if($current_user->user_level == 10) { wp_add_dashboard_widget('wpsc_dashboard_4months_widget', __('Sales by'),'wpsc_dashboard_4months_widget'); } } function wpsc_admin_4months_widget_rightnow() { $user = wp_get_current_user(); if($user->user_level>9){ echo "
"; echo "

".__('e-Commerce', 'wpsc')."

"; echo "

"; wpsc_dashboard_4months_widget(); echo "

"; } } function wpsc_getshopped_news_meta_box(){ $rss = fetch_feed('http://getshopped.org/category/community-plugins/feed/'); $args = array('show_author' => 1, 'show_date' => 1, 'show_summary' => 1, 'items'=>3 ); wp_widget_rss_output($rss, $args); } if( IS_WP27 ) { add_action('wp_dashboard_setup','wpsc_dashboard_4months_widget_setup'); } else { add_action('activity_box_end', 'wpsc_admin_4months_widget_rightnow'); } function wpsc_fav_action($actions) { $actions['admin.php?page=wpsc-edit-products'] = array('New Product', 'manage_options'); return $actions; } add_filter('favorite_actions', 'wpsc_fav_action'); function wpsc_admin_notices() { global $wpdb; // exit(get_option('wpsc_default_category')); if(get_option('wpsc_default_category') != 'all+list' && get_option('wpsc_default_category') != 'all' && get_option('wpsc_default_category') != 'list') { if((get_option('wpsc_default_category') < 1) || $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `id` IN ('".get_option('wpsc_default_category')."') AND `active` NOT IN ('1');")) { // if there is no default category or it is deleted if(!$_POST['wpsc_default_category']) { // if we are not changing the default category echo "
"; echo "

".__('Your "products page" is not currently set to display any products. You need to select a product grouping to display by default.
This is set in the Shop Settings page.', 'wpsc')."

"; echo "
\n\r"; } } } } if(stristr($_GET['page'], WPSC_DIR_NAME)) { add_action('admin_notices', 'wpsc_admin_notices'); } ?>