
<?php
	 $date_format = $this->session->userdata('date_format');  
	 $time_format = $this->session->userdata('time_format');  
	 $js_date_format = $this->session->userdata('js_date_format');  
	 $js_time_format = $this->session->userdata('js_time_format');  
	 $ampm="";
	 $js_time_format=str_replace ("tt", "TT" ,$js_time_format);
	 if(strpos($js_time_format, 'TT'))
	 {
		$ampm="ampm:true,";
	 }
?>
<style>
#tbl_rides_report tr td{
        border: 1px solid #FFFFFF;
        padding: 3px;
    }
.summery{
        margin-top: 30px;
    }
.summery tr td
{
	border: 1px solid #FFFFFF;
        padding: 4px;
}
.summery .blue_smoke{
  background-color: #DDE7FF;
  text-align: right;
  font-size:12px;
  font-weight: bold;
}
.summery .header_blue_smoke{
  background-color: #DDE7FF; 
  font-size:12px;
  font-weight: bold;
}
.summery .white_smoke{
  background-color: #F5F5F5;
  text-align: left;
  font-size:12px;
}
</style>

<script type="text/javascript">

jQuery().ready(function (){
       $("#loading_top").css("display","none");
       //$("#btn_export").addClass("ui-state-disabled");
       //$("#btn_export").attr("disabled","disabled");
       $("#summery_div").hide();
       jQuery("input:button, input:submit, input:reset").button();
        $("#summery_reports_device").html(assets_combo_opt);
        $("#summeryreport_alert_dialog").dialog({
		autoOpen: false,
		modal: true,
		title:'<?php echo $this->lang->line("Alert_Box"); ?>',
		open : function(){
			setTimeout('$("#summeryreport_alert_dialog").dialog("close")',5000);
		}
	});
	$("#summery_report_sdate").datetimepicker({dateFormat:'<?php echo $js_date_format; ?>',timeFormat: '<?php echo $js_time_format; ?>',<?php echo $ampm; ?>changeMonth: true,showSecond: true,changeYear: true});
	$("#summery_report_edate").datetimepicker({dateFormat:'<?php echo $js_date_format; ?>',timeFormat: '<?php echo $js_time_format; ?>',<?php echo $ampm; ?>changeMonth: true,showSecond: true,changeYear: true});
        $("#summery_report_sdate").datetimepicker('setDate', new Date('<?php echo date("Y/m/d H:i:s",strtotime("12:00:00 am")); ?>'));
	$("#summery_report_edate").datetimepicker('setDate', new Date('<?php echo date("Y/m/d H:i:s",strtotime("11:59:59 pm")); ?>'));
        
        $("#btn_export").click(function(){
        var sdate = $('#summery_report_sdate').val();
        var edate = $('#summery_report_edate').val();
       
        var str="<tr><th colspan='4'>Summery Report between "+ sdate +" and "+ edate;
        $(".summery").prepend(str);
        $(".summery").table2excel({
           //exclude: ".noExl",
           name: "Summery Of Vehicle"
        });
        $('.summery tr th').remove();
        
        });

});
function searchsummeryreport(){
	var sdate = $('#summery_report_sdate').val();
        var edate = $('#summery_report_edate').val();
        var device =$('#summery_reports_device').val();
        
        if(device == ""){
		$("#summeryreport_alert_dialog").html("<?php echo $this->lang->line("Please select device"); ?>");
		$("#summeryreport_alert_dialog").dialog("open");
		return false;
	}
       
       $.post("<?php echo base_url(); ?>index.php/reports/summeryreport/loaddata", { device: device, sdate: sdate, edate: edate },

        function(data){
			
            if(data){
               $("#div_summery_report").html(data);
               $("#summery_div").show();
              // $("#btn_export").removeClass("ui-state-disabled");
	       //$("#btn_export").removeAttr("disabled");
            }
            else{
                $("#summeryreport_alert_dialog").html("<?php echo "No Records found"; ?>");
		$("#summeryreport_alert_dialog").dialog("open");
	        return false;
            }
	});
        $("#loading_top").css("display","none");
	return false;
}


</script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/jquery.table2excel.js"></script>
<div id="">
<form id="form_id" onsubmit="return searchsummeryreport();">
<table border="5" width="100%" class="formtable" style="margin-bottom: 5px;">
<tr>
		<td width="22%"><?php echo $this->lang->line("Start"); ?> :<br> <input type="text" name="sdate" id="summery_report_sdate" class="date text ui-widget-content ui-corner-all" style="width:162px" value="" readonly="readonly"/></td>
		<td width="22%"><?php echo $this->lang->line("End"); ?> : <br><input type="text" name="edate" id="summery_report_edate" class="date text ui-widget-content ui-corner-all" style="width:161px" value="" readonly="readonly"/></td>
		<td width="20%"><?php echo $this->lang->line("Assets"); ?> :<select name="device" id="summery_reports_device" class="select ui-widget-content ui-corner-all"></select></td>
                <td width="15%"><input type="submit" style="margin:20px 0 0 30px;" value="<?php echo $this->lang->line("view"); ?>"/>
                <!--<td width="15%"><input type="button" style="margin:20px 0 0 0;" id="btn_export" value="<?php echo $this->lang->line("Export"); ?>"/>-->
	
</tr>
</table>
</form>
<div id="summery_div" style="margin-top:30px;">
<h3 class="title_black"><?php echo $this->lang->line("Summery of Vehicle"); ?></h3>
<div class="content toggle">
<div id="div_summery_report">
<p></br><?php echo $this->lang->line("no_records_found"); ?>.</p>
</div>
<div style="div_btn_export"><center><input type="button" style="margin:20px 0 0 0;display:none" id="btn_export" value="<?php echo $this->lang->line("Export"); ?>"/></center></div>
</div>
<div id="summeryreport_alert_dialog"></div>
</div>
