v2 first commit
This commit is contained in:
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class OfflineFile extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$module = Module::get('Offline');
|
||||
|
||||
if (!empty($module) && version_compare($module->get('version'), '1.0.0') == 0) {
|
||||
$offline_payments = json_decode(setting('offline.payment.methods'), true);
|
||||
|
||||
if (!empty($offline_payments)) {
|
||||
$offlinepayment = array();
|
||||
|
||||
foreach ($offline_payments as $offline_payment) {
|
||||
$code = explode('.', $offline_payment['code']);
|
||||
|
||||
$offline_payment['code'] = $code[1];
|
||||
|
||||
$offlinepayment[] = array(
|
||||
'code' => 'offlinepayment.' . $code[1] . '.' . $code[2],
|
||||
'name' => $offline_payment['name'],
|
||||
'customer' => 0,
|
||||
'order' => $offline_payment['order'],
|
||||
'description' => $offline_payment['description']
|
||||
);
|
||||
}
|
||||
|
||||
//$company_id = $this->command->argument('company');
|
||||
|
||||
// Set the active company settings
|
||||
setting()->setExtraColumns(['company_id' => 1]);
|
||||
|
||||
setting()->set('offline-payments.methods', json_encode($offlinepayment));
|
||||
|
||||
setting()->forget('offline.payment.methods');
|
||||
|
||||
setting()->save();
|
||||
}
|
||||
|
||||
$module->delete();
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Setting;
|
||||
|
||||
class OfflinePaymentsDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
$this->create();
|
||||
|
||||
Model::reguard();
|
||||
}
|
||||
|
||||
private function create()
|
||||
{
|
||||
$methods = array();
|
||||
|
||||
$methods[] = array(
|
||||
'code' => 'offline-payments.cash.1',
|
||||
'name' => 'Cash',
|
||||
'customer' => '0',
|
||||
'order' => '1',
|
||||
'description' => null,
|
||||
);
|
||||
|
||||
$methods[] = array(
|
||||
'code' => 'offline-payments.bank_transfer.2',
|
||||
'name' => 'Bank Transfer',
|
||||
'customer' => '0',
|
||||
'order' => '2',
|
||||
'description' => null,
|
||||
);
|
||||
|
||||
Setting::set('offline-payments.methods', json_encode($methods));
|
||||
}
|
||||
}
|
95
modules/OfflinePayments/Http/Controllers/Payment.php
Normal file
95
modules/OfflinePayments/Http/Controllers/Payment.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Http\Controllers;
|
||||
|
||||
use App\Abstracts\Http\PaymentController;
|
||||
use App\Http\Requests\Portal\InvoicePayment as PaymentRequest;
|
||||
use App\Models\Income\Invoice;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class Payment extends PaymentController
|
||||
{
|
||||
public $alias = 'offline-payments';
|
||||
|
||||
public $type = 'redirect';
|
||||
|
||||
public function show(Invoice $invoice, PaymentRequest $request)
|
||||
{
|
||||
$setting = [];
|
||||
|
||||
$payment_methods = json_decode(setting('offline-payments.methods'), true);
|
||||
|
||||
foreach ($payment_methods as $payment_method) {
|
||||
if ($payment_method['code'] == $request['payment_method']) {
|
||||
$setting = $payment_method;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$html = view('offline-payments::show', compact('setting', 'invoice'))->render();
|
||||
|
||||
return response()->json([
|
||||
'code' => $setting['code'],
|
||||
'name' => $setting['name'],
|
||||
'description' => $setting['description'],
|
||||
'redirect' => false,
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
public function signed(Invoice $invoice, PaymentRequest $request)
|
||||
{
|
||||
$setting = [];
|
||||
|
||||
$payment_methods = json_decode(setting('offline-payments.methods'), true);
|
||||
|
||||
foreach ($payment_methods as $payment_method) {
|
||||
if ($payment_method['code'] == $request['payment_method']) {
|
||||
$setting = $payment_method;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$confirm_url = URL::signedRoute('signed.invoices.offline-payments.confirm', [$invoice->id, 'company_id' => session('company_id')]);
|
||||
|
||||
$html = view('offline-payments::signed', compact('setting', 'invoice', 'confirm_url'))->render();
|
||||
|
||||
return response()->json([
|
||||
'code' => $setting['code'],
|
||||
'name' => $setting['name'],
|
||||
'description' => $setting['description'],
|
||||
'redirect' => false,
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
public function confirm(Invoice $invoice, Request $request)
|
||||
{
|
||||
try {
|
||||
event(new \App\Events\Income\PaymentReceived($invoice, $request));
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
|
||||
|
||||
$response = [
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => $message,
|
||||
'data' => false,
|
||||
];
|
||||
} catch(\Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
|
||||
$response = [
|
||||
'success' => false,
|
||||
'error' => true,
|
||||
'message' => $message,
|
||||
'data' => false,
|
||||
];
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
}
|
165
modules/OfflinePayments/Http/Controllers/Settings.php
Normal file
165
modules/OfflinePayments/Http/Controllers/Settings.php
Normal file
@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Http\Controllers;
|
||||
|
||||
use Artisan;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\OfflinePayments\Http\Requests\Setting as Request;
|
||||
use Modules\OfflinePayments\Http\Requests\SettingGet as GRequest;
|
||||
use Modules\OfflinePayments\Http\Requests\SettingDelete as DRequest;
|
||||
|
||||
class Settings extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$items = json_decode(setting('offline-payments.methods'));
|
||||
|
||||
return view('offline-payments::edit', compact('items'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$methods = json_decode(setting('offline-payments.methods'), true);
|
||||
|
||||
if (isset($request['method'])) {
|
||||
foreach ($methods as $key => $method) {
|
||||
if ($method['code'] != $request['method']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = explode('.', $request['method']);
|
||||
|
||||
$methods[$key]['code'] = 'offline-payments.' . $request['code'] . '.' . $method[2];
|
||||
$methods[$key]['name'] = $request['name'];
|
||||
$methods[$key]['customer'] = $request['customer'];
|
||||
$methods[$key]['order'] = $request['order'];
|
||||
$methods[$key]['description'] = $request['description'];
|
||||
}
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => $request['name']]);
|
||||
} else {
|
||||
$methods[] = array(
|
||||
'code' => 'offline-payments.' . $request['code'] . '.' . (count($methods) + 1),
|
||||
'name' => $request['name'],
|
||||
'customer' => $request['customer'],
|
||||
'order' => $request['order'],
|
||||
'description' => $request['description']
|
||||
);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => $request['name']]);
|
||||
}
|
||||
|
||||
// Set Api Token
|
||||
setting()->set('offline-payments.methods', json_encode($methods));
|
||||
|
||||
setting()->save();
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
$response = [
|
||||
'status' => null,
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => $message,
|
||||
'data' => null,
|
||||
'redirect' => route('offline-payments.edit'),
|
||||
];
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param GRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function get(GRequest $request)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$code = $request['code'];
|
||||
|
||||
$methods = json_decode(setting('offline-payments.methods'), true);
|
||||
|
||||
foreach ($methods as $key => $method) {
|
||||
if ($method['code'] != $code) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$method['title'] = trans('offline-payments::offline-payments.edit', ['method' => $method['name']]);
|
||||
$method['update'] = $code;
|
||||
|
||||
$code = explode('.', $method['code']);
|
||||
|
||||
$method['code'] = $code[1];
|
||||
|
||||
$data = $method;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'errors' => false,
|
||||
'success' => true,
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param DRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy(DRequest $request)
|
||||
{
|
||||
$code = $request['code'];
|
||||
|
||||
$methods = json_decode(setting('offline-payments.methods'), true);
|
||||
|
||||
$remove = false;
|
||||
|
||||
foreach ($methods as $key => $method) {
|
||||
if ($method['code'] != $code) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$remove = $methods[$key];
|
||||
unset($methods[$key]);
|
||||
}
|
||||
|
||||
// Set Api Token
|
||||
setting()->set('offline-payments.methods', json_encode($methods));
|
||||
|
||||
setting()->save();
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
$message = trans('messages.success.deleted', ['type' => $remove['name']]);
|
||||
|
||||
return response()->json([
|
||||
'errors' => false,
|
||||
'success' => true,
|
||||
'message' => $message
|
||||
]);
|
||||
}
|
||||
}
|
31
modules/OfflinePayments/Http/Requests/Setting.php
Normal file
31
modules/OfflinePayments/Http/Requests/Setting.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Http\Requests;
|
||||
|
||||
use App\Abstracts\Http\FormRequest as Request;
|
||||
|
||||
class Setting extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string',
|
||||
'code' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
30
modules/OfflinePayments/Http/Requests/SettingDelete.php
Normal file
30
modules/OfflinePayments/Http/Requests/SettingDelete.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Http\Requests;
|
||||
|
||||
use App\Abstracts\Http\FormRequest as Request;
|
||||
|
||||
class SettingDelete extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'code' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
30
modules/OfflinePayments/Http/Requests/SettingGet.php
Normal file
30
modules/OfflinePayments/Http/Requests/SettingGet.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Http\Requests;
|
||||
|
||||
use App\Abstracts\Http\FormRequest as Request;
|
||||
|
||||
class SettingGet extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'code' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
30
modules/OfflinePayments/Http/Requests/Show.php
Normal file
30
modules/OfflinePayments/Http/Requests/Show.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Http\Requests;
|
||||
|
||||
use App\Abstracts\Http\FormRequest as Request;
|
||||
|
||||
class Show extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'payment_method' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
23
modules/OfflinePayments/Listeners/ShowPaymentMethod.php
Normal file
23
modules/OfflinePayments/Listeners/ShowPaymentMethod.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Listeners;
|
||||
|
||||
use App\Events\Module\PaymentMethodShowing as Event;
|
||||
|
||||
class ShowPaymentMethod
|
||||
{
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param Event $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
{
|
||||
$methods = json_decode(setting('offline-payments.methods'), true);
|
||||
|
||||
foreach ($methods as $method) {
|
||||
$event->modules->payment_methods[] = $method;
|
||||
}
|
||||
}
|
||||
}
|
24
modules/OfflinePayments/Listeners/ShowSetting.php
Normal file
24
modules/OfflinePayments/Listeners/ShowSetting.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Listeners;
|
||||
|
||||
use App\Events\Module\SettingShowing as Event;
|
||||
|
||||
class ShowSetting
|
||||
{
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param Event $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
{
|
||||
$event->modules->settings['offline-payments'] = [
|
||||
'name' => trans('offline-payments::general.name'),
|
||||
'description' => trans('offline-payments::general.description'),
|
||||
'url' => 'settings/offline-payments',
|
||||
'icon' => 'fas fa-credit-card',
|
||||
];
|
||||
}
|
||||
}
|
106
modules/OfflinePayments/Providers/Main.php
Normal file
106
modules/OfflinePayments/Providers/Main.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider as Provider;
|
||||
use Modules\OfflinePayments\Listeners\ShowPaymentMethod;
|
||||
use Modules\OfflinePayments\Listeners\ShowSetting;
|
||||
|
||||
class Main extends Provider
|
||||
{
|
||||
/**
|
||||
* Boot the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->loadTranslations();
|
||||
$this->loadMigrations();
|
||||
$this->loadViews();
|
||||
$this->loadEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->loadRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadViews()
|
||||
{
|
||||
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'offline-payments');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadTranslations()
|
||||
{
|
||||
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'offline-payments');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadMigrations()
|
||||
{
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadEvents()
|
||||
{
|
||||
$this->app['events']->listen(\App\Events\Module\PaymentMethodShowing::class, ShowPaymentMethod::class);
|
||||
$this->app['events']->listen(\App\Events\Module\SettingShowing::class, ShowSetting::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load routes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadRoutes()
|
||||
{
|
||||
if (app()->routesAreCached()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$routes = [
|
||||
'admin.php',
|
||||
'portal.php',
|
||||
'signed.php',
|
||||
];
|
||||
|
||||
foreach ($routes as $route) {
|
||||
$this->loadRoutesFrom(__DIR__ . '/../Routes/' . $route);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
83
modules/OfflinePayments/Resources/assets/js/offline-payments.js
vendored
Normal file
83
modules/OfflinePayments/Resources/assets/js/offline-payments.js
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* First we will load all of this project's JavaScript dependencies which
|
||||
* includes Vue and other libraries. It is a great starting point when
|
||||
* building robust, powerful web applications using Vue and Laravel.
|
||||
*/
|
||||
|
||||
require('./../../../../../resources/assets/js/bootstrap');
|
||||
|
||||
import Vue from 'vue';
|
||||
|
||||
import Global from './../../../../../resources/assets/js/mixins/global';
|
||||
|
||||
import Form from './../../../../../resources/assets/js/plugins/form';
|
||||
|
||||
const app = new Vue({
|
||||
el: '#app',
|
||||
|
||||
mixins: [
|
||||
Global
|
||||
],
|
||||
|
||||
data() {
|
||||
return {
|
||||
form: new Form('offline-payments')
|
||||
}
|
||||
},
|
||||
|
||||
methods:{
|
||||
onEdit(event) {
|
||||
var code = event.target.dataset.code;
|
||||
this.form.loading = true;
|
||||
|
||||
axios.post('offline-payments/get', {
|
||||
code: code
|
||||
})
|
||||
.then(response => {
|
||||
this.form.name = response.data.data.name;
|
||||
this.form.code = response.data.data.code;
|
||||
this.form.customer = response.data.data.customer;
|
||||
this.form.order = response.data.data.order;
|
||||
this.form.description = response.data.data.description;
|
||||
this.form.update = response.data.data.update;
|
||||
this.form.loading = false;
|
||||
})
|
||||
.catch(error => {
|
||||
this.form.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
onDelete() {
|
||||
axios({
|
||||
method: 'DELETE',
|
||||
url: 'offline-payments/delete',
|
||||
data: {
|
||||
code: this.confirm.code
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (response.data.success) {
|
||||
var type = (response.data.success) ? 'success' : 'warning';
|
||||
|
||||
this.$notify({
|
||||
message: response.data.message,
|
||||
timeout: 5000,
|
||||
icon: 'fas fa-bell',
|
||||
type
|
||||
});
|
||||
|
||||
document.getElementById('method-' + this.confirm.code).remove();
|
||||
|
||||
this.confirm.code = '';
|
||||
this.confirm.title = '';
|
||||
this.confirm.message = '';
|
||||
|
||||
this.confirm.show = false;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.success = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
148309
modules/OfflinePayments/Resources/assets/js/offline-payments.min.js
vendored
Normal file
148309
modules/OfflinePayments/Resources/assets/js/offline-payments.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
21
modules/OfflinePayments/Resources/lang/en-GB/general.php
Normal file
21
modules/OfflinePayments/Resources/lang/en-GB/general.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'name' => 'Offline Payments',
|
||||
'description' => 'Create unlimited payment options for admin usage',
|
||||
|
||||
'add_new' => 'Add New',
|
||||
'edit' => 'Edit: :method',
|
||||
|
||||
'form' => [
|
||||
'code' => 'Code',
|
||||
'customer' => 'Show to Customer',
|
||||
'order' => 'Order'
|
||||
],
|
||||
|
||||
'methods' => 'Method|Methods',
|
||||
|
||||
'payment_gateways' => 'Offline Payment Methods',
|
||||
|
||||
];
|
@ -0,0 +1,7 @@
|
||||
<h2>{{ $setting['name'] }}</h2>
|
||||
|
||||
@if ($setting['description'])
|
||||
<div class="well well-sm">
|
||||
{{ $setting['description'] }}
|
||||
</div>
|
||||
@endif
|
124
modules/OfflinePayments/Resources/views/edit.blade.php
Normal file
124
modules/OfflinePayments/Resources/views/edit.blade.php
Normal file
@ -0,0 +1,124 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title', trans('offline-payments::general.name'))
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="mb-0">{{ trans('offline-payments::general.add_new') }}</h3>
|
||||
</div>
|
||||
|
||||
{!! Form::open([
|
||||
'id' => 'offline-payments',
|
||||
'route' => 'offline-payments.update',
|
||||
'@submit.prevent' => 'onSubmit',
|
||||
'@keydown' => 'form.errors.clear($event.target.name)',
|
||||
'files' => true,
|
||||
'role' => 'form',
|
||||
'class' => 'form-loading-button',
|
||||
'novalidate' => true
|
||||
]) !!}
|
||||
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
{{ Form::textGroup('name', trans('general.name'), 'money-check', ['required' => 'required'], null, 'col-md-12') }}
|
||||
|
||||
{{ Form::textGroup('code', trans('offline-payments::general.form.code'), 'code', ['required' => 'required'], null, 'col-md-12') }}
|
||||
|
||||
{{ Form::radioGroup('customer', trans('offline-payments::general.form.customer'), 0, trans('general.yes'), trans('general.no'), ['required' => 'required'], 'col-md-12') }}
|
||||
|
||||
{{ Form::textGroup('order', trans('offline-payments::general.form.order'), 'sort', [], null, 'col-md-12') }}
|
||||
|
||||
{{ Form::textareaGroup('description', trans('general.description')) }}
|
||||
|
||||
{!! Form::hidden('update', null) !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<div class="row float-right">
|
||||
{{ Form::saveButtons('apps/offline-payments/settings') }}
|
||||
</div>
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header border-bottom-0">
|
||||
<h3 class="mb-0">{{ trans('offline-payments::general.payment_gateways') }}</h3>
|
||||
</div>
|
||||
|
||||
<div id="delete-loading"></div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-flush table-hover" id="tbl-items">
|
||||
<thead class="thead-light">
|
||||
<tr class="row table-head-line">
|
||||
<th class="col-xs-6 col-sm-4 col-md-4 col-lg-3">{{ trans('general.name') }}</th>
|
||||
<th class="col-sm-4 col-md-4 col-lg-4 hidden-sm">{{ trans('offline-payments::general.form.code') }}</th>
|
||||
<th class="col-lg-2 hidden-lg">{{ trans('offline-payments::general.form.order') }}</th>
|
||||
<th class="col-xs-6 col-sm-4 col-md-4 col-lg-3 text-center">{{ trans('general.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if($items)
|
||||
@foreach($items as $item)
|
||||
<tr class="row align-items-center border-top-1" id="method-{{ $item->code }}">
|
||||
<td class="col-xs-6 col-sm-4 col-md-4 col-lg-3">{{ $item->name }}</td>
|
||||
<td class="col-sm-4 col-md-4 col-lg-4 hidden-sm">{{ $item->code }}</td>
|
||||
<td class="col-lg-2 hidden-lg">{{ $item->order }}</td>
|
||||
<td class="col-xs-6 col-sm-4 col-md-4 col-lg-3 text-center">
|
||||
<div class="dropdown">
|
||||
<a class="btn btn-neutral btn-sm text-light items-align-center p-2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-ellipsis-h text-muted"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
{!! Form::button(trans('general.edit'), array(
|
||||
'type' => 'button',
|
||||
'class' => 'dropdown-item method-edit',
|
||||
'title' => trans('general.edit'),
|
||||
'data-code' => $item->code,
|
||||
'id' => 'edit-' . $item->code,
|
||||
'@click' => 'onEdit'
|
||||
)) !!}
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::button(trans('general.delete'), array(
|
||||
'type' => 'button',
|
||||
'class' => 'dropdown-item method-delete',
|
||||
'title' => trans('general.delete'),
|
||||
'data-code' => $item->code,
|
||||
'id' => 'delete-' . $item->code,
|
||||
'@click' => 'confirmDelete("' . $item->code . '", "' . trans('general.delete') . ' ' . trans_choice('offline-payments::general.methods', 1) . '", "' . trans('general.delete_confirm', ['name' => '<strong>' . $item->name . '</strong>', 'type' => mb_strtolower(trans('offline-payments::general.title'))]) . '", "' . trans('general.cancel') . '", "' . trans('general.delete') . '")'
|
||||
)) !!}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<akaunting-modal
|
||||
:show="confirm.show"
|
||||
:title="confirm.title"
|
||||
:message="confirm.message"
|
||||
:button_cancel="confirm.button_cancel"
|
||||
:button_delete="confirm.button_delete"
|
||||
v-if='confirm.show'
|
||||
@confirm='onDelete'
|
||||
@cancel="cancelDelete">
|
||||
</akaunting-modal>
|
||||
@endsection
|
||||
|
||||
@push('scripts_start')
|
||||
<script src="{{ asset('modules/OfflinePayments/Resources/js/offline-payments.min.js?v=' . version('short')) }}"></script>
|
||||
@endpush
|
40
modules/OfflinePayments/Resources/views/show.blade.php
Normal file
40
modules/OfflinePayments/Resources/views/show.blade.php
Normal file
@ -0,0 +1,40 @@
|
||||
<h2>{{ $setting['name'] }}</h2>
|
||||
|
||||
@if ($setting['description'])
|
||||
<div class="well well-sm">
|
||||
{{ $setting['description'] }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="buttons">
|
||||
<div class="float-right">
|
||||
<input type="button" value="{{ trans('offline-payments::general.confirm') }}" id="button-confirm" class="btn btn-success" data-loading-text="{{ trans('offline-payments::general.loading') }}" />
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript"><!--
|
||||
$('#button-confirm').on('click', function() {
|
||||
$.ajax({
|
||||
url: '{{ route("portal.invoices.offline-payments.confirm", $invoice->id) }}',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: {payment_method: '{{ $setting['code'] }}'},
|
||||
cache: false,
|
||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||
beforeSend: function() {
|
||||
$('#button-confirm').button('loading');
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-confirm').button('reset');
|
||||
},
|
||||
success: function(data) {
|
||||
if (data['error']) {
|
||||
alert(data['error']);
|
||||
}
|
||||
|
||||
if (data['success']) {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
//--></script>
|
40
modules/OfflinePayments/Resources/views/signed.blade.php
Normal file
40
modules/OfflinePayments/Resources/views/signed.blade.php
Normal file
@ -0,0 +1,40 @@
|
||||
<h2>{{ $setting['name'] }}</h2>
|
||||
|
||||
@if ($setting['description'])
|
||||
<div class="well well-sm">
|
||||
{{ $setting['description'] }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="buttons">
|
||||
<div class="float-right">
|
||||
<input type="button" value="{{ trans('offline-payments::general.confirm') }}" id="button-confirm" class="btn btn-success" data-loading-text="{{ trans('offline-payments::general.loading') }}" />
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript"><!--
|
||||
$('#button-confirm').on('click', function() {
|
||||
$.ajax({
|
||||
url: '{!! urldecode($confirm_url) !!}',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: {payment_method: '{{ $setting['code'] }}'},
|
||||
cache: false,
|
||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||
beforeSend: function() {
|
||||
$('#button-confirm').button('loading');
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-confirm').button('reset');
|
||||
},
|
||||
success: function(data) {
|
||||
if (data['error']) {
|
||||
alert(data['error']);
|
||||
}
|
||||
|
||||
if (data['success']) {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
//--></script>
|
13
modules/OfflinePayments/Routes/admin.php
Normal file
13
modules/OfflinePayments/Routes/admin.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
Route::group([
|
||||
'middleware' => 'admin',
|
||||
'namespace' => 'Modules\OfflinePayments\Http\Controllers'
|
||||
], function () {
|
||||
Route::group(['prefix' => 'settings'], function () {
|
||||
Route::get('offline-payments', 'Settings@edit')->name('offline-payments.edit');
|
||||
Route::post('offline-payments', 'Settings@update')->name('offline-payments.update');
|
||||
Route::post('offline-payments/get', 'Settings@get')->name('offline-payments.get');
|
||||
Route::delete('offline-payments/delete', 'Settings@destroy')->name('offline-payments.delete');
|
||||
});
|
||||
});
|
10
modules/OfflinePayments/Routes/portal.php
Normal file
10
modules/OfflinePayments/Routes/portal.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
Route::group([
|
||||
'prefix' => 'portal',
|
||||
'middleware' => 'portal',
|
||||
'namespace' => 'Modules\OfflinePayments\Http\Controllers'
|
||||
], function () {
|
||||
Route::get('invoices/{invoice}/offline-payments', 'Payment@show')->name('portal.invoices.offline-payments.show');
|
||||
Route::post('invoices/{invoice}/offline-payments/confirm', 'Payment@confirm')->name('portal.invoices.offline-payments.confirm');
|
||||
});
|
10
modules/OfflinePayments/Routes/signed.php
Normal file
10
modules/OfflinePayments/Routes/signed.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
Route::group([
|
||||
'prefix' => 'signed',
|
||||
'middleware' => 'signed',
|
||||
'namespace' => 'Modules\OfflinePayments\Http\Controllers'
|
||||
], function () {
|
||||
Route::get('invoices/{invoice}/offline-payments', 'Payment@signed')->name('signed.invoices.offline-payments.show');
|
||||
Route::post('invoices/{invoice}/offline-payments/confirm', 'Payment@confirm')->name('signed.invoices.offline-payments.confirm');
|
||||
});
|
15
modules/OfflinePayments/composer.json
Normal file
15
modules/OfflinePayments/composer.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "akaunting/offlinepayment",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Akaunting",
|
||||
"email": "info@akaunting.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\OfflinePayment\\": ""
|
||||
}
|
||||
}
|
||||
}
|
4
modules/OfflinePayments/mix-manifest.json
Normal file
4
modules/OfflinePayments/mix-manifest.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"/Resources/assets/js/offline-payments.min.js": "/Resources/assets/js/offline-payments.min.js",
|
||||
"/public/css/argon.css": "/public/css/argon.css"
|
||||
}
|
14
modules/OfflinePayments/module.json
Normal file
14
modules/OfflinePayments/module.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"alias": "offline-payments",
|
||||
"version": "2.0.0",
|
||||
"category": "payment-method",
|
||||
"active": 1,
|
||||
"order": 0,
|
||||
"providers": [
|
||||
"Modules\\OfflinePayments\\Providers\\Main"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": [],
|
||||
"settings": []
|
||||
}
|
83
modules/OfflinePayments/package.json
Normal file
83
modules/OfflinePayments/package.json
Normal file
@ -0,0 +1,83 @@
|
||||
{
|
||||
"name": "akaunting",
|
||||
"version": "2.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run development",
|
||||
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"watch": "npm run development -- --watch",
|
||||
"watch-poll": "npm run watch -- --watch-poll",
|
||||
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"prod": "npm run production",
|
||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"serve": "vue-cli-service serve --open",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||
"@fullcalendar/core": "^4.3.1",
|
||||
"@fullcalendar/daygrid": "^4.3.0",
|
||||
"@fullcalendar/interaction": "^4.3.0",
|
||||
"@fullcalendar/timegrid": "^4.3.0",
|
||||
"@fullcalendar/vue": "^4.3.1",
|
||||
"bootstrap": "^4.3.1",
|
||||
"chart.js": "^2.7.1",
|
||||
"d3": "^5.12.0",
|
||||
"datamaps": "^0.5.9",
|
||||
"date-fns": "^1.30.1",
|
||||
"dropzone": "^5.5.1",
|
||||
"element-ui": "^2.12.0",
|
||||
"es6-promise": "^4.1.1",
|
||||
"flatpickr": "^4.6.3",
|
||||
"fuse.js": "^3.2.0",
|
||||
"google-maps": "^3.2.1",
|
||||
"nouislider": "^12.1.0",
|
||||
"nprogress": "^0.2.0",
|
||||
"perfect-scrollbar": "^1.3.0",
|
||||
"quill": "^1.3.7",
|
||||
"sweetalert2": "^7.29.2",
|
||||
"v-money": "^0.8.1",
|
||||
"vee-validate": "^2.2.15",
|
||||
"vue": "^2.6.10",
|
||||
"vue-chartjs": "^3.4.0",
|
||||
"vue-clipboard2": "^0.3.1",
|
||||
"vue-flatpickr-component": "^8.1.3",
|
||||
"vue-router": "^3.1.3",
|
||||
"vue2-transitions": "^0.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.11.0",
|
||||
"@vue/cli-plugin-eslint": "^3.11.0",
|
||||
"@vue/cli-service": "^3.11.0",
|
||||
"@vue/eslint-config-prettier": "^4.0.1",
|
||||
"axios": "^0.18.1",
|
||||
"babel-plugin-component": "^1.1.0",
|
||||
"bootstrap": "^4.0.0",
|
||||
"cross-env": "^5.2.1",
|
||||
"jquery": "^3.4.1",
|
||||
"laravel-mix": "^4.1.4",
|
||||
"lodash": "^4.17.15",
|
||||
"node-sass": "^4.12.0",
|
||||
"popper.js": "^1.12",
|
||||
"resolve-url-loader": "^2.3.1",
|
||||
"sass": "^1.22.12",
|
||||
"sass-loader": "^7.3.1",
|
||||
"vue": "^2.5.17",
|
||||
"vue-loading-overlay": "^3.2.0",
|
||||
"vue-template-compiler": "^2.6.10",
|
||||
"vue2-transitions": "^0.3.0"
|
||||
},
|
||||
"postcss": {
|
||||
"plugins": {
|
||||
"autoprefixer": {}
|
||||
}
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not ie <= 10"
|
||||
],
|
||||
"author": "Akaunting Inc <info@akaunting.com>",
|
||||
"description": "Free Accounting Software"
|
||||
}
|
18
modules/OfflinePayments/webpack.mix.js
vendored
Normal file
18
modules/OfflinePayments/webpack.mix.js
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
const mix = require('laravel-mix');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mix Asset Management
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Mix provides a clean, fluent API for defining some Webpack build steps
|
||||
| for your Laravel application. By default, we are compiling the Sass
|
||||
| file for the application as well as bundling up all the JS files.
|
||||
|
|
||||
*/
|
||||
|
||||
//mix.js('resources/assets/js/views/**/*.js', 'public/js')
|
||||
|
||||
mix.js('Resources/assets/js/offline-payments.js', 'Resources/assets/js/offline-payments.min.js')
|
||||
|
||||
.sass('./../../resources/assets/sass/argon.scss', './../../public/css');
|
Reference in New Issue
Block a user