<?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();

$id 		= explode(",", $_REQUEST['id']);
$comid 	= $id['4'];
$vendorid 	= $id['3'];
$page  		= $_REQUEST['page'];


if ($page == 1) {
	$page_link = "in_ops_at_glance.php";
	$page_bar = "In Ops at a glance";
	$nav = 5;
	$subtitle = 'VC';
} else if ($page == 2) {
	$page_link = "vessel_in_post_ops.php";
	$page_bar = "Vessels in Post Ops";
	$nav = 5;
	$subtitle = 'VC';
} else if ($page == 3) {
	$page_link = "vessel_in_history.php";
	$page_bar = "Vessels in History";
	$nav = 5;
	$subtitle = 'VC';
} else if ($page == 4) {
	$page_link = "coa_in_ops_at_glance.php";
	$page_bar = "In Ops at a glance - COA";
	$nav = 20;
	$subtitle = 'COA';
} else if ($page == 5) {
	$page_link = "coa_in_post_ops.php";
	$page_bar = "In Post Ops at a glance - COA";
	$nav = 20;
	$subtitle = 'COA';
} else if ($page == 6) {
	$page_link = "coa_in_history.php";
	$page_bar = "Vessels in History - COA";
	$nav = 20;
	$subtitle = 'COA';
} else {
	$page_link = "vessel_in_history_entry.php";
	$page_bar = "Historical Data - VC";
	$nav = 20;
	$subtitle = 'VC';
}


if (@$_REQUEST['action'] == 'submit') {
	$msg = $obj->insertRequestDetails();
	header('Location:./request_port_cost.php?voyage_no=' . $_GET['voyage_no'] . '&msg=' . $msg . '&id=' . $_REQUEST['id'] . '&page=' . $page . "&name=" . $_REQUEST['name']);
}

if (@$_REQUEST['action1'] == 'submit1') {
	$msg = $obj->insertRequestUploadDetails();
	header('Location:./request_port_cost.php?voyage_no=' . $_GET['voyage_no'] . '&msg=' . $msg . '&id=' . $_REQUEST['id'] . '&page=' . $page . "&name=" . $_REQUEST['name']);
}

if (@$_REQUEST['action2'] == 'submit2') {
	$msg = $obj->deleteRequestDetails();
	$msg = explode("_", $msg);
	header('Location:./request_port_cost.php?voyage_no=' . $_GET['voyage_no'] . '&msg=' . $msg[0] . '&id=' . $_REQUEST['id'] . '&page=' . $page . "&name=" . $_REQUEST['name']);
}


if (isset($_POST['invoice_id'])) {


	mysql_query("update alert_master set SHOW_STATUS=0 where IDENTIFYID='" . $_POST['invoice_id'] . "'");

	$sql_ufim = mysql_query("update request_master set STATUS=0,SYNC_STATUS=0,PAYMENT_STATUS='' where REQ_ID='" . $_POST['invoice_id'] . "'");

	echo true;
}





$creatorsarr = array();
$approverarr1 = array();
$approverarr2 = array();
$openarr2 = array();
$approverfieldname = '';
$creator = $approver1 = $approver2 = $openingright = 0;
if ($id[1] == 'Load Port Costs' || $id[1] == 'Discharge Port Costs' || $id[1] == 'Transit Port Costs') {
	$portcost = 0;
	if ($id[1] == 'Load Port Costs') {
		$portcost = $obj->getFDA($comid, 'LP', $id[2], $id['7']);
	}
	if ($id[1] == 'Discharge Port Costs') {
		$portcost = $obj->getFDA($comid, 'DP', $id[2], $id['7']);
	}
	if ($id[1] == 'Transit Port Costs') {
		$portcost = $obj->getFDA($comid, 'TP', $id[2], $id['7']);
	}
	if ($portcost > 0) {
		$creatorsarr = $obj->getUsersWithAuthority('FDA_CHK_CRETR');
		$approverarr1 = $obj->getUsersWithAuthority('FDA_CHK_APP_1');
		$approverarr2 = $obj->getUsersWithAuthority('FDA_CHK_APP_2');
		$approverfieldname = 'FDA_CHK_APP_1';

		$creator = $obj->getUserAuthority($_SESSION['uid'], 'FDA_CHK_CRETR');
		$approver1 = $obj->getUserAuthority($_SESSION['uid'], 'FDA_CHK_APP_1');
		$approver2 = $obj->getUserAuthority($_SESSION['uid'], 'FDA_CHK_APP_2');
	} else {
		$creatorsarr = $obj->getUsersWithAuthority('PDA_CHK_CRETR');
		$approverarr1 = $obj->getUsersWithAuthority('PDA_CHK_APP_1');
		$approverarr2 = $obj->getUsersWithAuthority('PDA_CHK_APP_2');
		$approverfieldname = 'PDA_CHK_APP_1';

		$creator = $obj->getUserAuthority($_SESSION['uid'], 'PDA_CHK_CRETR');
		$approver1 = $obj->getUserAuthority($_SESSION['uid'], 'PDA_CHK_APP_1');
		$approver2 = $obj->getUserAuthority($_SESSION['uid'], 'PDA_CHK_APP_2');
	}
} else {
	$creatorsarr = $obj->getUsersWithAuthority('OTHER_PAYMENT_CHK_CRETR');
	$approverarr1 = $obj->getUsersWithAuthority('OTHER_PAYMENT_CHK_APP_1');
	$approverarr2 = $obj->getUsersWithAuthority('OTHER_PAYMENT_CHK_APP_2');
	$approverfieldname = 'OTHER_PAYMENT_CHK_APP_1';

	$creator = $obj->getUserAuthority($_SESSION['uid'], 'OTHER_PAYMENT_CHK_CRETR');
	$approver1 = $obj->getUserAuthority($_SESSION['uid'], 'OTHER_PAYMENT_CHK_APP_1');
	$approver2 = $obj->getUserAuthority($_SESSION['uid'], 'OTHER_PAYMENT_CHK_APP_2');
}

$fcaid = $obj->getLatestCostSheetID($comid);
$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);

$pagename = basename($_SERVER['PHP_SELF']) . "?id=" . $_REQUEST['id'] . "&page=" . $page . "&name=" . $_REQUEST['name'];

$uid	  = $_SESSION['uid'];
$moduleid = $_SESSION['moduleid'];
if ($page == 1) {
	$linkid = 4;
} else {
	$linkid = 5;
}
$rights = $obj->getUserRights($uid, $moduleid, $linkid);


?>
<!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(); ?>
	<?php $display->js(); ?>
	<link type="text/css" href="../../css/chosen.css" rel="stylesheet" />
	<script src="../../js/chosen.jquery.js" type="text/javascript"></script>
	<!-- 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>
		.glow {
			font-size: 80px;
			color: #fff;
			text-align: center;
			animation: glow 1s ease-in-out infinite alternate;
		}

		@-webkit-keyframes glow {
			from {
				text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #e60000, 0 0 40px #e60000, 0 0 50px #e60000, 0 0 60px #e60000, 0 0 70px #e60000;
			}

			to {
				text-shadow: 0 0 20px #fff, 0 0 30px #e60000, 0 0 40px #e60000, 0 0 50px #e60000, 0 0 60px #e60000, 0 0 70px #e60000, 0 0 80px #e60000;
			}
		}


		.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;
		}

		.span span {
			font-weight: bold;
		}
	</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($nav); ?>
		<aside class="right-side">
			<!-- Content Header (Page header) -->
			<section class="content-header">
				<h1>
					<i class="fa fa-book"></i>&nbsp;Ops <?php echo $subtitle; ?>&nbsp;&nbsp;&nbsp;&nbsp;<small>
						<div class="headline text-center" id="time" style="color:#000; font-weight:bold; font-size:12px;">( 20 Jul 2015 4:40:44 PM )</div>
					</small>
				</h1>
				<ol class="breadcrumb">
					<li><a href="../"><i class="fa fa-home"></i> Home</a></li>
					<li class="active">Ops <?php echo $subtitle; ?>&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;<?php echo $page_bar; ?>&nbsp;&nbsp;&nbsp;</li>
				</ol>
			</section>
			<?php
			$sql = "select * from request_master where COMID='" . $comid . "' and MODULEID='" . $_SESSION['moduleid'] . "' and MCOMPANYID='" . $_SESSION['company'] . "' and LOGIN='INTERNAL_USER' and NAME='" . $id[1] . "' and NAME_ID='" . $id[0] . "' and GRADEID='" . $id[2] . "' and VENDOR='" . $id[3] . "' and STATUS<5";


			// echo $sql;
			// exit;

			$res  = mysql_query($sql);
			$rec = mysql_num_rows($res);
			$rows = mysql_fetch_assoc($res);

			$upload_attach = $rows['UPLOAD'];
			$upload_attach_name = $rows['UPLOAD_NAME'];

			?>

			<!-- Main content -->
			<section class="content invoice">
				<?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> <?php echo $id[1]; ?> added/updated successfully.
						</div>
					<?php } ?>
					<?php if ($msg == 1) { ?>
						<div class="alert alert-success alert-dismissable">
							<i class="fa fa-ban"></i>
							<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
							<b>Sorry!</b> <?php echo $id[1]; ?> can not be created.
						</div>
					<?php } ?>
					<?php if ($msg == 2) { ?>
						<div class="alert alert-success alert-dismissable">
							<i class="fa fa-ban"></i>
							<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
							<b>Congratulations!</b> <?php echo $id[1]; ?> deleted successfully.
						</div>
					<?php } ?>
					<?php if ($msg == 3) { ?>
						<div class="alert alert-success alert-dismissable">
							<i class="fa fa-ban"></i>
							<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
							<b>Congratulations!</b> Payment paid details saved successfully.
						</div>
					<?php } ?>
				<?php } ?>
				<!--   content put here..................-->
				<div align="right">
					<?php if ($rec > 0) { ?>

						<input type="hidden" name="flag" id="flag" value="false">
						<button class="btn btn-default" type="button" onClick="getPdf(<?php echo $rows['REQ_ID']; ?>);" style="margin-right: 5px;"><i class="fa fa-download"></i> Generate PDF</button>
					<?php } else { ?>
						<input type="hidden" name="flag" id="flag" value="true">

					<?php } ?>
					<a href="payment_grid.php?comid=<?php echo $comid; ?>&page=<?php echo $page; ?>&voyage_no=<?php echo $_REQUEST['voyage_no'] ?>">
						<button class="btn btn-info btn-flat" type="button">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>
						<div class="row">
							<div class="col-xs-12">
								<h2 class="page-header">
									Account <?php echo $id[1]; ?> : <?php echo $_REQUEST['name'] ?>
								</h2>
							</div><!-- /.col -->
						</div>

						<div class="row invoice-info">
							<div class="col-sm-3 invoice-col">
								Account Type
								<address>
									<select name="selAType" class="select form-control" id="selAType" onChange="getAlert()" required>
										<?php
										$obj->getAccountType();
										?>
									</select>
									<script>
										$('#selAType').val('<?php echo $rows['ACCOUNT_TYPE']; ?>');
									</script>
								</address>
							</div><!-- /.col -->
							<div class="col-sm-3 invoice-col">
								Payment No/Description
								<address>

									<input type="text" name="txtAccNO" id="txtAccNO" class="form-control" value="<?php echo $rows['PAYMENT_NO']; ?>" autocomplete="off" placeholder="Payment No/Description" />
								</address>
							</div><!-- /.col -->
							<div class="col-sm-3 invoice-col">
								CP Date
								<address>
									<?php echo date("d-m-Y", strtotime($obj->getFun3())); ?>
									<input type="hidden" name="txtCP_Date" id="txtCP_Date" class="form-control" value="<?php echo date("d-m-Y", strtotime($obj->getFun3())); ?>" autocomplete="off" readonly />
								</address>
							</div><!-- /.col -->
							<div class="col-sm-3 invoice-col">
								Date
								<?php $invdate = date('d-m-Y', strtotime($rows['DATE']));
								if ($invdate == '01-01-1970') {
									$invdate = '';
								} ?>
								<address>
									<input type="text" name="txtDate" id="txtDate" autcomplete="off" class="form-control" autocomplete="off" value="<?php echo $invdate; ?>" />
								</address>
							</div><!-- /.col -->
						</div>
						<div class="row invoice-info">
							<div class="col-sm-3 invoice-col">
								Nom ID
								<address>
									<?php echo $obj->getCompareTableData($comid, "MESSAGE"); ?>
								</address>
							</div><!-- /.col -->
							<div class="col-sm-3 invoice-col">
								Vessel
								<address>
									<?php echo $obj->getVesselIMOData($obj->getCompareEstimateData($comid, "VESSEL_IMO_ID"), "VESSEL_NAME"); ?>
								</address>
							</div><!-- /.col -->
							<div class="col-sm-3 invoice-col">
								Vendor
								<address>
									<?php echo $obj->getVendorListNewBasedOnID($vendorid); ?><input type="hidden" name="txtVendor" id="txtVendor" class="form-control" readonly value="<?php echo $vendorid; ?>" />
								</address>
							</div><!-- /.col -->

							<?php
							$vendor_id = mysql_fetch_assoc(mysql_query("SELECT * FROM vendor_master WHERE  CODE ='" . $vendorid . "' "))['VENDORID'];



							?>
							<div class="col-sm-3 invoice-col selBankingID_div" data-vendorid="<?= $vendor_id ?>">
								Banking Details
								<address>

									<select name="selBankingID" class="select form-control fadeInVenBank" id="selBankingID">
										<?php $obj->getBankingDetailsDataWithJsonVendor($vendorid, $rows['VENDOR_SLAVEID']); ?>
									</select>


									<select name="selBankingID" class="select form-control fadeInBbnInvCom" id="selBankingID" style="display:none;">
										<?php
										$obj->getBankingDetails($rows['VENDOR_SLAVEID']);
										?>
									</select>



								</address>
							</div><!-- /.col -->
						</div>
						<div class="row invoice-info">
							<div class="col-sm-3 invoice-col">
								Cost Type Desc.
								<address>
									<?php echo $_REQUEST['name'] ?>
								</address>
							</div><!-- /.col -->
							<div class="col-sm-3 invoice-col">
								Vendor Invoice Amount
								<address>
									<input type="text" name="txtV_I_Amt" id="txtV_I_Amt" class="form-control" autocomplete="off" value="<?php echo ($rec == 0) ? $id[5] : $rows['INVOICE_AMT']; ?>" placeholder="Vendor Invoice Amount" onkeyup="setAmountTtlPayable()" />
								</address>
							</div><!-- /.col -->

							<div class="col-sm-3 invoice-col">
								Invoice Date
								<address>
									<?php $invoicedate = date('d-m-Y', strtotime($rows['INVOICE_DATE']));
									if ($invoicedate == '01-01-1970') {
										$invoicedate = '';
									} ?>
									<input type="text" name="txtI_Date" id="txtI_Date" class="form-control" value="<?php echo $invoicedate; ?>" autocomplete="off" placeholder="dd-mm-yyyy" />
								</address>
							</div><!-- /.col -->
							<div class="col-sm-3 invoice-col">
								Remarks
								<address>
									<textarea name="txtRemarks" id="txtRemarks" class="form-control" rows="3" cols="15" placeholder="Remarks.."><?php echo $rows['REMARKS']; ?></textarea>
								</address>
							</div><!-- /.col -->
						</div>

						<div class="row invoice-info">
							<div class="col-sm-3 invoice-col">
								Exchange Rate
								<address>
									<input type="text" name="txtExchangeRate" id="txtExchangeRate" class="form-control numeric" placeholder="Exchange Rate" autocomplete="off" value="<?php echo $rows['EXCHANGE_RATE']; ?>" />
								</address>
							</div><!-- /.col -->
							<div class="col-sm-3 invoice-col">
								Exchange Date
								<address>
									<?php

									$exchangeDate = date('d-m-Y', strtotime($rows['EXCHANGE_DATE']));
									if ($exchangeDate == '01-01-1970') {
										$exchangeDate = '';
									}
									?>
									<input type="text" name="txtExchangeDate" id="txtExchangeDate" class="form-control datepicker" placeholder="dd-mm-yyyy" autocomplete="off" value="<?php echo $exchangeDate; ?>" />
								</address>
							</div><!-- /.col -->
							<div class="col-sm-3 invoice-col">


								Exchange To Currency
								<address>
									<select name="selExchangeCurrency" class="select form-control" id="selExchangeCurrency"><?php $obj->getCurrencyList(); ?></select>
								</address>
							</div>
							<script>
								$("#selExchangeCurrency").val('<?php echo $rows['EXCHANGE_CURRENCY']; ?>');
							</script>

							<?php
							if (substr($_REQUEST['voyage_no'], 0, 1) == 'U') {
							?>
								<div class="col-sm-3 invoice-col">
									Payment From DUBAI A/C
								</div>
							<?php
							}
							?>
							<?php
							if (substr($_REQUEST['voyage_no'], 0, 1) == 'S') {
							?>
								<div class="col-sm-3 invoice-col">
									Payment From SINGAPORE A/C
								</div>
							<?php
							}
							?>

							<input type="hidden" name="voyage_no" value="<?php echo $_REQUEST['voyage_no'] ?>">

						</div>
						<!-- ldj -->

						<!-- end ldj -->


						<?php if (strpos($_REQUEST['name'], 'Test Payment') !== false) { ?>
							<div class="row invoice-info">
								<div class="col-sm-3 invoice-col">

									Account Ledger
									<address>
										<select name="selAccountLedgre" class="select form-control" id="selAccountLedgre" required><?php $obj->getAccountLedgre(); ?></select>
									</address>
								</div>
								<script>
									$("#selAccountLedgre").val('<?php echo $rows['ACC_L_CODE']; ?>');
								</script>


							</div>

						<?php } ?>


						<div class="box">
							<div class="box-header">
								<h3 class="box-title">Account <?php echo $id[1]; ?> : Details</h3>
							</div><!-- /.box-header -->
							<div class="box-body no-padding">
								<table class="table table-striped" data-q="select * from request_master where COMID='<?= $comid ?>' and MODULEID='<?= $_SESSION['moduleid'] ?>' and MCOMPANYID='<?= $_SESSION['company'] ?>' and LOGIN='INTERNAL_USER' and NAME='<?= $id[1] ?>' and NAME_ID='<?= $id[0] ?>' and GRADEID='<?= $id[2] ?>' and VENDOR='<?= $id[3] ?>' and STATUS=5">
									<tbody>
										<tr>
											<td>Total Payable</td>
											<td><input type="text" name="txtTtl_Outs" id="txtTtl_Outs" class="form-control" readonly /></td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
											<script>

											</script>

										</tr>
										<?php
										$sql6 = "select * from request_master where COMID='" . $comid . "' and MODULEID='" . $_SESSION['moduleid'] . "' and MCOMPANYID='" . $_SESSION['company'] . "' and LOGIN='INTERNAL_USER' and NAME='" . $id[1] . "' and NAME_ID='" . $id[0] . "' and GRADEID='" . $id[2] . "' and VENDOR='" . $id[3] . "' and STATUS=5 and P_AMT is not null";
										$res6 = mysql_query($sql6);
										$rec6 = mysql_num_rows($res6);
										// echo $rec6;
										$n = 1;
										$cost = 0;
										$addition = $deduction = 0;
										while ($rows6 = mysql_fetch_assoc($res6)) {
											$sql7 = "select * from request_master_slave where REQ_ID='" . $rows6['REQ_ID'] . "'";
											$res7 = mysql_query($sql7);
											while ($rows7 = mysql_fetch_assoc($res7)) {
												if ($rows7['IDENTIFY'] == 'ADD') {
													$addition = $addition + $rows7['AMOUNT'];
												} else {
													$deduction   = $deduction + $rows7['AMOUNT'];
												}
											}
											$cost = $cost + $rows6['REQ_TO_PAY'];
										?>
											<tr id="row_1_<?php echo $n; ?>">
												<td>Amount Paid <?php echo $rows6['PAYMENT_NO']; ?></td>
												<td><input type="text" name="txtP_<?php echo $n; ?>" id="txtP_<?php echo $n; ?>" class="form-control" readonly value="<?php echo sprintf("%.2f", $rows6['P_AMT']); ?>" /></td>
												<td>&nbsp;</td>
												<td>&nbsp;</td>
											</tr>
										<?php $n++;
										} ?>

										<tr>
											<td>Balance Outstanding</td>
											<?php $cost = $id[5] - $cost;
											if ($rec6 == 0) { ?>
												<td><input type="text" name="txtBal_Outs" id="txtBal_Outs" class="form-control" readonly value="<?php echo sprintf("%.2f", $id[5]); ?>" />


												</td>
											<?php } else { ?>
												<td><input type="text" name="txtBal_Outs" id="txtBal_Outs" class="form-control" readonly value="<?php echo sprintf("%.2f", $cost); ?>" /></td>
											<?php } ?>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
										</tr>

									</tbody>
								</table>
							</div>
						</div>


						<div class="row">
							<div class="col-xs-12">
								<h2 class="page-header">
									Add Adjustment
								</h2>
							</div><!-- /.col -->
						</div>
						<!-- <tr> -->

						<div class="box">
							<div class="box-body no-padding">



								<td colspan="4">
									<table width="100%" class="table table-striped">
										<thead>
											<tr>
												<th></th>
												<th>Cost type</th>
												<th>Fixture no</th>
												<th>Vessel</th>
												<th width="16%">Description</th>
												<th width="16%">Amount</th>


											</tr>
										</thead>



										<?php $sql2 = "select * from request_adj_slave where REQ_ID='" . $rows['REQ_ID'] . "' and IDENTIFY='ADD'";

										//  ECHO '<H1>'.$sql2;
										$res2 = mysql_query($sql2);
										$num211 = mysql_num_rows($res2);
										if ($num211 > 0) {
											$num2111 = $num211;
										} else {
											$num2111 = 1;
										}
										?>
										<tbody id="tblAddADJ">
											<?php if ($num211 > 0) {
												$i = 0;
												while ($rows2 = mysql_fetch_assoc($res2)) {
													$i++;

													// print_r($rows2);
											?>



													<tr id="addadj_Row_<?php echo $i; ?>">
														<td align="center"><a href="#pr<?= $i ?>" onClick="removeAddAdjRow(<?= $i ?>);"><i class="fa fa-times" style="color:red;"></i></a></td>

														<td>
															<select class="form-control" name="txtCORCIDFORADDADJ_<?= $i ?>" id="txtCORCIDFORADDADJ_<?= $i ?>" style="width:100px;">
																<?php $obj->getOwnerRelatedCostListForTallyInvoice($rows2['ORC_ID']); ?>
															</select>
														</td>
														<td><select class="form-control" name="txtFixNoForADDADJ_<?= $i ?>" id="txtFixNoForADDADJ_<?= $i ?>" style="width:100px;" onchange="getVessel(this)">
																<?php $obj->getFixtureNoForTallyInvoice($rows2['FIXTURE_NO']); ?>
															</select></td>
														<td><select class="form-control check" name="txtVesselFORADDADJ_<?= $i ?>" id="txtVesselFORADDADJ_<?= $i ?>" data-check="io" style="width:100px;" readonly>

																<?php $obj->getVesselNameForTally($rows2['VESSEL']); ?>

															</select></td>

														<td><textarea class="form-control areasize" name="txtAddDesADJ_<?= $i ?>" id="txtAddDesADJ_<?= $i ?>" rows="2" placeholder="Description..."><?= $rows2['DESCRIPTION'] ?></textarea></td>
														<td><input type="text" name="txtAddADJAmt_<?= $i ?>" id="txtAddADJAmt_<?= $i ?>" class="form-control numeric" placeholder="Amount" autocomplete="off" value="<?= $rows2['AMOUNT'] ?>" onKeyUp="getDeduction();" /></td>


													</tr>


												<?php }
											} else { ?>
												<tr id="addadj_Row_1">

													<td align="center"><a href="#pr1" onClick="removeAddAdjRow(1);"><i class="fa fa-times" style="color:red;"></i></a></td>
													<td>
														<select class="form-control" name="txtCORCIDFORADDADJ_1" id="txtCORCIDFORADDADJ_1" style="width:100px;">
															<?php $obj->getOwnerRelatedCostListForTallyInvoice(); ?>
														</select>
													</td>
													<td><select class="form-control" name="txtFixNoForADDADJ_1" id="txtFixNoForADDADJ_1" style="width:100px;" onchange="getVessel(this)">
															<?php $obj->getFixtureNoForTallyInvoice(); ?>
														</select></td>
													<td id="checForCheck"><select class="form-control check" name="txtVesselFORADDADJ_1" id="txtVesselFORADDADJ_1" style="width:100px;" readonly>

														</select></td>

													<td><textarea class="form-control areasize" name="txtAddDesADJ_1" id="txtAddDesADJ_1" rows="2" placeholder="Description..."></textarea></td>
													<td><input type="text" name="txtAddADJAmt_1" id="txtAddADJAmt_1" class="form-control numeric" placeholder="Amount" autocomplete="off" value="" onKeyUp="getDeduction();" /></td>


												</tr>


											<?php } ?>
										</tbody>

										<tfoot>
											<tr>
												<td align="left"><button type="button" class="btn btn-primary btn-flat" onClick="AddNewAddADJRow();">Add</button></td>

												<td></td>
												<td></td>
												<td></td>
												<td>Total</td>
												<input type="hidden" name="txtAddADJID" id="txtAddADJID" value="<?php echo $num2111; ?>" />
												<td><input type="text" name="txtAddDesADJTotalAmt" id="txtAddDesADJTotalAmt" class="form-control" readonly placeholder="0.00" autocomplete="off" value="" /></td>
											</tr>
										</tfoot>

									</table>
								</td>

							</div>

						</div>
						<!-- </tr> -->

						<div class="row">
							<div class="col-xs-12">
								<h2 class="page-header">
									Add
								</h2>
							</div><!-- /.col -->
						</div>

						<div class="box">
							<div class="box-body no-padding">
								<table class="table table-striped">
									<thead>
										<tr>
											<th>#</th>
											<th>Cost Type</th>

											<th>Description</th>
											<?php $sql2 = "select * from request_master_slave where REQ_ID='" . $rows['REQ_ID'] . "' and IDENTIFY='ADD'";
											$res2 = mysql_query($sql2);
											$num2 = mysql_num_rows($res2);
											$sum1 = $sum2 = 0;
											if ($num2 > 0) {
												$num21 = $num2;
											} else {
												$num21 = 1;
											}
											?>
											<th>Amount<input type="hidden" name="txtAddID" id="txtAddID" value="<?php echo $num21; ?>" /></th>
										</tr>
									</thead>
									<tbody id="tblAdd">
										<?php if ($num2 > 0) {
											$i = 0;
											while ($rows2 = mysql_fetch_assoc($res2)) {
												$i++;
												$sum1 = $sum1 + $rows2['AMOUNT'];
										?>
												<tr id="add_Row_<?php echo $i; ?>">
													<td align="center"><a href="#pr<?php echo $i; ?>" onClick="removeAddRow(<?php echo $i; ?>);"><i class="fa fa-times" style="color:red;"></i></a></td>

													<td>

														<select class="form-control" name="txtCORCIDFOROTHERADD_<?php echo $i; ?>" id="txtCORCIDFOROTHERADD_<?php echo $i; ?>" style="width:100px;">
															<?php

															$obj->getOwnerRelatedCostListForTallyInvoice($rows2['ORC_ID']);

															?>
														</select>


													</td>



													<td><textarea class="form-control areasize" name="txtAddDes_<?php echo $i; ?>" id="txtAddDes_<?php echo $i; ?>" rows="2" placeholder="Description..."><?php echo $rows2['DESCRIPTION']; ?></textarea></td>
													<td><input type="text" name="txtAddDesAmt_<?php echo $i; ?>" id="txtAddDesAmt_<?php echo $i; ?>" class="form-control" placeholder="Amount" autocomplete="off" value="<?php echo $rows2['AMOUNT']; ?>" onKeyUp="getDeduction();" /></td>
												</tr>
											<?php }
										} else { ?>
											<tr id="add_Row_1">
												<td align="center"><a href="#pr1" onClick="removeAddRow(1);"><i class="fa fa-times" style="color:red;"></i></a></td>

												<td>

													<select class="form-control" name="txtCORCIDFOROTHERADD_1" id="txtCORCIDFOROTHERADD_1" style="width:100px;">
														<?php $obj->getOwnerRelatedCostListForTallyInvoice(); ?>
													</select>


												</td>
												<td><textarea class="form-control areasize" name="txtAddDes_1" id="txtAddDes_1" rows="2" placeholder="Description..."></textarea></td>
												<td><input type="text" name="txtAddDesAmt_1" id="txtAddDesAmt_1" class="form-control" placeholder="Amount" autocomplete="off" value="" onKeyUp="getDeduction();" /></td>
											</tr>
										<?php } ?>
									</tbody>
									<tfoot>
										<tr>
											<td align="left"><button type="button" class="btn btn-primary btn-flat" onClick="AddNewAddRow();">Add</button></td>

											<td></td>
											<td>Total</td>

											<td><input type="text" name="txtAddDesTotalAmt" id="txtAddDesTotalAmt" class="form-control" readonly placeholder="0.00" autocomplete="off" value="" /></td>
										</tr>
									</tfoot>
								</table>
							</div>
						</div>

						<div class="row">
							<div class="col-xs-12">
								<h2 class="page-header">
									Less Adjustment
								</h2>
							</div><!-- /.col -->
						</div>

						<div class="box">
							<div class="box-body no-padding">



								<td colspan="4">
									<table class="table table-striped">
										<thead>
											<tr>
												<th></th>
												<th>Cost type</th>
												<th>Fixture no</th>
												<th>Vessel</th>
												<th width="16%">Description</th>
												<th width="16%">Amount</th>


											</tr>
										</thead>



										<?php $sql2 = "select * from request_adj_slave where REQ_ID='" . $rows['REQ_ID'] . "' and IDENTIFY='SUB'";

										//  ECHO '<H1>'.$sql2;
										$res2 = mysql_query($sql2);
										$num2 = mysql_num_rows($res2);
										if ($num2 > 0) {
											$num21 = $num2;
										} else {
											$num21 = 1;
										}
										?>
										<tbody id="tblLessADJ">
											<?php if ($num2 > 0) {
												$i = 0;
												while ($rows2 = mysql_fetch_assoc($res2)) {
													$i++;

													// print_r($rows2);
											?>



													<tr id="lessadj_Row_<?php echo $i; ?>">
														<td align="center"><a href="#pr<?= $i ?>" onClick="removeLessAdjRow(<?= $i ?>);"><i class="fa fa-times" style="color:red;"></i></a></td>

														<td>
															<select class="form-control" name="txtCORCIDFORLESSADJ_<?= $i ?>" id="txtCORCIDFORLESSADJ_<?= $i ?>" style="width:100px;">
																<?php $obj->getOwnerRelatedCostListForTallyInvoice($rows2['ORC_ID']); ?>
															</select>
														</td>
														<td><select class="form-control" name="txtFixNoForLESSADJ_<?= $i ?>" id="txtFixNoForLESSADJ_<?= $i ?>" style="width:100px;" onchange="getVessel(this)">
																<?php $obj->getFixtureNoForTallyInvoice($rows2['FIXTURE_NO']); ?>
															</select></td>
														<td><select class="form-control check" name="txtVesselFORLESSADJ_<?= $i ?>" id="txtVesselFORLESSADJ_<?= $i ?>" style="width:100px;" readonly>
																<?php $obj->getVesselNameForTally($rows2['VESSEL']); ?>
															</select></td>

														<td><textarea class="form-control areasize" name="txtLessDesADJ_<?= $i ?>" id="txtLessDesADJ_<?= $i ?>" rows="2" placeholder="Description..."><?= $rows2['DESCRIPTION'] ?></textarea></td>
														<td><input type="text" name="txtLessADJAmt_<?= $i ?>" id="txtLessADJAmt_<?= $i ?>" class="form-control numeric" placeholder="Amount" autocomplete="off" value="<?= $rows2['AMOUNT'] ?>" onKeyUp="getDeduction();" /></td>


													</tr>
												<?php }
											} else { ?>
												<tr id="lessadj_Row_1">

													<td align="center"><a href="#pr1" onClick="removeLessAdjRow(1);"><i class="fa fa-times" style="color:red;"></i></a></td>
													<td>
														<select class="form-control" name="txtCORCIDFORLESSADJ_1" id="txtCORCIDFORLESSADJ_1" style="width:100px;">
															<?php $obj->getOwnerRelatedCostListForTallyInvoice(); ?>
														</select>
													</td>
													<td><select class="form-control" name="txtFixNoForLESSADJ_1" id="txtFixNoForLESSADJ_1" style="width:100px;" onchange="getVessel(this)">
															<?php $obj->getFixtureNoForTallyInvoice(); ?>
														</select></td>
													<td><select class="form-control check" name="txtVesselFORLESSADJ_1" id="txtVesselFORLESSADJ_1" style="width:100px;" readonly>

														</select></td>

													<td><textarea class="form-control areasize" name="txtLessDesADJ_1" id="txtLessDesADJ_1" rows="2" placeholder="Description..."></textarea></td>
													<td><input type="text" name="txtLessADJAmt_1" id="txtLessADJAmt_1" class="form-control numeric" placeholder="Amount" autocomplete="off" value="" onKeyUp="getDeduction();" /></td>


												</tr>


											<?php } ?>
										</tbody>

										<tfoot>
											<tr>
												<td align="left"><button type="button" class="btn btn-primary btn-flat" onClick="AddNewLESSADJRow();">Add</button></td>

												<td></td>
												<td></td>
												<td></td>


												<td>Total</td>
												<td><input type="text" name="txtSubDesADJTotalAmt" id="txtSubDesADJTotalAmt" class="form-control" readonly placeholder="0.00" autocomplete="off" value="" />
													<input type="hidden" name="txtLESSADJID" id="txtLESSADJID" value="<?php echo $num21; ?>" />


												</td>
											</tr>
										</tfoot>

									</table>


								</td>
								</tr>

							</div>
						</div>
						<div class="row">
							<div class="col-xs-12">
								<h2 class="page-header">
									Less
								</h2>
							</div><!-- /.col -->
						</div>
						<div class="box">
							<div class="box-body no-padding">
								<table class="table table-striped">
									<thead>
										<tr>
											<th>#</th>
											<th>Cost Type</th>

											<th>Description</th>
											<?php $sql2 = "select * from request_master_slave where REQ_ID='" . $rows['REQ_ID'] . "' and IDENTIFY='SUB'";
											$res2 = mysql_query($sql2);
											$num2 = mysql_num_rows($res2);
											if ($num2 > 0) {
												$num21 = $num2;
											} else {
												$num21 = 1;
											}
											?>
											<th>Amount<input type="hidden" name="txtSubID" id="txtSubID" value="<?php echo $num21; ?>" /></th>
										</tr>
									</thead>
									<tbody id="tblSub">
										<?php if ($num2 > 0) {
											$i = 0;
											while ($rows2 = mysql_fetch_assoc($res2)) {
												$i++;
												$sum2 = $sum2 + $rows2['AMOUNT'];
										?>
												<tr id="Sub_Row_<?php echo $i; ?>">
													<td align="center"><a href="#pr<?php echo $i; ?>" onClick="removeSubRow(<?php echo $i; ?>);"><i class="fa fa-times" style="color:red;"></i></a></td>

													<td> <select class="form-control" name="txtCORCIDFOROTHERLESS_<?php echo $i; ?>" id="txtCORCIDFOROTHERLESS_<?php echo $i; ?>" style="width:100px;">
															<?php $obj->getOwnerRelatedCostListForTallyInvoice($rows2['ORC_ID']); ?>
														</select></td>
													<td><textarea class="form-control areasize" name="txtSubDes_<?php echo $i; ?>" id="txtSubDes_<?php echo $i; ?>" rows="2" placeholder="Description..."><?php echo $rows2['DESCRIPTION']; ?></textarea></td>
													<td><input type="text" name="txtSubDesAmt_<?php echo $i; ?>" id="txtSubDesAmt_<?php echo $i; ?>" class="form-control" placeholder="Amount" autocomplete="off" value="<?php echo $rows2['AMOUNT']; ?>" onKeyUp="getDeduction();" /></td>
												</tr>
											<?php }
										} else { ?>
											<tr id="Sub_Row_1">
												<td align="center"><a href="#pr1" onClick="removeSubRow(1);"><i class="fa fa-times" style="color:red;"></i></a></td>

												<td>


													<select class="form-control" name="txtCORCIDFOROTHERLESS_1" id="txtCORCIDFOROTHERLESS_1" style="width:100px;">
														<?php $obj->getOwnerRelatedCostListForTallyInvoice(); ?>
													</select>

												</td>
												<td><textarea class="form-control areasize" name="txtSubDes_1" id="txtSubDes_1" rows="2" placeholder="Description..."></textarea></td>
												<td><input type="text" name="txtSubDesAmt_1" id="txtSubDesAmt_1" class="form-control" placeholder="Amount" autocomplete="off" value="" onKeyUp="getDeduction();" /></td>
											</tr>
										<?php } ?>
									</tbody>
									<tfoot>
										<tr>
											<td align="left"><button type="button" class="btn btn-primary btn-flat" onClick="SubNewSubRow();">Add</button></td>

											<td></td>


											<td>Total</td>
											<td><input type="text" name="txtSubDesTotalAmt" id="txtSubDesTotalAmt" class="form-control" readonly placeholder="0.00" autocomplete="off" value="" /></td>
										</tr>
									</tfoot>
								</table>
							</div>
						</div>



						<div class="box">
							<div class="box-header">
								<h3 class="box-title">Account <?php echo $id[1]; ?> : Net Payable</h3>
							</div><!-- /.box-header -->
							<div class="box-body no-padding">
								<table class="table table-striped">
									<tbody>
										<tr>
											<td>Net Payable</td>
											<td width="25%"><input type="text" name="txtNET" id="txtNET" class="form-control" value="<?php echo $rows['NET_AMT']; ?>" autocomplete="off" readonly /></td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
										</tr>
									</tbody>
								</table>
							</div>
						</div>

						<div class="box">
							<div class="box-header">
								<h3 class="box-title">Account <?php echo $id[1]; ?> : Requested To Pay/Recover</h3>
							</div><!-- /.box-header -->
							<div class="box-body no-padding">
								<table class="table table-striped">
									<tbody>
										<tr>
											<td width="25%">Requested To Pay/Recover</td>
											<td width="25%"><input type="text" name="txtROP_3" id="txtROP_3" class="form-control" value="<?php echo $rows['REQ_TO_PAY']; ?>" autocomplete="off" /></td>
											<td width="25%">
												Attachments
											</td>
											<td width="25%">
												<div class="btn btn-success btn-file btn-flat" data-toggle="tooltip">
													<i class="fa fa-paperclip"></i> Attachment
													<input type="file" class="form-control" multiple name="attach_file[]" id="attach_file" title="" data-widget="Attachment" data-toggle="tooltip" data-original-title="Attachment" />
												</div>

												<table width="100%">
													<?php if ($upload_attach != '') {
														$fileid = explode(",", $upload_attach);
														$filename = explode(",", $upload_attach_name); ?>
														<tr>
															<td colspan="2">
																Previous Attachments
															</td>
														</tr>

														<?php
														for ($j = 0; $j < sizeof($fileid); $j++) {
														?>
															<tr id="rowfile_<?php echo ($j + 1); ?>">
																<td width="90%" align="left" class="input-text" valign="top"><a href="../../attachment/<?php echo $fileid[$j]; ?>" target="_blank" style="color:blue;" data-toggle="tooltip" data-original-title="<?php echo $filename[$j]; ?>"><i class="fa fa-external-link"></i>&nbsp;&nbsp;<?php echo $filename[$j]; ?></a>
																	<input type="hidden" name="rfile_<?php echo $j + 1; ?>" id="rfile_<?php echo $j + 1; ?>" value="<?php echo $fileid[$j]; ?>" />
																	<input type="hidden" name="rname_<?php echo $j + 1; ?>" id="rname_<?php echo $j + 1; ?>" value="<?php echo $filename[$j]; ?>" />
																</td>
																<td><a href="#1" onClick="Del_Upload(<?php echo $j + 1; ?>);"><i class="fa fa-times " style="color:red;"></i></a></td>
															</tr>
														<?php } ?>
													<?php } ?>
												</table>

											</td>

										</tr>
										<tr>
											<td width="25%" class="changeCurreny">Exchange To Currency <?php
																										if ($rows['EXCHANGE_CURRENCY'] != ' ') {

																											echo '(' . $rows['EXCHANGE_CURRENCY'] . ')';
																										} else {
																											echo ' ';
																										}

																										?></td>
											<td width="25%" class="changeCurr"><input type="text" name="txtEOT" id="txtEOT" class="form-control" value="" autocomplete="off" disabled /></td>

											<script>
												$("#txtROP_3").keyup(function() {

													$('.changeCurreny').fadeIn();
													$('.changeCurr').fadeIn();

													var exchangeRate = $('#txtExchangeRate').val();


													var net_pay = $(this).val();

													$('#txtEOT').val(parseFloat(net_pay * exchangeRate).toFixed(2))


												});


												$("#txtExchangeRate").keyup(function() {

													// alert();

													$('.changeCurreny').fadeIn();
													$('.changeCurr').fadeIn();

													var exchangeRate = $(this).val();



													var net_pay = $('#txtROP_3').val();

													$('#txtEOT').val(parseFloat(net_pay * exchangeRate).toFixed(2))


												});




												$(function() {

													var exchangeRate = $('#txtExchangeRate').val();


													var net_pay = $('#txtROP_3').val();

													if ($('#selExchangeCurrency').val().length == 0) {

														$('.changeCurreny').fadeOut();
														$('.changeCurr').fadeOut();

													} else {
														$('#txtEOT').val(parseFloat(net_pay * exchangeRate).toFixed(2))

													}



												});

												$('#selExchangeCurrency').change(function() {


													$('.changeCurreny').fadeIn();
													$('.changeCurr').fadeIn();
													$('.changeCurreny').text('Exchange To Currency(' + $(this).val() + ')')

													if ($(this).val().length == 0) {

														$('.changeCurreny').fadeOut();
														$('.changeCurr').fadeOut();


													}

												});
											</script>

											<h1><?php //print_r($approverarr2) 
												?> </h1>

											<td width="25%">Level 1 Approver</td>
											<td width="25%"><select data-placeholder="Choose Approver..." class="input-text chzn-select" style="width:300px;" multiple name="selApprovers[]" id="selApprovers"><?php $obj->getApproverListBasedOnApprovalMatrix($approverfieldname, $rows['APPROVERS']); ?></select></td>
											<td colspan="2"></td>
										</tr>
									</tbody>
								</table>
								<hr>



								<h4>
									<?php if ($approver2 == 1 || $creator == 1) { ?>

										<legend>
											<h3 style="padding: 0 0 0 10px">Payment</h3>
										</legend>

										<?php if ($rows['PAYMENT_STATUS'] == 'payment_hold') { ?>
											<label style="padding: 0 0 0 11px;">Payment Hold(Accrual)</label>&nbsp;&nbsp;&nbsp;<input checked type="radio" id="payment_hold" name="payment_status" value="payment_hold" required />
										<?php } else { ?>
											<label style="padding: 0 0 0 11px;">Payment Hold(Accrual)</label>&nbsp;&nbsp;&nbsp;<input type="radio" id="payment_hold" name="payment_status" value="payment_hold" required />

										<?php }
										if ($rows['PAYMENT_STATUS'] == 'payment_payable') { ?>
											<label style="padding: 0 0 0 11px;">Payment Payable</label>&nbsp;&nbsp;&nbsp;<input checked type="radio" id="payment_payable" name="payment_status" value="payment_payable" required />
										<?php } else { ?>
											<label style="padding: 0 0 0 11px;">Payment Payable</label>&nbsp;&nbsp;&nbsp;<input type="radio" id="payment_payable" name="payment_status" value="payment_payable" required />
										<?php } ?>

									<?php } ?>
								</h4>
							</div>
						</div>

						<?php

						$venString = substr($obj->getVendorListNewBasedOnID($vendorid), 0, 3)


						?>
						<div class="box-footer" style="margin-bottom:10px;" align="right">
							<?php if (($rec == 0 && $creator == 1) || (($rows['STATUS'] == 0 || $rows['STATUS'] == 2) && $creator == 1)) {
								if (empty($approverarr1) && empty($approverarr2)) {
									$status = 5;
								} else if (empty($approverarr1) && !empty($approverarr2)) {
									$status = 4;
								} else {
									$status = 1;
								}
							?>
								<button type="submit" class="btn btn-primary btn-flat" onClick="return getSubmit(0);">Submit to edit</button>&nbsp;&nbsp;

								<?php
								if ($venString != 'TBN') {

								?>
									<button type="submit" class="btn btn-warning btn-flat" onClick="return getSubmit(<?= $status; ?>);">Send for Approval</button>

								<?php } ?>
							<?php } else if ($rec > 0 && ($rows['STATUS'] == 1 || $rows['STATUS'] == 4) && $approver1 == 1) {
								if (empty($approverarr2)) {
									$status = 5;
								} else {
									$status = 3;
								}
							?>
								<button type="submit" class="btn btn-primary btn-flat" onClick="return getSubmit(2);">Send for Review</button>&nbsp;&nbsp;

								<?php
								if ($venString != 'TBN') {

								?>


									<button type="submit" class="btn btn-warning btn-flat" onClick="return getSubmit(<?= $status; ?>);">Submit & Approve</button>

								<?php } ?>
							<?php } else if ($rec > 0 && $rows['STATUS'] == 3 && $approver2 == 1) {
								if (empty($approverarr1)) {
									$status = 2;
								} else {
									$status = 4;
								}
							?>
								<button type="submit" class="btn btn-primary btn-flat" onClick="return getSubmit(<?= $status; ?>);">Send for Review</button>&nbsp;&nbsp;

								<?php
								if ($venString != 'TBN') {

								?>
									<button type="submit" class="btn btn-warning btn-flat" onClick="return getSubmit(5);">Submit & Approve</button>

								<?php } ?>
							<?php } ?>

							<!--<button type="button" class="btn btn-primary btn-flat" onClick="return getSubmit1(0)">Submit</button>
								<button type="button" class="btn btn-primary btn-flat" onClick="return getSubmit(1)">Submit & Close</button>-->

							<input type="hidden" id="action" name="action" value="submit" />
							<input type="hidden" name="txtPaymentID" id="txtPaymentID" value="<?php echo $rows['REQ_ID']; ?>" />
							<input type="hidden" name="txtStatus" id="txtStatus" value="0" />
							<input type="hidden" name="txtCRMFILE" id="txtCRMFILE" value="" />
							<input type="hidden" name="txtCRMNAME" id="txtCRMNAME" value="" />
							<input type="hidden" name="grade_id_test" value="<?= $id[2] ?>" />
						</div>
						<?php //} 
						?>
					</div>
				</form>

				<form role="form" name="frm2" id="frm2" enctype="multipart/form-data" action="<?php echo $pagename; ?>" method="post">
					<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 request_master where COMID='<?= $comid ?>' and MODULEID='<?= $_SESSION['moduleid'] ?>' and MCOMPANYID='<?= $_SESSION['company'] ?>' and LOGIN='INTERNAL_USER' and NAME='<?= $id[1] ?>' and NAME_ID='<?= $id[0] ?>' and GRADEID='<?= $id[2] ?>' and VENDOR='<?= $id[3] ?>' and STATUS>=5">
								<thead>
									<tr>
										<th>Fixture No</th>
										<th>Vessel</th>
										<th>Cost Type</th>
										<th>Cost Desc.</th>
										<th>SOA Id</th>
										<th>Account Type</th>
										<th>Amount</th>
										<th>Payment No.</th>
										<th>Date</th>
										<th>Vendor</th>
										<th>Pdf/Json</th>
										<th>Paid Payment</th>

										<?php


										if ($_SESSION['iutype'] == 'mgmt_user') {
											# code...
											echo "<th>Delete</th>";
											echo "<th>Open</th>";
										}
										?>
										<th>Creator</th>
									</tr>
								</thead>
								<tbody>
									<?php
									$sql2 = "select *, (SELECT a.SOA_NO FROM combined_soa_payable_master a WHERE a.SOAID = request_master.SOAID) SOA_NO from request_master where COMID='" . $comid . "' and MODULEID='" . $_SESSION['moduleid'] . "' and MCOMPANYID='" . $_SESSION['company'] . "' and LOGIN='INTERNAL_USER' and NAME='" . $id[1] . "' and NAME_ID='" . $id[0] . "' and GRADEID='" . $id[2] . "' and VENDOR='" . $id[3] . "' and STATUS>=5";

									// echo $sql2;
									$res2 = mysql_query($sql2);
									$rec2 = mysql_num_rows($res2);
									while ($rows2 = mysql_fetch_assoc($res2)) {


										if ($rows2['PAYMENT_STATUS'] == 'payment_hold') {
											$accu = 'Accrual';
										} else {
											$accu = 'payment';
										}

									?>
										<tr data-status="<?= $rows2['STATUS'] ?>" data-name="<?= $rows2['NAME'] ?>" data-vendor="<?= $rows2['VENDOR'] ?>" data-gradeid="<?= $rows2['GRADEID'] ?>" data-itype="<?= $accu ?>">





											<td><?= $rows2['PAYMENT_STATUS'] == 'payment_hold' ? $obj->getCompareEstimateData($comid, "VOYAGE_NO") . '(Accrual)' : $obj->getCompareEstimateData($comid, "VOYAGE_NO"); ?></td>
											<td><?php echo $obj->getVesselIMOData($obj->getCompareEstimateData($comid, "VESSEL_IMO_ID"), "VESSEL_NAME"); ?></td>
											<td><?php echo $id[1]; ?></td>
											<td><?php echo $_REQUEST['name'] ?></td>
											<td><?php echo $rows2['SOA_NO']; ?></td>
											<td><?php echo $rows2['ACCOUNT_TYPE']; ?></td>
											<td><?php echo $rows2['REQ_TO_PAY']; ?></td>
											<td><?php echo $rows2['PAYMENT_NO']; ?></td>
											<td><?php echo date("d-M-Y", strtotime($rows2['DATE'])); ?></td>
											<td><?php echo $obj->getVendorListNewBasedOnID($rows2['VENDOR']); ?></td>
											<td><a href="#" title="Pdf" onClick="getPdf(<?php echo $rows2['REQ_ID']; ?>);"><button class="btn btn-default" style="margin-right: 5px;" type="button"><i class="fa fa-download"></i>Generate PDF</button></a>

												<hr style="margin-bottom:7px;margin-top:7px;">
												<a href="#jsondownload" title="Pdf" id="jsondownload"

													<?php

													$id 		= explode(",", $_REQUEST['id']);


													if ($id[1] == 'Bunkers Nett Supply') {

														$ledgerCode = 'DE0008';

														$type = 'Normal';
													} else if ($id[1] == 'Discharge Port Costs' || $id[1] == 'Load Port Costs' || $id[1] == 'Transit Port Costs') {


														if ($id[1] == 'Discharge Port Costs') {

															$ledgerCode = 'DE0024';
														} else if ($id[1] == 'Load Port Costs') {

															$ledgerCode = 'DE0033';
														} else {
															$ledgerCode = 'DE0076';
														}

														$type = 'Normal';
													} else {

														$ledgerCode = $_REQUEST['name'];

														$type = 'Operational Costs';
													}

													?>

													onClick="getDownloadJson(<?php echo $rows2['REQ_ID']; ?>,'<?php echo $ledgerCode; ?>','<?= $type ?>');"><button class="btn btn-primary" type="button" style="margin-right: 5px;"><i class="fa fa-download"></i> Generate Json</button></a>

											</td>

											<td>
												<a href="#?" title="Paid Payment" class="btn btn-default btn-sm" data-toggle="modal" data-target="#compose-modal" onClick="openWin1(<?php echo $rows2['REQ_ID']; ?>);">Paid Payment</a>
											</td>

											<?php
											if ($_SESSION['iutype'] == 'mgmt_user') {
											?>
												<td><a href="#1" title="Delete Entry" onClick="return getDel(<?php echo $rows2['REQ_ID']; ?>);"><img src="../../img/icon_delete.gif" /></a></td>

												<td align="left" valign="middle"><button style="" type="button" onclick="return openBtn('<?= $rows2['REQ_ID'] ?>');" class="btn btn-danger btn-flat open_btn">Open</button></td>
											<?php
											}
											?>

											<td><?php echo $obj->getUserDetailBaseOnId($rows2['CREATOR'], 'CONTACT_PERSON') ?></td>
										</tr>
									<?php } ?>
								</tbody>
							</table>
						</div>
					</div>
				</form>


				<div class="modal fade" id="compose-modal" tabindex="-1" role="dialog" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							</div>
							<div class="modal-body">
								<form name="frm3" id="frm3" enctype="multipart/form-data" action="<?php echo $pagename; ?>" method="post" />
								<div id="divPayment">

								</div>

								</form>
							</div>
						</div><!-- /.modal-content -->
					</div><!-- /.modal-dialog -->
				</div>
				<!--   content ends here..................-->
			</section><!-- /.content -->
		</aside><!-- /.right-side -->

	</div><!-- ./wrapper -->
	<?php $display->footer(); ?>
	<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
	<script src='../../js/jquery.autosize.js'></script>
	<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
	<script src="../../js/timer.js" type="text/javascript"></script>
	<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
	<script src="../../js/bootstrap-datepicker.js" type="text/javascript"></script>
	<script language="JavaScript" type="text/javascript" src="../../js/jquery.numeric.js"></script>
	<script language="JavaScript" type="text/javascript" src="../../js/jquery.calculation-min.js"></script>

	<script type="text/javascript">
		function getVessel(elx) {

			$.post("options.php?id=140", {
				fixtureNo: "" + $(elx).val() + ""
			}, function(data) {

				$(elx).closest('td').next().find('select.check').html(data)

			});
		}


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


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




		function AddNewLESSADJRow() {

			// console.log('dpkAddadj');
			var id = $("#txtLESSADJID").val();

			// console.log('')
			if ($("#txtLessADJAmt_" + id).val() != "" && $("#txtLessDesADJ_" + id).val() != "" && $("#txtCORCIDFORLESSADJ_" + id).val() != "") {
				id = (id - 1) + 2;
				$('<tr id="lessadj_Row_' + id + '"><td align="center"><a href="#pr' + id + '" onClick="removeLessAdjRow(' + id + ');"><i class="fa fa-times" style="color:red;"></i></a></td><td><select class="form-control" name="txtCORCIDFORLESSADJ_' + id + '" id="txtCORCIDFORLESSADJ_' + id + '" style="width:100px;" required><?php $obj->getOwnerRelatedCostListForTallyInvoice(); ?></select></td><td><select class="form-control" name="txtFixNoForLESSADJ_' + id + '" id="txtFixNoForLESSADJ_' + id + '" style="width:100px;" onchange="getVessel(this)" required><?php $obj->getFixtureNoForTallyInvoice(); ?></select></td><td><select class="form-control check" name="txtVesselFORLESSADJ_' + id + '" id="txtVesselFORLESSADJ_' + id + '" style="width:100px;" readonly></select></td><td><textarea class="form-control areasize" name="txtLessDesADJ_' + id + '" id="txtLessDesADJ_' + id + '" rows="2" placeholder="Description..." required></textarea></td><td><input type="text" name="txtLessADJAmt_' + id + '" id="txtLessADJAmt_' + id + '" class="form-control"  placeholder="Amount" autocomplete="off" value="" onKeyUp="getDeduction();" required/></td></tr>').appendTo("#tblLessADJ");
				$("#txtLESSADJID").val(id);
				$("[id^=txtLessADJAmt_]").numeric();
			}
		}



		function getDownloadJson(invid, ledgerCode, type) {
			$.post("options.php?id=134", {
				reqid: "" + invid + "",
				ledgerCode: "" + ledgerCode + "",
				type: "" + type + "",
				BalOut: "" + $('#txtBal_Outs').val() + ""
			}, function(json_data) {

				var json_data = JSON.parse(json_data);
				var data = json_data.jsondata;
				var filename = 'payment_' + json_data.inv_no + '.json';

				if (typeof data === "object") {
					data = JSON.stringify(data, undefined, 4)
				}

				var blob = new Blob([data], {
						type: 'text/json'
					}),
					e = document.createEvent('MouseEvents'),
					a = document.createElement('a')

				a.download = filename
				a.href = window.URL.createObjectURL(blob)
				a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
				e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
				a.dispatchEvent(e);
			});
		}


		function AddNewAddADJRow() {

			// console.log('dpkAddadj');
			var id = $("#txtAddADJID").val();

			// console.log('')
			if ($("#txtAddADJAmt_" + id).val() != "" && $("#txtAddDesADJ_" + id).val() != "" && $("#txtCORCIDFORADDADJ_" + id).val() != "") {
				id = (id - 1) + 2;
				$('<tr id="addadj_Row_' + id + '"><td align="center"><a href="#pr' + id + '" onClick="removeAddAdjRow(' + id + ');"><i class="fa fa-times" style="color:red;"></i></a></td><td><select class="form-control" name="txtCORCIDFORADDADJ_' + id + '" id="txtCORCIDFORADDADJ_' + id + '" style="width:100px;" required><?php $obj->getOwnerRelatedCostListForTallyInvoice(); ?></select></td><td><select class="form-control" name="txtFixNoForADDADJ_' + id + '" id="txtFixNoForADDADJ_' + id + '" style="width:100px;" onchange="getVessel(this)" required><?php $obj->getFixtureNoForTallyInvoice(); ?></select></td><td><select class="form-control check" name="txtVesselFORADDADJ_' + id + '" id="txtVesselFORADDADJ_' + id + '" style="width:100px;" readonly></select></td><td><textarea class="form-control areasize" name="txtAddDesADJ_' + id + '" id="txtAddDesADJ_' + id + '" rows="2" placeholder="Description..." required></textarea></td><td><input type="text" name="txtAddADJAmt_' + id + '" id="txtAddADJAmt_' + id + '" class="form-control"  placeholder="Amount" autocomplete="off" value="" onKeyUp="getDeduction();" required/></td></tr>').appendTo("#tblAddADJ");
				$("#txtAddADJID").val(id);
				$("[id^=txtAddADJAmt_]").numeric();
			}
		}





		$(document).ready(function() {


			setAmountTtlPayable();

			getDeduction();


			$("#txtROP_3,[id^=txtVC_DED_], #txtV_I_Amt,[id^=txtAddDesAmt_],[id^=txtSubDesAmt_],#txtExchangeRate").numeric();

			$('[id^=txtRemarks]').autosize({
				append: "\n"
			});
			$("#selApprovers").chosen();
			$("#frm1").validate({
				rules: {
					txtAccNO: "required",
					txtDate: "required",
					txtI_Date: "required",


				},
				messages: {
					txtAccNO: "*",
					txtDate: "*",
					txtI_Date: "*"
				},
				submitHandler: function(form) {

					if ($('#txtAddDes_1').val() != "" && ($('#txtAddDesAmt_1').val() != "" || $('#txtAddDesAmt_1').val() > 0.00) || $('#txtSubDes_1').val() != "" && ($('#txtSubDesAmt_1').val() != "" || $('#txtSubDesAmt_1').val() > 0.00)) {

						// console.log('dpk1');


						// console.log('dpk1213');
						if ($('#txtCORCIDFOROTHERADD_1').val() == "" && $('#txtAddDesAmt_1').val() > 0.00) {
							console.log('dpk');
							// console.log($('#txtCORCIDFOROTHERADD_1').val());

							jAlert('<b style="font-size:20px;">Please Select Cost Type</b>', 'Alert');

							return false;
						} else if ($('#txtCORCIDFOROTHERLESS_1').val() == "" && $('#txtSubDesAmt_1').val() > 0.00) {

							// console.log($('#txtCORCIDFOROTHERLESS_1').val());

							jAlert('<b style="font-size:20px;">Please Select Cost Type</b>', 'Alert');

							return false;
						} else {

							jConfirm('Are you sure you want to save this data ?', '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();
								} else {
									return false;
								}
							});



						}







					} else {


						jConfirm('Are you sure you want to save this data ?', '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();
							} else {
								return false;
							}
						});

					}

				}
			});


			let banking_lists = $('#selBankingID option').length;

			if (banking_lists == 1) {

				$("#selBankingID").rules("remove");
				let vendor_id = $('.selBankingID_div').data('vendorid');

				$('.selBankingID_div').html('<a href="updatevendor.php?id=' + vendor_id + '"><button class="btn btn-warning btn-flat" type="button">Create Banking Details </button></a>');

			}


			// $('#payment_payable').on('change',function(){

			// 	alert();


			// });

			$('#txtDate, #txtI_Date, #txtExchangeDate').datepicker({
				autoclose: true,
				format: 'dd-m-yyyy'
			});

			$('#txtROP_3').keyup(function() {
				if ($('#txtROP_3').val() > 0) {
					var var1 = parseFloat($('#txtROP_3').val());
				} else {
					var var1 = parseFloat(-($('#txtROP_3').val()));
				}

				if ($('#txtNET').val() > 0) {
					var var3 = parseFloat($('#txtNET').val());
				} else {
					var var3 = parseFloat(-($('#txtNET').val()));
				}

				// if(var3 < var1)
				// {
				// 	jAlert('Requested to pay is more than Net Payable', 'Alert');
				// 	$('#txtROP_3').val('0.00');
				// }

			});
			getDeduction();
		});



		function getSubmit(var1) {

			$('#txtStatus').val(var1);
			var file_temp_name1 = $("[id^=rfile_]").map(function() {
				return this.value;
			}).get().join(",");
			$('#txtCRMFILE').val(file_temp_name1);
			var file_actual_name1 = $("[id^=rname_]").map(function() {
				return this.value;
			}).get().join(",");
			$('#txtCRMNAME').val(file_actual_name1);

			if ($('#txtStatus').val() == 1) {
				if ($('#selApprovers').val() == null || $('#selApprovers').val() == '') {
					jAlert('Please select Level 1 Approvers first.', 'Alert');
					return false;
				} else {
					return true;
				}
			}


			if ($('#txtStatus').val() == 5) {

				var check = '<?php echo $rows['REQ_ID'] ?>';
				if ((check) == '') {

					var url = 'allPdf.php?voyage_no=<?= $_REQUEST['voyage_no'] ?>&preview_pdf=true&id=6&req_id=' + check + '&comid=' + <?php echo $comid; ?> + '&name_id=' + <?php echo $id[0]; ?> + '&grade=' + <?php echo $id[2]; ?> + '&name=' + <?php echo "'" . $id['1'] . " : " . $_REQUEST['name'] . "'"; ?> + '&vendorid=' + <?php echo "'" . $vendorid . "'"; ?> + '&ttl_outs=' + <?php echo $id[5]; ?>


				} else {

					var url = 'allPdf.php?voyage_no=<?= $_REQUEST['voyage_no'] ?>&preview_pdf=true&id=6&req_id=' + check + '&comid=' + <?php echo $comid; ?> + '&name_id=' + <?php echo $id[0]; ?> + '&grade=' + <?php echo $id[2]; ?> + '&name=' + <?php echo "'" . $id['1'] . " : " . $_REQUEST['name'] . "'"; ?> + '&vendorid=' + <?php echo "'" . $vendorid . "'"; ?> + '&ttl_outs=' + <?php echo $id[5]; ?>

				}

				$.ajax({

					url: url,
					cache: false,
					success: function(res) {
						// console.log(res);
					},

					error: function() {

					}

				});


			}


		}


		function testing() {

			if ($('#payment_payable').is(":checked")) {

				$('#chk_payment_hold').attr('disabled', true);
			} else {
				$('#chk_payment_hold').attr('disabled', false);
			}

		}



		function getSubmit1(var1) {
			jConfirm('Are you sure you want to "Submit"?', 'Confirmation', function(r) {
				if (r) {
					$('#txtStatus').val(var1);
					var file_temp_name1 = $("[id^=rfile_]").map(function() {
						return this.value;
					}).get().join(",");
					$('#txtCRMFILE').val(file_temp_name1);
					var file_actual_name1 = $("[id^=rname_]").map(function() {
						return this.value;
					}).get().join(",");
					$('#txtCRMNAME').val(file_actual_name1);
					return true;
				} else {
					return false;
				}
			});
		}



		function getValid() {
			if ($('#txtfile').val() == '') {
				jAlert('Please choose the file', 'Alert');
				return false;
			} else {
				return true;
			}
		}




		function getPdf(var1) {
			// console.log(var1);

			location.href = 'allPdf.php?voyage_no=<?= $_REQUEST['voyage_no'] ?>&id=6&req_id=' + var1 + '&comid=' + <?php echo $comid; ?> + '&name_id=' + <?php echo $id[0]; ?> + '&grade=' + <?php echo $id[2]; ?> + '&name=' + <?php echo "'" . $id['1'] . " : " . $_REQUEST['name'] . "'"; ?> + '&vendorid=' + <?php echo "'" . $vendorid . "'"; ?> + '&ttl_outs=' + <?php echo $id[5]; ?>;

			// console.log(location.href);
		}

		function getDel(req_id) {
			jConfirm('Are you sure you want to Delete this Entry?', 'Confirmation', function(r) {
				if (r) {
					$('#action2').val('submit2');
					$('#txtPaymentID2').val(req_id);
					document.frm2.submit();
				} else {
					return false;
				}
			});
		}

		function getDeduction() {


			$("#txtAddDesADJTotalAmt").val(parseFloat($("[id^=txtAddADJAmt_]").sum()).toFixed(2));
			$("#txtSubDesADJTotalAmt").val(parseFloat($("[id^=txtLessADJAmt_]").sum()).toFixed(2));
			$("#txtAddDesTotalAmt").val(parseFloat($("[id^=txtAddDesAmt_]").sum()).toFixed(2));
			$("#txtSubDesTotalAmt").val(parseFloat($("[id^=txtSubDesAmt_]").sum()).toFixed(2));
			var add1 = parseFloat($("#txtAddDesTotalAmt").val());
			if (isNaN(add1)) {
				add1 = 0;
			}
			var sub1 = parseFloat($("#txtSubDesTotalAmt").val());
			if (isNaN(sub1)) {
				sub1 = 0;
			}

			var addadj = parseFloat($("#txtAddDesADJTotalAmt").val());
			if (isNaN(add1)) {
				add1 = 0;
			}
			var subadj = parseFloat($("#txtSubDesADJTotalAmt").val());
			if (isNaN(sub1)) {
				sub1 = 0;
			}


			var ttl = (parseFloat($("[id^=txtVC_DED_]").sum())).toFixed(2);
			var net = (parseFloat($('#txtBal_Outs').val()) + parseFloat(add1) + parseFloat(addadj) - parseFloat(sub1) - parseFloat(subadj)).toFixed(2);



			$('#txtNET').val(net);

			console.log('dpk', net)
			if (net < 0) {

				$('.fadeInBbnInvCom').css('display', 'block');
				$('.fadeInVenBank').css('display', 'none');

				$('.fadeInVenBank').attr('name', 'hidesel');
				$('.fadeInBbnInvCom').attr('name', 'selBankingID');

			} else {

				$('.fadeInBbnInvCom').css('display', 'none');
				$('.fadeInVenBank').css('display', 'block');

				$('.fadeInVenBank').attr('name', 'selBankingID');
				$('.fadeInBbnInvCom').attr('name', 'hidesel');


			}






		}



		function AddNewAddRow() {
			var id = $("#txtAddID").val();
			if ($("#txtAddDes_" + id).val() != "" && $("#txtAddDesAmt_" + id).val() != "") {
				id = (id - 1) + 2;
				$('<tr id="add_Row_' + id + '"><td align="center"><a href="#pr1" onClick="removeAddRow(1);"><i class="fa fa-times" style="color:red;"></i></a></td><td><select class="form-control" name="txtCORCIDFOROTHERADD_' + id + '" id="txtCORCIDFOROTHERADD_' + id + '" style="width:100px;" required><?php $obj->getOwnerRelatedCostListForTallyInvoice(); ?></select></td><td><textarea class="form-control areasize" name="txtAddDes_' + id + '" id="txtAddDes_' + id + '" rows="2" placeholder="Description..."></textarea></td><td><input type="text" name="txtAddDesAmt_' + id + '" id="txtAddDesAmt_' + id + '" class="form-control"  placeholder="Amount" autocomplete="off" value="" onKeyUp="getDeduction();"/></td></tr>').appendTo("#tblAdd");
				$("#txtAddID").val(id);
				$("[id^=txtAddDesAmt_]").numeric();
			}
		}


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



		function SubNewSubRow() {
			var id = $("#txtSubID").val();
			if ($("#txtSubDes_" + id).val() != "" && $("#txtSubDesAmt_" + id).val() != "") {
				id = (id - 1) + 2;
				$('<tr id="Sub_Row_' + id + '"><td align="center"><a href="#pr1" onClick="removeSubRow(1);"><i class="fa fa-times" style="color:red;"></i></a></td><td><select class="form-control" name="txtCORCIDFOROTHERLESS_' + id + '" id="txtCORCIDFOROTHERLESS_' + id + '" style="width:100px;" required><?php $obj->getOwnerRelatedCostListForTallyInvoice(); ?></select></td><td><textarea class="form-control areasize" name="txtSubDes_' + id + '" id="txtSubDes_' + id + '" rows="2" placeholder="Description..."></textarea></td><td><input type="text" name="txtSubDesAmt_' + id + '" id="txtSubDesAmt_' + id + '" class="form-control"  placeholder="Amount" autocomplete="off" value="" onKeyUp="getDeduction();"/></td></tr>').appendTo("#tblSub");
				$("#txtSubID").val(id);
				$("[id^=txtSubDesAmt_]").numeric();
			}
		}


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



		function getValid() {
			if ($('#txtP_PR').val() == '' || $('#txtP_Date').val() == '' || $('#txtP_Remarks').val() == '') {
				jAlert('Please fill the Payment Received & Date & Remarks', 'Alert');
				return false;
			} else {
				var file_temp_name = $("[id^=file1_]").map(function() {
					return this.value;
				}).get().join(",");
				$('#txtCRMFILE1').val(file_temp_name);
				var file_actual_name = $("[id^=name1_]").map(function() {
					return this.value;
				}).get().join(",");
				$('#txtCRMNAME1').val(file_actual_name);
				document.frm1.submit();
				return true;
			}
		}

		function Del_Upload1(var2) {
			jConfirm('Are you sure you want to delete this upload permanently ?', 'Confirmation', function(r) {
				if (r) {
					$('#row_file1_' + var2).remove();
				}
			});
		}

		function onkeyUp1() {

		}


		function openWin1(var1) {
			$("#divPayment").empty();
			$("#divPayment").html('<div><img src="../../img/ajax-loader.gif" /><br><b>Loading...</b></div>');
			$.post("options.php?id=47", {
				invoiceid: "" + var1 + ""
			}, function(html) {
				$("#divPayment").empty();
				$("#divPayment").append(html);

				var isHoldVersion = document.getElementsByClassName('glow');
				if (isHoldVersion.length > 0) {

					$('#btnhide').hide()

				}



				$("#txtP_PR").numeric();

				$("#txtP_PREX").numeric();

				$('#txtP_Remarks').autosize({
					append: "\n"
				});
				$('#txtP_Date').datepicker({
					format: 'dd-mm-yyyy',
					autoclose: true
				});
				// if($("#txtP_PR").val() > 0 && $("#txtP_PR").val()==$("#txtP_Amt").val())
				// {
				//    $("#btnhide").hide();
				// }
			});
		}

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


		function setAmountTtlPayable() {


			var amtIAmt = $('#txtV_I_Amt').val();

			if (amtIAmt == ' ' || isNaN(amtIAmt)) {

				amtIAmt = 0;
			}




			$('#txtTtl_Outs').val(amtIAmt);

			var ttlPaidAmt = parseFloat($("[id^=txtP_]").sum());

			if (ttlPaidAmt == ' ' || isNaN(ttlPaidAmt)) {

				ttlPaidAmt = 0;
			}

			var balOut = parseFloat(amtIAmt) - parseFloat(ttlPaidAmt);



			if (balOut == ' ' || isNaN(balOut)) {

				balOut = 0;
			}


			//$('#txtBal_Outs').val(balOut);




			if ($('#flag').val() == 'true') {

				$('#txtROP_3').val(balOut)

			}

			getDeduction();


		}


		function openBtn(invoice_id) {

			jConfirm('Are you sure you want to open this record ?', '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();
					$.post("", {
						invoice_id: invoice_id
					}, function(html) {
						if (html) {
							location.reload();
						}
					});
				} else {
					return false;
				}
			});
		}

		// *******************************DPK**************************************//

		let frm_table = $('#frm2 table');
		let invoice_type = Array.from(frm_table.find("tr"));
		let invoice_result = invoice_type.filter(function(in_type) {
			var isCoa = '<?= $rowForQtyNRate['COAID'] ?>';
			console.log(typeof '<?= $rowForQtyNRate['COAID'] ?>')
			if (isCoa) {
				return false;
			} else {
				return $(in_type).data('status') == 5 && $(in_type).data('itype') == 'Accrual';
			}

		});
		if (invoice_result.length > 0) {
			$('#frm1').hide();
		}

		// ********************************************************************//
	</script>
</body>

</html>