delete payment gateway

This commit is contained in:
Ibnu Maksum 2024-03-12 10:00:28 +07:00
parent 3412ecc7de
commit 81572a61a4
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
2 changed files with 37 additions and 27 deletions

View File

@ -8,9 +8,17 @@
_admin(); _admin();
$ui->assign('_system_menu', 'paymentgateway'); $ui->assign('_system_menu', 'paymentgateway');
$action = alphanumeric($routes['1']); $action = alphanumeric($routes[1]);
$ui->assign('_admin', $admin); $ui->assign('_admin', $admin);
if ($action == 'delete') {
$pg = alphanumeric($routes[2]);
if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $pg . '.php')) {
deleteFile($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR, $pg);
}
r2(U . 'paymentgateway', 's', Lang::T('Payment Gateway Deleted'));
}
if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) { if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php')) {
include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php'; include $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
@ -55,3 +63,16 @@ if (file_exists($PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR . $action . '.php'))
$ui->display('paymentgateway.tpl'); $ui->display('paymentgateway.tpl');
} }
} }
function deleteFile($path, $name)
{
$files = scandir($path);
foreach ($files as $file) {
if (is_file($path . $file) && strpos($file, $name) !== false) {
unlink($path . $file);
} else if (is_dir($path . $file) && !in_array($file, ['.', '..'])) {
deleteFile($path . $file . DIRECTORY_SEPARATOR, $name);
}
}
}

View File

@ -1,33 +1,22 @@
{include file="sections/header.tpl"} {include file="sections/header.tpl"}
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-md-6 col-md-offset-3">
<div class="panel panel-info panel-hovered"> <div class="panel panel-info panel-hovered">
<div class="panel-heading">{Lang::T('Payment Gateway')}</div> <div class="panel-heading">{Lang::T('Payment Gateway')}</div>
<div class="panel-body row"> <div class="table-responsive">
<table class="table table-striped table-condensed">
<tbody>
{foreach $pgs as $pg} {foreach $pgs as $pg}
<div class="col-sm-4 mb20"> <tr>
<a href="{$_url}paymentgateway/{$pg}" class="btn btn-block btn-default">{ucwords($pg)}</a> <td><a href="{$_url}paymentgateway/{$pg}"
</div> class="btn btn-block btn-default text-left">{ucwords($pg)}</a></td>
<td width="10"><a href="{$_url}paymentgateway/delete/{$pg}" onclick="return confirm('{Lang::T('Delete')} {$pg}?')" class="btn btn-danger"><i
class="glyphicon glyphicon-trash"></i></a></td>
</tr>
{/foreach} {/foreach}
</div> </tbody>
<!-- <div class="panel-footer"> </table>
<form method="post">
<div class="form-group row">
<label class="col-md-2 control-label">Payment Gateway</label>
<div class="col-md-8">
<select name="payment_gateway" id="payment_gateway" class="form-control">
<option value="none">None</option>
{foreach $pgs as $pg}
<option value="{$pg}" {if $_c['payment_gateway'] eq {$pg}}selected="selected" {/if}>{ucwords($pg)}</option>
{/foreach}
</select>
</div>
<div class="col-md-2">
<button class="btn btn-block btn-primary" type="submit">{Lang::T('Save Changes')}</button>
</div> </div>
</div> </div>
</div> </div>
</div> --> {include file="sections/footer.tpl"}
</div>
</div>
{include file="sections/footer.tpl"}