Add pay now button to each row in table

This commit is contained in:
David Bomba 2019-10-08 16:09:59 +11:00
parent fb513ebe69
commit 2e4cd7459a
2 changed files with 16 additions and 4 deletions

View File

@ -44,7 +44,7 @@ class InvoiceController extends Controller
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index(InvoiceFilters $filters, Builder $builder) public function index(InvoiceFilters $filters, Builder $builder)
{// {
$invoices = Invoice::filter($filters)->with('client', 'client.country'); $invoices = Invoice::filter($filters)->with('client', 'client.country');
if (request()->ajax()) { if (request()->ajax()) {
@ -68,7 +68,6 @@ class InvoiceController extends Controller
}) })
->rawColumns(['checkbox', 'action', 'status_id']) ->rawColumns(['checkbox', 'action', 'status_id'])
->make(true); ->make(true);
} }
$data['html'] = $builder; $data['html'] = $builder;
@ -82,8 +81,10 @@ class InvoiceController extends Controller
$buttons = '<div>'; $buttons = '<div>';
if($invoice->isPayable()){ if($invoice->isPayable()){
$buttons .= '<a href="/client/invoices/'. $invoice->hashed_id .'" class="btn btn-sm btn-info"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.pay_now').'</a>'; $buttons .= "<button type=\"button\" class=\"btn btn-sm btn-info\" onclick=\"payInvoice('".$invoice->hashed_id."')\"><i class=\"glyphicon glyphicon-edit\"></i>".ctrans('texts.pay_now')."</button>";
// $buttons .= '<a href="/client/invoices/'. $invoice->hashed_id .'" class="btn btn-sm btn-info"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.pay_now').'</a>';
} }
$buttons .= '<a href="/client/invoices/'. $invoice->hashed_id .'" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>'; $buttons .= '<a href="/client/invoices/'. $invoice->hashed_id .'" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
$buttons .="</div>"; $buttons .="</div>";

View File

@ -218,6 +218,18 @@ function filterTable() {
data_table.ajax.reload(); data_table.ajax.reload();
} }
function payInvoice(hashed_id) {
$('#pay_invoices_drop').addClass('disabled');
$('#download_invoices').addClass('disabled');
$('#hashed_ids').val(hashed_id);
$('#action').val('payment');
$('#payment_form').submit();
}
// Setup status filter // Setup status filter
$('#statuses').select2({ $('#statuses').select2({
placeholder: "{{ ctrans('texts.status') }}", placeholder: "{{ ctrans('texts.status') }}",
@ -251,7 +263,6 @@ $('#statuses').select2({
data_table.ajax.reload(); data_table.ajax.reload();
}); });
</script> </script>
@endpush @endpush