<?php
include("finance_func.php");
$hddnFinanceId = $_SESSION['caller']['args'][1];
if ($_SESSION['user']['access_level'] < SABLE_ACCESS_MANAGER)
{
	SableGeneralFunctions::divertFromPage();
}
$row = $sableDB->getRow("select * from finance where finance_id = ".$hddnFinanceId);
$selClientId  = $sableDB->getValue("select concat(client_name, ' ', client_surname) from `client` 
									where client_id = '".$row["client_id"]."'");
$selTxnTypeId  = $sableDB->getValue("select txn_type_name from `txn_type` where txn_type_id = '".$row["txn_type_id"]."'");
$selPmId  = $sableDB->getValue("select pm_name from `payment_method` where pm_id = '".$row["pm_id"]."'");
$selBsId  = $sableDB->getValue("select booking_time from `booking_schedule` where bs_id = '".$row["bs_id"]."'");

$txnDate = new DateTime($row['txn_date']);
?>
<script src="<?php SableGeneralFunctions::printModuleJS('finance'); ?>"></script>

<!--// Finance -->
<form id="frmFinance" name="frmFinance" autocomplete="on">
	<input type="hidden" value="<?php echo(SableSystem::sableEncode($hddnFinanceId)); ?>" id="hddnFinanceId" name="hddnFinanceId" />
	<div class="forms">
		<div class="container forms-grids">
			<div class="row forms-grid">
				<div class="col-md-12">
					<h3 class="title"><i class="fa fa-eye" aria-hidden="true"></i>&nbsp;View Finance</h3>
					<p></p>
				</div>
			</div>
			<!--// edtTxnDate -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<input name="edtTxnDate" type="date" id="edtTxnDate" readonly value="<?= $txnDate->format('Y-m-d'); ?>" >
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_edtTxnDate">Txn Date</div>
				</div>
			</div>
			<p></p>
			<!-- edtTxnDate //-->
			<p></p>
			<!--// selClientId -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<input name="selClientId" type="text" id="selClientId"readonly value="<?php echo($selClientId); ?>" >
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_selClientId">Client</div>
				</div>
			</div>
			<p></p>
			<!-- selClientId //-->
			<p></p>
			<!--// selTxnTypeId -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<input name="selTxnTypeId" type="text" id="selTxnTypeId"readonly value="<?php echo($selTxnTypeId); ?>" >
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_selTxnTypeId">Transaction Type</div>
				</div>
			</div>
			<p></p>
			<!-- selTxnTypeId //-->
			<p></p>
			<!--// selPmId -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<input name="selPmId" type="text" id="selPmId"readonly value="<?php echo($selPmId); ?>" >
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_selPmId">Pay Method</div>
				</div>
			</div>
			<p></p>
			<!-- selPmId //-->
			<p></p>
			<!--// edtTxnAmount -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<input name="edtTxnAmount" type="text" id="edtTxnAmount" class="mod" readonly 
						   value="R<?php echo(number_format($row['txn_amount'], 2)); ?>" >
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_edtTxnAmount">Amount</div>
				</div>
			</div>
			<p></p>
			<!-- edtTxnAmount //-->
			<p></p>
			<!--// cbTxnPaid -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<?php $cbTxnPaid = $row['txn_paid']?"Yes":"No"; ?>
					<input name="cbTxnPaid" type="text" id="cbTxnPaid"readonly value="<?php echo($cbTxnPaid); ?>" >
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_cbTxnPaid">Txn Paid</div>
				</div>
			</div>
			<p></p>
			<!-- cbTxnPaid //-->
			<p></p>
			<!--// txtTxnNotes -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
			<textarea name="txtTxnNotes" type="textarea" id="txtTxnNotes" 
readonly><?php echo($row['txn_notes'])?></textarea>
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_txtTxnNotes">Notes</div>
				</div>
			</div>
			<p></p>
			<!-- txtTxnNotes //-->
			<p></p>
			<!--// selBsId -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<input name="selBsId" type="text" id="selBsId"readonly value="<?php echo($selBsId); ?>" >
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_selBsId">Booking Schedule</div>
				</div>
			</div>
			<p></p>
			<!-- selBsId //-->
			<p></p>
		<!--// buttons -->
			<div class="row forms-grid">
				<div class="col-md-2">
					<input type="button" id="btnCancel" value="Cancel"
					class="submit" onclick="window.location = '<?php SableSystem::printCallPageLink('/finance/'); ?>'"/>
				</div>
				<div class="col-md-2 forms-grid">
					<input id="btnOk" type="button" onclick="editFinance('<?php echo(SableSystem::sableEncode($hddnFinanceId)); ?>')" value="Modify Finance" class="submit"/>
				</div>
			</div>
		<!-- buttons //-->
		</div>
	</div>
</form>
<!-- Finance //-->
