<?php 
session_start();
require_once("../../includes/display_internal_user_dryout.inc.php");
require_once("../../includes/functions_internal_user_dryout.inc.php");

include_once("../../includes/fpdf.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
$id = $_REQUEST['id'];

// echo $id;

// die();



if(@$_REQUEST['action'] == 'submit')
{
	
	
 	$id = $obj->updateCombinedSOAPayableTC();
	header('Location:./combined_payable_soa_tc.php?id='.$id);
}
$obj->viewCombinedSOAPayableDataTC($id);


$ven_name=$obj->getFun15();

$exchng_rate=$obj->getFun13();
$exchng_curr=$obj->getFun11();
$creatorsarr = $obj->getUsersWithAuthority('SOA_CHK_CRETR');
$approverarr1 = $obj->getUsersWithAuthority('SOA_CHK_APP_1');
$approverarr2 = $obj->getUsersWithAuthority('SOA_CHK_APP_2');

$creator = $obj->getUserAuthority($_SESSION['uid'], 'SOA_CHK_CRETR');
$approver1 = $obj->getUserAuthority($_SESSION['uid'], 'SOA_CHK_APP_1');
$approver2 = $obj->getUserAuthority($_SESSION['uid'], 'SOA_CHK_APP_2');
$approver2 = $obj->getUserAuthority($_SESSION['uid'], 'SOA_CHK_APP_2');
$accounts = $obj->getUserAuthority($_SESSION['uid'], 'SOA_CHK_ACC');
$pagename = basename($_SERVER['PHP_SELF']).'?id='.$id;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php $display->title(); ?></title>
<?php $display->favicon(); ?>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php $display->css(); ?>
<?php $display->js(); ?>
<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>
<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>
<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>
.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td
{
	padding:3px; 
}

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

table{border-collapse:separate;}
select{height:19px;}
.select
{
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: bold;
    color: #333333;
    /* color: #FBC763; */
    text-decoration: none;
    line-height: 13px;
	height:13px;
}

.input-text
{
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
	font-weight: normal;
	color: #333333;
	text-decoration: none;
	/*text-transform:uppercase;
	line-height: 15px;*/
}

.input-textsmall
{
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9px;
	font-weight: normal;
	color: #333333;
	text-decoration:none;
	text-transform:uppercase;
}

.input 
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
color: #333333;
text-decoration: none;
}

#vertical-2 thead,#vertical-2 tbody{
                display:inline-block;
            }
</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(24); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        <i class="fa fa-dollar"></i>&nbsp;Combined SOA Payable&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">Combined SOA Payable</li>
                    </ol>
                </section>
                <!-- Main content -->
                <section class="content">
				    <div align="right"><a href="combined_payable_soa_tc.php"><button class="btn btn-info btn-flat">Back</button></a></div>
				    <div style="height:10px;">&nbsp;</div>
					<!--   content put here..................-->
					<div class="box box-primary" id="print_pdf">
						<h3 style=" text-align:center;">Combined SOA Payable</h3>
                        <form name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post"/>
						<div class="row invoice-info" style="margin-left:7px;margin-right:7px;">
						    
                            <div class="col-xs-3">
							     Vendor
								 <address>
                                 <select name="selVendor" id="selVendor" class="form-control" disabled="disabled">
								   <?php echo $obj->getVendorListNewUpdate();?>
                                  </select>  
								  </address>                
							</div><!-- /.col -->
							<div class="col-xs-6">&nbsp;
								
							</div>
							<div class="col-sm-3">
								&nbsp;<address>
									<!-- 77 -->
									<!-- 73 -->
								<a href="allPdf.php?id=91&csp=<?=$id?>" title="Pdf"><button type="button" class="btn btn-default" style="margin-right: 5px;"><i class="fa fa-download"></i> Generate PDF</button></a>
									
								</address>
							</div>
						</div>

						
						
						
						<div class="box-body table-responsive" style="overflow:auto;">
							<table id="vessel_list" class="table table-bordered table-striped" style="width:1500px;">
							    <thead>
								 <tr>
									<th>Payment/SOA Date</th>
									<th><input type="text" name="txtPaymentDate" id="txtPaymentDate" class="form-control required" autocomplete="off" value="<?= date('d-m-Y',strtotime($obj->getFun2()));?>" placeholder="dd-mm-yyyy" required/></th>
									<th>Exchange Currency</th>
									<th><select  name="selExchangeCurrency" class="form-control" id="selExchangeCurrency" style="width:150px;" onChange="getExchangeAmountCal();"><?php $obj->getCurrencyList();?></select></th>
									<th>Exchange Date</th>
									<?php $exchangedate = date('d-m-Y',strtotime($obj->getFun12()));
										if($exchangedate=='01-01-1970'){$exchangedate = '';}?>
									<th><input type="text" name="txtExchangeDate" id="txtExchangeDate" class="form-control" autocomplete="off" value="<?=$exchangedate;?>" placeholder="dd-mm-yyyy"/></th>
									<th>Exchange Rate</th>
									<th><input type="text" name="txtExchangeRate" id="txtExchangeRate" class="form-control numeric" onKeyUp="getExchangeAmountCal();" autocomplete="off" value="<?php echo $obj->getFun13();?>"/></th>
									<th>Banking Details</th>
									<th colspan="2"><select  name="selBankingDetails" class="form-control required" id="selBankingDetails" required><?php $obj->getBankingDetailsDataWithJsonVendor($obj->getFun15(),$obj->getFun14());?></select></th>

									<th>Attachments</th>
								</tr>
								<tr>
									<th align="left" valign="top" width="8%">Voyage No</th>
									<th align="left" valign="top" width="8%">Vessel Name</th>
									<th align="left" valign="top" width="8%">Cost Desc</th>
									<th align="left" valign="top" width="8%">Cost Type</th>
									<th align="left" valign="top" width="8%">Vendor Invoice Amount</th>
									<th align="left" valign="top" width="8%">Vendor Invoice Date</th>	
									<th align="left" valign="top" width="8%">Payment No</th>	
									<th align="left" valign="top" width="8%">Estimated Amount (USD)</th>
									<th align="left" valign="top" width="8%">Actual Amount (USD)</th>
									<th align="left" valign="top" width="8%">Exchange Amount (<span id="curr_span"></span>)</th>
									<th align="left" valign="top" width="12%">Remarks</th>
									<th align="left" valign="top" width="12%">Attachment</th>
								</tr>
								</thead>
								
								<tbody id="tbody1">
							<?php
							

							$sql= mysql_query("SELECT * FROM `request_mastertc` WHERE `SOAID` = '".$id."'");
						
							
							
							$sno = 0;
						
							while($rows=mysql_fetch_assoc($sql))
							{
								$upload_attach = $rows['ATTACHMENTS'];
								$upload_attach_name = $rows['ATTACHMENTS_NAME'];


								$sno++;

								$id = $obj->getLatestCostSheetIDTC($rows['COMID']);
								// $obj->viewTCEstimationTempleteRecordsNew($id);
								$test_rows = mysql_fetch_assoc(mysql_query("select * from chartering_estimate_tc_master where MODULEID='".$_SESSION['moduleid']."' and TCOUTID='".$id."' "));
								$tc_no=$test_rows['TC_NO'];
								$vessal_name=$obj->getVesselIMOData($test_rows['VESSEL_IMO_ID'],"VESSEL_NAME");

								$rows2= mysql_fetch_assoc(mysql_query("select * from chartering_estimate_tc_slave2 where TC_SLAVE2ID='".$rows['MAIN_TC_SLAVE']."'"));
								$upload_attach = $rows['ATTACHMENTS'];
								$upload_attach_name = $rows['ATTACHMENTS_NAME'];
								echo '<tr>';
								echo '<td>'.$tc_no.'</td>';
								echo '<td>'.$vessal_name.'</td>';
								echo '<input type="hidden" id="REQ_ID_'.$sno.'" name="REQ_ID_'.$sno.'" value="'.$rows['REQ_ID'].'"/>';

								echo '<input type="hidden" id="DESCID_'.$sno.'" name="DESCID_'.$sno.'" value="'.$rows2['DESCRIPTION'].'"/>';


								echo '<td align="left" valign="top" width="8%">'.$rows2['DESCRIPTION'].'</td>';
								echo '<td align="left" valign="top" width="8%">'.($rows2['EXPENSETYPEID']==1?"Charterer":($rows2['EXPENSETYPEID']==2?"Shipowner":"Technical")).'</td>';

								echo '<td align="left" valign="top" width="8%"><input type="text" name="txtInvoiceAmount_'.$sno.'" id="txtInvoiceAmount_'.$sno.'" class="form-control numeric" autocomplete="off" value="'.$rows['INVOICE_AMT'].'" placeholder=""/>
								<input type="hidden" id="COMID_'.$sno.'" name="COMID_'.$sno.'" value="'.$rows['COMID'].'"/></td>';

						$invoicedate = date('d-m-Y',strtotime($rows['INVOICE_DATE']));if($invoicedate=='01-01-1970'){$invoicedate = '';}


						echo '<td align="left" valign="top" width="8%"><input type="text" name="txtInvoiceDate_'.$sno.'" id="txtInvoiceDate_'.$sno.'" class="form-control" autocomplete="off" value="'.$invoicedate.'" placeholder="dd-mm-yyyy"></td>';
						echo '<td align="left" valign="top" width="8%"><input type="text" name="txtPaymentNo_'.$sno.'" id="txtPaymentNo_'.$sno.'" class="form-control" autocomplete="off" value="'.$rows['PAYMENT_NO'].'" placeholder=""></td>';

						// 
						
						echo '<td align="left" valign="top" width="8%"><input type="text" name="txtEstimatedAmt_'.$sno.'" id="txtEstimatedAmt_'.$sno.'" class="form-control valid" value="'.$rows2['OTHER_AMT'].'" readonly="true"></td>';
						echo '<td align="left" valign="top" width="8%"><input type="text" name="txtActualAmt_'.$sno.'" id="txtActualAmt_'.$sno.'" class="form-control numeric" autocomplete="off" value="'.number_format($rows['TTL_OUTSTANDINGS']*$exchng_rate,2,'.','').'" placeholder="0.00" onkeyup="getExchangeAmountCal();"></td>';
						echo '<td align="left" valign="top" width="8%"><input type="text" name="txtActualExchangeAmt_'.$sno.'" id="txtActualExchangeAmt_'.$sno.'" class="form-control" readonly="true" autocomplete="off" value="" placeholder="0.00"></td>';
						echo '<td   align="left" valign="top" width="8%"><textarea class="form-control" name="txtRemarks_'.$sno.'" id="txtRemarks_'.$sno.'" cols="30" rows="2" placeholder="Remarks ...">'.$rows['REMARKS'].'</textarea></td>';
						echo '<td align="left" valign="top" width="8%"><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_'.$sno.'[]" id="attach_file_'.$sno.'" title="" data-widget="Attachment" data-toggle="tooltip" data-original-title="Attachment">
						</div>
						

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

							// echo '<h1>'.sizeof($fileid).'</h1>';
							echo '<input type="hidden" name="countForAttachment_'.$sno.'" id="countForAttachment_'.$sno.'" value="'.sizeof($fileid).'">';
							for($j=0;$j<sizeof($fileid);$j++)
							{
						
							echo '<tr id="rowfile_'.($j+1).'">
								<td width="90%" align="left" class="input-text"  valign="top"><a href="../../attachment/'.$fileid[$j].'" target="_blank" style="color:blue;" data-toggle="tooltip" data-original-title="'. $filename[$j].'"><i class="fa fa-external-link"></i>&nbsp;&nbsp;'.$filename[$j].'</a>
								<input type="hidden" name="fileGrid_'.$sno.'_'.($j+1).'" id="fileGrid_'.$sno.'_'.($j+1).'" value="'.$fileid[$j].'" />
								<input type="hidden" name="nameGrid_'.$sno.'_'.($j+1).'" id="nameGrid_'.$sno.'_'. ($j+1).'" value="'. $filename[$j].'" />
								</td>
								

								<td ><a href="#1" onClick="Del_UploadOfGrid(this);"><i class="fa fa-times " style="color:red;"></i></a></td>
							</tr>';
							 }

						
					 }  

				echo '</table>
						
						
						</td>';								
				  echo '</tr>';

				  echo '<tr>';
						echo '<td colspan="10"><input type="hidden" id="txthddnBankingdetails" name="txthddnBankingdetails" value="'.$selectbox.'"/><input type="hidden" id="txtrowsid" name="txtrowsid" value="'.$sno.'"/></td>';
				  echo '</tr>';
								
							}
								

				// 			while($rows=mysql_fetch_assoc(mysql_query($sql)))
				// 			{
				// 				$sno++;
								
				// 				$rows2= mysql_fetch_assoc(mysql_query("select * from chartering_estimate_tc_slave2 where TC_SLAVE2ID='".$rows['MAIN_TC_SLAVE']."'"));

				// 				$upload_attach = $rows['ATTACHMENTS'];
				// 				$upload_attach_name = $rows['ATTACHMENTS_NAME'];
				// 				echo '<tr>';
				// 				echo '<td>'.$tc_no.'</td>';
				// 				echo '<td>'.$vessal_name.'</td>';
								
				// 				echo '<td align="left" valign="top" width="8%">'.$rows2['DESCRIPTION'].'</td>';
				// 				echo '<td align="left" valign="top" width="8%">'.($rows2['EXPENSETYPEID']==1?"Charterer":($rows2['EXPENSETYPEID']==2?"Shipowner":"Technical")).'</td>';

				// 				echo '<td align="left" valign="top" width="8%"><input type="text" name="txtInvoiceAmount_'.$sno.'" id="txtInvoiceAmount_'.$sno.'" class="form-control numeric" autocomplete="off" value="'.$rows['INVOICE_AMT'].'" placeholder=""/>
				// 				<input type="hidden" id="COMID_'.$sno.'" name="COMID_'.$sno.'" value="'.$rows['COMID'].'"/></td>';

				// 		$invoicedate = date('d-m-Y',strtotime($rows['INVOICE_DATE']));if($invoicedate=='01-01-1970'){$invoicedate = '';}


				// 		echo '<td align="left" valign="top" width="8%"><input type="text" name="txtInvoiceDate_'.$sno.'" id="txtInvoiceDate_'.$sno.'" class="form-control" autocomplete="off" value="'.$invoicedate.'" placeholder="dd-mm-yyyy"></td>';
				// 		echo '<td align="left" valign="top" width="8%"><input type="text" name="txtPaymentNo_'.$sno.'" id="txtPaymentNo_'.$sno.'" class="form-control" autocomplete="off" value="'.$rows['PAYMENT_NO'].'" placeholder=""></td>';

				// 		// 
						
				// 		echo '<td align="left" valign="top" width="8%"><input type="text" name="txtEstimatedAmt_'.$sno.'" id="txtEstimatedAmt_'.$sno.'" class="form-control valid" value="'.$rows2['OTHER_AMT'].'" readonly="true"></td>';
				// 		echo '<td align="left" valign="top" width="8%"><input type="text" name="txtActualAmt_'.$sno.'" id="txtActualAmt_'.$sno.'" class="form-control numeric" autocomplete="off" value="'.number_format($rows['TTL_OUTSTANDINGS']*$exchng_rate,2,'.','').'" placeholder="0.00" onkeyup="getExchangeAmountCal();"></td>';
				// 		echo '<td align="left" valign="top" width="8%"><input type="text" name="txtActualExchangeAmt_'.$sno.'" id="txtActualExchangeAmt_'.$sno.'" class="form-control" readonly="true" autocomplete="off" value="" placeholder="0.00"></td>';
				// 		echo '<td   align="left" valign="top" width="8%"><textarea class="form-control" name="txtRemarks_'.$sno.'" id="txtRemarks_'.$sno.'" cols="30" rows="2" placeholder="Remarks ..."></textarea></td>';
				// 		echo '<td align="left" valign="top" width="8%"><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_'.$sno.'[]" id="attach_file_'.$sno.'" title="" data-widget="Attachment" data-toggle="tooltip" data-original-title="Attachment">
				// 		</div></td>';								
				//   echo '</tr>';

				//   echo '<tr>';
				// 		echo '<td colspan="10"><input type="hidden" id="txthddnBankingdetails" name="txthddnBankingdetails" value="'.$selectbox.'"/><input type="hidden" id="txtrowsid" name="txtrowsid" value="'.$sno.'"/></td>';
				//   echo '</tr>';

				// 			}

							

								// $sql = "select * , (select TCOUTID from chartering_estimate_tc_master where chartering_estimate_tc_master.COMID=request_mastertc.COMID and MODULEID='".$_SESSION['moduleid']."' order by TCOUTID desc LIMIT 1)   as TCOUTID , chartering_estimate_tc_slave2.EXPENSETYPEID,chartering_estimate_tc_slave2.DESCRIPTION,chartering_estimate_tc_slave2.CHK_ADDTTL,chartering_estimate_tc_slave2.OTHER_AMT,chartering_estimate_tc_slave2.OTHER_EXP_VENDOR  from request_mastertc inner join chartering_estimate_tc_slave2 on chartering_estimate_tc_slave2.TC_SLAVE1ID = (select TCOUTID from chartering_estimate_tc_master where chartering_estimate_tc_master.COMID=request_mastertc.COMID and MODULEID='".$_SESSION['moduleid']."' order by TCOUTID desc LIMIT 1)  where SOAID='".$id."'  ";

								

								
								

							?>

												



								
						
								</tbody>
								<tfoot>
									<tr>
									   <td colspan="6"></td>
									   <td><strong>Total</strong></td>
									   <td><input type="text" name="txtTotalEstAmount" readonly="true" id="txtTotalEstAmount" class="form-control" placeholder="0.00" autocomplete="off" value=""/></td>
									   <td><input type="text" name="txtTotalAmount" readonly="true" id="txtTotalAmount" class="form-control" placeholder="0.00" autocomplete="off" value=""/></td>
									   <td><input type="text" name="txtTotalExAmount" readonly="true" id="txtTotalExAmount" class="form-control" placeholder="0.00" autocomplete="off" value=""/></td>
									   <td></td>

									   <td></td>
									   
									   
									</tr>
								</tfoot>
							</table>
						</div>
						
							<div class="col-md-6" id="test_bank">
								<h3>Banking Details</h3>
							<table class=" ">
									

									<tr>
										<th>Beneficiary Name	</th>
										<?php


											$vendor_id = mysql_fetch_assoc(mysql_query("select VENDORID from vendor_master where CODE='".$obj->getFun15()."'"))['VENDORID'];

											$sql2 = mysql_query("select * from vendor_master_slave where VENDORID='".$vendor_id."'");

											while ($rows_bd=mysql_fetch_assoc($sql2)) {
												?>
												<td> <?=$rows_bd['NAME']?> </td>
												<?php
											}

											?>
										
										
									</tr>
									<tr>
										<th>Beneficiary Address	</th>
										<?php


											$vendor_id = mysql_fetch_assoc(mysql_query("select VENDORID from vendor_master where CODE='".$obj->getFun15()."'"))['VENDORID'];

											$sql2 = mysql_query("select * from vendor_master_slave where VENDORID='".$vendor_id."'");

											while ($rows_bd=mysql_fetch_assoc($sql2)) {
												?>
												<td> <?=$rows_bd['ADDRESS']?> </td>
												<?php
											}

											?>
									</tr>
									<tr>
										<th>Beneficiary Account No	</th>
										<?php


											$vendor_id = mysql_fetch_assoc(mysql_query("select VENDORID from vendor_master where CODE='".$obj->getFun15()."'"))['VENDORID'];

											$sql2 = mysql_query("select * from vendor_master_slave where VENDORID='".$vendor_id."'");

											while ($rows_bd=mysql_fetch_assoc($sql2)) {
												?>
												<td> <?=$rows_bd['ACCOUNTNO']?> </td>
												<?php
											}

											?>
									</tr>
									<tr>
										<th>IBAN No	</th>
										<?php


											$vendor_id = mysql_fetch_assoc(mysql_query("select VENDORID from vendor_master where CODE='".$obj->getFun15()."'"))['VENDORID'];

											$sql2 = mysql_query("select * from vendor_master_slave where VENDORID='".$vendor_id."'");

											while ($rows_bd=mysql_fetch_assoc($sql2)) {
												?>
												<td> <?=$rows_bd['IBAN_NO']?> </td>
												<?php
											}

											?>
									</tr>
									<tr>
										<th>IBAN Remarks	</th>
										<?php


											$vendor_id = mysql_fetch_assoc(mysql_query("select VENDORID from vendor_master where CODE='".$obj->getFun15()."'"))['VENDORID'];

											$sql2 = mysql_query("select * from vendor_master_slave where VENDORID='".$vendor_id."'");

											while ($rows_bd=mysql_fetch_assoc($sql2)) {
												?>
												<td> <?=$rows_bd['IBAN_REMARKS']?> </td>
												<?php
											}

											?>
									</tr>
									<tr>
										<th>Beneficiary Bank Name	</th>
										<?php


											$vendor_id = mysql_fetch_assoc(mysql_query("select VENDORID from vendor_master where CODE='".$obj->getFun15()."'"))['VENDORID'];

											$sql2 = mysql_query("select * from vendor_master_slave where VENDORID='".$vendor_id."'");

											while ($rows_bd=mysql_fetch_assoc($sql2)) {
												?>
												<td> <?=$rows_bd['BANK_NAME']?> </td>
												<?php
											}

											?>
									</tr>
									<tr>
										<th>Beneficiary Bank Address		</th>
										<?php


											$vendor_id = mysql_fetch_assoc(mysql_query("select VENDORID from vendor_master where CODE='".$obj->getFun15()."'"))['VENDORID'];

											$sql2 = mysql_query("select * from vendor_master_slave where VENDORID='".$vendor_id."'");

											while ($rows_bd=mysql_fetch_assoc($sql2)) {
												?>
												<td> <?=$rows_bd['BANK_ADDRESS']?> </td>
												<?php
											}

											?>
									</tr>
									<tr>
										<th>Beneficiary Bank Swift Code	</th>
										<?php


											$vendor_id = mysql_fetch_assoc(mysql_query("select VENDORID from vendor_master where CODE='".$obj->getFun15()."'"))['VENDORID'];

											$sql2 = mysql_query("select * from vendor_master_slave where VENDORID='".$vendor_id."'");

											while ($rows_bd=mysql_fetch_assoc($sql2)) {
												?>
												<td> <?=$rows_bd['SWIFT_CODE']?> </td>
												<?php
											}

											?>
									</tr>
									<tr>
										<th>US Corresponding Bank</th>
										<?php


											$vendor_id = mysql_fetch_assoc(mysql_query("select VENDORID from vendor_master where CODE='".$obj->getFun15()."'"))['VENDORID'];

											$sql2 = mysql_query("select * from vendor_master_slave where VENDORID='".$vendor_id."'");

											while ($rows_bd=mysql_fetch_assoc($sql2)) {
												?>
												<td> <?=$rows_bd['US_CORRES_BANK']?> </td>
												<?php
											}

											?>
									</tr>
									
								
								
								</table>

							</div>
						<div class="row" style="padding-right:10px; padding-left:10px; margin-bottom:10px;">
							 <div class="col-xs-4" margin-bottom:30px;>
								 Attachment <?=$obj->getFun4()?><br>
								<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%" style="margin-top:10px;">
								<?php if($obj->getFun4() != '')
									{ 
										$file = explode(",",$obj->getFun4()); 
										$name = explode(",",$obj->getFun5()); ?>	
									   <?php
										$j =1;
										for($i=0;$i<sizeof($file);$i++)
										{
										?>
										<tr id="row_file_<?php echo $j;?>">
											<td width="80%" align="left" class="input-text"  valign="top"><a href="../../attachment/<?php echo $file[$i]; ?>" target="_blank" style="color:blue;" data-toggle="tooltip" data-original-title="<?php echo $name[$i];?>"><i class="fa fa-external-link"></i>&nbsp;&nbsp;<?php echo $name[$i];?></a>
											<input type="hidden" name="file_<?php echo $j;?>" id="file_<?php echo $j;?>" value="<?php echo $file[$i]; ?>" />
											<input type="hidden" name="name_<?php echo $j;?>" id="name_<?php echo $j;?>" value="<?php echo $name[$i]; ?>" />
											</td>
											<td ><a href="#1" onClick="Del_Upload(<?php echo $j;?>);"><i class="fa fa-times " style="color:red;"></i></a></td>
										</tr>
									   <?php $j++;}?>
							   <?php }?>
							   </table>
							 </div>
							 <div class="col-xs-4" margin-bottom:30px;>
								 Remarks<br/>
								<textarea name="txtRemarks" id="txtRemarks" class="form-control autosize" rows="3" placeholder="Remarks"><?=$obj->getFun9();?></textarea>
							 
							 </div>
							 <div class="col-sm-4 invoice-col">
							   Level 1 Approver<br/>
							   <?php
							  $fieldname = 'SOA_CHK_APP_1';
							   ?>
							
							  <select data-placeholder="Choose Approver..." class="input-text chzn-select" style="width:300px;" multiple name="selApprovers[]" id="selApprovers"><?php $obj->getApproverListBasedOnApprovalMatrix($fieldname,$obj->getFun7());?></select>
						   </div>
						</div>
						<div class="row" style="padding-right:10px; padding-left:10px; margin-bottom:10px;">
							 <div class="col-xs-12" margin-bottom:30px;>
							      <h4>
									<?php if($approver2==1){ ?>
									
									<legend><h3 style="padding: 0 0 0 10px">Payment</h3></legend>

									<?php if($obj->getFun16()=='payment_hold'){?>
									<label style="padding: 0 0 0 11px;">Payment Hold</label>&nbsp;&nbsp;<input checked type="radio" id="delivery" name="payment_status" value="payment_hold" />
									<?php }else{?>
										<label style="padding: 0 0 0 11px;">Payment Hold</label>&nbsp;&nbsp;<input type="radio" id="delivery" name="payment_status" value="payment_hold" />

										<?php }if($obj->getFun16()=='payment_payable'){?>
									<label style="padding: 0 0 0 11px;">Payment Payable</label>&nbsp;&nbsp;<input checked type="radio" id="delivery" name="payment_status" value="payment_payable" />
									<?php }else{?>
										<label style="padding: 0 0 0 11px;">Payment Payable</label>&nbsp;&nbsp;&nbsp;<input type="radio" id="delivery" name="payment_status" value="payment_payable" />
										<?php } ?>
							
								<?php } ?>
									</h4>
							 </div>
						</div>
						<div class="row" style="padding-right:10px; padding-left:10px; margin-bottom:50px;">
							 <div class="col-xs-12" style="margin-bottom:30px; text-align:center;">
							 <input type="hidden" name="txtStatus" id="txtStatus" value="" />
								<?php 
								$rec = 1;
								if(($rec==0 && $creator==1) || (($obj->getFun10()==0 || $obj->getFun10()==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 getValidate(0);">Submit to edit</button>&nbsp;&nbsp;
											<button type="submit" class="btn btn-warning btn-flat" onClick="return getValidate(<?=$status;?>);">Send for Approval</button>
									  <?php }else if($rec>0 && ($obj->getFun10()==1 || $obj->getFun10()==4) && $approver1 == 1){
												 if(empty($approverarr2)){$status = 5;}
												 else{$status = 3;}
										   ?>
											<button type="submit" class="btn btn-primary btn-flat" onClick="return getValidate(2);">Send for Review</button>&nbsp;&nbsp;
											<button type="submit" class="btn btn-warning btn-flat" onClick="return getValidate(<?=$status;?>);">Submit & Approve</button>
									  <?php }else if($rec>0 && $obj->getFun10()==3 && $approver2 == 1){
											   if(empty($approverarr1)){$status = 2;}
											   else{$status = 4;}
									  ?>
											<button type="submit" class="btn btn-primary btn-flat" onClick="return getValidate(<?=$status;?>);">Send for Review</button>&nbsp;&nbsp;
											<button type="submit" class="btn btn-warning btn-flat" onClick="return getValidate(5);">Submit & Approve</button>
									  <?php }else if($rec>0 && $obj->getFun10()==5 && $accounts == 1){
											   if(empty($approverarr1)){$status = 2;}
											   else{$status = 5;}
									  ?>
											<button type="submit" class="btn btn-warning btn-flat" onClick="return getValidate(6);">Approve </button>
									  <?php }?>
								<input type="hidden" name="action" id="action" value="submit" />
								   
									<input type="hidden" name="txtCRMFILE" id="txtCRMFILE" value="" />
									 <input type="hidden" name="txtCRMNAME" id="txtCRMNAME" value="" />

									 <input type="hidden" name="txtCRMFILEGrid" id="txtCRMFILEGrid" value="" />
									 <input type="hidden" name="txtCRMNAMEGrid" id="txtCRMNAMEGrid" value="" />

									<input type="hidden" name="txtrowcount" id="txtrowcount" value="<?=$sno;?>" /> 
							 </div>
						 </div>
						 <div class="row" style="padding-right:10px; padding-left:10px; margin-bottom:50px;">
						 <div class="col-xs-4" margin-bottom:30px;></div>
						 </div>
						</form>
					</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/datetimepicker/bootstrap-datetimepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/plugins/datetimepicker/bootstrap-datetimepicker.min.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 src="https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $(".sidebar-toggle").click();
	$("#txtPaymentDate,#txtExchangeDate").datepicker({
		format: 'dd-mm-yyyy',
		autoclose: true
	});
	$("#selVendor").val('<?php echo $ven_name;?>');
	$("#selExchangeCurrency").val('<?php echo $exchng_curr;?>');
	$(".numeric").numeric();
	$("#selApprovers").chosen();
	$(".areasize").autosize({append: "\n"});

	$("#frm1").validate({
		rules: {
		
		},
	messages: {
		
		},
	submitHandler: function(form)  {
		    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;}
			});
		}
	});
	$('[id^=txtInvoiceDate_]').datepicker({
		format: 'dd-mm-yyyy',
		autoclose: true
	});
	getExchangeAmountCal();
});

function getString(var1)
{
  var var2 = var1.split('-');  
  return var2[2]+'/'+var2[1]+'/'+var2[0];
}


function getExchangeAmountCal()
{
    var estimatedtotal = 0;
	var actualtotal = 0;
	var actualexchangetotal = 0;
    if($("#selExchangeCurrency").val()!='')
	{
	    $("#curr_span").text($("#selExchangeCurrency").val());
		var exchangerate = parseFloat($("#txtExchangeRate").val());
		if(isNaN(exchangerate)){exchangerate = 1;}
		var txtrowcount = $("#txtrowcount").val();
		for(var chkvalue=1;chkvalue <=txtrowcount;chkvalue++)
		{
			var txtEstimatedAmt = parseFloat($("#txtEstimatedAmt_"+chkvalue).val());
			if(isNaN(txtEstimatedAmt)){txtEstimatedAmt = 0;}
			
			var txtActualAmt = parseFloat($("#txtActualAmt_"+chkvalue).val());
			if(isNaN(txtActualAmt)){txtActualAmt = 0;}
			
			var txtActualExchangeAmt = parseFloat(txtActualAmt)*parseFloat(exchangerate);
			if(isNaN(txtActualExchangeAmt)){txtActualExchangeAmt = 0;}
			$("#txtActualExchangeAmt_"+chkvalue).val(txtActualExchangeAmt.toFixed(2));
			
			estimatedtotal = parseFloat(estimatedtotal) + parseFloat(txtEstimatedAmt);
			actualtotal = parseFloat(actualtotal) + parseFloat(txtActualAmt);
			actualexchangetotal = parseFloat(actualexchangetotal) + parseFloat(txtActualExchangeAmt);
		}
	}
	else
	{
		$("#curr_span").text('');
		var exchangerate = 0;
		var txtrowcount = $("#txtrowcount").val();
		for(var chkvalue=1;chkvalue <=txtrowcount;chkvalue++)
		{
			var txtEstimatedAmt = parseFloat($("#txtEstimatedAmt_"+chkvalue).val());
			if(isNaN(txtEstimatedAmt)){txtEstimatedAmt = 0;}
			
			var txtActualAmt = parseFloat($("#txtActualAmt_"+chkvalue).val());
			if(isNaN(txtActualAmt)){txtActualAmt = 0;}
			
			var txtActualExchangeAmt = parseFloat(txtActualAmt)*parseFloat(exchangerate);
			if(isNaN(txtActualExchangeAmt)){txtActualExchangeAmt = 0;}
			$("#txtActualExchangeAmt_"+chkvalue).val(txtActualExchangeAmt.toFixed(2));
			
			estimatedtotal = parseFloat(estimatedtotal) + parseFloat(txtEstimatedAmt);
			actualtotal = parseFloat(actualtotal) + parseFloat(txtActualAmt);
			actualexchangetotal = parseFloat(actualexchangetotal) + parseFloat(txtActualExchangeAmt);
		}
	}
	$("#txtTotalEstAmount").val(estimatedtotal.toFixed(2));
	$("#txtTotalAmount").val(actualtotal.toFixed(2));
	$("#txtTotalExAmount").val(actualexchangetotal.toFixed(2));
}

function getValidate(var1)
{
    $("#txtStatus").val(var1);
	var file_temp_name = $("[id^=file_]").map(function () {return this.value;}).get().join(",");
	$('#txtCRMFILE').val(file_temp_name);
	var file_actual_name = $("[id^=name_]").map(function () {return this.value;}).get().join(",");
	$('#txtCRMNAME').val(file_actual_name);


	// var file_temp_name_grid = $("[id^=fileGrid_]").map(function () {return this.value;}).get().join(",");
	// $('#txtCRMFILEGrid').val(file_temp_name_grid);
	// var file_actual_name_grid = $("[id^=nameGrid_]").map(function () {return this.value;}).get().join(",");
	// $('#txtCRMNAMEGrid').val(file_actual_name_grid);




	
	if($('#txtStatus').val()==1)
	{   
	    if($('#selApprovers').val()==null || $('#selApprovers').val()=='')
		{
		    jAlert('Please select Level 1 Approvers first.', 'Alert');
			return false;
		}
		else
		{
		    jConfirm('Are you sure you want to create Combined SOA?', 'Confirmation', function(r) {
			if(r){
				return true
			}
			else{return false;}
			});
		}
	}
}
 
 
function Del_Upload(var1)
{
	jConfirm('Are you sure you want to remove this attachment permanently ?', 'Confirmation', function(r) {
	if(r){
			$("#row_file_"+var1).remove();	
		 }
	else{return false;}
	});
}

function Del_UploadOfGrid(elx)
{

	jConfirm('Are you sure you want to remove this attachment permanently ?', 'Confirmation', function(r) {
	if(r){
			$(elx).parent().parent().remove();	
			$(elx).parent().parent().prev().val(parseInt($(elx).parent().parent().prev().val())-parseInt(1))
		 }
	else{return false;}
	});
}






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