<?php $this->load->view("partial/header"); ?>
<div id="page_title" style="margin-bottom:8px;"><?php echo $this->lang->line('reports_report_input'); ?></div>
<?php
if(isset($error))
{
	echo "<div class='error_message'>".$error."</div>";
}

$variable_array=explode("/",$_SERVER['PATH_INFO']);

$end_value=end($variable_array);

$search_array[0]="summary_duecustomers";
$search_array[1]="summary_duesuppliers";
?>
<?php if (!in_array($end_value, $search_array)){?>

    <table style='border-collapse: collapse; border: 2px solid #318ee1;width: 97%;margin: 12px;box-shadow: 0px 8px 8px #000;'>
   		 <tr>
   			 <td style="padding: 10px; font-weight:bold;color:#FFFFFF;font-size:18px;background-color:#327789;">
    			<?php echo $this->lang->line('reports_date_range');?>
    		</td>
    	</tr>
    	<tr>
   			 <td style="padding-left: 10px;padding-top: 10px; font-weight:bold;color:#FFFFFF;font-size:20px;background-color:#bbeefc;">
    			<div id='report_date_range_simple'>
					<input type="radio" name="report_type" id="simple_radio" value='simple' checked='checked'/>
						<?php echo form_dropdown('report_date_range_simple',$report_date_range_simple, '', 'id="report_date_range_simple" style="padding-top:4px; padding-bottom:4px;width:145px;"'); ?>
					</div>
    		</td>
    	</tr>
    	<tr>
   			 <td style="padding-left: 10px;padding-top: 2px;font-weight:bold;color:#FFFFFF;font-size:20px;background-color:#bbeefc;font-size:18px;">
    			<div id='report_date_range_complex'>
					<input type="radio" name="report_type" id="complex_radio" value='complex' />
					<?php echo form_dropdown('start_month',$months, $selected_month, 'id="start_month" style="padding-top:4px; padding-bottom:4px;width:70px;"'); ?>
					<?php echo form_dropdown('start_day',$days, $selected_day, 'id="start_day" style="padding-top:4px; padding-bottom:4px;width:70px;"'); ?>
					<?php echo form_dropdown('start_year',$years, $selected_year, 'id="start_year" style="padding-top:4px; padding-bottom:4px;width:70px;"'); ?>
					<font style="color:#000000;">TO</font>
					<?php echo form_dropdown('end_month',$months, $selected_month, 'id="end_month" style="padding-top:4px; padding-bottom:4px;width:70px;"'); ?>
					<?php echo form_dropdown('end_day',$days, $selected_day, 'id="end_day" style="padding-top:4px; padding-bottom:4px;width:70px;"'); ?>
					<?php echo form_dropdown('end_year',$years, $selected_year, 'id="end_year" style="padding-top:4px; padding-bottom:4px;width:70px;"'); ?>
				</div>
    		</td>
    	</tr>
    	<tr>
   			 <td style="padding: 10px; font-weight:bold;color:#FFFFFF;font-size:20px;background-color:#bbeefc;">
				<?php
				echo form_button(array(
				'name'=>'generate_report',
				'id'=>'generate_report',
				'content'=>$this->lang->line('common_submit'),
				'class'=>'button_thickbox_small button_thickbox_blue')
				);
				?>
    		</td>
    	</tr>
    </table>
   
	<?php }?>
	<div style="height:150px;"></div>
<?php $this->load->view("partial/footer"); ?>

<script type="text/javascript" language="javascript">
$(document).ready(function()
{
	$("#generate_report").click(function()
	{
		var sale_type = $("#sale_type").val();
		var export_excel = 0;
		if ($("#export_excel_yes").attr('checked'))
		{
			export_excel = 1;
		}

		if ($("#simple_radio").attr('checked'))
		{
			window.location = window.location+'/'+$("#report_date_range_simple option:selected").val();
		}
		else
		{
			var start_date = $("#start_year").val()+'-'+$("#start_month").val()+'-'+$('#start_day').val();
			var end_date = $("#end_year").val()+'-'+$("#end_month").val()+'-'+$('#end_day').val();

			window.location = window.location+'/'+start_date + '/'+ end_date;
		}
	});

	$("#start_month, #start_day, #start_year, #end_month, #end_day, #end_year").click(function()
	{
		$("#complex_radio").attr('checked', 'checked');
	});

	$("#report_date_range_simple").click(function()
	{
		$("#simple_radio").attr('checked', 'checked');
	});

});
</script>