<script>


function validation(url){
if($('#supp_name').val()==""){
	$('#supp_name').focus();
	return false;
	}else{
	dosubmit(url)
	}
				
}
function getdetail(action,detailid){

if(action==99){	
	$('#debet1').val($('#debet'+detailid).val());
	$('#credit1').val($('#credit'+detailid).val());
	$('#debet2').val($('#ndebet'+detailid).val());
	$('#credit2').val($('#ncredit'+detailid).val());
	$('#notes').val($('#notes'+detailid).val());
	$('#vcdate').val($('#vcdate'+detailid).val());
	$('#vcno').val($('#vcno'+detailid).val());
	$('#coaid').val($('#coa'+detailid).val()).trigger('chosen:updated');
	$('#coaid2').val($('#ncoa'+detailid).val()).trigger('chosen:updated');

}

	$.post('getdetail.php',{
		autoid:$('#autoid').val(),
		act:action,
		coa:$('#coaid').val(),
		vcno:$('#vcno').val(),
		vcdate:$('#vcdate').val(),
		debet:$('#debet1').val(),
		credit:$('#credit1').val(),
		debet2:$('#debet2').val(),
		credit2:$('#credit2').val(),
		coa2:$('#coaid2').val(),
		notes:$('#notes').val(),
		dautoid:detailid
		},function(data){
		
			$('#jtdetail').html(data);
		})


	}
function chk_acc1(){
	debet_1 = $('#debet1').val();
	debet_2 = $('#debet2').val();
	credit_1 = $('#credit1').val();
	credit_2 = $('#credit2').val();
	if(debet_1!=0){
		$('#credit2').val(debet_1);
		$('#credit1').val('');
		$('#debet2').val('');
		
		}

	if(credit_1!=0){
		$('#debet2').val(credit_1);
		$('#debet1').val('');
		$('#credit2').val('');
	}

	}
function chk_acc2(){
	debet_1 = $('#debet1').val();
	debet_2 = $('#debet2').val();
	credit_1 = $('#credit1').val();
	credit_2 = $('#credit2').val();
	
	if(debet_2!=0){
		
		$('#credit1').val(debet_2);
		$('#credit2').val('');
		$('#debet1').val('');
		}
	if(credit_2!=0){
		$('#debet1').val(credit_2);
		$('#debet2').val('');
		$('#credit1').val('');
		}	
	}

</script>
<style>
	.btn-blue{
		background-color:#069;
		color:white !important
		}
		
    .content_height{
		height:450px;
		overflow-y:scroll;
		}

</style>
<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 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"><input type="text" class="input" name="jt_no" value="<?php echo ($transno)?>"/></td>
		<td style="width:90px" class="tl">Journal Date</td>
		<td style="width:10px" class="tc">:</td>
		<td style="width:200px"><input type="text" class="input" name="jt_date" value="<?php echo $transdate?>"/>*dd/mm/yyyy</td>
	</tr>
	<tr>
		<td class="tl">Voucher No</td>
		<td class="tc">:</td>
		<td ><input type="text" name="jt_vcno" id="vcno" class="input" value="<?php echo $vcno?>"/></td>
		<td class="tl">Voucher Date</td>
		<td class="tc">:</td>
		<td><input type="text" name="jt_vcdate" id="vcdate" class="input" value="<?php echo $vcdate?>" autocomplete="off"/>*dd/mm/yyyy</td>
	</tr>
	<tr>
	<td class="tl">C O A I</td>
	<td class="tc">:</td>
	<td colspan="4">		
            <select id="coaid" class="form-control" style="width:90%;" tabindex="2">
			<?php 
				$sqlb = mysqli_query($conn,"select * from mst_coa order by coa_accno");
					  while($rs=mysqli_fetch_array($sqlb)) {;
					  $lvl = $rs["coa_acclvl"];
					  $type = $rs["coa_acctype"];
					  $coa_autoid = $rs['coa_autoid'];
					  $coa_accno = $rs['coa_accno'];
					  $coa_accdesc = $rs['coa_accdesc'];
			?>
					  <option value="<?php echo $coa_autoid?>"><?php echo $coa_accno?> - <?php echo $coa_accdesc?></option>
			<?php } ?>
			</select>


	</td>
	</tr>
	<tr style="display:none">
		<td class="tl">Debet</td>
		<td class="tc">:</td>
		<td>
			<input type="text" class="input tr" id="debet1" onkeyup="chk_acc1()" value=""/></td>
		<td class="tl">Credit</td>
		<td class="tc">:</td>
		<td>
			<input type="text" class="input tr" id="credit1" onkeyup="chk_acc1()" value=""/></td>
	</tr>
	<tr>
	<td class="tl">C O A II</td>
	<td class="tc">:</td>
	<td colspan="4">		
                    <select id="coaid2" class="form-control" style="width:90%;" tabindex="2">
			<?php 
				$sqlb = mysqli_query($conn,"select * from mst_coa order by coa_accno");
					  while($rs=mysqli_fetch_array($sqlb)) {;
					  $lvl = $rs["coa_acclvl"];
					  $type = $rs["coa_acctype"];
					  $coa_autoid = $rs['coa_autoid'];
					  $coa_accno = $rs['coa_accno'];
					  $coa_accdesc = $rs['coa_accdesc'];
			?>
					  <option value="<?php echo $coa_autoid?>"><?php echo $coa_accno?> - <?php echo $coa_accdesc?></option>
			<?php } ?>
			</select>

        
	</td>
</tr>	
	<tr>
		<td class="tl">Debet</td>
		<td class="tc">:</td>
		<td>
			<input type="text" class="input tr" id="debet2" onkeyup="chk_acc2()" value=""/></td>
		<td class="tl">Credit</td>
		<td class="tc">:</td>
		<td>
			<input type="text" class="input tr" id="credit2" onkeyup="chk_acc2()" value=""/></td>
	</tr>
	<tr>
		<td class="tl">Catatan</td>
		<td class="tc">:</td>
		<td colspan="4" class="tl">
			<input type="text" name="jt_notes" id="notes" class="input" value="<?php echo $jt_notes?>" style="width:70%"/>	
		<input type="button" class="btn btn-success btn-sm" value="Input" onclick="getdetail('1');"/>
		</td>
	</tr>
    </table>

		</div>
	</div>
    




<div class="col-sm-12 pl-3">
	<div id="jtdetail" style="overflow-y:scroll;height:300px"></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?>">

