<?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();
$_SESSION['moduleid'] = 6;
$_SESSION['selYear'] = date('Y', time());

$pagename = basename($_SERVER['PHP_SELF']);
$msg = NULL;



if (isset($_REQUEST['selBType']) && $_REQUEST['selBType'] != "") {
	$selBType = $_REQUEST['selBType'];
} else if (isset($_SESSION['selBType'])) {
	$selBType = $_SESSION['selBType'];
} else {
	$_SESSION['selBType'] = 2;

	$selBType =	$_SESSION['selBType'];
}

if ($_POST['del_alertid']) {
	$sql = mysql_query("update alert_master set SHOW_STATUS='0' where ALERTID='" . $_POST['del_alertid'] . "'");

	echo true;

	return;
	# code...
}



if (isset($_POST['id']) && isset($_POST['val']) && isset($_POST['iden'])) {


	$change_detials = mysql_query("UPDATE alert_master SET AL_REM='" . $_POST['val'] . "' where IDENTIFYID='" . $_POST['iden'] . "' and IDENTIFY='" . $_POST['id'] . "'");

	if ($change_detials) {
		echo true;
		return;
	}
}
?>
<!DOCTYPE html>
<html>

<head>
	<style>
		#add {
			display: inline-block;
			padding-left: 30px;
			float: left;
		}
	</style>
	<meta charset="UTF-8">
	<title><?php $display->title(); ?></title>
	<?php $display->favicon(); ?>
	<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
	<?php $display->css(); ?>
	<link href="../../css/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />

	<link href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
	<link href="https://cdn.datatables.net/buttons/2.2.2/css/buttons.dataTables.min.css" rel="stylesheet" type="text/css" />


	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
  <script src="../js/html5shiv.js"></script>
  <script src="../js/respond.min.js"></script>
<![endif]-->
</head>

<body class="skin-blue fixed">
	<!-- header logo: style can be found in header.less -->
	<?php $display->header_tag(); ?>
	<div class="wrapper row-offcanvas row-offcanvas-left">
		<?php $display->leftmenu(1); ?>

		<aside class="right-side">
			<!-- Content Header (Page header) -->
			<section class="content-header">
				<h1>
					<i class="fa fa-folder"></i>&nbsp;Dashboard&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">To - Do List</li>
				</ol>
			</section>

			<!-- Main content -->
			<section class="content">
				<!--   content put here..................-->
				<div class="box box-primary">
					<h3 style=" text-align:center;">To - Do List</h3>
					<form name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename; ?>" />

					<div align="right">
						<!--<a href="#" title="Pdf" onClick="getPdf();"><button class="btn btn-default" style="margin-right: 5px;" type="button"><i class="fa fa-download"></i>Generate PDF</button></a>-->
					</div>

					<div id="tabs" class="nav-tabs-custom">
						<ul class="nav nav-tabs">
							<li class="active"><a href="#tabs_2" data-toggle="tab">Payment Hold</a></li>
							<li><a href="#tabs_3" data-toggle="tab">Payment Payable</a></li>
						</ul>

						<?php

						$sqlForApp = 'select PAYMENT_UNLOCK from approval_matrix where LOGINID=' . $_SESSION['uid'] . '';

						$resultForApp = mysql_query($sqlForApp);
						$rowsForApp = mysql_fetch_assoc($resultForApp);

						// echo $rowsForApp['PAYMENT_UNLOCK'];

						// die();



						?>
						<div class="tab-content">
							<div id="tabs_2" class="tab-pane active">

								<div style="overflow:auto;">
									<div class="box-body table-responsive" style="overflow:auto;">

										<div class="row invoice-info">
											<div class="col-sm-3 invoice-col">
												Account Type
												<address>
													<select name="selBType3" class="form-control" id="selAccTypePayHold">
														<option value="0">---Select Account Type---</option>
														<option value="Singapore">Singapore</option>
														<option value="Dubai">Dubai</option>

													</select>
												</address>
											</div>
											<div class="col-sm-3 invoice-col">
												&nbsp;
												<address>
													<button type="button" class="btn btn-primary btn-flat" onClick="getToDoListAsPerAccTypeForPayHold();">Load</button>
												</address>
											</div><!-- /.col -->

											<div class="col-xs-6">
												<div style="float:right;"><a href="#" data-toggle="modal" data-target="#compose-search" title="Add New"><button type="button" class="btn btn-danger btn-flat"> Search For Voyage</button></a></div>
											</div>



										</div>




										<div align="right"></div>








										<table id="sf_list" class="table table-bordered table-striped">
											<thead>
												<tr>
													<th align="left" valign="top" width="3%">#</th>
													<th align="left" valign="top" width="5%">Vessel</th>
													<th align="left" valign="top" width="5%">Voyage No</th>
													<th align="left" valign="top" width="5%">Form Name</th>
													<th align="left" valign="top" width="5%">Invoice/Advice No./SOA No.</th>
													<th align="left" valign="top" width="5%">Type</th>
													<th align="left" valign="top" width="5%">Hold by</th>
													<th align="left" valign="top" width="5%">Vendor Name</th>
													<th align="left" valign="top" width="6%">Status</th>
													<th align="left" valign="top" width="10%">Date</th>
													<th align="left" valign="top" width="10%" class="not-export-col">Documents</th>
													<th align="left" valign="top" width="5%" class="not-export-col">Edit Link</th>
													<?php if ($rowsForApp['PAYMENT_UNLOCK'] == 1) { ?>
														<th align="left" valign="top" width="5%">Accruals</th>
														<th align="left" valign="top" width="5%">Payment Unhold</th>
													<?php } ?>


													<th align="left" valign="top" width="5%">Inactive</th>


												</tr>
											</thead>
											<tbody id="tbody1">
												<?php $i = 0;
												$sel = "select * from alert_master where SHOW_STATUS=1 and SENDTO='" . $_SESSION['uid'] . "' order by ADDONDATE DESC";


												$result = mysql_query($sel);


												while ($rows = mysql_fetch_assoc($result)) {



													$voyagename = '';
													$voyageno = '';
													$status = '';
													$comid = '';
													$vendorname = '';
													$invoiceno = '';
													$formname = '';
													if ($rows['IDENTIFY'] == 'FREIGHT INVOICE') {
														$sql1 = "select COMID, INVOICEID, MESSAGE, VENDOR, STATUS, I_TYPE,PAYMENT_STATUS from freight_invoice_master where INVOICEID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														if ($rows1['PAYMENT_STATUS'] == 'payment_hold') {
															$comid = $rows1['COMID'];
															$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
															$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
															$status = $rows1['STATUS'];
															$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
															$invoiceno  = $rows1['MESSAGE'];
															$formname = $rows['I_TYPE'] . ' Freight Invoice';
															$paytype = 'Receivable';
														}
													}

													if ($rows['IDENTIFY'] == 'GENERIC INVOICE') {
														$sql1 = "select * from generic_invoice_master where INVOICEID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														if ($rows1['PAYMENT_STATUS'] == 'payment_hold') {
															$comid = $rows1['COMID'];
															$payment_status = $rows1['PAYMENT_STATUS'];
															$voyageno = $rows1['INVOICE_NO'];
															$voyagename = 'GENERIC INVOICE';
															$status = $rows1['STATUS'];
															$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
															$invoiceno  = $rows1['REMARKS'];
															$formname = $rows['I_TYPE'] . ' Generic Invoice';

															if ($rows1['TYPE'] == 'payment') {

																$paytype = 'Payable';
															} else {
																$paytype = 'Receivable';
															}
														}
													}


													if ($rows['IDENTIFY'] == 'OTHER TC PAYMENT') {
														$sql1 = "select PAYMENTID, COMID, INVOICE_NO, RANDOMID, STATUS, VENDOR, SHORT_DESC,PAYMENT_STATUS from payment_tcother_master where PAYMENTID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														if ($rows1['PAYMENT_STATUS'] == 'payment_hold') {
															$comid = $rows1['COMID'];
															$voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'], "TC_NO");
															$voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
															$status = $rows1['STATUS'];
															$invoiceno  = $rows1['INVOICE_NO'];
															$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
															$formname =  "Other TC Payment";
															$paytype = 'Payable';
														}
													}


													if ($rows['IDENTIFY'] == 'FDA') {
														$sql1 = "select COMID, LP_COST_ID, SUBMITID, PORT, PORTID, RANDOMID,PAYMENT_STATUS from loadport_cost_master where LP_COST_ID='" . $rows['IDENTIFYID'] . "'";

														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);


														if ($rows1['PAYMENT_STATUS'] == 'payment_hold') {
															$comid = $rows1['COMID'];
															$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
															$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
															$status = $rows1['SUBMITID'];
															$invoiceno  = $rows1['PORT'] . ' - ' . $obj->getPortNameBasedOnID($rows1['PORTID']);

															$sqltc = "SELECT PORT_COSTLP_VENDOR, PORT_COSTDP_VENDOR, PORT_COSTTP_VENDOR from freight_cost_estimete_slave1 where FCAID='" . $obj->getCompareEstimateData($rows1['COMID'], "FCAID") . "' and RANDOMID='" . $rows1['RANDOMID'] . "'";
															$restc 	= mysql_query($sqltc);
															$rectc 	= mysql_num_rows($restc);
															$rowstc = mysql_fetch_assoc($restc);
															if ($rows1['PORT'] == 'LP') {
																$vendorname = $obj->getVendorListNewBasedOnID($rowstc['PORT_COSTLP_VENDOR']);
															}
															if ($rows1['PORT'] == 'DP') {
																$vendorname = $obj->getVendorListNewBasedOnID($rowstc['PORT_COSTDP_VENDOR']);
															}
															if ($rows1['PORT'] == 'TP') {
																$vendorname = $obj->getVendorListNewBasedOnID($rowstc['PORT_COSTTP_VENDOR']);
															}

															$formname = 'FDA';
															$paytype = 'Payable';
														}
													}


													if ($rows['IDENTIFY'] == 'HIRE INVOICE') {
														$sql1 = "select COMID, INVOICEID, INVOICE_NO, RANDOMID, STATUS, INVOICE_TYPE,PAYMENT_STATUS from invoice_tchire_master where INVOICEID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);
														if ($rows1['PAYMENT_STATUS'] == 'payment_hold' || $rows1['INVOICE_TYPE'] == 'Accrual') {
															$comid = $rows1['COMID'];

															$voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'], "TC_NO");
															$voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
															$status = $rows1['STATUS'];
															$invoiceno  = $rows1['INVOICE_NO'];

															$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='" . $obj->getCharteringEstimateTCData($rows1['COMID'], "TCOUTID") . "' and RANDOMID='" . $rows1['RANDOMID'] . "'";
															$restc 	= mysql_query($sqltc);
															$rectc 	= mysql_num_rows($restc);
															$rowstc = mysql_fetch_assoc($restc);
															$vendorname = $obj->getVendorListNewBasedOnID($rowstc['TTL_REV_VENDOR']);
															$formname = ucwords($rows['INVOICE_TYPE']) . ' TC Hire Invoice';
															$paytype = 'Receivable';
														}
													}



													if ($rows['IDENTIFY'] == 'OTHER INVOICE') {
														$sql1 = "select COMID, INVOICEID, MESSAGE, VENDOR, STATUS, P_TYPE,PAYMENT_STATUS from other_invoice_master where INVOICEID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														if ($rows1['PAYMENT_STATUS'] == 'payment_hold') {

															$comid = $rows1['COMID'];
															$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
															$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
															$status = $rows1['STATUS'];
															$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
															$invoiceno  = $rows1['MESSAGE'];
															$formname = $rows1['P_TYPE'];
															$paytype = 'Receivable';
														}
													}

													if ($rows['IDENTIFY'] == 'HIRE STATEMENT') {

														$sql1 = "select COMID, INVOICEID, INVOICE_NO,INVOICE_TYPE, STATUS,PAYMENT_STATUS from invoice_hire_master where INVOICEID='" . $rows['IDENTIFYID'] . "' AND (PAYMENT_STATUS='payment_hold' || INVOICE_TYPE='Accrual')";


														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														if ($rows1['PAYMENT_STATUS'] == 'payment_hold' || $rows1['INVOICE_TYPE'] == 'Accrual') {

															$comid = $rows1['COMID'];
															$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
															$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
															$status = $rows1['STATUS'];
															$vendorname = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows1['COMID'], "DTCVENDORID"));
															$invoiceno  = $rows1['INVOICE_NO'];
															$formname = 'Hire Statement';
															$paytype = 'Payable';
														}
													}




													if ($rows['IDENTIFY'] == 'PAYMENT') {

														$sql1 = "select COMID, REQ_ID, PAYMENT_NO, VENDOR, STATUS, NAME,PAYMENT_STATUS from request_master where REQ_ID='" . $rows['IDENTIFYID'] . "' AND PAYMENT_STATUS='payment_hold'";



														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);
														if ($rows1['PAYMENT_STATUS'] == 'payment_hold') {

															$comid = $rows1['COMID'];
															$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
															$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
															$status = $rows1['STATUS'];
															$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
															$invoiceno  = $rows1['PAYMENT_NO'];
															$formname = $rows1['NAME'];
															$paytype = 'Payable';
														}
													}



													if ($rows['IDENTIFY'] == 'TC HIRE STATEMENT') {
														$sql1 = "select COMID, INVOICEID, INVOICE_NO, RANDOMID, STATUS, INVOICE_TYPE,PAYMENT_STATUS from invoice_hiretc_master where INVOICEID='" . $rows['IDENTIFYID'] . "' AND (PAYMENT_STATUS='payment_hold' || INVOICE_TYPE='Accrual')";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														if ($rows1['PAYMENT_STATUS'] == 'payment_hold' || $rows1['INVOICE_TYPE'] == 'Accrual') {
															$comid = $rows1['COMID'];
															$voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'], "TC_NO");
															$voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
															$status = $rows1['STATUS'];
															$invoiceno  = $rows1['INVOICE_NO'];

															$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='" . $obj->getCharteringEstimateTCData($rows1['COMID'], "TCOUTID") . "' and RANDOMID='" . $rows1['RANDOMID'] . "'";
															$restc 	= mysql_query($sqltc);
															$rectc 	= mysql_num_rows($restc);
															$rowstc = mysql_fetch_assoc($restc);
															$vendorname = $obj->getVendorListNewBasedOnID($rowstc['TC_FINAL_HIERAGE_VENDOR']);
															$formname =  $rows['INVOICE_TYPE'] . ' TC Hire Statement';
															$paytype = 'Payable';
														}
													}

													if ($rows['IDENTIFY'] == 'COMBINED SOA PAYABLE') {
														$sql1 = "select SOA_NO, STATUS, VENDOR, SOAID, PAYMENT_STATUS from combined_soa_payable_master where SOAID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														if ($rows1['PAYMENT_STATUS'] == 'payment_hold') {
															$comid = $rows1['COMID'];
															$voyageno = $rows1['SOA_NO'];
															$voyagename = " - ";
															$status = $rows1['STATUS'];
															$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
															$invoiceno  = $rows1['SOA_NO'];
															$formname = "COMBINED SOA PAYABLE";
															$paytype = 'Payable';
														}
													}
													if ($rows['IDENTIFY'] == 'COMBINED SOA PAYABLE TC') {
														$sql1 = "select SOA_NO, STATUS, VENDOR, SOAID, PAYMENT_STATUS from combined_soa_payable_master_tc where SOAID='" . $rows['IDENTIFYID'] . "'";



														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														if ($rows1['PAYMENT_STATUS'] == 'payment_hold') {
															$comid = $rows1['COMID'];
															$voyageno = $rows1['SOA_NO'];
															$voyagename = " - ";
															$status = $rows1['STATUS'];
															$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
															$invoiceno  = $rows1['SOA_NO'];
															$formname = "COMBINED SOA PAYABLE TC";
															$paytype = 'Payable';
														}
													}

												?>
													<?php if (($rows1['PAYMENT_STATUS'] == "payment_hold"  || $rows1['INVOICE_TYPE'] == 'Accrual') && !empty($voyageno) && !empty($voyagename)) {
														$i++; ?>
														<tr>

															<td><?= $i; ?></td>
															<td><?= $voyagename; ?></td>
															<td><?= $voyageno; ?></td>
															<td><?= $formname; ?></td>
															<td><?= $invoiceno; ?></td>
															<td><?= $paytype; ?></td>
															<td><?= $obj->getLoginNameForFfa($rows['ALTERED_BY']); ?></td>
															<td><?= $vendorname; ?></td>
															<td><strong>
																	<?php if ($status == 0) { ?>
																		<span class="label label-primary">Submit to Edit</span>
																	<?php } else if ($status == 1) { ?>
																		<span class="label label-danger">Level 1 Approval Pending Since <?= $obj->getDaysDifference($rows['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } else if ($status == 2) { ?>
																		<span class="label label-warning">Sent for Review To Creator Since <?= $obj->getDaysDifference($rows1['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } else if ($status == 3) { ?>
																		<span class="label label-danger">Level 2 Approval Pending Since <?= $obj->getDaysDifference($rows['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } else if ($status == 4) { ?>
																		<span class="label label-danger">Sent for Review To Approver 1 Since <?= $obj->getDaysDifference($rows1['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } else { ?>
																		<span class="label label-warning">Payment Received/Paid Pending Since <?= $obj->getDaysDifference($rows['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } ?>
																</strong>
															</td>
															<td><?= date('Y/m/d', strtotime($rows['ADDONDATE'])); ?></td>
															<td><?php if ($comid != '') { ?><a href="documents.php?comid=<?= $comid; ?>&amp;page=1" style="color:green;" title="Click me">Docs</a><?php } ?></td>
															<td>
																<?php if ($rows['REDIRECTTO'] != '') { ?>
																	<a href="<?= $rows['REDIRECTTO']; ?>&alertid=<?= $rows['ALERTID']; ?>"><i class="fa fa-edit "></i> View</a>
																<?php } else { ?>
																	<a href="payment_grid.php?comid=<?= $comid; ?>&page=<?= $obj->getCompareTableData($comid, 'STATUS'); ?>&alertid=<?= $rows['ALERTID']; ?>"><i class="fa fa-edit "></i> View</a>
																<?php
																} ?>


															</td>
															<?php if ($rowsForApp['PAYMENT_UNLOCK'] == 1) {

																// if($rows['IDENTIFY']=='HIRE STATEMENT' || $rows['IDENTIFY']=='PAYMENT' || $rows['IDENTIFY']=='TC HIRE STATEMENT' || $rows['IDENTIFY']=='COMBINED SOA PAYABLE TC' || $rows['IDENTIFY']=='COMBINED SOA PAYABLE'){
															?>


																<td align="left" valign="middle"><input type="text" data-comid="<?= $rows['IDENTIFY'] ?>" data-iden="<?php echo $rows['IDENTIFYID'] ?>" name="add_rem" id="add_rem" onkeydown="updateDetInTab(this)" value="<?= $rows['AL_REM'] ?>"></td>

																<td>
																	<button type="button" class="btn btn-primary" onClick="unholdPayment('<?php echo $rows['IDENTIFY'] ?>','<?php echo $rows['IDENTIFYID'] ?>','<?php echo $rows['ALERTID'] ?>')">Unhold</button>

																</td>
																<?php //}else{
																?>
																<!-- <td></td> -->

															<?php //} 
															} ?>


															<td>


																<button type="button" class="btn btn-danger btn-flat" onclick="makeInactive(this,'<?= $rows['ALERTID'] ?>');">Inactive</button>



															</td>




														</tr>
													<?php } ?>
												<?php } ?>
											</tbody>
										</table>
									</div>
								</div>

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

							<div id="tabs_3" class="tab-pane" style="overflow:auto;">

								<div style="overflow:auto;">
									<div class="box-body table-responsive" style="overflow:auto;">
										<div class="row invoice-info">
											<div class="col-sm-3 invoice-col">
												Account Type
												<address>
													<select name="selBType3" class="form-control" id="selAccType">
														<option value="0">---Select Account Type---</option>
														<option value="Singapore">Singapore</option>
														<option value="Dubai">Dubai</option>

													</select>
												</address>
											</div>

											<div class="col-sm-3 invoice-col">
												&nbsp;
												<address>
													<button type="button" class="btn btn-primary btn-flat" onClick="getToDoListAsPerAccTypeForPayPayable();">Load</button>
												</address>
											</div><!-- /.col -->


										</div>
										<table id="testing" class="table table-bordered table-striped">
											<thead>
												<tr>
													<th align="left" valign="top" width="3%">#</th>
													<th align="left" valign="top" width="5%">Vessel</th>
													<th align="left" valign="top" width="5%">Voyage No</th>
													<th align="left" valign="top" width="5%">Form Name</th>
													<th align="left" valign="top" width="5%">Invoice/Advice No.</th>
													<th align="left" valign="top" width="5%">Type</th>
													<th align="left" valign="top" width="5%">Unhold By</th>
													<th align="left" valign="top" width="5%">Vendor Name</th>
													<th align="left" valign="top" width="6%">Status</th>
													<th align="left" valign="top" width="25%">Date</th>
													<th align="left" valign="top" width="10%">Documents</th>
													<th align="left" valign="top" width="5%">Edit Link</th>
													<?php if ($rowsForApp['PAYMENT_UNLOCK'] == 1) { ?>
														<th align="left" valign="top" width="5%">Payment Hold</th>
													<?php } ?>
													<th align="left" valign="top" width="5%">Inactive</th>

												</tr>
											</thead>
											<tbody id="tbody1">
												<?php $j = 0;
												$sel = "select * from alert_master where SHOW_STATUS=1 and SENDTO='" . $_SESSION['uid'] . "' order by ADDONDATE DESC";

												//   echo '<pre>';



												//   die();
												$result = mysql_query($sel);
												while ($rows = mysql_fetch_assoc($result)) {
													// print_r($rows);



													$voyagename = '';
													$voyageno = '';
													$status = '';
													$comid = '';
													$vendorname = '';
													$invoiceno = '';
													$formname = '';
													$payment_status = '';
													$I_TYPE = '';

													if ($rows['IDENTIFY'] == 'FREIGHT PAYMENT') {
														$sql1 = "select COMID, INVOICEID, MESSAGE, VENDOR, STATUS, I_TYPE from freight_invoice_in_master where INVOICEID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);
														$comid = $rows1['COMID'];
														$I_TYPE = $rows1['I_TYPE'];
														$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['STATUS'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$invoiceno  = $rows1['MESSAGE'];
														$formname = $rows['I_TYPE'] . 'FREIGHT PAYMENT';
														$paytype = 'Payable';
													}

													if ($rows['IDENTIFY'] == 'GENERIC INVOICE') {
														$sql1 = "select * from generic_invoice_master where INVOICEID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);
														$comid = $rows1['COMID'];
														$payment_status = $rows1['PAYMENT_STATUS'];
														$voyageno = $rows1['INVOICE_NO'];
														$I_TYPE = $rows1['I_TYPE'];
														$voyagename = 'GENERIC INVOICE';
														$status = $rows1['STATUS'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$invoiceno  = $rows1['REMARKS'];
														$formname = $rows['I_TYPE'] . ' Generic Invoice';
														if ($rows1['TYPE'] == 'payment') {
															$paytype = 'Payable';
														} else {
															$paytype = 'Receivable';
														}
													}



													if ($rows['IDENTIFY'] == 'FREIGHT INVOICE') {
														$sql1 = "select COMID, INVOICEID, MESSAGE, VENDOR, STATUS, I_TYPE,PAYMENT_STATUS from freight_invoice_master where INVOICEID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);
														$comid = $rows1['COMID'];
														$payment_status = $rows1['PAYMENT_STATUS'];
														$I_TYPE = $rows1['I_TYPE'];
														$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['STATUS'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$invoiceno  = $rows1['MESSAGE'];
														$formname = $rows['I_TYPE'] . ' Freight Invoice';
														$paytype = 'Receivable';
													}

													if ($rows['IDENTIFY'] == 'OTHER INVOICE') {
														$sql1 = "select COMID, INVOICEID, MESSAGE, VENDOR, STATUS, P_TYPE,PAYMENT_STATUS from other_invoice_master where INVOICEID='" . $rows['IDENTIFYID'] . "'";

														//   echo '<h1>'.$sql1;

														//   die();


														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														$payment_status = $rows1['PAYMENT_STATUS'];

														$comid = $rows1['COMID'];
														$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['STATUS'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$invoiceno  = $rows1['MESSAGE'];
														$formname = $rows1['P_TYPE'];
														$paytype = 'Receivable';
													}

													if ($rows['IDENTIFY'] == 'HIRE STATEMENT') {
														$sql1 = "select COMID, INVOICEID, INVOICE_NO,PAYMENT_STATUS,STATUS from invoice_hire_master where INVOICEID='" . $rows['IDENTIFYID'] . "' and (PAYMENT_STATUS!='payment_hold' || INVOICE_TYPE!='Accrual')";

														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														//if($rows1['PAYMENT_STATUS']=='payment_payable' || $rows1['PAYMENT_STATUS']==NULL || $rows1['PAYMENT_STATUS']==0){
														$payment_status = $rows1['PAYMENT_STATUS'];
														$I_TYPE = $rows1['I_TYPE'];
														$comid = $rows1['COMID'];
														$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['STATUS'];
														$vendorname = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows1['COMID'], "DTCVENDORID"));
														$invoiceno  = $rows1['INVOICE_NO'];
														$formname = 'Hire Statement';
														$paytype = 'Payable';
														//}
													}

													if ($rows['IDENTIFY'] == 'PAYMENT') {
														$sql1 = "select COMID, REQ_ID, PAYMENT_NO, VENDOR, STATUS, NAME,PAYMENT_STATUS from request_master where REQ_ID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														//if($rows1['PAYMENT_STATUS']=='payment_payable' || $rows1['PAYMENT_STATUS']==NULL || $rows1['PAYMENT_STATUS']==0){
														$payment_status = $rows1['PAYMENT_STATUS'];
														$comid = $rows1['COMID'];
														$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['STATUS'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$invoiceno  = $rows1['PAYMENT_NO'];
														$formname = $rows1['NAME'];
														$paytype = 'Payable';
														//}
													}

													if ($rows['IDENTIFY'] == 'COMBINED SOA PAYABLE') {
														$sql1 = "select SOA_NO, STATUS, VENDOR, SOAID, PAYMENT_STATUS from combined_soa_payable_master where SOAID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														//if($rows1['PAYMENT_STATUS']=='payment_payable' || $rows1['PAYMENT_STATUS']==NULL || $rows1['PAYMENT_STATUS']==0){
														$payment_status = $rows1['PAYMENT_STATUS'];
														$comid = '';
														$voyageno = " - ";
														$voyagename = " - ";
														$status = $rows1['STATUS'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$invoiceno  = $rows1['SOA_NO'];
														$formname = "COMBINED SOA PAYABLE";
														$paytype = 'Payable';

														//}
													}
													if ($rows['IDENTIFY'] == 'COMBINED SOA PAYABLE TC') {
														$sql1 = "select SOA_NO, STATUS, VENDOR, SOAID, PAYMENT_STATUS from combined_soa_payable_master_tc where SOAID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														//if($rows1['PAYMENT_STATUS']=='payment_payable' || $rows1['PAYMENT_STATUS']==NULL || $rows1['PAYMENT_STATUS']==0){
														$payment_status = $rows1['PAYMENT_STATUS'];
														$comid = '';
														$voyageno = " - ";
														$voyagename = " - ";
														$status = $rows1['STATUS'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$invoiceno  = $rows1['SOA_NO'];
														$formname = "COMBINED SOA PAYABLE TC";
														$paytype = 'Payable';

														//}
													}


													if ($rows['IDENTIFY'] == 'LAYTIME') {
														$sql1 = "select COMID, LAYTIME_ID, SUBMITID, PORT, PORTID, VENDOR from laytime_master where LAYTIME_ID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);
														$comid = $rows1['COMID'];
														$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['SUBMITID'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$invoiceno  = $rows1['PORT'] . ' - ' . $obj->getPortNameBasedOnID($rows1['PORTID']);
														$formname = 'LAYTIME';
														$paytype = 'Receivable';
													}

													if ($rows['IDENTIFY'] == 'FDA') {
														$sql1 = "select COMID, LP_COST_ID, SUBMITID, PORT, PORTID, RANDOMID,PAYMENT_STATUS from loadport_cost_master where LP_COST_ID='" . $rows['IDENTIFYID'] . "'";

														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);
														$comid = $rows1['COMID'];

														$payment_status = $rows1['PAYMENT_STATUS'];

														$voyageno = $obj->getCompareEstimateData($rows1['COMID'], "VOYAGE_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['SUBMITID'];
														$invoiceno  = $rows1['PORT'] . ' - ' . $obj->getPortNameBasedOnID($rows1['PORTID']);

														$sqltc = "SELECT PORT_COSTLP_VENDOR, PORT_COSTDP_VENDOR, PORT_COSTTP_VENDOR from freight_cost_estimete_slave1 where FCAID='" . $obj->getCompareEstimateData($rows1['COMID'], "FCAID") . "' and RANDOMID='" . $rows1['RANDOMID'] . "'";
														$restc 	= mysql_query($sqltc);
														$rectc 	= mysql_num_rows($restc);
														$rowstc = mysql_fetch_assoc($restc);
														if ($rows1['PORT'] == 'LP') {
															$vendorname = $obj->getVendorListNewBasedOnID($rowstc['PORT_COSTLP_VENDOR']);
														}
														if ($rows1['PORT'] == 'DP') {
															$vendorname = $obj->getVendorListNewBasedOnID($rowstc['PORT_COSTDP_VENDOR']);
														}
														if ($rows1['PORT'] == 'TP') {
															$vendorname = $obj->getVendorListNewBasedOnID($rowstc['PORT_COSTTP_VENDOR']);
														}

														$formname = 'FDA';
														$paytype = 'Payable';
													}


													if ($rows['IDENTIFY'] == 'HIRE INVOICE') {
														$sql1 = "select COMID, INVOICEID, INVOICE_NO, RANDOMID, STATUS, INVOICE_TYPE,PAYMENT_STATUS from invoice_tchire_master where INVOICEID='" . $rows['IDENTIFYID'] . "' and (PAYMENT_STATUS!='payment_hold' || INVOICE_TYPE!='Accrual')";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);
														$comid = $rows1['COMID'];
														$payment_status = $rows1['PAYMENT_STATUS'];
														$voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'], "TC_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['STATUS'];
														$invoiceno  = $rows1['INVOICE_NO'];
														$I_TYPE = $rows1['I_TYPE'];
														$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='" . $obj->getCharteringEstimateTCData($rows1['COMID'], "TCOUTID") . "' and RANDOMID='" . $rows1['RANDOMID'] . "'";
														$restc 	= mysql_query($sqltc);
														$rectc 	= mysql_num_rows($restc);
														$rowstc = mysql_fetch_assoc($restc);
														$vendorname = $obj->getVendorListNewBasedOnID($rowstc['TTL_REV_VENDOR']);
														$formname = ucwords($rows['INVOICE_TYPE']) . ' TC Hire Invoice';
														$paytype = 'Receivable';
													}

													if ($rows['IDENTIFY'] == 'TC HIRE STATEMENT') {
														$sql1 = "select COMID, INVOICEID, INVOICE_NO, RANDOMID, STATUS, INVOICE_TYPE, PAYMENT_STATUS from invoice_hiretc_master where INVOICEID='" . $rows['IDENTIFYID'] . "' and (PAYMENT_STATUS!='payment_hold' || INVOICE_TYPE!='Accrual')";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														//if($rows1['PAYMENT_STATUS']=='payment_payable' || $rows1['PAYMENT_STATUS']==NULL || $rows1['PAYMENT_STATUS']==0 ){
														$payment_status = $rows1['PAYMENT_STATUS'];
														$I_TYPE = $rows1['I_TYPE'];
														$comid = $rows1['COMID'];
														$voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'], "TC_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['STATUS'];
														$invoiceno  = $rows1['INVOICE_NO'];

														$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='" . $obj->getCharteringEstimateTCData($rows1['COMID'], "TCOUTID") . "' and RANDOMID='" . $rows1['RANDOMID'] . "'";
														$restc 	= mysql_query($sqltc);
														$rectc 	= mysql_num_rows($restc);
														$rowstc = mysql_fetch_assoc($restc);
														$vendorname = $obj->getVendorListNewBasedOnID($rowstc['TC_FINAL_HIERAGE_VENDOR']);
														$formname =  $rows['INVOICE_TYPE'] . ' TC Hire Statement';
														$paytype = 'Payable';
														//}
													}

													if ($rows['IDENTIFY'] == 'OTHER TC INVOICE') {
														$sql1 = "select COMID, INVOICEID, INVOICE_NO, RANDOMID, STATUS, VENDOR, SHORT_DESC from invoice_tcother_master where INVOICEID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														//   $payment_status = $rows1['PAYMENT_STATUS'];
														$comid = $rows1['COMID'];
														$voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'], "TC_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['STATUS'];
														$invoiceno  = $rows1['INVOICE_NO'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$formname =  $rows['SHORT_DESC'];
														$paytype = 'Receivable';
													}

													if ($rows['IDENTIFY'] == 'OTHER TC PAYMENT') {
														$sql1 = "select PAYMENTID, COMID, INVOICE_NO, RANDOMID, STATUS, VENDOR, SHORT_DESC,PAYMENT_STATUS from payment_tcother_master where PAYMENTID='" . $rows['IDENTIFYID'] . "'";
														$result1 = mysql_query($sql1) or die($sql1);
														$rows1 = mysql_fetch_assoc($result1);

														$payment_status = $rows1['PAYMENT_STATUS'];
														$comid = $rows1['COMID'];
														$voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'], "TC_NO");
														$voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'], "VESSEL_IMO_ID"), "VESSEL_NAME");
														$status = $rows1['STATUS'];
														$I_TYPE = $rows1['I_TYPE'];
														$invoiceno  = $rows1['INVOICE_NO'];
														$vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
														$formname =  "Other TC Payment";
														$paytype = 'Payable';
													} ?>

													<?php if ((($payment_status == "payment_payable" || $payment_status == '' || $payment_status == NULL || $payment_status == 0) && $payment_status != "payment_hold") &&  $I_TYPE != 'Accrual' && !empty($voyageno) && !empty($voyagename)) {
														$j++; ?>
														<tr>

															<td><?= $j; ?></td>
															<td><?= $voyagename; ?></td>
															<td><?= $voyageno; ?></td>
															<td><?= $formname; ?></td>
															<td><?= $invoiceno; ?></td>
															<td><?= $paytype; ?></td>
															<td><?= $obj->getLoginNameForFfa($rows['ALTERED_BY']) ?></td>
															<td><?= $vendorname; ?></td>
															<td><strong>
																	<?php if ($status == 0) { ?>
																		<span class="label label-primary">Submit to Edit</span>
																	<?php } else if ($status == 1) { ?>
																		<span class="label label-danger">Level 1 Approval Pending Since <?= $obj->getDaysDifference($rows['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } else if ($status == 2) { ?>
																		<span class="label label-warning">Sent for Review To Creator Since <?= $obj->getDaysDifference($rows1['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } else if ($status == 3) { ?>
																		<span class="label label-danger">Level 2 Approval Pending Since <?= $obj->getDaysDifference($rows['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } else if ($status == 4) { ?>
																		<span class="label label-danger">Sent for Review To Approver 1 Since <?= $obj->getDaysDifference($rows1['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } else { ?>
																		<span class="label label-warning">Payment Received/Paid Pending Since <?= $obj->getDaysDifference($rows['ADDONDATE'], date('Y-m-d', time())); ?> Days</span>
																	<?php } ?>
																</strong>
															</td>
															<td width="25%"><?= date('Y/m/d', strtotime($rows['ADDONDATE'])); ?></td>
															<td><?php if ($comid != '') { ?><a href="documents.php?comid=<?= $comid; ?>&amp;page=1" style="color:green;" title="Click me">Docs</a><?php } ?></td>
															<td>
																<?php if ($rows['REDIRECTTO'] != '') { ?>
																	<a href="<?= $rows['REDIRECTTO']; ?>&alertid=<?= $rows['ALERTID']; ?>"><i class="fa fa-edit "></i> View</a>
																<?php } else { ?>
																	<a href="payment_grid.php?comid=<?= $comid; ?>&page=<?= $obj->getCompareTableData($comid, 'STATUS'); ?>&alertid=<?= $rows['ALERTID']; ?>"><i class="fa fa-edit "></i> View</a>
																<?php } ?>


															</td>


															<?php if ($rowsForApp['PAYMENT_UNLOCK'] == 1) {


																// if($rows['IDENTIFY']=='HIRE STATEMENT' || $rows['IDENTIFY']=='PAYMENT' || $rows['IDENTIFY']=='TC HIRE STATEMENT' || $rows['IDENTIFY']=='COMBINED SOA PAYABLE TC' || $rows['IDENTIFY']=='COMBINED SOA PAYABLE'){
															?>


																<td>
																	<button type="button" class="btn btn-primary" onClick="holdPayment('<?php echo $rows['IDENTIFY'] ?>','<?php echo $rows['IDENTIFYID'] ?>','<?php echo $rows['ALERTID'] ?>')">HOLD</button>

																</td>
																<?php //}else{
																?>
																<!-- <td></td> -->
															<?php //}
															}

															?>

															<td>


																<button type="button" class="btn btn-danger btn-flat" onclick="makeInactive(this,'<?= $rows['ALERTID'] ?>');">Inactive</button>



															</td>






														</tr>
													<?php } ?>
												<?php } ?>
											</tbody>
										</table>
									</div>
								</div>

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

						</div>

					</div>



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


		<div class="modal fade" id="compose-search" tabindex="-1" role="dialog" aria-hidden="true">
			<div class="modal-dialog" style="width:50%;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" id="closepdfmodel" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					</div>
					<div class="modal-body modal-sm">
						<form name="frm5" id="frm5" enctype="multipart/form-data" action="<?php echo $pagename; ?>" method="post" />
						<div class="row invoice-info">




							<div class="col-sm-12 invoice-col">


								<strong>Business Type</strong>
								<address>
									<select name="selBType1" class="form-control" id="selBType1">

										<?php
										$obj->getBusinessTypeList1($selBType);
										?>
									</select>
								</address>
								</select>
							</div>



							<div class="col-sm-12 invoice-col">


								<strong>Voyage Type</strong>
								<address>
									<select name="selVoyType" class="form-control" id="selVoyType">
										<option value="">---Select Type---</option>
										<option value="VC">VC</option>
										<option value="TC">TC</option>
										<option value="COA">COA</option>

									</select>
								</address>

							</div>





							<div class="col-sm-12 invoice-col">

								<strong>Search By</strong>
								<address>
									<select name="selSearchBy" class="form-control" id="selSearchBy" onchange="setSearchBy()">
										<option value="">---Select Search By---</option>
										<option value="1">Voyage Number</option>
										<option value="2">Vessel</option>

									</select>
								</address>
								</select>
							</div>



							<div class="col-sm-12 invoice-col vessel" style="display: none;">

								<strong>Vessel</strong>
								<address>
									<select name="selVessel" class="form-control" id="selVessel">
										<?php
										$obj->getVesselTypeListMemberWise($estimatetype);
										?>

									</select>
								</address>
								</select>
							</div>










							<div class="col-sm-12 invoice-col voy_no" style="display: none;">
								<strong>Enter Voyage Number</strong>
								<address>
									<input type="text" name="txtvoyageno" id="txtvoyageno" class="form-control" placeholder="Voyage Number" autocomplete="off" value="" required />

								</address>
							</div>



						</div>

						<div class="box-footer" align="right">
							<button type="button" class="btn btn-info btn-flat" onClick="searchForVoyage();">Search</button>
						</div>
						</form>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->
		</div>


		<div class="modal fade" id="vesselDet" tabindex="-1" role="dialog" aria-hidden="true">
			<div class="modal-dialog" style="width:50%;">
				<div class="modal-content">
					<div class="modal-header">

						<button type="button" id="closepdfmodel" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					</div>
					<div align='center'>
						<h3><i>Search For Vessel<i></h3>
						<hr>
						<div>
							<div class="modal-body modal-sm">
								<form name="frm5" id="frm5" enctype="multipart/form-data" action="<?php echo $pagename; ?>" method="post" />
								<div class="row invoice-info" border="2px">


									<div id="pasteHere">


									</div>

								</div>
								</form>
							</div>
						</div><!-- /.modal-content -->
					</div><!-- /.modal-dialog -->
				</div>



			</div><!-- ./wrapper -->
			<?php $display->footer(); ?>
			<?php $display->js(); ?>
			<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js" type="text/javascript"></script>

			<!-- new scripts -->
			<script src="https://cdn.datatables.net/buttons/2.2.2/js/dataTables.buttons.min.js" type="text/javascript"></script>
			<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js" type="text/javascript"></script>
			<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js" type="text/javascript"></script>
			<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js" type="text/javascript"></script>
			<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js" type="text/javascript"></script>
			<script src="https://cdn.datatables.net/buttons/2.2.2/js/buttons.html5.min.js" type="text/javascript"></script>
			<script src="https://cdn.datatables.net/buttons/2.2.2/js/buttons.print.min.js" type="text/javascript"></script>


			<script src="
https://cdn.jsdelivr.net/npm/sweetalert2@11.12.4/dist/sweetalert2.all.min.js
"></script>
			<link href="
https://cdn.jsdelivr.net/npm/sweetalert2@11.12.4/dist/sweetalert2.min.css
" rel="stylesheet">



			<script src="../../js/timer.js" type="text/javascript"></script>
			<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
			<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
			<script src="../../js/bootstrap-datepicker.js" type="text/javascript"></script>
			<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
			<script type="text/javascript">
				$(document).ready(function() {


					$("#selBType").val('<?php echo $selBType; ?>');
					$("#selBType1").val('<?php echo $selBType; ?>');

					$("#sf_list").DataTable({

						dom: 'Blfrtip',
						"searching": true,


						paging: true,

						buttons: [{
								extend: 'excel',

								title: "Todo List",
								sFileName: "Todo List",

								footer: true,
								exportOptions: {
									columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
								},



							},

						]
					});

					$("#testing").DataTable({

						dom: 'Blfrtip',
						"searching": true,


						paging: true,

						buttons: [{
								extend: 'excel',

								title: "Todo List",
								sFileName: "Todo List",
								footer: true,
								exportOptions: {
									columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
								},


							},

						]

					});



					// $('#add').css('display: inline-block')



				});


				function unholdPayment(idenType, idenId, alertId) {

					jConfirm('Are you sure you want to unhold this payment ?', '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("options.php?id=107", {
								idenType: "" + idenType + "",
								idenId: "" + idenId + "",
								alertId: "" + alertId + ""
							}, function(res) {

								if (res == true) {

									location.reload();
								}
							});

						} else {
							return false;
						}
					});

				}


				function holdPayment(idenType, idenId, alertId) {

					jConfirm('Are you sure you want to hold this payment ?', '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("options.php?id=123", {
								idenType: "" + idenType + "",
								idenId: "" + idenId + "",
								alertId: "" + alertId + ""
							}, function(res) {

								if (res == true) {

									location.reload();
								}
							});

						} else {
							return false;
						}
					});

				}




				function getToDoListAsPerAccTypeForPayHold() {

					var table = $('#sf_list').dataTable();

					if (table != null) table.fnDestroy();

					table = $("#sf_list").DataTable({

						"processing": true,
						"searching": true,


						"paging": true,
						"searchable": true,
						"dataSrc": "",

						"order": [
							[1, 'desc']
						],
						"ajax": {
							"url": "options.php?id=109?",
							"type": "POST",
							"dataSrc": function(d) {
								return d.records;
							},
							"data": function(d) {
								d.accountType = $("#selAccTypePayHold").val()
							},
						},


						dom: 'Bfrtip',
						buttons: [{
								extend: 'excel',

								title: "Todo List",
								sFileName: "Todo List"


							},

						],
						"columns": [{
								"data": "col1"
							},
							{
								"data": "col2"
							},
							{
								"data": "col3"
							},
							{
								"data": "col4"
							},
							{
								"data": "col5"
							},
							{
								"data": "col6"
							},
							{
								"data": "col7"
							},
							{
								"data": "col8"
							},
							{
								"data": "col9"
							},
							{
								"data": "col10"
							},
							{
								"data": "col11"
							},
							{
								"data": "col12"
							},
							{
								"data": "col13"
							}
						],
						"language": {
							"zeroRecords": "SORRY CURRENTLY THERE ARE ZERO(0) RECORDS"
						},
						"fnDrawCallback": function(oSettings, json) {
							$('[data-toggle="tooltip"]').tooltip();
						},
						"columnDefs": [

							{
								"targets": 6,
								"orderable": false
							},
							{
								"targets": 7,
								"orderable": false
							},
							{
								"targets": 8,
								"orderable": false
							},
							{
								"targets": 9,
								"orderable": false
							},
							{
								"targets": 10,
								"orderable": false
							},
							{
								"targets": 11,
								"orderable": false
							},





						]

					});

				}



				function getToDoListAsPerAccTypeForPayPayable() {


					// console.log($("#selBTypePeroid").val());



					var table = $('#testing').dataTable();

					if (table != null) table.fnDestroy();

					table = $("#testing").DataTable({
						"processing": true,
						"searching": true,



						"paging": true,
						"searchable": true,
						"dataSrc": "",

						"order": [
							[1, 'desc']
						],
						"ajax": {
							"url": "options.php?id=108",
							"type": "POST",
							"dataSrc": function(d) {
								return d.records;
							},
							"data": function(d) {
								d.accountType = $("#selAccType").val()
							},
						},


						dom: 'Bfrtip',
						buttons: [{
								extend: 'excel',

								title: "Todo List",
								sFileName: "Todo List"


							},

						],



						"columns": [{
								"data": "col1"
							},
							{
								"data": "col2"
							},
							{
								"data": "col3"
							},
							{
								"data": "col4"
							},
							{
								"data": "col5"
							},
							{
								"data": "col6"
							},
							{
								"data": "col7"
							},
							{
								"data": "col8"
							},
							{
								"data": "col9"
							},
							{
								"data": "col10"
							},
							{
								"data": "col11"
							},
							{
								"data": "col12"
							},
							{
								"data": "col13"
							},



						],
						"language": {
							"zeroRecords": "SORRY CURRENTLY THERE ARE ZERO(0) RECORDS"
						},
						"fnDrawCallback": function(oSettings, json) {
							$('[data-toggle="tooltip"]').tooltip();
						},
						"columnDefs": [

							{
								"targets": 5,
								"orderable": false
							},
							{
								"targets": 6,
								"orderable": false
							},
							{
								"targets": 7,
								"orderable": false
							},
							{
								"targets": 8,
								"orderable": false
							},
							{
								"targets": 9,
								"orderable": false
							},
							{
								"targets": 10,
								"orderable": false
							},



						]





					});

				}

				function makeInactive(elx, alertId) {
					// alert(alertId);


					Swal.fire({
						title: "Are you sure?",
						text: "You won't be able to revert this!",
						icon: "warning",
						showCancelButton: true,
						confirmButtonColor: "#3085d6",
						cancelButtonColor: "#d33",
						confirmButtonText: "Yes, Inactive it!"
					}).then((result) => {
						if (result.isConfirmed) {


							$.post("to_do_list.php", {
								del_alertid: alertId
							}, function(res) {
								if (res) {
									Swal.fire({
										title: "Alterted!",
										text: "Alert queue alterted.",
										icon: "success"
									});
									$(elx).parent().parent().remove();
								}
							});




						}
					});






				}


				function searchForVoyage() {

					// if()

					if ($("#selVoyType").val().length != 0 && $("#selSearchBy").val().length != 0 && $("#selBType1").val().length != 0 && $("#txtvoyageno").val().length != 0) {


						$.post("options.php?id=126", {
							txtvoyageno: "" + $("#txtvoyageno").val() + "",
							voytype: "" + $("#selVoyType").val() + "",
							selBType1: "" + $("#selBType1").val() + ""
						}, function(res) {

							var obj = JSON.parse(res)

							// console.log(obj);

							// return false;
							if (obj.type == 'vc') {
								if (obj.status == 1) {

									location.href = 'in_ops_at_glance.php?selYear=' + obj.year + '&voy_no=' + obj.voyage;
									$("#closepdfmodel").click();

								}
								if (obj.status == 2) {


									location.href = 'vessel_in_post_ops.php?selYear=' + obj.year + '&voy_no=' + obj.voyage;
									$("#closepdfmodel").click();

								}
								if (obj.status == 5) {


									location.href = 'vessel_in_history.php?selYear=' + obj.year + '&voy_no=' + obj.voyage;
									$("#closepdfmodel").click();

								}

								if (obj.res == 0) {


									jAlert('No Data Found', 'Alert');
									// return false;

								}
							}
							if (obj.type == 'tc') {

								if (obj.status == 1) {

									location.href = 'in_ops_tc.php?selYear=' + obj.year + '&voy_no=' + obj.voyage;
									$("#closepdfmodel").click();

								}
								if (obj.status == 2) {


									location.href = 'vessel_in_post_tc.php?selYear=' + obj.year + '&voy_no=' + obj.voyage;
									$("#closepdfmodel").click();

								}
								if (obj.status == 5) {

									location.href = 'vessel_in_history_tc.php?selYear=' + obj.year + '&voy_no=' + obj.voyage;
									$("#closepdfmodel").click();

								}

								if (obj.res == 0) {


									jAlert('No Data Found', 'Alert');
									// return false;

								}
							}
							if (obj.type == 'COA') {

								if (obj.status == 1) {

									location.href = 'coa_in_ops_at_glance.php?selYear=' + obj.year + '&voy_no=' + obj.voyage;
									$("#closepdfmodel").click();

								}
								if (obj.status == 2) {


									location.href = 'coa_in_post_ops.php?selYear=' + obj.year + '&voy_no=' + obj.voyage;
									$("#closepdfmodel").click();

								}
								if (obj.status == 5 || obj.status == 3) {

									location.href = 'coa_in_history.php?selYear=' + obj.year + '&voy_no=' + obj.voyage;
									$("#closepdfmodel").click();

								}

								if (obj.res == 0) {


									jAlert('No Data Found', 'Alert');
									// return false;

								}
							}

						});
					} else if ($("#selVoyType").val().length != 0 && $("#selSearchBy").val().length != 0 && $("#selBType1").val().length != 0 && $("#selVessel").val().length != 0) {

						$.post("options.php?id=153", {
							selVessel: "" + $("#selVessel").val() + "",
							voytype: "" + $("#selVoyType").val() + "",
							selBType1: "" + $("#selBType1").val() + ""
						}, function(res) {

							var obj = JSON.parse(res)

							var href = '';
							flag = 0;
							$('#pasteHere').empty();
							jQuery.each(obj, (index, item) => {

								if (obj[index].type == 'vc') {

									if (obj[index].res == 0) {


										jAlert('No Data Found', 'Alert');
										flag = 0;
										// return false;

									} else if (obj[index].status == 1) {

										href = 'in_ops_at_glance.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;
									} else if (obj[index].status == 2) {
										href = 'vessel_in_post_ops.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										// $("#closepdfmodel").click();
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;
									} else if (obj[index].status == 3 || obj[index].status == 4) {

										href = 'vessel_in_history.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;

									} else if (obj[index].status == 5) {

										href = 'vessel_in_history_entry.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;

									} else {

										jAlert('No Data Found', 'Alert');
										flag = 0;
									}
								} else if (obj[index].type == 'tc') {


									if (obj[index].res == 0) {


										jAlert('No Data Found', 'Alert');
										// return false;
										flag = 0;
									} else if (obj[index].status == 1) {

										href = 'in_ops_tc.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;


									} else if (obj[index].status == 2) {

										href = 'vessel_in_post_tc.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;


									} else if (obj[index].status == 3 || obj[index].status == 4) {

										href = 'vessel_in_history_tc.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;


									} else if (obj[index].status == 5) {

										href = 'vessel_in_history_tc_entry.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;


									}


								} else if (obj[index].type == 'COA') {

									if (obj[index].res == 0) {


										jAlert('No Data Found', 'Alert');
										// return false;
										flag = 0;
									} else if (obj[index].status == 1) {

										href = 'coa_in_ops_at_glance.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;

									} else if (obj[index].status == 2) {


										href = 'coa_in_post_ops.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;

									} else if (obj[index].status == 4 || obj[index].status == 3) {

										href = 'coa_in_history.php?selYear=' + obj[index].year + '&voy_no=' + obj[index].voyage;
										$("<div> <h4><i><a href=" + href + " style='font-size:27px;font-weight:bold;'>" + obj[index].Charterer + " - " + obj[index].voyage + " (" + obj[index].CP_DATE + ")</a></i><h4><hr></div>").appendTo("#pasteHere")
										flag = 1;

									}


								}



							});

							if (flag == 1) {

								$('#vesselDet').modal('show');

							}


						})
					} else {

						jAlert('Please ensure to select/fill Voyage No./Vessel,Business type,Voyage Type and Search by', 'Alert');

						return false;
					}





				}



				const debounce = (func, wait) => {
					let timeout;

					return function executedFunction(...args) {
						const later = () => {
							clearTimeout(timeout);
							func(...args);
						};

						clearTimeout(timeout);
						timeout = setTimeout(later, wait);
					};
				};






				function updateDetInTab(elx) {

					debounce(function() {

						$.ajax({

							type: "POST",
							data: {
								id: $(elx).data('comid'),
								val: $(elx).val(),
								iden: $(elx).data('iden')
							},
							dataType: "json",

							success: function(result) {
								// when call is sucessfull
								if (result) {
									// $(clx).parent().prev().text(f_year);
									console.log('DATA POSTED');
								}
							},
							error: function(err) {
								// check the err for error details


							}
						});



					}, 500).call();

				}


				function setSearchBy() {
					if ($("#selSearchBy").val().length != 0) {

						if ($("#selSearchBy").val() == 1) {

							$(".voy_no").css("display", "block");
							$(".vessel").css("display", "none");

						} else {
							$(".voy_no").css("display", "none");
							$(".vessel").css("display", "block");

						}


					} else {


						$(".voy_no").css("display", "none");
						$(".vessel").css("display", "none");


						jAlert('Please Select Search By', 'Alert');

					}


				}
			</script>

</body>

</html>