2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
2016-01-07 20:39:51 +01:00
|
|
|
|
|
|
|
use App\Ninja\Repositories\PaymentTermRepository;
|
2017-02-26 10:39:25 +01:00
|
|
|
use App\Ninja\Datatables\PaymentTermDatatable;
|
2017-01-30 20:40:43 +01:00
|
|
|
use URL;
|
2016-01-07 20:39:51 +01:00
|
|
|
|
|
|
|
class PaymentTermService extends BaseService
|
|
|
|
{
|
|
|
|
protected $paymentTermRepo;
|
|
|
|
protected $datatableService;
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* PaymentTermService constructor.
|
|
|
|
*
|
|
|
|
* @param PaymentTermRepository $paymentTermRepo
|
2017-01-30 20:40:43 +01:00
|
|
|
* @param DatatableService $datatableService
|
2016-07-03 18:11:58 +02:00
|
|
|
*/
|
2016-01-07 20:39:51 +01:00
|
|
|
public function __construct(PaymentTermRepository $paymentTermRepo, DatatableService $datatableService)
|
|
|
|
{
|
|
|
|
$this->paymentTermRepo = $paymentTermRepo;
|
|
|
|
$this->datatableService = $datatableService;
|
|
|
|
}
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @return PaymentTermRepository
|
|
|
|
*/
|
2016-01-07 20:39:51 +01:00
|
|
|
protected function getRepo()
|
|
|
|
{
|
|
|
|
return $this->paymentTermRepo;
|
|
|
|
}
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @param int $accountId
|
2017-01-30 20:40:43 +01:00
|
|
|
*
|
2016-07-03 18:11:58 +02:00
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
2016-01-07 20:39:51 +01:00
|
|
|
public function getDatatable($accountId = 0)
|
|
|
|
{
|
2017-02-26 10:39:25 +01:00
|
|
|
$datatable = new PaymentTermDatatable(false);
|
2016-01-07 20:39:51 +01:00
|
|
|
|
2017-02-26 10:39:25 +01:00
|
|
|
$query = $this->paymentTermRepo->find($accountId);
|
|
|
|
|
|
|
|
return $this->datatableService->createDatatable($datatable, $query);
|
2016-01-07 20:39:51 +01:00
|
|
|
}
|
|
|
|
|
2016-05-23 18:52:20 +02:00
|
|
|
public function columns($entityType, $hideClient)
|
2016-01-07 20:39:51 +01:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'name',
|
|
|
|
function ($model) {
|
2016-03-02 14:36:42 +01:00
|
|
|
return link_to("payment_terms/{$model->public_id}/edit", $model->name)->toHtml();
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-01-07 20:39:51 +01:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'days',
|
|
|
|
function ($model) {
|
|
|
|
return $model->num_days;
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
|
|
|
],
|
2016-01-07 20:39:51 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-05-23 18:52:20 +02:00
|
|
|
public function actions($entityType)
|
2016-01-07 20:39:51 +01:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
uctrans('texts.edit_payment_terms'),
|
|
|
|
function ($model) {
|
|
|
|
return URL::to("payment_terms/{$model->public_id}/edit");
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
|
|
|
],
|
2016-01-07 20:39:51 +01:00
|
|
|
];
|
|
|
|
}
|
2016-05-23 18:52:20 +02:00
|
|
|
}
|