-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
WpStarter
committed
Mar 17, 2023
1 parent
afa3851
commit eb051f3
Showing
32 changed files
with
903 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace App\Admin\Controllers; | ||
|
||
use App\Banking\Api\Momo; | ||
use App\Banking\Api\Momo\MomoApi; | ||
use WpStarter\Support\Carbon; | ||
use WpStarter\Wordpress\Admin\Facades\Notice; | ||
|
||
class MomoController extends Controller | ||
{ | ||
function getIndex(){ | ||
$momo=MomoApi::make(); | ||
$config=$momo->config(); | ||
return ws_view('admin::momo',[ | ||
'phone'=>$config->phone, | ||
'name'=>$config->name, | ||
'balance'=>wc_price($config->balance,['currency'=>'VND']), | ||
'updated_at'=>$config->logged_in_at?Carbon::createFromTimestamp($config->logged_in_at)->tz(wp_timezone()):'' | ||
]); | ||
} | ||
function postUpdate(){ | ||
Notice::success('Cập nhật thành công'); | ||
MomoApi::make()->reloadUserData(true); | ||
return ws_redirect()->back(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Admin\Controllers; | ||
|
||
use App\Admin\ListTable\TransactionsListTable; | ||
use WpStarter\Http\Request; | ||
use WpStarter\Wordpress\Admin\Facades\Notice; | ||
|
||
class TransactionsController | ||
{ | ||
function index(){ | ||
$table=new TransactionsListTable(); | ||
$table->prepare_items(); | ||
return ws_view('admin::table',['table'=>$table]); | ||
} | ||
function getAdd(){ | ||
|
||
} | ||
function postAdd(){ | ||
|
||
} | ||
function getDelete(Request $request){ | ||
Notice::success('Deleted'); | ||
return ws_redirect()->back(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace App\Admin\ListTable; | ||
|
||
use App\Banking\Model\BankTransaction; | ||
|
||
class TransactionsListTable extends \WP_List_Table | ||
{ | ||
function get_bulk_actions() { | ||
|
||
$actions = array( | ||
'delete' => 'Delete' | ||
); | ||
return $actions; | ||
} | ||
public function get_columns() | ||
{ | ||
return [ | ||
'cb'=>'cb', | ||
'id'=>'ID', | ||
'tid'=>'Transaction ID', | ||
'bank'=>'Bank', | ||
'content'=>'Content', | ||
'amount'=>'Amount', | ||
'prefix'=>'Prefix', | ||
'order_id'=>'Order', | ||
'status'=>'Status', | ||
'created_at'=>'Created At', | ||
'received_at'=>'Received At', | ||
'notified_at'=>'Notified At', | ||
]; | ||
} | ||
public function prepare_items() | ||
{ | ||
$this->items=BankTransaction::query() | ||
->latest('created_at') | ||
->paginate(15,'*','paged'); | ||
$this->set_pagination_args(array( | ||
'total_items' => $this->items->total(), | ||
'total_pages' => $this->items->lastPage(), | ||
'per_page' => $this->items->perPage(), | ||
)); | ||
} | ||
function column_cb($item){ | ||
$checkbox = '<label class="screen-reader-text" for="transaction_' . $item->id . '">' . sprintf( __( 'Select %s'), $item->id ) . '</label>' | ||
. "<input type='checkbox' name='transactions[]' id='transaction_{$item->id}' value='{$item->id}' />"; | ||
return $checkbox; | ||
} | ||
protected function column_default($item, $column_name) | ||
{ | ||
return $item->$column_name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@extends('admin::layout') | ||
@section('content') | ||
<h3>Thông tin tài khoản</h3> | ||
@if($phone) | ||
<table> | ||
<tr> | ||
<td>Số điện thoại</td> | ||
<td>{{$phone}}</td> | ||
</tr> | ||
<tr> | ||
<td>Tên tài khoản</td> | ||
<td>{{$name}}</td> | ||
</tr> | ||
<tr> | ||
<td>Số dư</td> | ||
<td>{!! $balance !!}</td> | ||
</tr> | ||
<tr> | ||
<td>Cập nhật</td> | ||
<td>{{$updated_at}}</td> | ||
</tr> | ||
</table> | ||
<form method="POST"> | ||
@csrf | ||
<button name="action" value="update" class="button button-primary">Cập nhật</button> | ||
</form> | ||
@else | ||
<p>Chưa kết nối momo</p> | ||
@endif | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@extends('admin::layout') | ||
@section('content') | ||
{{$table->views()}} | ||
<form> | ||
<input type="hidden" name="page" value="{{ws_request('page')}}"> | ||
{{$table->search_box( 'Search', 's' )}} | ||
{{$table->display()}} | ||
</form> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.