Skip to content
This repository was archived by the owner on Nov 17, 2021. It is now read-only.

Commit 764528f

Browse files
committed
Merge branch 'release/1.2.0'
2 parents e1242c1 + ce13e02 commit 764528f

File tree

4 files changed

+133
-4
lines changed

4 files changed

+133
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [1.2.0](https://github.com/rvola/woo-stripe-fee-in-report/tree/1.2.0) - 2019-03-08
4+
[Full Changelog](https://github.com/rvola/woo-stripe-fee-in-report/compare/1.1.4...1.2.0)
5+
* Add data to CSV export
6+
* ✔ Check compatbility WP 5.1
7+
* FIX / url GitHub
8+
39
## [1.1.4](https://github.com/rvola/woo-stripe-fee-in-report/tree/1.1.4) - 2018-10-22
410
[Full Changelog](https://github.com/rvola/woo-stripe-fee-in-report/compare/1.1.3...1.1.4)
511

includes/class-report.php

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,124 @@ function () {
394394
}
395395
);
396396

397+
jQuery( '.export_csv' ).click( function() {
398+
var exclude_series = jQuery( this ).data( 'exclude_series' ) || '';
399+
exclude_series = exclude_series.toString();
400+
exclude_series = exclude_series.split( ',' );
401+
var xaxes_label = jQuery( this ).data( 'xaxes' );
402+
var groupby = jQuery( this ) .data( 'groupby' );
403+
var index_type = jQuery( this ).data( 'index_type' );
404+
var export_format = jQuery( this ).data( 'export' );
405+
var csv_data = 'data:text/csv;charset=utf-8,\uFEFF';
406+
var s, series_data, d;
407+
408+
if ( 'table' === export_format ) {
409+
410+
jQuery( this ).offsetParent().find( 'thead tr,tbody tr' ).each( function() {
411+
jQuery( this ).find( 'th, td' ).each( function() {
412+
var value = jQuery( this ).text();
413+
value = value.replace( '[?]', '' ).replace( '#', '' );
414+
csv_data += '"' + value + '"' + ',';
415+
});
416+
csv_data = csv_data.substring( 0, csv_data.length - 1 );
417+
csv_data += '\n';
418+
});
419+
420+
jQuery( this ).offsetParent().find( 'tfoot tr' ).each( function() {
421+
jQuery( this ).find( 'th, td' ).each( function() {
422+
var value = jQuery( this ).text();
423+
value = value.replace( '[?]', '' ).replace( '#', '' );
424+
csv_data += '"' + value + '"' + ',';
425+
if ( jQuery( this ).attr( 'colspan' ) > 0 ) {
426+
for ( i = 1; i < jQuery(this).attr('colspan'); i++ ) {
427+
csv_data += '"",';
428+
}
429+
}
430+
});
431+
csv_data = csv_data.substring( 0, csv_data.length - 1 );
432+
csv_data += '\n';
433+
});
434+
435+
} else {
436+
437+
if ( ! window.main_chart ) {
438+
return false;
439+
}
440+
441+
var the_series = stripe_main_char.getData();
442+
var series = [];
443+
csv_data += '"' + xaxes_label + '",';
444+
445+
jQuery.each( the_series, function( index, value ) {
446+
if ( ! exclude_series || jQuery.inArray( index.toString(), exclude_series ) === -1 ) {
447+
series.push( value );
448+
}
449+
});
450+
451+
// CSV Headers
452+
for ( s = 0; s < series.length; ++s ) {
453+
csv_data += '"' + series[s].label + '",';
454+
}
455+
456+
csv_data = csv_data.substring( 0, csv_data.length - 1 );
457+
csv_data += '\n';
458+
459+
// Get x axis values
460+
var xaxis = {};
461+
462+
for ( s = 0; s < series.length; ++s ) {
463+
series_data = series[s].data;
464+
for ( d = 0; d < series_data.length; ++d ) {
465+
xaxis[series_data[d][0]] = [];
466+
// Zero values to start
467+
for ( var i = 0; i < series.length; ++i ) {
468+
xaxis[series_data[d][0]].push(0);
469+
}
470+
}
471+
}
472+
473+
// Add chart data
474+
for ( s = 0; s < series.length; ++s ) {
475+
series_data = series[s].data;
476+
for ( d = 0; d < series_data.length; ++d ) {
477+
xaxis[series_data[d][0]][s] = series_data[d][1];
478+
}
479+
}
480+
481+
// Loop data and output to csv string
482+
jQuery.each( xaxis, function( index, value ) {
483+
var date = new Date( parseInt( index, 10 ) );
484+
485+
if ( 'none' === index_type ) {
486+
csv_data += '"' + index + '",';
487+
} else {
488+
if ( groupby === 'day' ) {
489+
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '-' + date.getUTCDate() + '",';
490+
} else {
491+
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",';
492+
}
493+
}
494+
495+
for ( var d = 0; d < value.length; ++d ) {
496+
var val = value[d];
497+
498+
if ( Math.round( val ) !== val ) {
499+
val = parseFloat( val );
500+
val = val.toFixed( 2 );
501+
}
502+
503+
csv_data += '"' + val + '",';
504+
}
505+
csv_data = csv_data.substring( 0, csv_data.length - 1 );
506+
csv_data += '\n';
507+
} );
508+
}
509+
510+
// Set data as href and return
511+
jQuery( this ).attr( 'href', encodeURI( csv_data ) );
512+
return true;
513+
});
514+
397515
});
398516
</script>
399517
<?php

readme.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Donate link: https://www.paypal.me/rvola
44
Tags: stripe, woocommerce, woocommerce-plugin, woocommerce-extension, wordpress-plugin, wordpress, chart, reporting, report, stripe-payments, stripe-gateway
55
Requires PHP: 7.0
66
Requires at least: 4.4
7-
Tested up to: 5.0
8-
Stable tag: 1.1.4
7+
Tested up to: 5.1
8+
Stable tag: 1.2.0
99
License: GPLv3
1010
License URI: https://www.gnu.org/licenses/gpl-3.0.html
1111

@@ -41,6 +41,11 @@ The GIT repository is available here [https://github.com/rvola/woo-stripe-fee-in
4141

4242
== Changelog ==
4343

44+
= 1.2.0 / 2019-03-08 =
45+
* Add data to CSV export
46+
* ✔ Check compatbility WP 5.1
47+
* FIX / url GitHub
48+
4449
= 1.1.4 / 2018-10-22 =
4550
* End support PHP 5.6
4651
* ✔︎ Check compatbility WP 5.0

woo-stripe-fee-in-report.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*
66
* Description: Shows Stripe fees in WooCommerce charts. Calculates a correct net total.
77
*
8-
* Version: 1.1.4
9-
* Revision: 2018-10-22
8+
* Version: 1.2.0
9+
* Revision: 2019-03-08
1010
* Creation: 2018-02-24
1111
*
1212
* Author: studio RVOLA

0 commit comments

Comments
 (0)