#!/usr/bin/perl

BEGIN { use lib '/usr/home/cfg' ; require push_inc ; }
    
require cfg ;

use CGI::Carp qw(fatalsToBrowser) ;
# use Date::Calc qw(:all);
# use DBI;

# https://itvadmin.co.za/cgi-bin/scripts/admin/oneoff/find_saved_fixtures.pl?1
# https://itvadmin.co.za/cgi-bin/scripts/admin/oneoff/build_poc_table.pl?1&recipient

#-------------------------------------------------------------------------------

my  @ARGV     = split(/\&/, $ENV{'QUERY_STRING'});
our $debug    = $ARGV[0] ;
our $poc_or_recipient 	= $ARGV[1] ;
# our $username = 'rory' ;

if ($debug) { print "Content-type: text/html\n\n"; }

#------------------------------------------------------------------------------------------

&today ;
	
&db_open_upd ;
# &db_open_ro ;
    our $db_ignore_open_close = 1 ; # do one open and one close instead of repeating it
		&load_vars ;
	$db_ignore_open_close = 0 ; # do one open and one close instead of repeating it
&db_close_conn ;

if ($debug) { print "Done."; }

exit;

#------------------------------------------------------------------------------------------

sub load_vars {
	
	&db_min_ro('analytics_event_bookings','id,fixtures_saved_values','','','') ; 
	
	foreach my $id (keys %{$db{analytics_event_bookings}}) {
		if ($db{analytics_event_bookings}{$id}{fixtures_saved_values}) {
			my @abc = split(/\|/,$db{analytics_event_bookings}{$id}{fixtures_saved_values}) ; 
			foreach my $fixture (@abc) {
				my @abc2 = split(/\;/,$fixture) ;
				print "\n $abc2[9],$abc2[10],$abc2[11]" if $abc2[9] || $abc2[10] || $abc2[11] ;
			}
		}
	}
	
}

use db ;
use today ;
use common ;
use common_min ;
