#!/usr/bin/perl

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

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

use CGI::Carp qw(fatalsToBrowser);
use CGI;
use Mail::Sendmail;
use Fcntl qw(:flock);
use File::Copy;
use File::Basename;
use Date::Calc qw(:all);
use Excel::Writer::XLSX;

&today;

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

@ARGV   = split(/\\*\&/, $ENV{'QUERY_STRING'});
$action = $ARGV[0] ;

our ($q)                 = CGI -> new() ;
our $iaction             = $q -> param('iaction')                || $action ;
our $isaved              = $q -> param('isaved')                 || '' ;

# our $debug = 1 ;
# our $testing = 1 ;

#-------- page opts --------------------------------------------------------------------------------------------------------------------------------------------------

&page_opts ;

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

print "Content-type: text/html\n\n";
	
our $srchscr   = 0 ;
our $fnsortcol = 0 ;
our $redirtype = 'summary' ; # our $redirtype = 'list' ; # $redirtype = 'search' ;
    
&common_min_action;

exit;

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

sub validate {

# called from common_min_action

# my $exists   = '' ;

# &db_min_ro($table,'*',"name='$i{name}'",'','') ;

# foreach my $id (keys %{$db{$table}}) {
    # if ($db{$table}{$id}{name} eq $i{name}) {
		# $exists = 1 ;
		# }
	# }
	
# if ($exists) {
    # $alert = &common_min_alert('warning',"NAME ALREADY EXISTS!",'ok') ;
	# %col_name = ();
    # # &add_screen;
    # # &screen1;
	# &common_min_add_screen;
    # &common_min_screen1;
    # }

} #------------------------------------------------------------------------------------------

sub insert {

&add_db_fields ;

$i{last_edited_by} = $userid ; 
$i{added_by} = $userid ;

$i{id} = &db_min_get_max($table,'id') ;
$i{type_cnt} = &db_min_get_max($table,'type_cnt',"`type`='$i{type}'") ;

if ($i{type} =~ /\_/g) { my @t = split(/\_/,$i{type}); $code_start = substr($t[0],0,2) . substr($t[1],0,1) ; } else { $code_start = substr($i{type},0,3) ;}

$i{item_code}    = uc $code_start . sprintf("%03s", $i{type_cnt}) ;

&val_check ;

$i{date_added}   = "$now_ccyy_mm_dd" ;
$i{last_updated} = "$now_ccyy_mm_dd $now_hour:$now_min:$now_sec" ;

&db_min_insert($table) ;

} #------------------------------------------------------------------------------------------

sub update {

unless ($i{id}) { $error = qq(NO ID) ; return ; }

&edit_db_fields ;

if ($userid) { $i{last_edited_by} = $userid ; }

&val_check ;

$i{last_updated} = "$now_ccyy_mm_dd $now_hour:$now_min:$now_sec" ;

&db_min_upd($table,"id='$i{id}'") ;

} #------------------------------------------------------------------------------------------

sub val_check {
	
unless ($i{excl})               { $i{excl}              = '0' ; }
unless ($i{excl_from_summary})  { $i{excl_from_summary} = '0' ; }

$i{nett}             = sprintf("%.2f",$i{nett}) ; 
$i{freight}          = sprintf("%.2f",$i{freight}) ; 
$i{main_price}       = sprintf("%.2f",$i{main_price}) ; 

# $i{gross_10_1_50}    = sprintf("%.2f",$i{gross_10_1_50}) ; 
# $i{gross_10_51_plus} = sprintf("%.2f",$i{gross_10_51_plus}) ; 
# $i{gross_20_1_50}    = sprintf("%.2f",$i{gross_20_1_50}) ; 
# $i{gross_20_51_plus} = sprintf("%.2f",$i{gross_20_51_plus}) ; 
# $i{gross_50}         = sprintf("%.2f",$i{gross_50}) ; 

$i{'source_admin'}   = sprintf("%.2f",$i{'source_admin'}) ; 
$i{'3_perc'}         = sprintf("%.2f",$i{'3_perc'}) ; 
$i{'5_perc'}         = sprintf("%.2f",$i{'5_perc'}) ; 
$i{'6_perc'}         = sprintf("%.2f",$i{'6_perc'}) ; 
$i{'8_perc'}         = sprintf("%.2f",$i{'8_perc'}) ; 
$i{'10_perc'}        = sprintf("%.2f",$i{'10_perc'}) ; 
$i{'15_perc'}        = sprintf("%.2f",$i{'15_perc'}) ; 
$i{'20_perc'}        = sprintf("%.2f",$i{'20_perc'}) ; 
	
} #------------------------------------------------------------------------------------------

sub sort_fields {
	
%sort_field = () ;

$sort_field{1}  = 'description' ;
$sort_field{2}  = 'type' if $iaction eq 'add' ;
$sort_field{3}  = 'excl' ;
$sort_field{4}  = 'excl_from_summary' ;
$sort_field{6}  = 'nett' ;
$sort_field{7}  = 'freight' ;
$sort_field{8}  = 'source_admin' ;
$sort_field{9}  = 'main_price' ;
$sort_field{10} = '3_perc'  ; $preferred_title{'3_perc'}  = '3%'  ;
$sort_field{11} = '5_perc'  ; $preferred_title{'5_perc'}  = '5%'  ;
$sort_field{12} = '6_perc'  ; $preferred_title{'6_perc'}  = '6%'  ;
$sort_field{13} = '8_perc'  ; $preferred_title{'8_perc'}  = '8%'  ;
$sort_field{14} = '10_perc' ; $preferred_title{'10_perc'} = '10%' ;
$sort_field{15} = '15_perc' ; $preferred_title{'15_perc'} = '15%' ;
$sort_field{16} = '20_perc' ; $preferred_title{'20_perc'} = '20%' ;

} #-------------------------------------------------------------------------------

sub report_ifields {
	
&db_open_ro ;
    our $db_ignore_open_close = 1 ; # do one open and one close instead of repeating it
	&load_search_vars ;
	$db_ignore_open_close = 0 ; # do one open and one close instead of repeating it
&db_close_conn ;
	
if ($i{date_added_from} and $i{date_added_to}) { # check dates
    my $date_added_from_check = $i{date_added_from} ;
       $date_added_from_check =~ s/\-//g ;
    my $date_added_to_check = $i{date_added_to} ;
       $date_added_to_check =~ s/\-//g ;
    if ($date_added_from_check > $date_added_to_check) { $error = qq(PRICE LIST FROM ($i{date_added_from}) > PRICE LIST TO ($i{date_added_to})); &report_screen; }
    }
    
if ($i{date_added_from}) {
    push @report_sql, "(`date_added` >= '$i{date_added_from}')" ;
    push @report_results, "date_added >= $i{date_added_from}" ;
    }

if ($i{date_added_to}) {
    push @report_sql, "(`date_added` <= '$i{date_added_to}')" ;
    push @report_results, "date_added <= $i{date_added_to}" ;
    }
	
$report_results_msg = uc join(', ', @report_results) ;

unless ($report_results_msg) { $error = qq(ENTER AT LEAST ONE SEARCH PARAMETER); &report_screen; } else { $isaved = qq(SELECT WHERE $report_results_msg) ; }
 
} #------------------------------------------------------------------------------------------

sub load_search_vars {

# &db_min_ro('camera','id,name','','','') ;
# foreach my $id (keys %{$db{camera}}) { $camera_name{$id} = $db{camera}{$id}{name} ; }
	
# &db_min_ro('company','id,name','','','') ;
# foreach my $id (keys %{$db{company}}) { $company_name{$id} = $db{company}{$id}{name} ; }
	
# &db_min_ro('insurer','id,name','','','') ;
# foreach my $id (keys %{$db{insurer}}) { $asset_insurer_name{$id} = $db{insurer}{$id}{name} ; }

} #------------------------------------------------------------------------------------------

sub sort_prefixes {
	
	if ($iaction eq 'summary') {
		$sort_prefix_title{systems}                  = 'aaa' ; 
		$sort_prefix{systems}                        = 'bbb' ;
		$sort_prefix_title{software_licence}         = 'ccc' ;
		$sort_prefix{software_licence}               = 'ddd' ; 
		$sort_prefix_title{installation_kits}        = 'eee' ; 
		$sort_prefix{installation_kits}              = 'fff' ; 
		$sort_prefix_title{hardware_add_ons}         = 'ggg' ;
		$sort_prefix{hardware_add_ons}               = 'hhh' ;
		$sort_prefix_title{game_breakdown_analytics} = 'iii' ; 
		$sort_prefix{game_breakdown_analytics}       = 'jjj' ; 
		$sort_prefix_title{additional_services}      = 'kkk' ; 
		$sort_prefix{additional_services}            = 'lll' ; 
		$sort_prefix_title{match_credits}            = 'sss' ; 
		$sort_prefix{match_credits}                  = 'ttt' ; 
	} else {
		$sort_prefix_title{systems}                  = 'aaa' ; 
		$sort_prefix{systems}                        = 'bbb' ;
		$sort_prefix_title{software_licence}         = 'ccc' ;
		$sort_prefix{software_licence}               = 'ddd' ; 
		$sort_prefix_title{installation_kits}        = 'eee' ; 
		$sort_prefix{installation_kits}              = 'fff' ; 
		$sort_prefix_title{hardware_add_ons}         = 'ggg' ;
		$sort_prefix{hardware_add_ons}               = 'hhh' ;
		$sort_prefix_title{game_breakdown_analytics} = 'iii' ; 
		$sort_prefix{game_breakdown_analytics}       = 'jjj' ; 
		$sort_prefix_title{additional_services}      = 'kkk' ; 
		$sort_prefix{additional_services}            = 'lll' ; 
		$sort_prefix_title{extended_services}        = 'mmm' ; 
		$sort_prefix{extended_services}              = 'nnn' ; 
		$sort_prefix_title{training_services}        = 'ooo' ; 
		$sort_prefix{training_services}              = 'ppp' ; 
		$sort_prefix_title{other_services}           = 'qqq' ; 
		$sort_prefix{other_services}                 = 'rrr' ; 
		$sort_prefix_title{match_credits}            = 'sss' ; 
		$sort_prefix{match_credits}                  = 'ttt' ; 
	}

} #------------------------------------------------------------------------------------------

sub list_screen {
	
&sort_prefixes ;

my $srch_where_sql = join(' AND ', @report_sql) ;

my $add_sql_where = '' ;  
    
# our @sql_col_display = ("id","item_code","excl","main_price","nett","type","type_cnt","description","freight","gross_10_1_50","gross_10_51_plus","gross_20_1_50","gross_20_51_plus","gross_50","last_updated","last_edited_by","") ;
# our @sql_col_display = ("id","item_code","excl","main_price","nett","type","type_cnt","description","freight","source_admin","3_perc","5_perc","8_perc","10_perc","15_perc","20_perc","") ;
# our @sql_col_display = ("description","main_price","3_perc","5_perc","6_perc","8_perc","10_perc","15_perc","20_perc") ;
our  @sql_col_display = ("description") ;
push @sql_col_display, "nett" if $useropts{boss}{$username} ;
push @sql_col_display, "main_price" ;
push @sql_col_display, "3_perc" ;
push @sql_col_display, "5_perc" ;
push @sql_col_display, "6_perc" ;
push @sql_col_display, "8_perc" ;
push @sql_col_display, "10_perc" ;
push @sql_col_display, "15_perc" ;
push @sql_col_display, "20_perc" ;
push @sql_col_display, "" ;

our $exportdir = 'pricelist' ;

&report_xls_export_header("Price-list$xlsreportname",$exportdir) ;

&db_open_ro ;
    our $db_ignore_open_close = 1 ; # do one open and one close instead of repeating it
	&load_list_vars("$srch_where_sql$add_sql_where") ;
	$db_ignore_open_close = 0 ; # do one open and one close instead of repeating it
&db_close_conn ;

my $table_colspan = scalar @sql_col_display ; # get number ioif columns

# foreach my $id (sort {$b <=> $a} keys %{$db{$table}}) {
foreach my $id (sort {$db{$table}{$b}{type} cmp $db{$table}{$a}{type}} keys %{$db{$table}}) {
    
	# if (($i{active} == 1) and ($camera_id_in_use_for_devices{$id} < 1)) { next ; } # Active with devices
	# if (($i{active} == 2) and ($camera_id_in_use_for_devices{$id} > 0)) { next ; } # Active without devices
	
	# &common_debug("$iaction - $db{$table}{$id}{excl_from_summary} [description=$db{$table}{$id}{description}]") ;
	
	if ($iaction eq 'summary') {
		next if $db{$table}{$id}{excl_from_summary} ;
		next unless $sort_prefix_title{$db{$table}{$id}{type}} ;
	}
	
	my $print_type = uc $db{$table}{$id}{type} ; $print_type =~ s/\_/ /g ;# my @type_parts = split(/\_/,$print_type) ; @type_parts = map ucfirst, @type_parts; $print_type = join(" ", @type_parts) ;
	unless ($done_type_group{$db{$table}{$id}{type}}){
		# $print_tbody .= qq~<tr><td style="background-color:white;color:black;font-weight:bold;font-size:100%;"><span style="display:none;">$sort_prefix_title{$db{$table}{$id}{type}}</span>$print_type</td>~ ;
		$print_tbody .= qq~<tr><td style="background-color:#71919b;color:white;font-weight:bold;font-size:100%;"><span style="display:none;">$sort_prefix_title{$db{$table}{$id}{type}}</span>$print_type</td>~ ;
		for (1 .. $table_colspan-1) {
			# $print_tbody .= qq~<td style="background-color:white;">&nbsp;</td>~ ;
			$print_tbody .= qq~<td style="background-color:#71919b;">&nbsp;</td>~ ;
		}
		$print_tbody .= qq~</tr>~ ;
		$done_type_group{$db{$table}{$id}{type}} = 1 ;
	}
		
	# $print_tbody .= qq~<tr><th colspan="$table_colspan" style="background-color:white;color:black;">$print_type</th></tr>~ unless $done_type_group{$db{$table}{$id}{type}} ; $done_type_group{$db{$table}{$id}{type}} = 1 ;
	# $print_tbody .= qq~<tr><th style="background-color:white;color:black;">$print_type</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th></tr>~ unless $done_type_group{$db{$table}{$id}{type}} ; $done_type_group{$db{$table}{$id}{type}} = 1 ;
	
	$print_tbody .= qq~<tr>~ ;
	
	$xlscol=0; my $style = '' ;
	
	foreach (@sql_col_display) { 
		unless ($_) { next ; } # blank for the buttons column
        my $val = $db{$table}{$id}{$_} ;
		my $align = '' ;
		
		# if ($_ eq 'item_code') { $val .= " [$db{$table}{$id}{type}]" ; }
		
		my $center = qq~ class="dt-center"~ ;
		my $right  = qq~ class="dt-right"~ ;

		# if ($_ eq 'active') { if ($val == 1) { $val = &set_tick('green', '') ; } else { $val = &set_tick('red', '') ; } $align = $center ; }
		
		&report_xls_export_process_cell('','',$val) ; # ------------------------------------------------------------------------- HTML AFTER
		$xlscol++; 		
		
		$align = $right unless $_ eq 'description' ;
		$val   = &common_commify($val) unless $_ eq 'description' ;
		
		# $val   = qq~<span style="display:none;">$sort_prefix{$db{$table}{$id}{type}}</span>~ . $val if $_ eq 'description' ;
		$val   = qq~<span style="display:none;">$sort_prefix{$db{$table}{$id}{type}}$val</span>~ . $val if $_ eq 'description' ;
		
		$style = ($db{$table}{$id}{excl}) ? qq~style="background-color:#cb2c2c;color:white;"~ : '' ;
		
		$print_tbody .= qq~<td $align $style>$val</td>~ ;  
        }
	
	my $delete_butt = '' ; my $edit_butt = '' ;	
	
	if ($useropts{boss}{$username} or $useropts{super}{$username}) {
		$edit_butt   = qq(<a class="btn btn-info btn-xs" href="javascript:editMinItem('$id');"><i class="glyphicon glyphicon-edit icon-white"></i></a>) ;
		# $delete_butt = qq(<a class="btn btn-danger btn-xs" href="javascript:deleteMinItem('$db{$table}{$id}{camera_nr}','$id')"><i class="glyphicon glyphicon-trash icon-white"></i></a>) ;
		}
        
    # if ($camera_id_in_use_for_devices{$id}) { $delete_butt = '' ; }
		
	$print_tbody .= qq~<td  $style nowrap>&nbsp;$edit_butt&nbsp;$delete_butt</td></tr>~ ;
    $xlsrow++ ;
	}
	
&report_xls_export_footer('L',15,$exportdir) ;
	
# $glob_sort_col = 0 ; # order by ol devices col
# $glob_sort_asc_desc = 'desc' ;
$fnsortorder = 'asc' ;

$print_more_boxes .= qq~<br><button type="button" class="btn btn-default" onclick="history.go(-1);">Back</button>~ ;
	
&common_min_extra_crumb("search-$lcpage\s","Search Screen") ;

$box_icon .= qq~<div class="box-icon" title='Detailed price list' data-toggle="tooltip" data-placement="left"><a class="btn btn-default btn-round" href="/detailed-price-list" style="padding-top:1px;"><i class="glyphicon glyphicon-th icon-white"></i></a></div>~ ;
	
} #------------------------------------------------------------------------------------------

# sub set_tick {
	
# my ($color,$tooltip) = @_ ;
	
# $tick{green}  = qq~<span style="display:none;">2</span><span class="label label-success"><i $tooltip class="glyphicon glyphicon-ok"></i></span>~ ;
# $tick{orange} = qq~<span style="display:none;">1</span><span class="label label-warning"><i $tooltip class="glyphicon glyphicon-ok"></i></span>~ ;
# $tick{red}    = qq~<span style="display:none;">0</span><span class="label label-danger"><i $tooltip class="glyphicon glyphicon-ok"></i></span>~ ;

# return ($tick{$color}) ;
		
# } #------------------------------------------------------------------------------------------

sub load_list_vars {
	
my ($where) = @_ ;

# &db_min_ro('device','id,camera_id,online,type_id',$acc_id_sql_where,'','') ;
# foreach my $id (keys %{$db{device}}) { 
	# $camera_id_in_use_for_devices{$db{device}{$id}{camera_id}}++ ; 	
	# $cnt_dev_typ{$db{device}{$id}{camera_id}}{$dev_nam}++ ;		
	# }
	
&db_min_ro($table,'*',$where,'type DESC','') ;

} #------------------------------------------------------------------------------------------

sub thead {

&common_min_thead ;
    
} #-------------------------------------------------------------------------------

sub hidden_db_fields {

$ignore{iaction} = 1 ;

$checkbox{excl} = 1 ;
$checkbox{excl_from_summary} = 1 ;

$hidden{last_updated} = 2 ;
$hidden{last_edited_by} = 2 ;
$hidden{date_added} = 2 ;
$hidden{added_by} = 2 ;
$hidden{type_cnt} = 2 ;
$hidden{item_code} = 2 ;

# $required{nett} = 1 ;
# $required{freight} = 1 ;
# $required{gross_10_1_50} = 1 ;
# $required{gross_10_51_plus} = 1 ;
# $required{gross_20_1_50} = 1 ;
# $required{gross_20_51_plus} = 1 ;
# $required{gross_50} = 1 ;
# $required{main_price} = 1 ;

$required{description} = 1 ;

# $required{item_code} = 2 ;

} #------------------------------------------------------------------------------------------

sub add_db_fields {
	
&sort_fields;

&hidden_db_fields ;

$hidden{id} = 2 ;

$db{$table}{''}{nett}         = '0.00' ;
$db{$table}{''}{freight}      = '0.00' ;
$db{$table}{''}{main_price}   = '0.00' ;
$db{$table}{''}{source_admin} = '0.00' ;

$db{$table}{''}{'3_perc'}     = '0.00' ;
$db{$table}{''}{'5_perc'}     = '0.00' ;
$db{$table}{''}{'6_perc'}     = '0.00' ;
$db{$table}{''}{'8_perc'}     = '0.00' ;
$db{$table}{''}{'10_perc'}    = '0.00' ;
$db{$table}{''}{'15_perc'}    = '0.00' ;
$db{$table}{''}{'20_perc'}    = '0.00' ;

# $db{$table}{''}{gross_10_1_50} = '0.00' ;
# $db{$table}{''}{gross_10_51_plus} = '0.00' ;
# $db{$table}{''}{gross_20_1_50} = '0.00' ;
# $db{$table}{''}{gross_20_51_plus} = '0.00' ;
# $db{$table}{''}{gross_50} = '0.00' ;

if ($iaction eq 'add'){ &build_boxes_add ; } # can't be in add_screen, only works if here

} #------------------------------------------------------------------------------------------

sub edit_db_fields {
	
&sort_fields;

&hidden_db_fields ;

$ignore{date_added} = 1 ;
$ignore{added_by} = 1 ;
$ignore{last_updated} = 1 ;
$hidden{id} = 1 ; # 1 = bypass for db update
$hidden{type_cnt} = 2 ; # 1 = bypass for db update
$hidden{type} = 2 ; # 1 = bypass for db update

} #------------------------------------------------------------------------------------------

sub select_opts {

my ($id) = @_ ;

&common_min_select_opts('type',"itv_admin_db.$table",'type',$db{$table}{$id}{type},1,'','','type','','DISTINCT type') ; # 

# &common_min_select_opts('client_id','customers','name',$db{$table}{$id}{client_id},1) ;

} #-------------------------------------------------------------------------------

sub add_screen {

# called from common_add_screen

# $db{$table}{''}{camera_id} = $client_id ; # set for input box

&select_opts('') ;

} #------------------------------------------------------------------------------------------

sub build_boxes_add {

$print_box_content_rows .= &common_min_forms_start($table) ;

$print_box_content_rows .= qq(<div class='row'><div class='col-md-6'>) ;
$print_box_content_rows .= &common_min_box_top('list-alt',"&nbsp;&nbsp;$page_title",$box_main_bg) ;  
$print_box_content_rows .= &common_min_add_form($table,'save',3,9,1,1) ;
$print_box_content_rows .= &common_min_box_foot ;
$print_box_content_rows .= qq(</div><div class='col-md-6'>) ;

&build_boxes_right;

$print_box_content_rows .= qq(</div></div>) ;

$print_box_content_rows .= &common_min_forms_end('',$table,'save') ;

} #----------------------------------------------------------------------------------------

sub edit_screen {

our ($lcol,$fcol) = &common_min_columns($label_col,$field_col) ;

$db{$table}{$i{id}}{source_admin} = '0.00' unless $db{$table}{$i{id}}{source_admin} ;

&select_opts($i{id}) ;

&build_boxes_edit($i{id}) ;  

} #------------------------------------------------------------------------------------------

sub build_boxes_edit {

my ($id) = @_ ;

$print_box_content_rows  .= &common_min_forms_start($table) ;
$print_box_content_rows  .= qq(<div class='row'><div class='col-md-6'>) ;
$print_box_content_rows  .= &common_min_box_top('user',"&nbsp;&nbsp;$page_title : $db{$table}{$id}{id}",$box_main_bg) ;  
$print_box_content_rows  .= &common_min_edit_form($i{id},$table,'update',3,9,1,1) ;
$print_box_content_rows  .= &common_min_box_foot ;
$print_box_content_rows  .= qq(</div><div class='col-md-6'>) ;   

&build_boxes_right($id);

$print_box_content_rows  .= qq(</div></div>) ;

$print_box_content_rows  .= &common_min_forms_end($id,$table,'update',$skip) ;

} #----------------------------------------------------------------------------------------

sub build_boxes_right {

my ($id) = @_ ;

# my $box_icon = '' ;

# $print_box_content_rows .= &common_min_box_top('picture','Logo Upload',$box_right_bg,$box_icon) ;

# $print_box_content_rows .= qq(<div class="row"><div class="col-md-12">&nbsp;</div></div><div class="row">);
        
# $print_box_content_rows .= qq(</div>);
    
# $print_box_content_rows .= &common_min_box_foot ;
                          
} #----------------------------------------------------------------------------------------

sub page_opts {
	
$s{no}=1; # don't add an s

our $glyphicon = 'list' ;
our $lcpage    = 'price-list' ;

&common_page_name ;
   
our $table     = 'price_list' ;

$page_title    = 'Price List' ;

&common_min_add_extras ;

} #-------------------------------------------------------------------------------

sub report_screen {

our $lcol = 2 ;
our $fcol = 5 ;

my ($set_year,$set_month,$set_day) = Add_Delta_Days($now_year,$now_mm,$now_dd,-42); # 6 weeks back

$set_month  = sprintf("%02s", $set_month) ;
$set_day    = sprintf("%02s", $set_day) ;

my $set_ccyy_dd_mm = $set_year . '-' . $set_month . '-' . $set_day ;

$print_box_content_rows .= &common_min_forms_start('report') ;

$print_box_content_rows .= &common_min_form_datepicker('date_added_from',$set_ccyy_dd_mm) ;
$print_box_content_rows .= &common_min_form_datepicker('date_added_to',$now_ccyy_mm_dd) ;
 
$print_box_content_rows .= &common_min_forms_end('','','report') ;

&common_min_search_screen ;

} #-------------------------------------------------------------------------------

use common ;
use report ;
use xlsxcreator ;
use today ;

1;