plugin_url = WP_PLUGIN_URL . '/' . str_replace( basename( __FILE__ ), '' , plugin_basename( __FILE__ ) ); add_filter( 'woocommerce_reports_charts', array( &$this, 'reports' ) ); add_action( 'admin_head', array( &$this, 'admin_head' ) ) ; } function admin_head() { global $WC_Donations; wp_register_script( 'donation_tablesorter', $WC_Donations->plugin_url . '/assets/js/datatables/jquery.dataTables.min.js', array( 'jquery' ), '2.0' ); wp_enqueue_script( 'donation_tablesorter' ); wp_register_script( 'donation_tablesorter_clip', $WC_Donations->plugin_url . '/assets/js/datatables/media/js/ZeroClipboard.js', array( 'jquery' ), '2.0' ); wp_enqueue_script( 'donation_tablesorter_clip' ); wp_register_script( 'donation_tablesorter_tools', $WC_Donations->plugin_url . '/assets/js/datatables/media/js/TableTools.js', array( 'jquery' ), '2.0' ); wp_enqueue_script( 'donation_tablesorter_tools' ); wp_register_style( 'donation_tablesorter_css', $WC_Donations->plugin_url . '/assets/js/datatables/media/css/jquery.dataTables.css' ); wp_enqueue_style( 'donation_tablesorter_css' ); wp_register_style( 'donation_tablesorter_tools_css', $WC_Donations->plugin_url . '/assets/js/datatables/media/css/TableTools.css' ); wp_enqueue_style( 'donation_tablesorter_tools_css' ); ?> __( 'Donations', 'woocommerce' ), 'charts' => array( array( 'title' => __('Donations Reporting', 'woocommerce'), 'description' => '', 'hide_title' => true, 'function' => 'ignitewoo_donation_details' ), ) ); return $reports; } function get_product( $product_id, $args = array() ) { $product = null; if ( version_compare( WOOCOMMERCE_VERSION, "2.0.0" ) >= 0 ) { // WC 2.0 $product = get_product( $product_id, $args ); } else { // old style, get the product or product variation object if ( isset( $args['parent_id'] ) && $args['parent_id'] ) { $product = new WC_Product_Variation( $product_id, $args['parent_id'] ); } else { // get the regular product, but if it has a parent, return the product variation object $product = new WC_Product( $product_id ); if ( $product->get_parent() ) { $product = new WC_Product_Variation( $product->id, $product->get_parent() ); } } } return $product; } } global $ignitewoo_event_reports; $ignitewoo_event_reports = new IgniteWoo_Donation_Reports(); function ignitewoo_donation_details() { global $wpdb, $woocommerce; $sql = ' SELECT ID, post_title FROM `' . $wpdb->posts . '` left join `' . $wpdb->postmeta . '` m1 on ID = m1.post_id WHERE m1.meta_key = "_donation" and m1.meta_value = "yes" ORDER BY post_title ASC '; $posts = $wpdb->get_results( $sql ); if ( !isset( $posts ) || '' == $posts ) { _e( 'No donations have been created yet.', 'woocommerce' ); return; } $current_event = absint( $_POST['ignitewoo_donation_select'] ); $event = array(); $options = ''; foreach( $posts as $p ) { $options .= ''; } ?>


posts} AS posts LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) LEFT JOIN {$wpdb->terms} AS term USING( term_id ) WHERE meta.meta_key = '_order_items' AND posts.post_type = 'shop_order' AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN (" . $statuses . ") AND posts.post_date > date_sub( NOW(), INTERVAL 1 YEAR ) ORDER BY posts.post_date ASC "; $order_items = $wpdb->get_results( $sql ); if ( $order_items ) { foreach ( $order_items as $order_item ) { $date = date( 'Ym', strtotime( $order_item->post_date ) ); $items = maybe_unserialize( $order_item->items ); foreach ( $items as $item ) { if ( 'yes' != get_post_meta( $item['id'], '_donation', true ) ) continue; if ( $item['id'] != $donation_id & ! in_array( $item['id'], $children_ids ) ) continue; if ( 1 == $_POST['ignitewoo_donation_report_fields']['items'] ) { $all_items = $items; } $info = get_post_custom( $order_item->ID, false ); if ( isset( $item['line_total'] ) ) $row_cost = $item['line_total']; else $row_cost = $item['cost'] * $item['qty']; $buyers[] = array( 'name' => $info['_billing_last_name'][0] . ' ' . $info['_billing_first_name'][0], 'first_name' => $info['_billing_first_name'][0], 'last_name' => $info['_billing_last_name'][0], 'billing_address' => $info['_billing_address_1'][0] . $info['_billing_address_2'][0], 'billing_city' => $info['_billing_city'][0], 'billing_state' => $info['_billing_state'][0], 'billing_country' => $info['_billing_country'][0], 'billing_postalcode' => $info['_billing_postcode'][0], 'email' => $info['_billing_email'][0], 'phone' => $info['_billing_phone'][0], 'qty' => $item['qty'], 'total' => $row_cost, 'item_meta' => $item['item_meta'], 'prefix' => $order_item->ID . '-' . $item['id'] . '-', // ticket numbers prefix 'items' => $all_items, 'order_total' => get_post_meta( $order_item->ID, '_order_total', true ) ); } } } if ( !$buyers ) { _e( 'No donors', 'woocommerce' ); return false; } ?>


' . __( 'Shipped to:', 'woocommerce' ) . '
' . $b['shipping'] ?>

' . __( 'Shipped to:', 'woocommerce' ) . '
' . $b['shipping'] ?>
'; ?> '; ?>

'; ?>
$vals ) { // Do not print customer-supplied meta data that contains a URL - could expose sensitive info // depending on what the customer uploaded via the Event forms if ( false === strpos( $vals['meta_value'], 'http://' ) && false === strpos( $vals['meta_value'], 'https://' ) ) echo '

' . $vals['meta_name'] . ' – ' . $vals['meta_value'] . '

'; } ?>
0 ) $_product = $ignitewoo_event_reports->get_product( $item['variation_id'] ); //$_product = new WC_Product_Variation( $item['variation_id'] ); else $_product = $ignitewoo_event_reports->get_product( $item['id'] ); //$_product = new WC_Product( $item['id'] ); echo ''; $b['total'] = $b['order_total']; } ?>
'; if ( $_product->sku ) echo $_product->sku; else echo '-'; echo '' . $item['name']; if (isset($_product->variation_data)) echo '
' . woocommerce_get_formatted_variation( $_product->variation_data, true ); echo '