@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | ) |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
| 51 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
| 50 | + $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
| 51 | + $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
| 52 | 52 | |
| 53 | 53 | $pdf = new give_pdf(); |
| 54 | 54 | $pdf->AddPage( 'L', 'A4' ); |
@@ -80,15 +80,15 @@ discard block |
||
| 80 | 80 | $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
| 81 | 81 | $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
| 82 | 82 | |
| 83 | - // Display Categories Heading only, if user has opted for it. |
|
| 84 | - if ( $categories_enabled ) { |
|
| 83 | + // Display Categories Heading only, if user has opted for it. |
|
| 84 | + if ( $categories_enabled ) { |
|
| 85 | 85 | $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
| 86 | - } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // Display Tags Heading only, if user has opted for it. |
|
| 89 | - if ( $tags_enabled ) { |
|
| 88 | + // Display Tags Heading only, if user has opted for it. |
|
| 89 | + if ( $tags_enabled ) { |
|
| 90 | 90 | $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
| 94 | 94 | $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
@@ -125,17 +125,17 @@ discard block |
||
| 125 | 125 | $price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - // Display Categories Data only, if user has opted for it. |
|
| 129 | - if ( $categories_enabled ) { |
|
| 130 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
| 131 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
| 132 | - } |
|
| 128 | + // Display Categories Data only, if user has opted for it. |
|
| 129 | + if ( $categories_enabled ) { |
|
| 130 | + $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
| 131 | + $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - // Display Tags Data only, if user has opted for it. |
|
| 135 | - if ( $tags_enabled ) { |
|
| 136 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
| 137 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
| 138 | - } |
|
| 134 | + // Display Tags Data only, if user has opted for it. |
|
| 135 | + if ( $tags_enabled ) { |
|
| 136 | + $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
| 137 | + $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | $sales = give_get_form_sales_stats( $form->ID ); |
| 141 | 141 | $link = get_permalink( $form->ID ); |
@@ -147,23 +147,23 @@ discard block |
||
| 147 | 147 | $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - // This will help filter data before appending it to PDF Receipt. |
|
| 151 | - $prepare_pdf_data = array(); |
|
| 152 | - $prepare_pdf_data[] = $title; |
|
| 153 | - $prepare_pdf_data[] = $price; |
|
| 150 | + // This will help filter data before appending it to PDF Receipt. |
|
| 151 | + $prepare_pdf_data = array(); |
|
| 152 | + $prepare_pdf_data[] = $title; |
|
| 153 | + $prepare_pdf_data[] = $price; |
|
| 154 | 154 | |
| 155 | - // Append Categories Data only, if user has opted for it. |
|
| 156 | - if ( $categories_enabled ) { |
|
| 157 | - $prepare_pdf_data[] = $categories; |
|
| 158 | - } |
|
| 155 | + // Append Categories Data only, if user has opted for it. |
|
| 156 | + if ( $categories_enabled ) { |
|
| 157 | + $prepare_pdf_data[] = $categories; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - // Append Tags Data only, if user has opted for it. |
|
| 161 | - if ( $tags_enabled ) { |
|
| 162 | - $prepare_pdf_data[] = $tags; |
|
| 163 | - } |
|
| 160 | + // Append Tags Data only, if user has opted for it. |
|
| 161 | + if ( $tags_enabled ) { |
|
| 162 | + $prepare_pdf_data[] = $tags; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - $prepare_pdf_data[] = $sales; |
|
| 166 | - $prepare_pdf_data[] = $earnings; |
|
| 165 | + $prepare_pdf_data[] = $sales; |
|
| 166 | + $prepare_pdf_data[] = $earnings; |
|
| 167 | 167 | |
| 168 | 168 | $pdf->Row( $prepare_pdf_data ); |
| 169 | 169 | endforeach; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly.. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,94 +25,94 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @uses give_pdf |
| 27 | 27 | */ |
| 28 | -function give_generate_pdf( $data ) { |
|
| 28 | +function give_generate_pdf($data) { |
|
| 29 | 29 | |
| 30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
| 31 | - wp_die( esc_html__( 'You do not have permission to generate PDF sales reports.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 30 | + if ( ! current_user_can('view_give_reports')) { |
|
| 31 | + wp_die(esc_html__('You do not have permission to generate PDF sales reports.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
| 35 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
| 35 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php'; |
|
| 39 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php'; |
|
| 38 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php'; |
|
| 39 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php'; |
|
| 40 | 40 | |
| 41 | 41 | $daterange = utf8_decode( |
| 42 | 42 | sprintf( |
| 43 | 43 | /* translators: 1: start date 2: end date */ |
| 44 | - esc_html__( '%1$s to %2$s', 'give' ), |
|
| 45 | - date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
| 46 | - date_i18n( give_date_format() ) |
|
| 44 | + esc_html__('%1$s to %2$s', 'give'), |
|
| 45 | + date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
| 46 | + date_i18n(give_date_format()) |
|
| 47 | 47 | ) |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
| 51 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
| 50 | + $categories_enabled = give_is_setting_enabled(give_get_option('categories', 'disabled')); |
|
| 51 | + $tags_enabled = give_is_setting_enabled(give_get_option('tags', 'disabled')); |
|
| 52 | 52 | |
| 53 | 53 | $pdf = new give_pdf(); |
| 54 | - $pdf->AddPage( 'L', 'A4' ); |
|
| 54 | + $pdf->AddPage('L', 'A4'); |
|
| 55 | 55 | |
| 56 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
| 57 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
| 58 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
| 56 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
| 57 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
| 58 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
| 59 | 59 | |
| 60 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 ); |
|
| 60 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8); |
|
| 61 | 61 | |
| 62 | - $pdf->SetMargins( 8, 8, 8 ); |
|
| 63 | - $pdf->SetX( 8 ); |
|
| 62 | + $pdf->SetMargins(8, 8, 8); |
|
| 63 | + $pdf->SetX(8); |
|
| 64 | 64 | |
| 65 | - $pdf->SetFont( 'Helvetica', '', 16 ); |
|
| 66 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
| 67 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
| 65 | + $pdf->SetFont('Helvetica', '', 16); |
|
| 66 | + $pdf->SetTextColor(50, 50, 50); |
|
| 67 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
| 68 | 68 | |
| 69 | - $pdf->SetFont( 'Helvetica', '', 13 ); |
|
| 69 | + $pdf->SetFont('Helvetica', '', 13); |
|
| 70 | 70 | $pdf->Ln(); |
| 71 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
| 72 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
| 71 | + $pdf->SetTextColor(150, 150, 150); |
|
| 72 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
| 73 | 73 | $pdf->Ln(); |
| 74 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
| 75 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
| 76 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
| 77 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
| 74 | + $pdf->SetTextColor(50, 50, 50); |
|
| 75 | + $pdf->SetFont('Helvetica', '', 14); |
|
| 76 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
| 77 | + $pdf->SetFont('Helvetica', '', 12); |
|
| 78 | 78 | |
| 79 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
| 80 | - $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
| 81 | - $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
| 79 | + $pdf->SetFillColor(238, 238, 238); |
|
| 80 | + $pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
| 81 | + $pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
| 82 | 82 | |
| 83 | 83 | // Display Categories Heading only, if user has opted for it. |
| 84 | - if ( $categories_enabled ) { |
|
| 85 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
| 84 | + if ($categories_enabled) { |
|
| 85 | + $pdf->Cell(45, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Display Tags Heading only, if user has opted for it. |
| 89 | - if ( $tags_enabled ) { |
|
| 90 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
| 89 | + if ($tags_enabled) { |
|
| 90 | + $pdf->Cell(45, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
| 94 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
| 93 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
| 94 | + $pdf->Cell(45, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
| 95 | 95 | |
| 96 | - $year = date( 'Y' ); |
|
| 97 | - $give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) ); |
|
| 96 | + $year = date('Y'); |
|
| 97 | + $give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1)); |
|
| 98 | 98 | |
| 99 | - if ( $give_forms ) { |
|
| 100 | - $pdf->SetWidths( array( 70, 30, 45, 45, 45, 45 ) ); |
|
| 99 | + if ($give_forms) { |
|
| 100 | + $pdf->SetWidths(array(70, 30, 45, 45, 45, 45)); |
|
| 101 | 101 | |
| 102 | - foreach ( $give_forms as $form ): |
|
| 103 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
| 102 | + foreach ($give_forms as $form): |
|
| 103 | + $pdf->SetFillColor(255, 255, 255); |
|
| 104 | 104 | |
| 105 | 105 | $title = $form->post_title; |
| 106 | 106 | |
| 107 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
| 107 | + if (give_has_variable_prices($form->ID)) { |
|
| 108 | 108 | |
| 109 | - $prices = give_get_variable_prices( $form->ID ); |
|
| 109 | + $prices = give_get_variable_prices($form->ID); |
|
| 110 | 110 | |
| 111 | 111 | $first = $prices[0]['_give_amount']; |
| 112 | - $last = array_pop( $prices ); |
|
| 112 | + $last = array_pop($prices); |
|
| 113 | 113 | $last = $last['_give_amount']; |
| 114 | 114 | |
| 115 | - if ( $first < $last ) { |
|
| 115 | + if ($first < $last) { |
|
| 116 | 116 | $min = $first; |
| 117 | 117 | $max = $last; |
| 118 | 118 | } else { |
@@ -120,31 +120,31 @@ discard block |
||
| 120 | 120 | $max = $first; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - $price = html_entity_decode( give_currency_filter( give_format_amount( $min ) ) . ' - ' . give_currency_filter( give_format_amount( $max ) ) ); |
|
| 123 | + $price = html_entity_decode(give_currency_filter(give_format_amount($min)).' - '.give_currency_filter(give_format_amount($max))); |
|
| 124 | 124 | } else { |
| 125 | - $price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) ); |
|
| 125 | + $price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID))); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Display Categories Data only, if user has opted for it. |
| 129 | - if ( $categories_enabled ) { |
|
| 130 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
| 131 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
| 129 | + if ($categories_enabled) { |
|
| 130 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
| 131 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Display Tags Data only, if user has opted for it. |
| 135 | - if ( $tags_enabled ) { |
|
| 136 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
| 137 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
| 135 | + if ($tags_enabled) { |
|
| 136 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
| 137 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
| 141 | - $link = get_permalink( $form->ID ); |
|
| 142 | - $earnings = html_entity_decode( give_currency_filter( give_get_form_earnings_stats( $form->ID ) ) ); |
|
| 140 | + $sales = give_get_form_sales_stats($form->ID); |
|
| 141 | + $link = get_permalink($form->ID); |
|
| 142 | + $earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID))); |
|
| 143 | 143 | |
| 144 | - if ( function_exists( 'iconv' ) ) { |
|
| 144 | + if (function_exists('iconv')) { |
|
| 145 | 145 | // Ensure characters like euro; are properly converted. |
| 146 | - $price = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) ); |
|
| 147 | - $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
|
| 146 | + $price = iconv('UTF-8', 'windows-1252', utf8_encode($price)); |
|
| 147 | + $earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings)); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // This will help filter data before appending it to PDF Receipt. |
@@ -153,42 +153,42 @@ discard block |
||
| 153 | 153 | $prepare_pdf_data[] = $price; |
| 154 | 154 | |
| 155 | 155 | // Append Categories Data only, if user has opted for it. |
| 156 | - if ( $categories_enabled ) { |
|
| 156 | + if ($categories_enabled) { |
|
| 157 | 157 | $prepare_pdf_data[] = $categories; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Append Tags Data only, if user has opted for it. |
| 161 | - if ( $tags_enabled ) { |
|
| 161 | + if ($tags_enabled) { |
|
| 162 | 162 | $prepare_pdf_data[] = $tags; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $prepare_pdf_data[] = $sales; |
| 166 | 166 | $prepare_pdf_data[] = $earnings; |
| 167 | 167 | |
| 168 | - $pdf->Row( $prepare_pdf_data ); |
|
| 168 | + $pdf->Row($prepare_pdf_data); |
|
| 169 | 169 | endforeach; |
| 170 | 170 | } else { |
| 171 | - $pdf->SetWidths( array( 280 ) ); |
|
| 172 | - $title = utf8_decode( esc_html__( 'No forms found.', 'give' ) ); |
|
| 173 | - $pdf->Row( array( $title ) ); |
|
| 171 | + $pdf->SetWidths(array(280)); |
|
| 172 | + $title = utf8_decode(esc_html__('No forms found.', 'give')); |
|
| 173 | + $pdf->Row(array($title)); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $pdf->Ln(); |
| 177 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
| 178 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
| 179 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
| 180 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
| 181 | - |
|
| 182 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
| 183 | - $image = str_replace( ' ', '%20', $image ); |
|
| 184 | - |
|
| 185 | - $pdf->SetX( 25 ); |
|
| 186 | - $pdf->Image( $image . '&file=.png' ); |
|
| 187 | - $pdf->Ln( 7 ); |
|
| 188 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
| 177 | + $pdf->SetTextColor(50, 50, 50); |
|
| 178 | + $pdf->SetFont('Helvetica', '', 14); |
|
| 179 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
| 180 | + $pdf->SetFont('Helvetica', '', 12); |
|
| 181 | + |
|
| 182 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
| 183 | + $image = str_replace(' ', '%20', $image); |
|
| 184 | + |
|
| 185 | + $pdf->SetX(25); |
|
| 186 | + $pdf->Image($image.'&file=.png'); |
|
| 187 | + $pdf->Ln(7); |
|
| 188 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
| 191 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | 194 | * Draws Chart for PDF Report. |
@@ -205,38 +205,38 @@ discard block |
||
| 205 | 205 | * @return string $chart->getUrl() URL for the Google Chart |
| 206 | 206 | */ |
| 207 | 207 | function give_draw_chart_image() { |
| 208 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
| 209 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
| 210 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
| 208 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
| 209 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
| 210 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
| 211 | 211 | |
| 212 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
| 212 | + $chart = new GoogleChart('lc', 900, 330); |
|
| 213 | 213 | |
| 214 | 214 | $i = 1; |
| 215 | 215 | $earnings = ""; |
| 216 | 216 | $sales = ""; |
| 217 | 217 | |
| 218 | - while ( $i <= 12 ) : |
|
| 219 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
| 220 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
| 221 | - $i ++; |
|
| 218 | + while ($i <= 12) : |
|
| 219 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
| 220 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
| 221 | + $i++; |
|
| 222 | 222 | endwhile; |
| 223 | 223 | |
| 224 | - $earnings_array = explode( ",", $earnings ); |
|
| 225 | - $sales_array = explode( ",", $sales ); |
|
| 224 | + $earnings_array = explode(",", $earnings); |
|
| 225 | + $sales_array = explode(",", $sales); |
|
| 226 | 226 | |
| 227 | 227 | $i = 0; |
| 228 | - while ( $i <= 11 ) { |
|
| 229 | - if ( empty( $sales_array[ $i ] ) ) { |
|
| 230 | - $sales_array[ $i ] = 0; |
|
| 228 | + while ($i <= 11) { |
|
| 229 | + if (empty($sales_array[$i])) { |
|
| 230 | + $sales_array[$i] = 0; |
|
| 231 | 231 | } |
| 232 | - $i ++; |
|
| 232 | + $i++; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | $min_earnings = 0; |
| 236 | - $max_earnings = max( $earnings_array ); |
|
| 237 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
| 236 | + $max_earnings = max($earnings_array); |
|
| 237 | + $earnings_scale = round($max_earnings, - 1); |
|
| 238 | 238 | |
| 239 | - $data = new GoogleChartData( array( |
|
| 239 | + $data = new GoogleChartData(array( |
|
| 240 | 240 | $earnings_array[0], |
| 241 | 241 | $earnings_array[1], |
| 242 | 242 | $earnings_array[2], |
@@ -249,25 +249,25 @@ discard block |
||
| 249 | 249 | $earnings_array[9], |
| 250 | 250 | $earnings_array[10], |
| 251 | 251 | $earnings_array[11] |
| 252 | - ) ); |
|
| 252 | + )); |
|
| 253 | 253 | |
| 254 | - $data->setLegend( esc_html__( 'Income', 'give' ) ); |
|
| 255 | - $data->setColor( '1b58a3' ); |
|
| 256 | - $chart->addData( $data ); |
|
| 254 | + $data->setLegend(esc_html__('Income', 'give')); |
|
| 255 | + $data->setColor('1b58a3'); |
|
| 256 | + $chart->addData($data); |
|
| 257 | 257 | |
| 258 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
| 259 | - $shape_marker->setColor( '000000' ); |
|
| 260 | - $shape_marker->setSize( 7 ); |
|
| 261 | - $shape_marker->setBorder( 2 ); |
|
| 262 | - $shape_marker->setData( $data ); |
|
| 263 | - $chart->addMarker( $shape_marker ); |
|
| 258 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
| 259 | + $shape_marker->setColor('000000'); |
|
| 260 | + $shape_marker->setSize(7); |
|
| 261 | + $shape_marker->setBorder(2); |
|
| 262 | + $shape_marker->setData($data); |
|
| 263 | + $chart->addMarker($shape_marker); |
|
| 264 | 264 | |
| 265 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
| 266 | - $value_marker->setColor( '000000' ); |
|
| 267 | - $value_marker->setData( $data ); |
|
| 268 | - $chart->addMarker( $value_marker ); |
|
| 265 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
| 266 | + $value_marker->setColor('000000'); |
|
| 267 | + $value_marker->setData($data); |
|
| 268 | + $chart->addMarker($value_marker); |
|
| 269 | 269 | |
| 270 | - $data = new GoogleChartData( array( |
|
| 270 | + $data = new GoogleChartData(array( |
|
| 271 | 271 | $sales_array[0], |
| 272 | 272 | $sales_array[1], |
| 273 | 273 | $sales_array[2], |
@@ -280,46 +280,46 @@ discard block |
||
| 280 | 280 | $sales_array[9], |
| 281 | 281 | $sales_array[10], |
| 282 | 282 | $sales_array[11] |
| 283 | - ) ); |
|
| 284 | - $data->setLegend( esc_html__( 'Donations', 'give' ) ); |
|
| 285 | - $data->setColor( 'ff6c1c' ); |
|
| 286 | - $chart->addData( $data ); |
|
| 287 | - |
|
| 288 | - $chart->setTitle( esc_html__( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
| 289 | - |
|
| 290 | - $chart->setScale( 0, $max_earnings ); |
|
| 291 | - |
|
| 292 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
| 293 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
| 294 | - $chart->addAxis( $y_axis ); |
|
| 295 | - |
|
| 296 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
| 297 | - $x_axis->setTickMarks( 5 ); |
|
| 298 | - $x_axis->setLabels( array( |
|
| 299 | - esc_html__( 'Jan', 'give' ), |
|
| 300 | - esc_html__( 'Feb', 'give' ), |
|
| 301 | - esc_html__( 'Mar', 'give' ), |
|
| 302 | - esc_html__( 'Apr', 'give' ), |
|
| 303 | - esc_html__( 'May', 'give' ), |
|
| 304 | - esc_html__( 'June', 'give' ), |
|
| 305 | - esc_html__( 'July', 'give' ), |
|
| 306 | - esc_html__( 'Aug', 'give' ), |
|
| 307 | - esc_html__( 'Sept', 'give' ), |
|
| 308 | - esc_html__( 'Oct', 'give' ), |
|
| 309 | - esc_html__( 'Nov', 'give' ), |
|
| 310 | - esc_html__( 'Dec', 'give' ) |
|
| 311 | - ) ); |
|
| 312 | - $chart->addAxis( $x_axis ); |
|
| 313 | - |
|
| 314 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
| 315 | - $shape_marker->setSize( 6 ); |
|
| 316 | - $shape_marker->setBorder( 2 ); |
|
| 317 | - $shape_marker->setData( $data ); |
|
| 318 | - $chart->addMarker( $shape_marker ); |
|
| 319 | - |
|
| 320 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
| 321 | - $value_marker->setData( $data ); |
|
| 322 | - $chart->addMarker( $value_marker ); |
|
| 283 | + )); |
|
| 284 | + $data->setLegend(esc_html__('Donations', 'give')); |
|
| 285 | + $data->setColor('ff6c1c'); |
|
| 286 | + $chart->addData($data); |
|
| 287 | + |
|
| 288 | + $chart->setTitle(esc_html__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
| 289 | + |
|
| 290 | + $chart->setScale(0, $max_earnings); |
|
| 291 | + |
|
| 292 | + $y_axis = new GoogleChartAxis('y'); |
|
| 293 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
| 294 | + $chart->addAxis($y_axis); |
|
| 295 | + |
|
| 296 | + $x_axis = new GoogleChartAxis('x'); |
|
| 297 | + $x_axis->setTickMarks(5); |
|
| 298 | + $x_axis->setLabels(array( |
|
| 299 | + esc_html__('Jan', 'give'), |
|
| 300 | + esc_html__('Feb', 'give'), |
|
| 301 | + esc_html__('Mar', 'give'), |
|
| 302 | + esc_html__('Apr', 'give'), |
|
| 303 | + esc_html__('May', 'give'), |
|
| 304 | + esc_html__('June', 'give'), |
|
| 305 | + esc_html__('July', 'give'), |
|
| 306 | + esc_html__('Aug', 'give'), |
|
| 307 | + esc_html__('Sept', 'give'), |
|
| 308 | + esc_html__('Oct', 'give'), |
|
| 309 | + esc_html__('Nov', 'give'), |
|
| 310 | + esc_html__('Dec', 'give') |
|
| 311 | + )); |
|
| 312 | + $chart->addAxis($x_axis); |
|
| 313 | + |
|
| 314 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
| 315 | + $shape_marker->setSize(6); |
|
| 316 | + $shape_marker->setBorder(2); |
|
| 317 | + $shape_marker->setData($data); |
|
| 318 | + $chart->addMarker($shape_marker); |
|
| 319 | + |
|
| 320 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
| 321 | + $value_marker->setData($data); |
|
| 322 | + $chart->addMarker($value_marker); |
|
| 323 | 323 | |
| 324 | 324 | return $chart->getUrl(); |
| 325 | 325 | } |