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