<?php

//////////////////////////////////////////////////////////////
//===========================================================
// edittransaction_theme.php
//===========================================================
// SOFTACULOUS VIRTUALIZOR
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       8th Mar 2010
// Time:       23:00 hrs
// Site:       https://www.virtualizor.com/ (SOFTACULOUS VIRTUALIZOR)
// ----------------------------------------------------------
// Please Read the Terms of use at https://www.virtualizor.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('VIRTUALIZOR')){

	die('Hacking Attempt');

}

function edittransaction_theme(){

global $theme, $l, $globals, $kernel, $user, $error, $done, $users, $tranx;

softheader($l['<title>']);
					
$GLOBALS['breadcrumbs'] = ['dashboard', 'transactions', 'lms_edittransaction'];

echo page_header(__('Edit Transaction'), 'fas fa-credit-card', '', 1, 0);

error_handle($error);

if(!empty($done)){
	show_alert(__('The Transaction has been edited. Return to <a href="index.php?act=transactions">Transactions Overview</a>'));
}

echo '
<div id="form-container" class="card p-2 mx-3">
	<form accept-charset="'.$globals['charset'].'" name="edittransaction" method="post" action="" class="form-horizontal">
		<div class="row mx-auto w-100 my-3">
			<div class="col-sm-12 col-md-6 col-lg-6">
			<label class="control-label">'.__('Select User').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Select the user the invoice belongs to').'"><i class="fas text-primary fa-info-circle"></i></a></label><br>
				<select class="custom-select" name="uid" id="uid">
				<option value="0" '.(POSTval('uid') == 0 ? 'selected="selected"' : '').'>'.__('Select User').'</option>';	
				foreach($users as $k => $v){		 
					echo '<option value="'.$k.'" '.POSTselect('uid', $k, $k == $tranx['uid']).'>'.$v['email'].'</option>';
				}
		
			echo '</select>
			</div>
			<div class="col-sm-12 col-md-6 col-lg-6">
				<label class="control-label">'.__('Date').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Effective Transaction Date').'"><i class="fas text-primary fa-info-circle"></i></a></label><br>
				
				<div class="input-group ">
				<input type="text" class="form-control" placeholder="DD/MM/YYYY" name="date" id="date" size="30" value="'.POSTval('date', datetime($tranx['date'])).'" />
				<div class="input-group-append">
					<a class="input-group-text" onclick="$_(\'date\').value=\''.datify(time(), 0, 1, 'd/m/Y').'\'" tooltip="'.__('Today').'" /><i class="fas fa-calendar-week"></i></a>
				</div>
				</div>	
				
			</div>
		</div>
		<div class="row mx-auto w-100 my-3">
			<div class="col-sm-12 col-md-6 col-lg-6">
				<label class="control-label">'.__('Time').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Time of transaction').'"><i class="fas text-primary fa-info-circle"></i></a></label><br>
				
				<div class="input-group ">
				<input type="text" class="form-control" placeholder="HH:MM:SS" name="time" id="trtime" size="30" value="'.POSTval('time', datify($tranx['unixtime'], 0, 1, 'h:i:s')).'" />
				<div class="input-group-append">
					<a class="input-group-text" onclick="$_(\'trtime\').value=\''.datify(time(), 0, 1, 'h:i:s').'\'" tooltip="'.__('Now').'" /><i class="fas fa-clock"></i></a>
				</div>
				</div>
				
			</div>
			<div class="col-sm-12 col-md-6 col-lg-6">
				<label class="control-label">'.__('Gateway').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Payment gateway through which the transaction was done').'"><i class="fas text-primary fa-info-circle"></i></a></label><br><input type="text" class="form-control" name="gateway" id="gateway" value="'.POSTval('gateway', $tranx['gateway']).'" />
			</div>
		</div>
		<div class="row mx-auto w-100 my-3">
			<div class="col-sm-12 col-md-6 col-lg-6">
				<label class="control-label">'.__('Payment Token').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('(Optional) A reference to the payment transaction').'"><i class="fas text-primary fa-info-circle"></i></a></label><br><input type="text" class="form-control" name="token" id="token" value="'.POSTval('token', $tranx['token']).'" />
				
			</div>
			<div class="col-sm-12 col-md-6 col-lg-6">
				<label class="control-label">'.__('Amount').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The Transaction Amount').'"><i class="fas text-primary fa-info-circle"></i></a></label><br><input type="text" class="form-control" name="amt" id="amt" value="'.POSTval('amt', $tranx['amt']).'" onchange="calc_net()" onchange="calc_net()" />
			</div>
			
		</div>
		<div class="row mx-auto w-100 my-3">
			<div class="col-sm-12 col-md-6 col-lg-6">
				<label class="control-label">'.__('Fees').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('(Optional) Fees charged by the Gateway').'"><i class="fas text-primary fa-info-circle"></i></a></label><br><input type="text" class="form-control" name="fees" id="fees" value="'.POSTval('fees', $tranx['fees']).'" onchange="calc_net()" />
			</div>
			<div class="col-sm-12 col-md-6 col-lg-6">
				<label class="control-label">'.__('Net Amount').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('The net amount received').'"><i class="fas text-primary fa-info-circle"></i></a></label><br>
				<input type="text" disabled="disabled" class="form-control" name="net" id="net" value="" />
			</div>
		</div>
		<br /><br />
		<center>
			<input type="submit" class="go_btn" name="edittransaction" value="'.__('Submit').'">
		</center>
	</form>

	<script language="javascript" type="text/javascript">
		
		function calc_net(){
			var amt = parseFloat($_("amt").value);
			var fees = parseFloat($_("fees").value);
			if(amt > 0){
				$_("net").value = amt - (fees > 0 ? fees : 0);
			}
		};

		calc_net();
	</script>
</div>';

softfooter();

}
