<?php 

session_start();
require_once("../../includes/display_internal_user_risk.inc.php");
require_once("../../includes/functions_internal_user_riskmangement.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
$id = $_REQUEST['id'];
if (@$_REQUEST['action'] == 'submit')
 {

 	$msg = $obj->updateCargoRisk();
	header('Location:./cargorisk.php?msg='.$msg);
 }

 if($_REQUEST['type']=='updated'){

	$obj->viewCargoRisk($id);

 }else{


	$obj->viewCargoRisknormal($id);
 }

$pagename = basename($_SERVER['PHP_SELF'])."?id=".$id;
?>






<!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(); ?>
<!-- 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]-->
<style>
.animated {
				vertical-align: top; 
				transition: height 0.2s;
				-webkit-transition: height 0.2s; 
				-moz-transition: height 0.2s; 
			}

form.cmxform label.error, label.error {
		/* remove the next line when you have trouble in IE6 with labels in list */
		font-family:Verdana, Arial, Helvetica, sans-serif;
		font-size:10px;
		color: red;
		font-style:normal;
		font-weight:lighter;
		margin:5px;
		vertical-align:top;
		}
</style>
</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(3); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                 <section class="content-header">
                    <h1>
                        <i class="fa fa-folder-open"></i>&nbsp;RISK CARGO&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 class="active">Cargo&nbsp;&nbsp;&nbsp;&nbsp; > RISK CARGO</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content invoice">
				<!--   content put here..................-->
				<div align="right"><a href="cargorisk.php"><button class="btn btn-info btn-flat">Back</button></a></div>
				<div style="height:10px;">&nbsp;</div>
				<form role="form" name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post">			
				<div class="row">
                        <div class="col-xs-12">
                            <h2 class="page-header">
                             UPDATE CARGO RISK 
                            </h2>                            
                        </div><!-- /.col -->
                    </div>
					
					<div class="box-body">
                    
                       

					<div class="form-group" style="width:49%; float:left;">
							<label for="txtVName" >Folder No</label>

							<input type="text" class="form-control" id="txtfolderNo" name="txtfolderNo"  placeholder="Folder No" autocomplete="off" value="<?= $obj->getfun1()?>" readonly>      


						
						</div>
                    
                        <div class="form-group" style="width:49%; float:left;padding-left:1%;">
						<label for="txtVName" >Revised Date</label>
							<input type="text" class="form-control" id="txtCpDate" name="txtCpDate"  placeholder="Date" autocomplete="off" value="<?= date("d-m-Y",strtotime($obj->getfun2()));?>" >                                     
						</div>

                        <div class="form-group" style="width:49%; float:left;">
							<label for="txtVName" >Vessel Name</label>
							<input type="text" class="form-control" id="txtVesselName" name="txtVesselName" placeholder="Vessel Name" autocomplete="off" onKeyUp="setCalculationForffa()" value="<?= $obj->getfun3()?> " readonly/>                        
						</div>
                    
                        <div class="form-group" style="width:49%; float:left;padding-left:1%;">
						<label for="txtVName" >Pic Name</label>
							<input type="text" class="form-control" id="txtPicName" name="txtPicName" placeholder="Pic Name" autocomplete="off" value="<?= $obj->getfun4()?>" readonly>                      
						</div>

					    <div class="form-group" style="width:24%; float:left;">
							<label for="txtVName" >Previous Hire
						</label>
							<input type="text" class="form-control" id="txtHire" name="txtHire" placeholder="Hire" autocomplete="off" onKeyUp="getpl()" value="<?= $obj->getfun5()?>" readonly>                        </div>

							<div class="form-group" style="width:25%; float:left;">
							<label for="txtVName" >Hire
						</label>
							<input type="text" class="form-control" id="txtNewHire" name="txtNewHire" placeholder="Hire" autocomplete="off" onKeyUp="getpl()" >                        
						</div>


                    
                        <div class="form-group" style="width:49%; float:left;padding-left:1%;">
						<label for="txtVName" >Cargo Name

						</label>
							<input type="text" class="form-control" id="txtCargoName" name="txtCargoName" placeholder="Cargo Name
						" autocomplete="off" value="<?= $obj->getfun6()?>" readonly>                      
						</div>






						


						 <div class="form-group" style="width:49%; float:left;">
							<label for="txtVCode" >Cargo Qty </label>
							<input type="text" class="form-control" id="txtNewCargoQty" name="txtNewCargoQty" placeholder="Cargo Qty" autocomplete="off" onKeyUp="getpl()" value="<?= $obj->getfun7()?>" readonly>    
							
						 </div>




						 <div style="clear:both;"></div>	

						<div class="form-group" style="width:49%; float:left;">
						<label for="txtDraft" >
						No Of Shipments
						</label>
						<input type="text" class="form-control" id="txtNoofShipment" name="txtNoofShipment" placeholder="No Of Shipments" autocomplete="off" value="<?= $obj->getfun21()?>" onkeyup="getpl()" readonly>                         
						</div>



						

						 <div class="form-group" style="width:49%; float:left;padding-left:1%;">
							<label for="txtVCode" >Freight USD / PMT </label>
							<input type="text" class="form-control" id="txtNewFrtRate" name="txtNewFrtRate" placeholder="Freight USD / PMT" autocomplete="off" onKeyUp="getpl()" value="<?= $obj->getfun8()?>" readonly>    
						
						 </div><br/>




					 		<div style="clear:both;"></div>	
                        
                      
						<div class="form-group" style="width:49%;  float:left;">
						<label for="txtDWT">TCE
							</label>
							


							<input type="text" class="form-control" id="txtTCE" name="txtTCE" placeholder="TCE" autocomplete="off" value="<?= $obj->getfun9()?>" readonly>    
						


						</div>


					
						<div class="form-group" style="width:49%; float:left;padding-left:1%;" id="drycargo7">
							<label for="txtVesselGroup">Ballast Bonus
						</label>
						<input type="text" class="form-control" id="txtBallastBonus" name="txtBallastBonus" placeholder="Ballast Bonus" autocomplete="off" onKeyUp="getpl()" value="<?= $obj->getfun10()?>">  
						</div>

						<div style="clear:both;"></div>	
                        
                        

						


						<!-- <div style="clear:both;"></div> -->

						
						

                        <div class="form-group" style="width:49%; float:left;">
						<label for="txtDraft" >Voyage duration

						</label>
							<input type="text" class="form-control" id="txtVoyageDuration" name="txtVoyageDuration" placeholder="Voyage duration

							" autocomplete="off" value="<?= $obj->getfun11()?>">                         
						</div>


						<div class="form-group" style="width:49%;  padding-left:1%;float:left;" id="drycargo1">
							<label for="txtCraneSize">Remarks
						</label>
						<textarea name="txtRemarks" id="txtRemarks" class="form-control" cols="42" rows="4"><?= $obj->getfun12()?></textarea>
						</div>
						

						

                        <div style="clear:both;"></div>

		
						<!-- <div class="form-group" style="width:49%; float:left;" id="drycargo8">
						<label for="txtVesselGroup">Remarks</label>
							<textarea name="txtRemarks" id="txtRemarks" class="form-control" cols="42" rows="4"></textarea>
						</div> -->

						
						

						





						
												
						
<?php $display->js(); ?>
<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
<script src='../../js/jquery.autosize.js'></script>

<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/plugins/datepicker/bootstrap-datepicker.js" type="text/javascript"></script>


<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script src="../../js/timer.js" type="text/javascript"></script>
<script type="text/javascript">

function getpl(){


var ttlbunker = parseFloat($("#txtTotalBunkerCost").val());
if(isNaN(ttlbunker)){ttlbunker = 0.0000;}
var hire = parseFloat($("#txtNewHire").val());
if(isNaN(txtHire)){txtHire = 0.0000;}
var txtCargoQty = parseFloat($("#txtNewCargoQty").val());
if(isNaN(txtCargoQty)){txtCargoQty = 0.0000;}
var txtFrtRate = parseFloat($("#txtNewFrtRate").val());
if(isNaN(txtFrtRate)){txtFrtRate = 0.0000;}
var txtBallastBonus = parseFloat($("#txtBallastBonus").val());
if(isNaN(txtBallastBonus)){txtBallastBonus = 0.0000;}


var txtVoyageDuration = parseFloat($("#txtVoyageDuration").val());
	if(isNaN(txtVoyageDuration)){txtVoyageDuration = 0.0000;}

	var txtNoofShipment = parseFloat($("#txtNoofShipment").val());
	if(isNaN(txtNoofShipment)){txtNoofShipment = 0.0000;}


	var expense = ttlbunker+(hire*txtVoyageDuration)+txtBallastBonus;
	var income = txtFrtRate*(txtCargoQty*txtNoofShipment);
	if(isNaN(expense)){expense = 0.0000;}
	if(isNaN(income)){income = 0.0000;}

$("#txtPl").val('');

$("#txtPl").val((income-expense).toFixed(2))



}



function getRepl(){


var ttlbunker = parseFloat($("#RevisebunC").val());
if(isNaN(ttlbunker)){ttlbunker = 0.0000;}
var hire = parseFloat($("#reHire").val());
if(isNaN(txtHire)){txtHire = 0.0000;}
var txtCargoQty = parseFloat($("#reCqty").val());
if(isNaN(txtCargoQty)){txtCargoQty = 0.0000;}
var txtFrtRate = parseFloat($("#ReviseFrate").val());
if(isNaN(txtFrtRate)){txtFrtRate = 0.0000;}
var txtBallastBonus = parseFloat($("#txtBallastBonus").val());
if(isNaN(txtBallastBonus)){txtBallastBonus = 0.0000;}


var expense = ttlbunker+hire+txtBallastBonus;
var income = txtFrtRate*txtCargoQty;
if(isNaN(expense)){expense = 0.0000;}
if(isNaN(income)){income = 0.0000;}

$("#rePL").val('');

$("#rePL").val((income-expense).toFixed(2))



}








$(document).ready(function(){ 
	getBunkerCalculation();


	$('#selType').val('<?= $obj->getfun25()?>')
	$('#selSellBuy').val('<?= $obj->getfun1()?>')

	$('#txtCpDate').datepicker({

                   
format: 'dd-mm-yyyy',
autoclose: true,
todayBtn: true,
minuteStep: 1
}).on('changeDate', function(){  

// setCalculationForffa();
});



$('#ReviseDate').datepicker({

                   
format: 'dd-mm-yyyy',
autoclose: true,
todayBtn: true,
minuteStep: 1
}).on('changeDate', function(){  

// setCalculationForffa();
});




$('#txtPeriod').datepicker({

                   
format: 'mm-yyyy',
autoclose: true,
todayBtn: true,
minuteStep: 1
}).on('changeDate', function(){  

// setCalculationForffa();
});




getpl();

getRepl();

// setCalculationForffa();


$("#selPort").val('<?php echo $obj->getFun3();?>');
$(".areasize").autosize({append: "\n"});
$("#frm1").validate({
	rules: {
		ReviseDate:"required",
	
		},
	messages: {	
		ReviseDate:"*",
		
		},
submitHandler: function(form)  {
		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();
	}
});

});







function getBunkerCalculation()
{
        var totalfoConsumption = totaldoConsumption = 0;
	    var txtSECAConBunkerCount = $("#txtSECAConBunkerCount").val();
		for(var i=1;i<=txtSECAConBunkerCount;i++)
		{
		    var txtSECABunkerQty = $("#txtSECABunkerQty_"+i).val();
			var txtSECABunkerPrice = $("#txtSECABunkerPrice_"+i).val();
		    if($("#ChkSECACalBunker_"+i).is(":checked"))
			{
			    if($("#txtSECAIdentify_"+i).val()=='FO')
			    {
				    totalfoConsumption = parseFloat(totalfoConsumption) + parseFloat(txtSECABunkerQty);
				}
				if($("#txtSECAIdentify_"+i).val()=='DO')
			    {
				    totaldoConsumption = parseFloat(totaldoConsumption) + parseFloat(txtSECABunkerQty);
				}
			}
			var calc = parseFloat(txtSECABunkerQty) * parseFloat(txtSECABunkerPrice);if(isNaN(calc)){calc =0; }
			// $("#txtSECABunkerAmt_"+i).val(calc.toFixed(2));
		}
		// $("#txtTotalSECAConsumption").val($("[id^=txtSECABunkerAmt_]").sum().toFixed(2));
		
		var txtNONSECAConBunkerCount = $("#txtNONSECAConBunkerCount").val();
		for(var i=1;i<=txtNONSECAConBunkerCount;i++)
		{
		    var txtNONSECABunkerQty = $("#txtNONSECABunkerQty_"+i).val();
			var txtNONSECABunkerPrice = $("#txtNONSECABunkerPrice_"+i).val();
			
		    if($("#ChkNONSECACalBunker_"+i).is(":checked"))
			{
			    if($("#txtNONSECAIdentify_"+i).val()=='FO')
			    {
				    totalfoConsumption = parseFloat(totalfoConsumption) + parseFloat(txtNONSECABunkerQty);
				}
				if($("#txtNONSECAIdentify_"+i).val()=='DO')
			    {
				    totaldoConsumption = parseFloat(totaldoConsumption) + parseFloat(txtNONSECABunkerQty);
				}
			}
			var calc = parseFloat(txtNONSECABunkerQty) * parseFloat(txtNONSECABunkerPrice);if(isNaN(calc)){calc =0; }
			// $("#txtNONSECABunkerAmt_"+i).val(calc.toFixed(2));
		}
		// $("#txtTotalNONSECAConsumption").val($("[id^=txtNONSECABunkerAmt_]").sum().toFixed(2));
		
		$("#txtTFUMT").val(totalfoConsumption.toFixed(2));$("#txtTDUMT").val(totaldoConsumption.toFixed(2));
		
		// $("#txtTotalBunkerCost").val($("#txtTotalNONSECAConsumption,#txtTotalSECAConsumption").sum().toFixed(2));
		
		var txtBunkerCount = $("#txtBunkerCount").val();
		for(var i=1;i<=txtBunkerCount;i++)
		{
			var txtBunkerQty = $("#txtBunkerQty_"+i).val();if(isNaN(txtBunkerQty)){txtBunkerQty =0; }
			var txtBunkerPrice = $("#txtBunkerPrice_"+i).val();if(isNaN(txtBunkerPrice)){txtBunkerPrice =0; }
			var calc = parseFloat(txtBunkerQty) * parseFloat(txtBunkerPrice);
			if(isNaN(calc)){calc =0; }
			$("#txtBunkerAmt_"+i).val(calc.toFixed(2));
		}
		
		var txtConBunkerCount = $("#txtConBunkerCount").val();

		var sumCon = 0;
		for(var i=1;i<=txtConBunkerCount;i++)
		{
			var txtConBunkerQty = $("#txtConBunkerQty_"+i).val();if(isNaN(txtConBunkerQty)){txtConBunkerQty =0; }
			var txtConBunkerPrice = $("#txtConBunkerPrice_"+i).val();if(isNaN(txtConBunkerPrice)){txtConBunkerPrice =0; }
			var calc = parseFloat(txtConBunkerQty) * parseFloat(txtConBunkerPrice);
			if(isNaN(calc)){calc =0; }
			$("#txtConBunkerAmt_"+i).val(calc.toFixed(2));

			sumCon=parseFloat(sumCon) + parseFloat(calc.toFixed(2));

		}



		var otheradd = parseFloat(sumCon);

		// var check = $("[id^=txtConBunkerAmt_]").sum();

		console.log(otheradd)
		if(sumCon > 0){$("#txtTotalBunkerCost").val(sumCon)}
	// getFinalCalculation();

	console.log($("#txtTotalBunkerCost").val())
}





function addConBunkerRow()
{
	var id = $("#txtConBunkerCount").val();
	if($("#txtConBunkerQty_"+id).val() != "" && $("#selConBunker_"+id).val() != "" && $("#txtConBunkerPrice_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="DivConBunkeractual_'+id+'"><td><a href="#tbb'+id+'" onclick="removeConBunkerRows('+id+');"><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="selConBunker_'+id+'" id="selConBunker_'+id+'" style="width:90px;" class="input-text form-control"><?php $obj->getBunkerList();?></select></td><td><input type="text" name="txtConBunkerQty_'+id+'" id="txtConBunkerQty_'+id+'" style="width:90px;" class="input-text numeric form-control" onkeyup="getBunkerCalculation();getpl();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtConBunkerPrice_'+id+'" id="txtConBunkerPrice_'+id+'" style="width:90px;" class="input-text numeric form-control" onkeyup="getBunkerCalculation();getpl();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtConBunkerAmt_'+id+'" id="txtConBunkerAmt_'+id+'" style="width:90px;" class="input-text form-control" placeholder="0.00" readonly="" autocomplete="off" value=""></td></tr>').appendTo("#ConbunkerTBody");
		$("#txtConBunkerCount").val(id);
		$("#selConBunkerVendor_"+id).html($("#selVendor").html());
		$(".numeric").numeric();	
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}



function removeConBunkerRows(var1)
{
	jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
		if(r){
				$("#DivConBunkeractual_"+var1).remove();
				getBunkerCalculation();			
			 }
		else{return false;}
		});
}








</script>



<div style="clear:both;"></div>

						<hr>

						<div><strong style="font-size:13px;">Bunkers Consumed</strong></div>
                                <table width="100%" class='tablesorter'>
								  <tr>
								    <td></td>
									<td>Bunker Grade</td>
									<td>Qty(MT)</td>
									<td>Price(USD)</td>
									<td>Amount(USD)</td>
									</tr>
									<tbody id="ConbunkerTBody">
                                    <?php
									
									if($_REQUEST['type']=='updated'){

										$sql_bunk = "select * from cargo_risk_slave where MAST_SLAV_ID='".$id."' and IDENTIFY='CONSUMPTION'";
									
									 }else{

										$sql_bunk = "select * from cargo_risk_slave where ID='".$id."' and IDENTIFY='CONSUMPTION'";
										
									 }
									 
									 
									
									$res_bunk = mysql_query($sql_bunk);
									$num_bunk = mysql_num_rows($res_bunk);
									if($num_bunk==0)
									{$num_bunk =1;?>
							  		<tr id="DivConBunkeractual_1">
									<td><a href="#tb1'" onClick="removeConBunkerRows(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
									<td><select name="selConBunker_1" id="selConBunker_1" style="width:90px;" class="input-text form-control"><?php $obj->getBunkerList();?></select></td>
									<td><input type="text" name="txtConBunkerQty_1" id="txtConBunkerQty_1" style="width:90px;" class="input-text numeric form-control" onKeyUp="getBunkerCalculation();getpl();" placeholder="0.00" autocomplete="off" value=""/></td>
									<td><input type="text" name="txtConBunkerPrice_1" id="txtConBunkerPrice_1" style="width:90px;" class="input-text numeric form-control" onKeyUp="getBunkerCalculation();getpl();" placeholder="0.00" autocomplete="off" value=""/></td>
									<td><input type="text" name="txtConBunkerAmt_1" id="txtConBunkerAmt_1" style="width:90px;" class="input-text form-control"  placeholder="0.00" readonly autocomplete="off" value=""/></td>
								  </tr>
                                  <?php }else{ $bunk = 0;
									  while($rows_bunk = mysql_fetch_assoc($res_bunk))
									  {$bunk++;
									  ?>
								   <tr id="DivConBunkeractual_<?php echo $bunk;?>">
									<td><a href="#tb<?php echo $bunk;?>'" onClick="removeConBunkerRows(<?php echo $bunk;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
									<td><select name="selConBunker_<?php echo $bunk;?>" id="selConBunker_<?php echo $bunk;?>" style="width:90px;" class="input-text form-control"><?php $obj->getBunkerList();?></select></td>
									<td><input type="text" name="txtConBunkerQty_<?php echo $bunk;?>" id="txtConBunkerQty_<?php echo $bunk;?>" style="width:90px;" class="input-text numeric form-control" onKeyUp="getBunkerCalculation();getpl()" placeholder="0.00" autocomplete="off" value="<?php echo $rows_bunk['QTY']; ?>" readonly/></td>
									<td><input type="text" name="txtConBunkerPrice_<?php echo $bunk;?>" id="txtConBunkerPrice_<?php echo $bunk;?>" style="width:90px;" class="input-text numeric form-control" onKeyUp="getBunkerCalculation();getpl();" placeholder="0.00" autocomplete="off" value="<?php echo $rows_bunk['PRICE'];?>"/></td>
									<td><input type="text" name="txtConBunkerAmt_<?php echo $bunk;?>" id="txtConBunkerAmt_<?php echo $bunk;?>" style="width:90px;" class="input-text form-control"  placeholder="0.00" readonly autocomplete="off" value="<?php echo $rows_bunk['COST'];?>"/></td>
								  </tr>
                                  <script>$("#selConBunker_<?php echo $bunk;?>").val('<?php echo $rows_bunk['BUNKERGRADEID'];?>');</script>
                                  <?php }$num_bunk =$bunk; }?>
								</tbody>
								  <tr>
									<td colspan="5"><button type="button" class="btn btn-primary btn-flat" onClick="addConBunkerRow()">Add</button><input type="hidden" name="txtConBunkerCount" id="txtConBunkerCount" value="<?php echo $num_bunk;?>"/></td>
								  </tr>
								</table>


								<hr>



								<div class="form-group" style="width:49%; float:left;" id="drycargo1">
							<label for="txtCraneSize">P/L
						</label>
							<input type="text" class="form-control" id="txtPl" name="txtPl" placeholder="PL
						" autocomplete="off" readonly value="<?= $obj->getfun14()?>">
						</div>
					

                        
						<div class="form-group" style="width:49%;  padding-left:1%;float:left;">
							<label for="txtDraft" >Fxd / Cancelled
						</label>
						<select  name="selFxdCancelled"  class="form-control" id="selFxdCancelled" >
							
							<option value="">Please select a option</option>
							<option value="Fxd" <?php if($obj->getfun13()=='Fxd'){echo 'selected';}?>>Fixed</option>
							<option value="Cancelled" <?php if($obj->getfun13()=='Cancelled'){echo 'selected';}?>>Cancelled</option>
							</select>                                     
						</div>
						<div style="clear:both;"></div>


						










					</div><!-- /.box-body -->
                        
                      
                    
                  
                    
				<div class="box-footer" align="right">
				<input type="hidden" id="txtTotalBunkerCost" name="txtTotalBunkerCost" value="" />
							<button type="submit" class="btn btn-primary btn-flat" onClick="return getValidate(0);">Submit</button>
							<input type="hidden" name="action" value="submit" /><input type="hidden" name="upstatus" id="upstatus" value="" />
				</div>
         
										
				<hr>
					
				</form>
				
				<!--   content ends here..................-->



				<div class="box">
								<div class="box-header">
									<h3 class="box-title">&nbsp;<input type="hidden" id="action2" name="action2" value="submit2" />
								<input type="hidden" name="txtPaymentID2" id="txtPaymentID2" value=""/></h3>
								</div><!-- /.box-header -->
								<div class="box-body no-padding" style="overflow:auto;">
									<table class="table table-striped" data-q="select * from cargo_risk_master_slave where ID='<?=$id?>'">
										<thead>
											<tr>
												<th>Folder no</th>
												<th>Vessel name</th>
												<th>Revised date</th>
												<th>Freight rate</th>
												<th>Cargo qty</th>
												<th>No. Of Shipments</th>
												<th>Total Qty</th>
												<th>Hire</th>
												<th>Bunker Cost</th>
												<th>P/L</th>
											

											
											
											</tr>
										</thead>
										<tbody>
											<?php 
											$sql2 = "select * from cargo_risk_master_slave where ID='".$id."'";
											$res2 = mysql_query($sql2);
											$rec2 = mysql_num_rows($res2);
											while($rows2 = mysql_fetch_assoc($res2))
											{?>
											<tr>
												<td><?php echo  $rows2['FOLDERNO'];?></td>
												<td><?php echo $rows2['VESSEL_NAME'];?></td>
												<td><?php echo date("d-M-Y", strtotime($rows2['CPDATE']));?></td>
												<td><?php echo $rows2['Freight_rate'];?></td>
												<td><?php echo $rows2['Cargo_Qty'];?></td>
												<td><?php echo $rows2['N_OF_SHIPMENT'];?></td>
												<td><?php echo $rows2['Cargo_Qty']*$rows2['N_OF_SHIPMENT'];?></td>
												<td><?php echo $rows2['Hire'];?></td>
												<?php
												$sql1 = "SELECT sum(COST)  as sum1 FROM cargo_risk_slave where MAST_SLAV_ID='".$rows2['SLAVE_ID']."'";
				$res1 = mysql_query($sql1);
				$rows1 = mysql_fetch_assoc($res1);?>


												<td><?php echo $rows1['sum1'];?></td>
												<td><?php echo $rows2['pl'];?></td>
											
											
												
											</tr>
											<?php }?>
										</tbody>
									</table>
								</div>
							</div>				

                </section><!-- /.content -->
            </aside><!-- /.right-side -->
			
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>






    </body>
</html>