<?php 
session_start();
require_once("../../includes/display_internal_user_dryout.inc.php");
require_once("../../includes/functions_internal_user_dryout.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
$pagename = basename($_SERVER['PHP_SELF']);
$msg = NULL;
if($_REQUEST['action'] == 'submit')
{ 
	$msg = $obj->updatePLDifference();
	//echo $obj->updatePLDifference();die;
	header('Location:./soa_pl_report.php?msg='.$msg);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php $display->title(); ?></title>
<?php $display->favicon(); ?>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php $display->css(); ?>
<link href="../../css/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="../js/html5shiv.js"></script>
  <script src="../js/respond.min.js"></script>
<![endif]-->
</head>
    <body class="skin-blue fixed">
        <!-- header logo: style can be found in header.less -->
        <?php $display->header_tag(); ?>
		<div class="wrapper row-offcanvas row-offcanvas-left">
            <?php $display->leftmenu(7,4); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        <i class="fa fa-bar-chart-o"></i>&nbsp;Reports&nbsp;&nbsp;&nbsp;&nbsp;<small><div class="headline text-center" id="time" style="color:#000; font-weight:bold; font-size:12px;"></div></small>
                    </h1>
                    <ol class="breadcrumb">
                         <li><a href="../"><i class="fa fa-home"></i> Home</a></li>
                         <li>Reports</li>
						 <li>Management Reports</li>
						 <li class="active">SOA Report</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
				<?php if(isset($_REQUEST['msg'])){
						$msg = $_REQUEST['msg'];
						if($msg == 0){?>
				<div class="alert alert-success alert-dismissable">
					<i class="fa fa-check"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Congratulations!</b> data added/updated successfully.
				</div>
				<?php }}?>
				<!--   content put here..................-->
				<div class="box box-primary">
					<h3 style=" text-align:center;">SOA Report</h3>
					<div class="row invoice-info" style="margin-left:10px;">
						<div class="col-sm-4 invoice-col">
                           Year
                            <address>
								<select name="selYear" id="selYear" class="form-control">
							   <?php echo $obj->getYearList($selYear);?>
							  </select>  
							</address>
						</div>
						
                        <div class="col-sm-4 invoice-col">
                                     &nbsp;
                        </div><!-- /.col -->
						<div class="col-sm-2 invoice-col">
							&nbsp;
                            <address>
								<button class="btn btn-info btn-flat" id="inner-login-button" type="button" onClick="getData()">Search</button>
							</address>
						</div>
					</div>
					<!--<div align="right">
						<a href="#" title="Pdf" onClick="getExcel();"><button class="btn btn-default" style="margin-right: 5px;" type="button"><i class="fa fa-download"></i>Generate Excel</button></a>
                        <a href="#" title="Pdf" onClick="getPdf();"><button class="btn btn-default" style="margin-right: 5px;" type="button"><i class="fa fa-download"></i>Generate PDF</button></a>
					</div>-->
					<div style="height:10px;"></div>
					<div class="box-body table-responsive" style="overflow:auto;" id="compssdbody">
                     		<table id="voyage_list" class="table table-bordered table-striped dataTable">
							<thead>
							<tr>
								<th align="left" valign="top" width="5%">S.No.</th>
								<th align="left" valign="top" width="10%">CP Date</th>
								<th align="left" valign="top" width="10%">Voyage No.</th>
								<th align="left" valign="top" width="10%">Vessel Name</th>	
								<th align="left" valign="top" width="10%">Cargo Qty. (MT)</th>
								<th align="left" valign="top" width="10%">TC Earning (USD)</th>
								<th align="left" valign="top" width="10%">P&L (USD)</th>
								<th align="left" valign="top" width="10%">Comparision</th>
							</tr>
							</thead>
							<tbody>
								
							</tbody>
							
						</table>
                        </div>
				</div>
				<!--   content ends here..................-->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
			
			<div class="modal fade" id="compose-modal2" tabindex="-1" role="dialog" aria-hidden="true">
				<div class="modal-dialog" style="width:98%">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title"><i class="fa fa-file-text-o"></i>&nbsp;&nbsp;Compare Sheets</h4>
						</div>
						<form role="form" name="frm2" id="frm2" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post">	
						<div class="modal-body" id="div_3" style="overflow:auto;">
						</div>
						<div class="box-footer" align="center">
						<button type="submit" class="btn btn-warning btn-flat" onClick="return getValidate(0);">Submit</button>&nbsp;&nbsp;
						<input type="hidden" id="action" name="action" value="submit" />
                            <input type="hidden" name="txtCOMID" id="txtCOMID" value="0"/>
						</div>
						<div style="margin-bottom:20px;"></div>
						</form>
					</div>
				</div><!-- /.modal-dialog -->
			</div>	
			
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>
<?php $display->js(); ?>
<script src="../../js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
<script src="../../js/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
<script src="../../js/timer.js" type="text/javascript"></script>
<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/bootstrap-datepicker.js" type="text/javascript"></script>
<script src="../../js/jquery.numeric.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script src='../../js/jquery.autosize.js'></script>
<script type="text/javascript">
$(document).ready(function(){
	
	$("#frm2").validate({
		rules: {
	    
		},
	messages: {
		
		},
	submitHandler: function(form)  {
		jConfirm('Are you sure you want to Submit ?', 'Confirmation', function(r) {
				if(r)
				{
					jAlert('<b style="font-size:25px;">Please wait . . .</b><br><br><img src="../../img/loading.gif"  />', 'Alert');
					$("#popup_container").css({"background": "rgba(255,255,255,0.1)","border": "10px solid rgba(255,255,255,0.1)","width": "100%"});
					$("#popup_content").css({"background":"none","text-align":"center"});
					$("#popup_ok,#popup_title").hide();  
					form.submit();
				}
			});
		}
	});
	getData();
});


function getData()
{
	if($("#selYear").val() != "")
	{
		$('#compssdbody').html("");
		$('#compssdbody').html('<tr><td colspan="6"><span style="text-align:center;display:block;"><img src="../../img/loading.gif" /></span></td></tr>');
		$.post("options.php?id=92",{selYear:""+$("#selYear").val()+""}, function(html) {
			$('#compssdbody').html("");
			$('#compssdbody').html(html);
			
			$("#voyage_list").DataTable();
			
		});
	}else{
		jAlert('Please select Year', 'Alert Dialog');
	}
}

function getExcel()
{
	location.href='allExcel.php?id=30&txtFrom_Date='+$("#txtFrom_Date").val()+'&txtTo_Date='+$("#txtTo_Date").val()+'&selBType='+$("#selBType").val();
}


function getCompareSheetData(comid)
{
	$("#div_3").empty();$("#txtCOMID").val('');
	$("#div_3").html('<div style="height:200px;text-align:center;"><img src="../../img/loading.gif" /></div>');
	$.post("options.php?id=94",{comid:""+comid+""}, function(html) {
		$("#div_3").empty();
		$("#div_3").html(html);
		$("#txtCOMID").val(comid);
		$(".numeric").numeric();
		calculete()
	});
}

function calculete()
{
    var txtCalPL = parseFloat($("#txtCalPL").val());if(isNaN(txtCalPL)){txtCalPL = 0;}
	var txtPLDifference = parseFloat($("#txtPLDifference").val());if(isNaN(txtPLDifference)){txtPLDifference = 0;}
	var txtActualPL = parseFloat(txtCalPL) - parseFloat(txtPLDifference);
	if(isNaN(txtActualPL)){txtActualPL = 0;}
	$("#txtActualPL").val(txtActualPL.toFixed(2));
}

function getValidate()
{
    return true;
}

</script>
</body>
</html>