Skip to content

Commit

Permalink
Add sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
westi committed Feb 12, 2023
1 parent b456097 commit 14d2052
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions sales-by-days-to-show-by-performance.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
date_default_timezone_set('UTC');

require_once( 'generic-report-parser.php' );

Expand Down Expand Up @@ -30,11 +31,18 @@ function summarise_sales_report( $filename, $first_show_dates ) {
foreach( $_performances as $_performance => &$_weeks ) {
krsort( $_weeks );
}
uksort( $_performances, '_date_sort_helper' );
}

return $_summary;
}

function _date_sort_helper( $a, $b ) {
$_date_a = strtotime( $a );
$_date_b = strtotime( $b );
return $_date_a - $_date_b;
}

function graph_sales_for_show( $show_sales, $sales_per_char = 25 ) {

foreach( $show_sales as $_show => $_performances ) {
Expand Down Expand Up @@ -82,6 +90,7 @@ function csv_sales_for_show( $show_sales, $show ) {
'A Dark & Stormy Night' => '2015-03-26',
'Its All Greek To Me' => '2016-03-31',
'Step Right Up' => '2017-03-23',
'In The Same Boat' => '2018-03-22',
)
);
graph_sales_for_show( $__summary );
Expand All @@ -91,14 +100,15 @@ function csv_sales_for_show( $show_sales, $show ) {
'A Dark & Stormy Night' => '2015-03-26',
'Its All Greek To Me' => '2016-03-31',
'Step Right Up' => '2017-03-23',
'In The Same Boat' => '2018-03-22',
)
);
*/
$__summary = summarise_sales_report(
realpath( 'Sales_Listing-_Online_-_Box_Office.csv' ),
realpath( 'Sales_Listing__Online___Box_Office.csv' ),
array(
'Step Right Up' => '2017-03-23',
'In The Same Boat' => '2018-03-22',
)
);
graph_sales_for_show( $__summary );
csv_sales_for_show( $__summary, 'Step Right Up' );
csv_sales_for_show( $__summary, 'In The Same Boat' );

0 comments on commit 14d2052

Please sign in to comment.