<?php 

function pm_add_payment_cb() {
	$invoice = new pm_invoice();
	$invoice->get_invoice_by_number($_GET['ref']);
	$user_meta = get_user_meta($invoice->invoice->user_id);
    $banks = pm_bank_accounts_option();
	$options = array_merge($banks, ["Cash Payment" => "Cash Payment", "Others" => "Others"]);
	?>
    <div class="row">
		<div class="col-md-6">
			<div class="card">
			    <div class="card-body">
			    	<?php do_action('drag_n_drop_uploader', ["ref" => "pop-".$invoice->invoice->invoice_number, "user_id" => $invoice->invoice->user_id, "accepts" => "image/*,application/pdf", "max_files" => 3]); 
			    		$token = new_token();
			    	?>
			      	<form id="new-payment-form" method="post" enctype="multipart/form-data" action="contents/plugins/payment_module/ajax.php" data-clearform=1>
						<input type="hidden" name="<?php echo SALT; ?>" id="salt" value="<?php echo $token; ?>">
			      		<input type="hidden" name="in_ref" id="in_ref" value="<?php echo $invoice->invoice->invoice_number ?>">
			      		<input type="hidden" name="user_id" id="user_id" value="<?php echo $invoice->invoice->user_id ?>">
			      		<?php 
			      			select(['label' => 'Mode of Payment', 'id' => 'mode', 'required' => 'required'], $options, "Cash Payment");
			      			input(['label' => 'Amount ('.get_option('default_currency').')', 'id' => 'amount', 'class' => 'form-control numbers-only', 'required' => 'required', 'value' => $invoice->total(true)]);
			      			submit_btn("add_payment", "Submit"); 
			      		?>
			      	</form>
			    </div>
			</div>
		</div>
	</div>
	<?php
	global $post_meta;
	add_page_javascript('app/assets/js/page-scripts/js-functions.js');
	add_page_javascript('app/assets/js/page-scripts/submit.js');
	add_page_javascript('app/assets/js/page-scripts/koweb.js');
}