From fb50ccddb686f8585563c17b6d2d53a6eb8729bc Mon Sep 17 00:00:00 2001 From: merdan Date: Tue, 9 Nov 2021 19:11:32 +0500 Subject: [PATCH] ukraska listow produkts i paymants wadminki dobavlena knopka approve decline na paymenrt --- plugins/rainlab/user/Plugin.php | 1 + plugins/tps/birzha/Plugin.php | 44 ++++++++-- plugins/tps/birzha/controllers/Payments.php | 8 ++ .../birzha/controllers/payments/update.htm | 87 ++++++++++++------- .../tps/birzha/models/payment/columns.yaml | 8 +- plugins/tps/birzha/models/payment/fields.yaml | 7 +- .../tps/birzha/models/product/columns.yaml | 28 +++--- 7 files changed, 131 insertions(+), 52 deletions(-) diff --git a/plugins/rainlab/user/Plugin.php b/plugins/rainlab/user/Plugin.php index b781a6274..cbce1a461 100644 --- a/plugins/rainlab/user/Plugin.php +++ b/plugins/rainlab/user/Plugin.php @@ -2,6 +2,7 @@ use App; use Auth; +use Carbon\Carbon; use Event; use Backend; use System\Classes\PluginBase; diff --git a/plugins/tps/birzha/Plugin.php b/plugins/tps/birzha/Plugin.php index f7ab94cfd..ffb580a6f 100644 --- a/plugins/tps/birzha/Plugin.php +++ b/plugins/tps/birzha/Plugin.php @@ -37,6 +37,40 @@ class Plugin extends PluginBase { $this->registerConsoleCommand('birzha:databasebackup', DatabaseBackUp::class); } + public function registerListColumnTypes() + { + return [ + // A local method, i.e $this->evalUppercaseListColumn() + 'status' => [$this, 'statusListColumn'], + 'vendor' => [$this, 'vendorLinkListColumn'], + 'user' => [$this, 'userLinkListColumn'], + + ]; + } + + public function userLinkListColumn($value, $column, $record){ + return ''.$value.''; + } + + public function vendorLinkListColumn($value, $column, $record){ + return ''.$value.''; + } + + public function statusListColumn($value, $column, $record) + { + switch ($value){ + case 'draft' : return ''.$value.''; + case 'bank' : return ''.$value.''; + case 'online' : return ''.$value.''; + case 'approved' : return ''.$value.''; + case 'payed' : return ''.$value.''; + case 'new' : return ''.$value.''; + case 'denied' : return ''.$value.''; + case 'disabled' : return ''.$value.''; + default : return $value; + } + + } public function registerSchedule($schedule) { @@ -88,9 +122,9 @@ class Plugin extends PluginBase $controller = \Cms\Classes\Controller::getController() ?? new \Cms\Classes\Controller(); // Search your plugin's contents - + $locale = Session::get('rainlab.translate.locale'); - + if($locale == 'tm') { // user enters product name $items = Models\Product @@ -100,7 +134,7 @@ class Plugin extends PluginBase ->get(); } else { $queryString = $query; - + // user enters product name $items = Models\Product::whereHas('translations', function ($query) use ($locale,$queryString) { $query->where('locale', $locale)->where('attribute_data', 'like', "%${queryString}%"); @@ -109,8 +143,8 @@ class Plugin extends PluginBase ->where('ends_at','>=',\DB::raw('curdate()'))->orderBy('updated_at', 'desc') ->get(); } - - + + // show all offers that have that product // $items = collect(new Offer); // foreach($products as $p) { diff --git a/plugins/tps/birzha/controllers/Payments.php b/plugins/tps/birzha/controllers/Payments.php index 84ca53503..e3f33f56c 100644 --- a/plugins/tps/birzha/controllers/Payments.php +++ b/plugins/tps/birzha/controllers/Payments.php @@ -3,6 +3,7 @@ use Backend\Classes\Controller; use BackendMenu; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use TPS\Birzha\Models\Payment; class Payments extends Controller @@ -47,5 +48,12 @@ class Payments extends Controller ?? 0; } + public function onApprove(){ + Log::info('test approve'); + } + + public function onDecline(){ + Log::info('test approve'); + } //todo amount funksia yazmaly } diff --git a/plugins/tps/birzha/controllers/payments/update.htm b/plugins/tps/birzha/controllers/payments/update.htm index ac8bb7496..29cf24e84 100644 --- a/plugins/tps/birzha/controllers/payments/update.htm +++ b/plugins/tps/birzha/controllers/payments/update.htm @@ -2,9 +2,62 @@ - + + + +
+
+
+ + + + + + + + + + +
+
+
fatalError): ?> 'layout']) ?> @@ -15,35 +68,7 @@
- - - - - -
@@ -51,4 +76,4 @@

fatalError)) ?>

- \ No newline at end of file + diff --git a/plugins/tps/birzha/models/payment/columns.yaml b/plugins/tps/birzha/models/payment/columns.yaml index 413c32cd9..dc1955f6c 100644 --- a/plugins/tps/birzha/models/payment/columns.yaml +++ b/plugins/tps/birzha/models/payment/columns.yaml @@ -8,11 +8,15 @@ columns: invisible: false user_id: label: User - type: text + type: user relation: user + valueFrom: email amount: label: Amount type: text payment_type: label: 'Payment type' - type: text + type: status + status: + label: Status + type: status diff --git a/plugins/tps/birzha/models/payment/fields.yaml b/plugins/tps/birzha/models/payment/fields.yaml index d7e962424..6616c3d0b 100644 --- a/plugins/tps/birzha/models/payment/fields.yaml +++ b/plugins/tps/birzha/models/payment/fields.yaml @@ -4,6 +4,7 @@ fields: span: auto disabled: 0 readOnly: 0 + required: 1 type: number user: label: Payer @@ -20,17 +21,21 @@ fields: type: datepicker payment_type: label: 'Payment type' - span: auto options: bank: Bank online: Online + span: auto + readOnly: 1 type: balloon-selector status: label: Status options: new: new + approved: approved + declined: declined payed: payed span: auto + readOnly: 1 type: balloon-selector note: label: Note diff --git a/plugins/tps/birzha/models/product/columns.yaml b/plugins/tps/birzha/models/product/columns.yaml index ac06234dc..36d255be5 100644 --- a/plugins/tps/birzha/models/product/columns.yaml +++ b/plugins/tps/birzha/models/product/columns.yaml @@ -3,28 +3,30 @@ columns: label: id type: number sortable: true - created_at: - label: 'Created at' - type: datetime - invisible: true - updated_at: - label: 'Updated at' - type: datetime - invisible: true name: label: Name type: text searchable: true - sortable: true + sortable: + user_id: + label: User + type: vendor + relation: vendor + valueFrom: email status: label: Status - type: text + type: status sortable: true - slug: - label: Slug - type: text mark: label: Marka type: text searchable: true sortable: true + updated_at: + label: 'Updated at' + type: datetime + invisible: true + ends_at: + label: 'Ends at' + type: datetime + invisible: true