Change UI and code payment gateway audit

This commit is contained in:
Ibnu Maksum 2024-08-07 09:51:37 +07:00
parent cf04a50c35
commit 3c218d9ec9
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
4 changed files with 127 additions and 97 deletions

View File

@ -259,16 +259,4 @@ class Lang
} }
} }
// echo Json array to text
public static function jsonArray2text($array, $start = '', $result = '')
{
foreach ($array as $k => $v) {
if (is_array($v)) {
$result .= self::jsonArray2text($v, "$start$k.", '');
} else {
$result .= "$start$k = " . strval($v) . "\n";
}
}
return $result;
}
} }

View File

@ -83,4 +83,30 @@ class Text
return $datalimit; return $datalimit;
} }
} }
// echo Json array to text
public static function jsonArray2text($array, $start = '', $result = '')
{
foreach ($array as $k => $v) {
if (is_array($v)) {
$result .= self::jsonArray2text($v, "$start$k.", '');
} else {
$result .= "$start$k = " . strval($v) . "\n";
}
}
return $result;
}
public static function jsonArray21Array($array){
$text = self::jsonArray2text($array);
$lines = explode("\n", $text);
$result = [];
foreach($lines as $line){
$parts = explode(' = ', $line);
if(count($parts) == 2){
$result[trim($parts[0])] = trim($parts[1]);
}
}
return $result;
}
} }

View File

@ -10,16 +10,15 @@ $ui->assign('_system_menu', 'paymentgateway');
$action = alphanumeric($routes[1]); $action = alphanumeric($routes[1]);
$ui->assign('_admin', $admin); $ui->assign('_admin', $admin);
switch ($action) {
if ($action == 'delete') { case 'delete':
$pg = alphanumeric($routes[2]); $pg = alphanumeric($routes[2]);
if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $pg . '.php')) { if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $pg . '.php')) {
deleteFile($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR, $pg); deleteFile($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR, $pg);
} }
r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted')); r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted'));
}
if ($action == 'audit') { case 'audit':
$pg = alphanumeric($routes[2]); $pg = alphanumeric($routes[2]);
$q = alphanumeric(_req('q'), '-._ '); $q = alphanumeric(_req('q'), '-._ ');
$query = ORM::for_table('tbl_payment_gateway')->order_by_desc("id"); $query = ORM::for_table('tbl_payment_gateway')->order_by_desc("id");
@ -36,19 +35,17 @@ if ($action == 'audit') {
$ui->assign('pg', $pg); $ui->assign('pg', $pg);
$ui->assign('q', $q); $ui->assign('q', $q);
$ui->display('paymentgateway-audit.tpl'); $ui->display('paymentgateway-audit.tpl');
die(); break;
} case 'auditview':
if ($action == 'auditview') {
$pg = alphanumeric($routes[2]); $pg = alphanumeric($routes[2]);
$d = ORM::for_table('tbl_payment_gateway')->find_one($pg); $d = ORM::for_table('tbl_payment_gateway')->find_one($pg);
$d['pg_request'] = (!empty($d['pg_request']))? Text::jsonArray21Array(json_decode($d['pg_request'], true)) : [];
$d['pg_paid_response'] = (!empty($d['pg_paid_response']))? Text::jsonArray21Array(json_decode($d['pg_paid_response'], true)) : [];
$ui->assign('_title', 'Payment Gateway Audit View'); $ui->assign('_title', 'Payment Gateway Audit View');
$ui->assign('pg', $d); $ui->assign('pg', $d);
$ui->display('paymentgateway-audit-view.tpl'); $ui->display('paymentgateway-audit-view.tpl');
die(); break;
} default:
if (_post('save') == 'actives') { if (_post('save') == 'actives') {
$pgs = ''; $pgs = '';
if (is_array($_POST['pgs'])) { if (is_array($_POST['pgs'])) {
@ -98,6 +95,7 @@ if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php'))
$ui->display('paymentgateway.tpl'); $ui->display('paymentgateway.tpl');
} }
} }
}
function deleteFile($path, $name) function deleteFile($path, $name)

View File

@ -67,13 +67,31 @@
<div class="panel-heading"> <div class="panel-heading">
Response when request payment Response when request payment
</div> </div>
<pre class="panel-body p-1">{if $pg['pg_request'] != null}{Lang::jsonArray2text(json_decode($pg['pg_request'], true))}{/if}</pre> <div class="table-responsive">
<table class="table table-bordered table-striped table-condensed">
{foreach $pg['pg_request'] as $k => $v}
<tr>
<td>{$k}</td>
<td>{$v}</td>
</tr>
{/foreach}
</table>
</div>
</div> </div>
<div class="panel panel-hovered mb20 panel-primary"> <div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading"> <div class="panel-heading">
Response when payment PAID Response when payment PAID
</div> </div>
<pre class="panel-body p-1">{if $pg['pg_request'] != null}{Lang::jsonArray2text(json_decode($pg['pg_paid_response'], true))}{/if}</pre> <div class="table-responsive">
<table class="table table-bordered table-striped table-condensed">
{foreach $pg['pg_paid_response'] as $k => $v}
<tr>
<td>{$k}</td>
<td>{$v}</td>
</tr>
{/foreach}
</table>
</div>
</div> </div>
{include file="sections/footer.tpl"} {include file="sections/footer.tpl"}