<script>


function validation(url){
if($('#supp_name').val()==""){
	$('#supp_name').focus();
	return false;
	}else{
	dosubmit(url)
	}
				
}
</script>

<div id="adj_qty"></div>
	<input type="hidden" name="outlet_autoid" id="outlet_autoid" value="<?php echo $user_outlet?>">
	<input type="hidden" class="input prevent_key" style="width:100px" name="transno" id="transno" value="<?php echo $transno?>">
    
<div class="row pb-3">
	<div class="col-sm-12">
    <div>
    	<?php if($act=="delete"){?>
    	<h5 class="ml-2 my-0 text text-danger">Hapus Jurnal</h5>
        <?php } if($act=="post"){?>
    	<h5 class="ml-2 my-0 text text-success">Posting Jurnal</h5>        
        <?php } ?>
	</div>
		<div class="px-3 py-2">
		<table class="table table-sm table-border">
    	<tr>
		<td style="width:90px" class="tl">Journal No
        </td>
		<td style="width:10px" class="tc">:</td>
		<td style="width:200px"><?php echo ($transno)?></td>
		<td style="width:90px" class="tl">Journal Date</td>
		<td style="width:10px" class="tc">:</td>
		<td style="width:200px"><?php echo $transdate?></td>
	</tr>
	<tr>
		<td class="tl">Voucher No</td>
		<td class="tc">:</td>
		<td><?php echo $vcno?></td>
		<td class="tl">Voucher Date</td>
		<td class="tc">:</td>
		<td><?php echo $vcdate?></td>
	</tr>
	<tr>
		<td class="tl">Catatan</td>
		<td class="tc">:</td>
		<td colspan="4" class="tl">
			<?php echo $jt_notes?>

		</td>
	</tr>
    </table>

		</div>
	</div>
    




<div class="col-sm-12 pl-3">
	<div id="jtdetail" style="overflow-y:scroll;height:300px">
    <table class="table table-sm table-border w-100">
<thead>
<tr class="thead" style="background-color:#333;color:white">
	<td class="tl" style="width:80px;">VC No</td>
    <td class="tl" style="width:80px;">VC Date</td>
	<td class="tl" style="width:250px;">Chart of Account</td>
    <td class="tr" style="width:120px;">Debet</td>
	<td class="tr" style="width:120px">Credit</td>
	<td class="tc" style="width:130px">Catatan</td>
	<td style="width:20px"></td>
</tr>
</thead>
<?php
$x = 0;
$tdebit = 0;
$tcredit = 0;
$sqld = "select * from jtdetail WHERE jt_autoid = '$autoid' ORDER BY jtd_autoid DESC";
$dcon = $conn->query($sqld) or die($sqld);
while($rs= $dcon->fetch_assoc()){
	
	$jtd_autoid = $rs['jtd_autoid'];
	$coa_autoid_1 = $rs['coa_autoid'];
	$coa_autoid_2 = $rs['coa_autoid2'];
	if($x%2==0){
		$style = "background-color:#FFFDDF";
		}else{$style="background-color:white";}

?>
<tr class="tdetail" style="<?php echo ($style)?>">
	<td><?php echo $rs['jtd_vcno'];?> </td>
	<td><?php echo dtostr($rs['jtd_vcdate']);?></td>
	<td><?php echo $_coa_accno[$coa_autoid_1] . " - " .$_coa_accdesc[$coa_autoid_1]?></td>
	<td class="tr"><?php echo number_format($rs['jtd_debit']);?>&nbsp;</td>
	<td class="tr"><?php echo number_format($rs['jtd_credit']);?>&nbsp;</td>
    <td style="background-color:white" rowspan="2"><?php echo $rs['jtd_notes'];?></td>
	
	<td style="background-color:white" rowspan="2" class="tc">

    	<input type="hidden" id="coa<?php echo $jtd_autoid?>" value="<?php echo $rs[coa_autoid]?>"/>
		<input type="hidden" id="debet<?php echo $jtd_autoid?>" value="<?php echo $rs[jtd_debit]?>"/>
        <input type="hidden" id="credit<?php echo $jtd_autoid?>" value="<?php echo $rs[jtd_credit]?>"/>
        <input type="hidden" id="coadesc<?php echo $jtd_autoid?>" value="<?php echo $rs[coa_accdesc]?>"/>
        <input type="hidden" id="notes<?php echo $jtd_autoid?>" value="<?php echo $rs[jtd_notes]?>"/>
        <input type="hidden" id="vcno<?php echo $jtd_autoid?>" value="<?php echo $rs[jtd_vcno]?>"/>
        <input type="hidden" id="vcdate<?php echo $jtd_autoid?>" value="<?php echo dtostr($rs[jtd_vcdate])?>"/>
		<input type="hidden" id="ncoa<?php echo $jtd_autoid?>" value="<?php echo $rs[coa_autoid2]?>"/>
		<input type="hidden" id="ndebet<?php echo $jtd_autoid?>" value="<?php echo $rs['jtd_debit2']?>"/>
        <input type="hidden" id="ncredit<?php echo $jtd_autoid?>" value="<?php echo $rs['jtd_credit2']?>"/>
        <input type="hidden" id="ncoadesc<?php echo $jtd_autoid?>" value="<?php echo $coadesc?>"/>
    </td>
</tr>
<tr class="tdetail" style="<?php echo ($style)?>">
	<td><?php echo $rs['jtd_vcno'];?> </td>
	<td><?php echo dtostr($rs['jtd_vcdate']);?></td>
	<td><span style="margin-left:20px"></span><?php echo $_coa_accno[$coa_autoid_2] . " - " .$_coa_accdesc[$coa_autoid_2]?></td>
	<td class="tr"><?php echo number_format($rs['jtd_debit2']);?>&nbsp;</td>
	<td class="tr"><?php echo number_format($rs['jtd_credit2']);?>&nbsp;</td>
</tr>
<?php 
$tdebit = $tdebit + $rs['jtd_debit'] + $rs['jtd_debit2'];
$tcredit = $tcredit + $rs['jtd_credit']+ $rs['jtd_credit2'];
$x = $x+1;
}
$strdx = "select * from jtdetail where jt_autoid = '$autoid' order by jtd_autoid desc";
$dx_conn = $conn->query($strdx) or die($strdx);
$rdx = $dx_conn->fetch_assoc();
$njtdautoid = $rdx['jtd_autoid'];
$ncoaid 	= $rdx['coa_autoid'];

if($tdebit==$tcredit){
	$njtdautoid = "";
	$ncoaid = "";
	}
?>
<tr class="theader" style="background-color:#CCC;font-weight:bold;font-size:14px;">
	<td colspan="3" class="tr">Total : </td>
	<td class="tr"><?php echo number_format($tdebit)?>&nbsp;</td>
	<td class="tr"><?php echo number_format($tcredit)?>&nbsp;</td>
    <td></td>
	<td class="tr">
	</td>

</tr>
</table>

    
    </div>
</div> <!-- end col -->


</div>

	<input type="hidden" name="autoid" id="autoid" value="<?php echo $autoid?>">
	<input type="hidden" name="act" id="act" value="<?php echo $act?>">

