diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 762140c6955f..b9f66049e3a1 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -21,6 +21,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Yajra\DataTables\Facades\DataTables; use Yajra\DataTables\Html\Builder; +use Barracuda\ArchiveStream\Archive; /** * Class InvoiceController @@ -85,27 +86,59 @@ class InvoiceController extends Controller */ public function bulk() { -Log::error(request()->input('hashed_ids')); $transformed_ids = $this->transformKeys(explode(",",request()->input('hashed_ids'))); - $invoices = Invoice::whereIn('id', $transformed_ids) + if(request()->input('action') == 'payment') + return $this->makePayment($transformed_ids); + else if(request()->input('action') == 'download') + return $this->downloadInvoicePDF($transformed_ids); + + } + + + private function makePayment(array $ids) + { + + $invoices = Invoice::whereIn('id', $ids) ->whereClientId(auth()->user()->client->id) ->get() ->filter(function ($invoice){ return $invoice->isPayable(); }); -Log::error($invoices); - $data = [ 'invoices' => $invoices, ]; return view('portal.default.invoices.payment', $data); - + } + private function downloadInvoicePDF(array $ids) + { + $invoices = Invoice::whereIn('id', $ids) + ->whereClientId(auth()->user()->client->id) + ->get() + ->filter(function ($invoice){ + return $invoice->isPayable(); + }); + //generate pdf's of invoices locally + + + //if only 1 pdf, output to buffer for download + + + //if multiple pdf's, output to zip stream using Barracuda lib + + +/* + $zip = Archive::instance_by_useragent(date('Y-m-d') . '_' . str_replace(' ', '_', trans('texts.invoices'))); + $zip->add_file($name, $document->getRaw()); + $zip->finish(); +*/ + } + } diff --git a/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php new file mode 100644 index 000000000000..55d9ad085b93 --- /dev/null +++ b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php @@ -0,0 +1,77 @@ +ajax()) { + + return DataTables::of(Invoice::filter($filters))->addColumn('action', function ($invoice) { + return ''.ctrans('texts.view').''; + }) + ->editColumn('status_id', function ($invoice){ + return Invoice::badgeForStatus($invoice->status); + }) + ->rawColumns(['checkbox', 'action', 'status_id']) + ->make(true); + + } + + $data['html'] = $builder; + + return view('portal.default.recurring_invoices.index', $data); + + } + + /** + * Display the specified resource. + * + * @param \App\Models\Invoice $invoice The invoice + * + * @return \Illuminate\Http\Response + */ + public function show(RecurringInvoice $invoice) + { + + + } + + + +} diff --git a/app/Http/ViewComposers/PortalComposer.php b/app/Http/ViewComposers/PortalComposer.php index 10e04c046fcf..b5926acdb1fc 100644 --- a/app/Http/ViewComposers/PortalComposer.php +++ b/app/Http/ViewComposers/PortalComposer.php @@ -59,6 +59,7 @@ class PortalComposer $data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'fa fa-tachometer fa-fw fa-2x']; $data[] = [ 'title' => ctrans('texts.invoices'), 'url' => 'client.invoices.index', 'icon' => 'fa fa-file-pdf-o fa-fw fa-2x']; + $data[] = [ 'title' => ctrans('texts.recurring_invoices'), 'url' => 'client.recurring_invoices.index', 'icon' => 'fa fa-files-o fa-fw fa-2x']; return $data; diff --git a/app/Utils/SystemHealth.php b/app/Utils/SystemHealth.php index c49953f6ee29..f141919985d7 100644 --- a/app/Utils/SystemHealth.php +++ b/app/Utils/SystemHealth.php @@ -25,6 +25,7 @@ class SystemHealth 'gd', 'curl', 'zip', + 'gmp' ]; private static $php_version = 7.3; diff --git a/resources/views/portal/default/invoices/index.blade.php b/resources/views/portal/default/invoices/index.blade.php index 89077955c493..6499e14b9378 100644 --- a/resources/views/portal/default/invoices/index.blade.php +++ b/resources/views/portal/default/invoices/index.blade.php @@ -169,7 +169,7 @@ $(document).ready(function() { $('#hashed_ids').val(selected); - $('#action').val('pay'); + $('#action').val('payment'); $('#payment_form').submit(); }); diff --git a/resources/views/portal/default/recurring_invoices/index.blade.php b/resources/views/portal/default/recurring_invoices/index.blade.php new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/routes/client.php b/routes/client.php index 53b3e072b7ab..7c54247ca187 100644 --- a/routes/client.php +++ b/routes/client.php @@ -16,6 +16,7 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c Route::get('dashboard', 'ClientPortal\DashboardController@index')->name('dashboard'); // name = (dashboard. index / create / show / update / destroy / edit Route::get('invoices', 'ClientPortal\InvoiceController@index')->name('invoices.index'); + Route::get('recurring_invoices', 'ClientPortal\RecurringInvoiceController@index')->name('recurring_invoices.index'); Route::post('invoices/payment', 'ClientPortal\InvoiceController@bulk')->name('invoices.bulk'); Route::get('profile/{client_contact}/edit', 'ClientPortal\ProfileController@edit')->name('profile.edit'); Route::put('profile/{client_contact}/edit', 'ClientPortal\ProfileController@update')->name('profile.update');