1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/app/Services/RecurringInvoiceService.php

32 lines
972 B
PHP
Raw Normal View History

2015-11-05 23:37:04 +01:00
<?php namespace App\Services;
2016-03-16 00:08:00 +01:00
use Auth;
2015-11-05 23:37:04 +01:00
use Utils;
use App\Ninja\Repositories\InvoiceRepository;
2016-05-23 18:52:20 +02:00
use App\Ninja\Datatables\RecurringInvoiceDatatable;
2015-11-05 23:37:04 +01:00
class RecurringInvoiceService extends BaseService
{
protected $invoiceRepo;
protected $datatableService;
public function __construct(InvoiceRepository $invoiceRepo, DatatableService $datatableService)
{
$this->invoiceRepo = $invoiceRepo;
$this->datatableService = $datatableService;
}
public function getDatatable($accountId, $clientPublicId = null, $entityType, $search)
{
2016-05-23 18:52:20 +02:00
$datatable = new RecurringInvoiceDatatable( ! $clientPublicId, $clientPublicId);
2015-11-05 23:37:04 +01:00
$query = $this->invoiceRepo->getRecurringInvoices($accountId, $clientPublicId, $search);
2016-03-16 00:08:00 +01:00
if(!Utils::hasPermission('view_all')){
$query->where('invoices.user_id', '=', Auth::user()->id);
}
2015-11-05 23:37:04 +01:00
2016-05-23 18:52:20 +02:00
return $this->datatableService->createDatatable($datatable, $query);
2015-11-05 23:37:04 +01:00
}
2016-05-23 18:52:20 +02:00
}