<? global $vis_language;?>
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <? if($invoice['vis_invoice_id'] != 0): ?>	
            <h4 class="modal-title"><? echo $vis_language['TXTAPPLYCREDIT']; ?></h4>
            <? else: ?>
            <h4 class="modal-title"><? echo $vis_language['TXTADDBALANCE']; ?></h4>
            <? endif; ?>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="col-sm-12">
                    <form role="form" class="form-horizontal" name="vis_add_balance_form" id="vis_add_balance_form">
					<div class="form-group">	
					<? if($invoice['vis_invoice_id'] != 0): ?>	
					<label class="col-sm-3 control-label"><?= $vis_language['TXTAVAILABLECREDIT'].' ('.$domain['currency'].')'; ?></label>
					<div class="col-sm-9">
						<input class="form-control input-sm" type="text" name="vis_available_credit" id="vis_available_credit" value="<?php echo $invoice['available_credit']; ?>" readonly>
					</div>	
					<? else: ?>
						<label class="col-sm-3 control-label"><?= $vis_language['TXTCREDITTYPE']; ?></label>
						<div class="col-sm-9">
							<div class="radio i-checks pull-left m-r-lg">
							<label>
								<input type="radio" name="vis_type" id="vis_type_in" value="0" checked="checked"><i></i>
								<? echo $vis_language['TXTCASHBAL']; ?>
							</label></div>
							<div class="radio i-checks pull-left">
							<label>
								<input type="radio" id="vis_type_ex" name="vis_type" value="1" ><i></i>
								<? echo $vis_language['TXTTKTBAl']; ?>
							</label></div>	
						</div>	
					<? endif; ?>
					</div>
					<div class="form-group" id="vis_show_ticket_balance" style="display:none;">
					<label class="col-sm-3 control-label"><?= $vis_language['TXTTKTBAl']; ?></label>
					<div class="col-sm-9">
						<input class="form-control input-sm" type="text" name="vis_ticket" id="vis_ticket" value="0">
					</div>	
				</div>
                        <div class="form-group" id="vis_show_amt_balance">
                            <label class="col-sm-3 control-label txt_nowrap"><?= $vis_language['TXTAMOUNT'].' ('.$domain['currency'].')'; ?></label>
                            <div class="col-sm-9">
                                <input class="form-control input-sm" type="text" name="vis_balance" id="vis_balance" value="<?php echo $invoice['amount']; ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><?= $vis_language['TXTDETAILS']; ?></label>
                            <div class="col-sm-9">
                                <textarea class="form-control input-sm" name="vis_details" id="vis_details"><?php echo $invoice['details']; ?></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label txt_nowrap"><?= $vis_language['TXTTRANSACTIONID']; ?></label>
                            <div class="col-sm-9">
                                <input class="form-control input-sm" type="text" name="vis_transaction" id="vis_transaction" value="">
                                <input type="hidden" name="vis_client_id" value="<? echo $operation['vis_client_id']; ?>" />
                                <?php if($invoice['vis_invoice_id']!=0) echo '<input type="hidden" name="vis_invoice_id" value="'.$operation['vis_invoice_id'].'" /> <input type="hidden" name="vis_remaining_bal" value="'.$invoice_det[0]['balance'].'">' ?>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="modal-footer">
			<a class="btn btn-default" data-dismiss="modal"><? echo $vis_language['TXTCANCEL']; ?></a>
            <a class="btn btn-primary" onclick="$(this).visExecution('submit_form',{'vis_module':'billing', 'vis_operation':'create_balance', 'vis_form':'vis_add_balance_form'});"><? echo $vis_language['TXTOK']; ?></a>
        </div>
    </div>
</div>
<script>
$("#vis_type_in").change( function(){ $("#vis_show_ticket_balance").hide(); });
	$("#vis_type_ex").change( function(){ $("#vis_show_ticket_balance").show(); });
	$("#vis_type_in").change( function(){ $("#vis_show_amt_balance").show(); });
	$("#vis_type_ex").change( function(){ $("#vis_show_amt_balance").hide(); });
</script>
