refs #78
This commit is contained in:
parent
f78237f7ce
commit
6e7b9d6964
@ -102,14 +102,12 @@ class Invoices extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function printInvoice($invoice_id)
|
||||
public function printInvoice(Invoice $invoice)
|
||||
{
|
||||
$sub_total = 0;
|
||||
$tax_total = 0;
|
||||
$paid = 0;
|
||||
|
||||
$invoice = Invoice::where('id', $invoice_id)->first();
|
||||
|
||||
foreach ($invoice->items as $item) {
|
||||
$sub_total += ($item->price * $item->quantity);
|
||||
$tax_total += ($item->tax * $item->quantity);
|
||||
@ -136,14 +134,12 @@ class Invoices extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function pdfInvoice($invoice_id)
|
||||
public function pdfInvoice(Invoice $invoice)
|
||||
{
|
||||
$sub_total = 0;
|
||||
$tax_total = 0;
|
||||
$paid = 0;
|
||||
|
||||
$invoice = Invoice::where('id', $invoice_id)->first();
|
||||
|
||||
foreach ($invoice->items as $item) {
|
||||
$sub_total += ($item->price * $item->quantity);
|
||||
$tax_total += ($item->tax * $item->quantity);
|
||||
@ -177,10 +173,13 @@ class Invoices extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function payment(PaymentRequest $request)
|
||||
public function payment(Invoice $invoice, PaymentRequest $request)
|
||||
{
|
||||
$invoice = Invoice::where(['id' => $request['invoice_id'], 'customer_id' => Auth::user()->customer->id])->first();
|
||||
if (!$invoice) {
|
||||
return response()->json(
|
||||
|
||||
);
|
||||
}
|
||||
// Fire the event to extend the menu
|
||||
$result = event(new PaymentGatewayConfirm($request['payment_method'], $invoice));
|
||||
|
||||
|
@ -13,37 +13,55 @@ class Modules
|
||||
|
||||
public static function getPaymentMethods()
|
||||
{
|
||||
$payment_methods = Cache::get('payment_methods');
|
||||
|
||||
$payment_methods = Cache::get('payment_methods.admin');
|
||||
|
||||
$customer = auth()->user()->customer;
|
||||
|
||||
if ($customer) {
|
||||
$payment_methods = Cache::get('payment_methods.customer');
|
||||
}
|
||||
|
||||
if (!empty($payment_methods)) {
|
||||
return $payment_methods;
|
||||
}
|
||||
|
||||
$gateways = array();
|
||||
$gateways = [];
|
||||
$methods = [];
|
||||
|
||||
// Fire the event to extend the menu
|
||||
$results = event(new PaymentGatewayListing($gateways));
|
||||
|
||||
foreach ($results as $gateways) {
|
||||
foreach ($gateways as $gateway) {
|
||||
if ($customer && empty($gateway['customer'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$methods[] = $gateway;
|
||||
}
|
||||
}
|
||||
|
||||
$sort_order = array();
|
||||
$sort_order = [];
|
||||
|
||||
foreach ($methods as $key => $value) {
|
||||
$sort_order[$key] = $value['order'];
|
||||
if ($methods) {
|
||||
foreach ($methods as $key => $value) {
|
||||
$sort_order[$key] = $value['order'];
|
||||
}
|
||||
|
||||
array_multisort($sort_order, SORT_ASC, $methods);
|
||||
|
||||
foreach ($methods as $method) {
|
||||
$payment_methods[$method['code']] = $method['name'];
|
||||
}
|
||||
}
|
||||
|
||||
array_multisort($sort_order, SORT_ASC, $methods);
|
||||
|
||||
foreach ($methods as $method) {
|
||||
$payment_methods[$method['code']] = $method['name'];
|
||||
if ($customer) {
|
||||
Cache::put('payment_methods.customer', $payment_methods, Date::now()->addHour(6));
|
||||
} else {
|
||||
Cache::put('payment_methods.admin', $payment_methods, Date::now()->addHour(6));
|
||||
}
|
||||
|
||||
Cache::put('payment_methods', $payment_methods, Date::now()->addHour(6));
|
||||
|
||||
return $payment_methods;
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ class OfflinePaymentConfirm
|
||||
*/
|
||||
public function handle(PaymentGatewayConfirm $event)
|
||||
{
|
||||
/*if (strpos($event->gateway, 'offlinepayment') === false) {
|
||||
return false;
|
||||
if (strpos($event->gateway, 'offlinepayment') === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
@ -23,6 +23,6 @@ class OfflinePaymentConfirm
|
||||
'name' => $event->gateway,
|
||||
'redirect' => false,
|
||||
'html' => true,
|
||||
];*/
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class Settings extends Controller
|
||||
|
||||
$offlinepayment[$key]['code'] = 'offlinepayment.' . $request['code'] . '.' . $method[2];
|
||||
$offlinepayment[$key]['name'] = $request['name'];
|
||||
$offlinepayment[$key]['customer'] = $request['customer'];
|
||||
$offlinepayment[$key]['order'] = $request['order'];
|
||||
$offlinepayment[$key]['description'] = $request['description'];
|
||||
}
|
||||
@ -48,6 +49,7 @@ class Settings extends Controller
|
||||
$offlinepayment[] = array(
|
||||
'code' => 'offlinepayment.' . $request['code'] . '.' . (count($offlinepayment) + 1),
|
||||
'name' => $request['name'],
|
||||
'customer' => $request['customer'],
|
||||
'order' => $request['order'],
|
||||
'description' => $request['description']
|
||||
);
|
||||
@ -83,6 +85,8 @@ class Settings extends Controller
|
||||
$method['code'] = $code[1];
|
||||
|
||||
$data = $method;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ return [
|
||||
'add_new' => 'Add New',
|
||||
'edit' => 'Edit: :method',
|
||||
'code' => 'Code',
|
||||
'customer' => 'Show to Customer',
|
||||
'order' => 'Order',
|
||||
'payment_gateways' => 'Offline Payment Methods',
|
||||
|
||||
|
@ -20,7 +20,9 @@
|
||||
|
||||
{{ Form::textGroup('code', trans('offlinepayment::offlinepayment.code'), 'key', ['required' => 'required'], null, 'col-md-12') }}
|
||||
|
||||
{{ Form::textGroup('order', trans('offlinepayment::offlinepayment.order'), 'sort', [], 0, 'col-md-12') }}
|
||||
{{ Form::radioGroup('customer', trans('offlinepayment::offlinepayment.customer'), '', ['required' => 'required'], 0, 'col-md-12') }}
|
||||
|
||||
{{ Form::textGroup('order', trans('offlinepayment::offlinepayment.order'), 'sort', [], null, 'col-md-12') }}
|
||||
|
||||
{{ Form::textareaGroup('description', trans('general.description')) }}
|
||||
</div>
|
||||
@ -109,6 +111,9 @@
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var text_yes = '{{ trans('general.yes') }}';
|
||||
var text_no = '{{ trans('general.no') }}';
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.method-edit').on('click', function() {
|
||||
var code = $(this).attr('id').replace('edit-', '');
|
||||
@ -134,6 +139,13 @@
|
||||
$('.col-md-4.no-padding-left .box-header.with-border .box-title').html(json['data']['title']);
|
||||
$('input[name="name"]').val(json['data']['name']);
|
||||
$('input[name="code"]').val(json['data']['code']);
|
||||
|
||||
if (json['data']['customer']) {
|
||||
$('#customer_1 input').trigger('click');
|
||||
} else {
|
||||
$('#customer_0 input').trigger('click');
|
||||
}
|
||||
|
||||
$('input[name="order"]').val(json['data']['order']);
|
||||
$('input[name="description"]').val(json['data']['description']);
|
||||
|
||||
|
18
public/css/app.css
vendored
18
public/css/app.css
vendored
@ -241,6 +241,12 @@ div.required .control-label:not(span):after, td.required:after {
|
||||
left: 40%;
|
||||
}
|
||||
|
||||
.confirm #loading {
|
||||
position: inherit;
|
||||
top: 40%;
|
||||
left: 40%;
|
||||
}
|
||||
|
||||
#payment-modal .form-group.col-md-6 .help-block {
|
||||
color : #F00;
|
||||
}
|
||||
@ -488,3 +494,15 @@ ul.add-new.nav.navbar-nav.pull-left {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
}
|
||||
/*
|
||||
.content-wrapper {
|
||||
overflow: inherit;
|
||||
}
|
||||
|
||||
.main-footer {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
z-index: 999;
|
||||
}*/
|
@ -152,11 +152,12 @@
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2">
|
||||
{!! Form::select('payment_method', $payment_methods, null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)])])) !!}
|
||||
@if ($payment_methods)
|
||||
{!! Form::select('payment_method', $payment_methods, null, array_merge(['id' => 'payment-method', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)])])) !!}
|
||||
{!! Form::hidden('invoice_id', $invoice->id, []) !!}
|
||||
<button type="button" id="button-payment" class="btn btn-success">
|
||||
<i class="fa fa-credit-card"></i> {{ trans('invoices.add_payment') }}
|
||||
</button>
|
||||
@else
|
||||
|
||||
@endif
|
||||
</div>
|
||||
<div class="confirm"></div>
|
||||
</div>
|
||||
@ -167,9 +168,9 @@
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$(document).on('click', '#button-payment', function (e) {
|
||||
$(document).on('change', '#payment-method', function (e) {
|
||||
$.ajax({
|
||||
url: '{{ url("customers/invoices/payment") }}',
|
||||
url: '{{ url("customers/invoices/" . $invoice->id . "payment") }}',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: $('.box-footer input, .box-footer select'),
|
||||
@ -183,7 +184,7 @@
|
||||
success: function(data) {
|
||||
$("#payment-modal").modal('hide');
|
||||
|
||||
location.reload();
|
||||
//location.reload();
|
||||
},
|
||||
error: function(data){
|
||||
|
||||
|
@ -120,9 +120,9 @@ Route::group(['middleware' => 'language'], function () {
|
||||
Route::group(['prefix' => 'customers'], function () {
|
||||
Route::get('/', 'Customers\Dashboard@index');
|
||||
|
||||
Route::get('invoices/{id}/print', 'Customers\Invoices@printInvoice');
|
||||
Route::get('invoices/{id}/pdf', 'Customers\Invoices@pdfInvoice');
|
||||
Route::post('invoices/payment', 'Customers\Invoices@payment');
|
||||
Route::get('invoices/{invoice}/print', 'Customers\Invoices@printInvoice');
|
||||
Route::get('invoices/{invoice}/pdf', 'Customers\Invoices@pdfInvoice');
|
||||
Route::post('invoices/{invoice}/payment', 'Customers\Invoices@payment');
|
||||
Route::resource('invoices', 'Customers\Invoices');
|
||||
Route::resource('payments', 'Customers\Payments');
|
||||
Route::resource('transactions', 'Customers\Transactions');
|
||||
|
Loading…
x
Reference in New Issue
Block a user