
<script type="text/javascript">


var element_id=null;
var back_data=null;
var installment=null;
var commission=null;

function getId(elem){


	$('#'+elem.id).html(back_data);
	back_data=null;

}

function show_approve_selected(obj,event,elementClassName){

var elemnt = "."+elementClassName;
    if($(obj).is(':checked')){
        $(elemnt).find("input").each(function(){
            $(this).prop('disabled',false);
        });
        $(elemnt).find("select").prop('disabled',false);
        $('.approve_button').prop('disabled',false);
    }
    else{
        $(elemnt).find("input").not("[type=checkbox]").each(function(){
            $(this).prop('disabled',true);
        });
        $(elemnt).find("select").prop('disabled',true);
    }



    if($('.checkbox_transaction:checked').length === 0){

        $('.approve_button').prop('disabled',true);
    }

    

    
    
}

//GET THE DROP DOWN USER LIST BY TYPE
function userList(elem){

	var usertype = elem.id;

	var option=$('#'+usertype).val();

	var route = null;
	route="<?php echo e(url('/userlist')); ?>/"+option;

	$.get(route,function(data,status){
		back_data=data.view;
	});

}

//GET THE DROP DOWN SUB HEAD USER LIST BY HEAD
function headDb(elem,subheaddb){
var option=$('#'+elem.id).val();

	var route = null;
	route="<?php echo e(url('vouchersubheadlist')); ?>/"+option;

	$.get(route,function(data,status){



		$('#'+subheaddb).html(data);

	});


}
function headCr(elem,subheadcr){
var option=$('#'+elem.id).val();
	var route = null;
	route="<?php echo e(url('vouchersubheadlist')); ?>/"+option;

	$.get(route,function(data,status){

		$('#'+subheadcr).html(data);

	});

}



	function payment_type(elem,commission,installment){


	var option=$('#'+elem.id).val();
			var route = null;


	if(option =="Installment"){

		if(VOUCHER_ID == null){

			$('#installment_dropdown_'+'<?php echo e($voucher_id); ?>').show();
			$('#commission_dropdown_'+'<?php echo e($voucher_id); ?>').hide();
			$('#amount_field_'+'<?php echo e($voucher_id); ?>').show();

		}
		if(VOUCHER_ID != null){

			$('#installment_dropdown_'+'<?php echo e($voucher_id); ?>'+VOUCHER_ID).show();
			$('#commission_dropdown_'+'<?php echo e($voucher_id); ?>'+VOUCHER_ID).hide();
			$('#amount_field_'+'<?php echo e($voucher_id); ?>'+VOUCHER_ID).show();

		}


		route="<?php echo e(url('voucherinstallments')); ?>/"+booking_id;

		$.get(route,function(data,status){
			$('#'+installment).html(data);




	});

	}

	if(option =="Commission"){
		if(VOUCHER_ID == null){
			$('#commission_dropdown_'+'<?php echo e($voucher_id); ?>').show();
			$('#installment_dropdown_'+'<?php echo e($voucher_id); ?>').hide();
			$('#amount_field_'+'<?php echo e($voucher_id); ?>').show();

		}
		if(VOUCHER_ID != null){
			$('#commission_dropdown_'+'<?php echo e($voucher_id); ?>'+VOUCHER_ID).show();
			$('#installment_dropdown_'+'<?php echo e($voucher_id); ?>'+VOUCHER_ID).hide();
			$('#amount_field_'+'<?php echo e($voucher_id); ?>'+VOUCHER_ID).show();

		}
	route="<?php echo e(url('vouchercommission')); ?>/"+booking_id;

	$.get(route,function(data,status){

			$('#'+commission).html(data);
	});


	}
}



var booking_id=null;


// GET INSTALLMENTS BY SELECTING BOOKING
function booking(elem){
	booking_id = elem.id;
	booking_id = $('#'+booking_id).val();


}
// GET AMOUNT BY SELECTING INSTALLMENT

function installmentAmount(elem,amount){

var id=$('#'+elem.id).val();
	var route = null;
	route="<?php echo e(url('voucherinstallmentamount')); ?>/"+id;



	$.get(route,function(data,status){
		$('#'+amount).val(data);

	});

}



// GET AMOUNT BY SELECTING COMMISSION
function commissionAmount(elem,amount){
var id=$('#'+elem.id).val();

	var route = null;
	route="<?php echo e(url('vouchercommissionamount')); ?>/"+id;
	$.get(route,function(data,status){

		$('#'+amount).val(data);
	});

}





</script>
<script>
	// CREATE MULTIPLE VOUCHER
var add=0;
var vocuherId=null;
$(document.body).on('click','#add',function(event){
	++add;


});
	//ON CLICK GET ID
 var VOUCHER_ID=null;
function getGvVocuherId(elem,key_element){

    var voucher_type = $('select[name=voucher_list]').val();


	var curr_branch = $('.branch_curr').val();
	++add;
	var id = elem.id;
	id =id + add;
	var route = null;
	VOUCHER_ID=id;
	route="<?php echo e(url('vouchergvsethtml')); ?>/"+curr_branch+'/'+voucher_type;

	$.get(route,function(data,status){

		$("#view_data").append(data);

		$('#installment_dropdown_'+'<?php echo e($voucher_id); ?>'+id).hide();
		$('#commission_dropdown_'+'<?php echo e($voucher_id); ?>'+id).hide();
		$('#amount_field_'+'<?php echo e($voucher_id); ?>'+id).hide();
	});

	changePaymentMode();
}
function removeGvVoucher(elem){

	 $('.gv_full_'+elem.id).remove();
}
function getCrVocuherId(elem){

	var curr_branch = $('.branch_curr').val();
    var voucher_type = $('select[name=voucher_list]').val();


	++add;
	var id = elem.id;
	id =id + add;
		VOUCHER_ID=id;
	var route = null;
	route="<?php echo e(url('vouchercrvsethtml')); ?>/"+curr_branch+'/'+voucher_type;;
	$.get(route,function(data,status){

	$("#view_data").append(data);

			$('#installment_dropdown_'+'<?php echo e($voucher_id); ?>'+id).hide();
			$('#commission_dropdown_'+'<?php echo e($voucher_id); ?>'+id).hide();
			$('#amount_field_'+'<?php echo e($voucher_id); ?>'+id).hide();


	});
	changePaymentMode();


}
function removeCrVoucher(elem){

	 $('.crv_full_'+elem.id).remove();
}
function getDbVocuherId(elem){

	var curr_branch = $('.branch_curr').val();
    var voucher_type = $('select[name=voucher_list]').val();


	++add;
	var id = elem.id;
	id =id + add;
		VOUCHER_ID=id;
	var route = null;
	route="<?php echo e(url('voucherdbsethtml')); ?>/"+curr_branch+'/'+voucher_type;;

	$.get(route,function(data,status){

	$("#view_data").append(data);
			$('#installment_dropdown_'+'<?php echo e($voucher_id); ?>'+id).hide();
			$('#commission_dropdown_'+'<?php echo e($voucher_id); ?>'+id).hide();
			$('#amount_field_'+'<?php echo e($voucher_id); ?>'+id).hide();


	});
	changePaymentMode();

}
function removeDbVoucher(elem){

	 $('.db_full_'+elem.id).remove();
}

function getJorunalById(elem){
	var id = elem.id;

	var route = null;
	route="<?php echo e(url('voucherapprove')); ?>/"+id;

	$.get(route,function(data,status){


	 $("#journal_view").html(data);

	    $('#transaction_id').val(elem.id);
		var id= $('#voucher_journal_id').html();
		$(".id").hide();
	    $('#journal_id').val(id);



	});
}



</script>


<?php /**PATH /var/www/skylite/resources/views/scripts/voucher.blade.php ENDPATH**/ ?>