mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
5f928ecf01
@ -7,4 +7,4 @@ We welcome contributions! We'll improve this guide over time...
|
|||||||
Guidelines
|
Guidelines
|
||||||
* Try to follow [PSR-2 guidlines](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
|
* Try to follow [PSR-2 guidlines](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
|
||||||
* Create pull requests against the develop branch
|
* Create pull requests against the develop branch
|
||||||
* Submit translations through [Transifex](https://www.transifex.com/invoice-ninja/)
|
* Submit translations through [Transifex](https://www.transifex.com/invoice-ninja/invoice-ninja/)
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
### Pull Requests
|
### Pull Requests
|
||||||
* Please create pull requests against the develop branch
|
* Please create pull requests against the develop branch
|
||||||
* Submit translations through [Transifex](https://www.transifex.com/invoice-ninja/)
|
* Submit translations through [Transifex](https://www.transifex.com/invoice-ninja/invoice-ninja/)
|
||||||
|
|
||||||
### Contributors
|
### Contributors
|
||||||
* [Troels Liebe Bentsen](https://github.com/tlbdk)
|
* [Troels Liebe Bentsen](https://github.com/tlbdk)
|
||||||
|
@ -268,7 +268,12 @@ class AppController extends BaseController
|
|||||||
Artisan::call('migrate', array('--force' => true));
|
Artisan::call('migrate', array('--force' => true));
|
||||||
Artisan::call('db:seed', array('--force' => true, '--class' => "UpdateSeeder"));
|
Artisan::call('db:seed', array('--force' => true, '--class' => "UpdateSeeder"));
|
||||||
Event::fire(new UserSettingsChanged());
|
Event::fire(new UserSettingsChanged());
|
||||||
Session::flash('message', trans('texts.processed_updates'));
|
|
||||||
|
// show message with link to Trello board
|
||||||
|
$message = trans('texts.see_whats_new', ['version' => NINJA_VERSION]);
|
||||||
|
$message = link_to(RELEASES_URL, $message, ['target' => '_blank']);
|
||||||
|
$message = sprintf('%s - %s', trans('texts.processed_updates'), $message);
|
||||||
|
Session::flash('warning', $message);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Utils::logError($e);
|
Utils::logError($e);
|
||||||
return Response::make($e->getMessage(), 500);
|
return Response::make($e->getMessage(), 500);
|
||||||
|
@ -72,7 +72,10 @@ class ClientController extends BaseController
|
|||||||
|
|
||||||
public function getDatatable()
|
public function getDatatable()
|
||||||
{
|
{
|
||||||
return $this->clientService->getDatatable(Input::get('sSearch'));
|
$search = Input::get('sSearch');
|
||||||
|
$userId = Auth::user()->filterId();
|
||||||
|
|
||||||
|
return $this->clientService->getDatatable($search, $userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ use App\Events\QuoteInvitationWasViewed;
|
|||||||
use App\Services\PaymentService;
|
use App\Services\PaymentService;
|
||||||
use Barracuda\ArchiveStream\ZipArchive;
|
use Barracuda\ArchiveStream\ZipArchive;
|
||||||
|
|
||||||
class PublicClientController extends BaseController
|
class ClientPortalController extends BaseController
|
||||||
{
|
{
|
||||||
private $invoiceRepo;
|
private $invoiceRepo;
|
||||||
private $paymentRepo;
|
private $paymentRepo;
|
||||||
@ -323,7 +323,7 @@ class PublicClientController extends BaseController
|
|||||||
->addColumn('activity_type_id', function ($model) {
|
->addColumn('activity_type_id', function ($model) {
|
||||||
$data = [
|
$data = [
|
||||||
'client' => Utils::getClientDisplayName($model),
|
'client' => Utils::getClientDisplayName($model),
|
||||||
'user' => $model->is_system ? ('<i>' . trans('texts.system') . '</i>') : ($model->user_first_name . ' ' . $model->user_last_name),
|
'user' => $model->is_system ? ('<i>' . trans('texts.system') . '</i>') : ($model->account_name),
|
||||||
'invoice' => $model->invoice,
|
'invoice' => $model->invoice,
|
||||||
'contact' => Utils::getClientDisplayName($model),
|
'contact' => Utils::getClientDisplayName($model),
|
||||||
'payment' => $model->payment ? ' ' . $model->payment : '',
|
'payment' => $model->payment ? ' ' . $model->payment : '',
|
@ -80,8 +80,13 @@ class DashboardApiController extends BaseAPIController
|
|||||||
->where('accounts.id', '=', Auth::user()->account_id)
|
->where('accounts.id', '=', Auth::user()->account_id)
|
||||||
->where('clients.is_deleted', '=', false)
|
->where('clients.is_deleted', '=', false)
|
||||||
->groupBy('accounts.id')
|
->groupBy('accounts.id')
|
||||||
->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END'))
|
->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END'));
|
||||||
->get();
|
|
||||||
|
if (!$view_all) {
|
||||||
|
$balances->where('clients.user_id', '=', $user_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$balances = $balances->get();
|
||||||
|
|
||||||
$pastDue = DB::table('invoices')
|
$pastDue = DB::table('invoices')
|
||||||
->leftJoin('clients', 'clients.id', '=', 'invoices.client_id')
|
->leftJoin('clients', 'clients.id', '=', 'invoices.client_id')
|
||||||
|
@ -82,8 +82,13 @@ class DashboardController extends BaseController
|
|||||||
->where('accounts.id', '=', Auth::user()->account_id)
|
->where('accounts.id', '=', Auth::user()->account_id)
|
||||||
->where('clients.is_deleted', '=', false)
|
->where('clients.is_deleted', '=', false)
|
||||||
->groupBy('accounts.id')
|
->groupBy('accounts.id')
|
||||||
->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END'))
|
->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END'));
|
||||||
->get();
|
|
||||||
|
if (!$view_all) {
|
||||||
|
$balances->where('clients.user_id', '=', $user_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$balances = $balances->get();
|
||||||
|
|
||||||
$activities = Activity::where('activities.account_id', '=', Auth::user()->account_id)
|
$activities = Activity::where('activities.account_id', '=', Auth::user()->account_id)
|
||||||
->where('activities.activity_type_id', '>', 0);
|
->where('activities.activity_type_id', '>', 0);
|
||||||
|
@ -84,13 +84,14 @@ class ExportController extends BaseController
|
|||||||
if ($key === 'account' || $key === 'title' || $key === 'multiUser') {
|
if ($key === 'account' || $key === 'title' || $key === 'multiUser') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ($key === 'recurringInvoices') {
|
||||||
|
$key = 'recurring_invoices';
|
||||||
|
}
|
||||||
$label = trans("texts.{$key}");
|
$label = trans("texts.{$key}");
|
||||||
$excel->sheet($label, function($sheet) use ($key, $data) {
|
$excel->sheet($label, function($sheet) use ($key, $data) {
|
||||||
if ($key === 'quotes') {
|
if ($key === 'quotes') {
|
||||||
$key = 'invoices';
|
$key = 'invoices';
|
||||||
$data['entityType'] = ENTITY_QUOTE;
|
$data['entityType'] = ENTITY_QUOTE;
|
||||||
} elseif ($key === 'recurringInvoices') {
|
|
||||||
$key = 'recurring_invoices';
|
|
||||||
}
|
}
|
||||||
$sheet->loadView("export.{$key}", $data);
|
$sheet->loadView("export.{$key}", $data);
|
||||||
});
|
});
|
||||||
|
@ -37,36 +37,36 @@ Route::post('/get_started', 'AccountController@getStarted');
|
|||||||
|
|
||||||
// Client visible pages
|
// Client visible pages
|
||||||
Route::group(['middleware' => 'auth:client'], function() {
|
Route::group(['middleware' => 'auth:client'], function() {
|
||||||
Route::get('view/{invitation_key}', 'PublicClientController@view');
|
Route::get('view/{invitation_key}', 'ClientPortalController@view');
|
||||||
Route::get('download/{invitation_key}', 'PublicClientController@download');
|
Route::get('download/{invitation_key}', 'ClientPortalController@download');
|
||||||
Route::get('view', 'HomeController@viewLogo');
|
Route::get('view', 'HomeController@viewLogo');
|
||||||
Route::get('approve/{invitation_key}', 'QuoteController@approve');
|
Route::get('approve/{invitation_key}', 'QuoteController@approve');
|
||||||
Route::get('payment/{invitation_key}/{payment_type?}/{source_id?}', 'PaymentController@show_payment');
|
Route::get('payment/{invitation_key}/{payment_type?}/{source_id?}', 'PaymentController@show_payment');
|
||||||
Route::post('payment/{invitation_key}', 'PaymentController@do_payment');
|
Route::post('payment/{invitation_key}', 'PaymentController@do_payment');
|
||||||
Route::match(['GET', 'POST'], 'complete', 'PaymentController@offsite_payment');
|
Route::match(['GET', 'POST'], 'complete', 'PaymentController@offsite_payment');
|
||||||
Route::get('client/paymentmethods', 'PublicClientController@paymentMethods');
|
Route::get('client/paymentmethods', 'ClientPortalController@paymentMethods');
|
||||||
Route::post('client/paymentmethods/verify', 'PublicClientController@verifyPaymentMethod');
|
Route::post('client/paymentmethods/verify', 'ClientPortalController@verifyPaymentMethod');
|
||||||
Route::get('client/paymentmethods/add/{payment_type}/{source_id?}', 'PublicClientController@addPaymentMethod');
|
Route::get('client/paymentmethods/add/{payment_type}/{source_id?}', 'ClientPortalController@addPaymentMethod');
|
||||||
Route::post('client/paymentmethods/add/{payment_type}', 'PublicClientController@postAddPaymentMethod');
|
Route::post('client/paymentmethods/add/{payment_type}', 'ClientPortalController@postAddPaymentMethod');
|
||||||
Route::post('client/paymentmethods/default', 'PublicClientController@setDefaultPaymentMethod');
|
Route::post('client/paymentmethods/default', 'ClientPortalController@setDefaultPaymentMethod');
|
||||||
Route::post('client/paymentmethods/{source_id}/remove', 'PublicClientController@removePaymentMethod');
|
Route::post('client/paymentmethods/{source_id}/remove', 'ClientPortalController@removePaymentMethod');
|
||||||
Route::get('client/quotes', 'PublicClientController@quoteIndex');
|
Route::get('client/quotes', 'ClientPortalController@quoteIndex');
|
||||||
Route::get('client/invoices', 'PublicClientController@invoiceIndex');
|
Route::get('client/invoices', 'ClientPortalController@invoiceIndex');
|
||||||
Route::get('client/invoices/recurring', 'PublicClientController@recurringInvoiceIndex');
|
Route::get('client/invoices/recurring', 'ClientPortalController@recurringInvoiceIndex');
|
||||||
Route::post('client/invoices/auto_bill', 'PublicClientController@setAutoBill');
|
Route::post('client/invoices/auto_bill', 'ClientPortalController@setAutoBill');
|
||||||
Route::get('client/documents', 'PublicClientController@documentIndex');
|
Route::get('client/documents', 'ClientPortalController@documentIndex');
|
||||||
Route::get('client/payments', 'PublicClientController@paymentIndex');
|
Route::get('client/payments', 'ClientPortalController@paymentIndex');
|
||||||
Route::get('client/dashboard', 'PublicClientController@dashboard');
|
Route::get('client/dashboard', 'ClientPortalController@dashboard');
|
||||||
Route::get('client/documents/js/{documents}/{filename}', 'PublicClientController@getDocumentVFSJS');
|
Route::get('client/documents/js/{documents}/{filename}', 'ClientPortalController@getDocumentVFSJS');
|
||||||
Route::get('client/documents/{invitation_key}/{documents}/{filename?}', 'PublicClientController@getDocument');
|
Route::get('client/documents/{invitation_key}/{documents}/{filename?}', 'ClientPortalController@getDocument');
|
||||||
Route::get('client/documents/{invitation_key}/{filename?}', 'PublicClientController@getInvoiceDocumentsZip');
|
Route::get('client/documents/{invitation_key}/{filename?}', 'ClientPortalController@getInvoiceDocumentsZip');
|
||||||
|
|
||||||
Route::get('api/client.quotes', array('as'=>'api.client.quotes', 'uses'=>'PublicClientController@quoteDatatable'));
|
Route::get('api/client.quotes', array('as'=>'api.client.quotes', 'uses'=>'ClientPortalController@quoteDatatable'));
|
||||||
Route::get('api/client.invoices', array('as'=>'api.client.invoices', 'uses'=>'PublicClientController@invoiceDatatable'));
|
Route::get('api/client.invoices', array('as'=>'api.client.invoices', 'uses'=>'ClientPortalController@invoiceDatatable'));
|
||||||
Route::get('api/client.recurring_invoices', array('as'=>'api.client.recurring_invoices', 'uses'=>'PublicClientController@recurringInvoiceDatatable'));
|
Route::get('api/client.recurring_invoices', array('as'=>'api.client.recurring_invoices', 'uses'=>'ClientPortalController@recurringInvoiceDatatable'));
|
||||||
Route::get('api/client.documents', array('as'=>'api.client.documents', 'uses'=>'PublicClientController@documentDatatable'));
|
Route::get('api/client.documents', array('as'=>'api.client.documents', 'uses'=>'ClientPortalController@documentDatatable'));
|
||||||
Route::get('api/client.payments', array('as'=>'api.client.payments', 'uses'=>'PublicClientController@paymentDatatable'));
|
Route::get('api/client.payments', array('as'=>'api.client.payments', 'uses'=>'ClientPortalController@paymentDatatable'));
|
||||||
Route::get('api/client.activity', array('as'=>'api.client.activity', 'uses'=>'PublicClientController@activityDatatable'));
|
Route::get('api/client.activity', array('as'=>'api.client.activity', 'uses'=>'ClientPortalController@activityDatatable'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ Route::group(['middleware' => 'auth:user'], function() {
|
|||||||
Route::resource('expenses', 'ExpenseController');
|
Route::resource('expenses', 'ExpenseController');
|
||||||
Route::get('expenses/create/{vendor_id?}/{client_id?}', 'ExpenseController@create');
|
Route::get('expenses/create/{vendor_id?}/{client_id?}', 'ExpenseController@create');
|
||||||
Route::get('api/expense', array('as'=>'api.expenses', 'uses'=>'ExpenseController@getDatatable'));
|
Route::get('api/expense', array('as'=>'api.expenses', 'uses'=>'ExpenseController@getDatatable'));
|
||||||
Route::get('api/expenseVendor/{id}', array('as'=>'api.expense', 'uses'=>'ExpenseController@getDatatableVendor'));
|
Route::get('api/vendor_expense/{id}', array('as'=>'api.expense', 'uses'=>'ExpenseController@getDatatableVendor'));
|
||||||
Route::post('expenses/bulk', 'ExpenseController@bulk');
|
Route::post('expenses/bulk', 'ExpenseController@bulk');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5,4 +5,11 @@ use Eloquent;
|
|||||||
class DateFormat extends Eloquent
|
class DateFormat extends Eloquent
|
||||||
{
|
{
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
$date = mktime(0, 0, 0, 12, 31, date('Y'));
|
||||||
|
|
||||||
|
return date($this->format, $date);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,4 +5,11 @@ use Eloquent;
|
|||||||
class DatetimeFormat extends Eloquent
|
class DatetimeFormat extends Eloquent
|
||||||
{
|
{
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
$date = mktime(0, 0, 0, 12, 31, date('Y'));
|
||||||
|
|
||||||
|
return date($this->format, $date);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,6 +332,10 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
|||||||
public function owns($entity) {
|
public function owns($entity) {
|
||||||
return !empty($entity->user_id) && $entity->user_id == $this->id;
|
return !empty($entity->user_id) && $entity->user_id == $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function filterId() {
|
||||||
|
return $this->hasPermission('view_all') ? false : $this->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
User::updating(function ($user) {
|
User::updating(function ($user) {
|
||||||
|
110
app/Ninja/Datatables/AccountGatewayDatatable.php
Normal file
110
app/Ninja/Datatables/AccountGatewayDatatable.php
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
use App\Models\Gateway;
|
||||||
|
use App\Models\AccountGateway;
|
||||||
|
|
||||||
|
class AccountGatewayDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_ACCOUNT_GATEWAY;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'name',
|
||||||
|
function ($model) {
|
||||||
|
if ($model->deleted_at) {
|
||||||
|
return $model->name;
|
||||||
|
} elseif ($model->gateway_id != GATEWAY_WEPAY) {
|
||||||
|
return link_to("gateways/{$model->public_id}/edit", $model->name)->toHtml();
|
||||||
|
} else {
|
||||||
|
$accountGateway = AccountGateway::find($model->id);
|
||||||
|
$config = $accountGateway->getConfig();
|
||||||
|
$endpoint = WEPAY_ENVIRONMENT == WEPAY_STAGE ? 'https://stage.wepay.com/' : 'https://www.wepay.com/';
|
||||||
|
$wepayAccountId = $config->accountId;
|
||||||
|
$wepayState = isset($config->state)?$config->state:null;
|
||||||
|
$linkText = $model->name;
|
||||||
|
$url = $endpoint.'account/'.$wepayAccountId;
|
||||||
|
$wepay = \Utils::setupWepay($accountGateway);
|
||||||
|
$html = link_to($url, $linkText, array('target'=>'_blank'))->toHtml();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($wepayState == 'action_required') {
|
||||||
|
$updateUri = $wepay->request('/account/get_update_uri', array(
|
||||||
|
'account_id' => $wepayAccountId,
|
||||||
|
'redirect_uri' => URL::to('gateways'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$linkText .= ' <span style="color:#d9534f">('.trans('texts.action_required').')</span>';
|
||||||
|
$url = $updateUri->uri;
|
||||||
|
$html = "<a href=\"{$url}\">{$linkText}</a>";
|
||||||
|
$model->setupUrl = $url;
|
||||||
|
} elseif ($wepayState == 'pending') {
|
||||||
|
$linkText .= ' ('.trans('texts.resend_confirmation_email').')';
|
||||||
|
$model->resendConfirmationUrl = $url = URL::to("gateways/{$accountGateway->public_id}/resend_confirmation");
|
||||||
|
$html = link_to($url, $linkText)->toHtml();
|
||||||
|
}
|
||||||
|
} catch(\WePayException $ex){}
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'payment_type',
|
||||||
|
function ($model) {
|
||||||
|
return Gateway::getPrettyPaymentType($model->gateway_id);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
uctrans('texts.resend_confirmation_email'),
|
||||||
|
function ($model) {
|
||||||
|
return $model->resendConfirmationUrl;
|
||||||
|
},
|
||||||
|
function($model) {
|
||||||
|
return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY && !empty($model->resendConfirmationUrl);
|
||||||
|
}
|
||||||
|
], [
|
||||||
|
uctrans('texts.finish_setup'),
|
||||||
|
function ($model) {
|
||||||
|
return $model->setupUrl;
|
||||||
|
},
|
||||||
|
function($model) {
|
||||||
|
return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY && !empty($model->setupUrl);
|
||||||
|
}
|
||||||
|
] , [
|
||||||
|
uctrans('texts.edit_gateway'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("gateways/{$model->public_id}/edit");
|
||||||
|
},
|
||||||
|
function($model) {
|
||||||
|
return !$model->deleted_at;
|
||||||
|
}
|
||||||
|
], [
|
||||||
|
uctrans('texts.manage_wepay_account'),
|
||||||
|
function ($model) {
|
||||||
|
$accountGateway = AccountGateway::find($model->id);
|
||||||
|
$endpoint = WEPAY_ENVIRONMENT == WEPAY_STAGE ? 'https://stage.wepay.com/' : 'https://www.wepay.com/';
|
||||||
|
return array(
|
||||||
|
'url' => $endpoint.'account/'.$accountGateway->getConfig()->accountId,
|
||||||
|
'attributes' => 'target="_blank"'
|
||||||
|
);
|
||||||
|
},
|
||||||
|
function($model) {
|
||||||
|
return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
52
app/Ninja/Datatables/ActivityDatatable.php
Normal file
52
app/Ninja/Datatables/ActivityDatatable.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class ActivityDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_ACTIVITY;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'activities.id',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::timestampToDateTimeString(strtotime($model->created_at));
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'activity_type_id',
|
||||||
|
function ($model) {
|
||||||
|
$data = [
|
||||||
|
'client' => link_to('/clients/' . $model->client_public_id, Utils::getClientDisplayName($model))->toHtml(),
|
||||||
|
'user' => $model->is_system ? '<i>' . trans('texts.system') . '</i>' : Utils::getPersonDisplayName($model->user_first_name, $model->user_last_name, $model->user_email),
|
||||||
|
'invoice' => $model->invoice ? link_to('/invoices/' . $model->invoice_public_id, $model->is_recurring ? trans('texts.recurring_invoice') : $model->invoice)->toHtml() : null,
|
||||||
|
'quote' => $model->invoice ? link_to('/quotes/' . $model->invoice_public_id, $model->invoice)->toHtml() : null,
|
||||||
|
'contact' => $model->contact_id ? link_to('/clients/' . $model->client_public_id, Utils::getClientDisplayName($model))->toHtml() : Utils::getPersonDisplayName($model->user_first_name, $model->user_last_name, $model->user_email),
|
||||||
|
'payment' => $model->payment ?: '',
|
||||||
|
'credit' => $model->payment_amount ? Utils::formatMoney($model->credit, $model->currency_id, $model->country_id) : '',
|
||||||
|
'payment_amount' => $model->payment_amount ? Utils::formatMoney($model->payment_amount, $model->currency_id, $model->country_id) : null,
|
||||||
|
'adjustment' => $model->adjustment ? Utils::formatMoney($model->adjustment, $model->currency_id, $model->country_id) : null
|
||||||
|
];
|
||||||
|
|
||||||
|
return trans("texts.activity_{$model->activity_type_id}", $data);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'balance',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'adjustment',
|
||||||
|
function ($model) {
|
||||||
|
return $model->adjustment != 0 ? Utils::wrapAdjustment($model->adjustment, $model->currency_id, $model->country_id) : '';
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
42
app/Ninja/Datatables/BankAccountDatatable.php
Normal file
42
app/Ninja/Datatables/BankAccountDatatable.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class BankAccountDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_BANK_ACCOUNT;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'bank_name',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("bank_accounts/{$model->public_id}/edit", $model->bank_name)->toHtml();
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'bank_library_id',
|
||||||
|
function ($model) {
|
||||||
|
return 'OFX';
|
||||||
|
}
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
uctrans('texts.edit_bank_account'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("bank_accounts/{$model->public_id}/edit");
|
||||||
|
},
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
136
app/Ninja/Datatables/ClientDatatable.php
Normal file
136
app/Ninja/Datatables/ClientDatatable.php
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class ClientDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_CLIENT;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'name',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("clients/{$model->public_id}", $model->name ?: '')->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'first_name',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("clients/{$model->public_id}", $model->first_name.' '.$model->last_name)->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'email',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("clients/{$model->public_id}", $model->email ?: '')->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'clients.created_at',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::timestampToDateString(strtotime($model->created_at));
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'last_login',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::timestampToDateString(strtotime($model->last_login));
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'balance',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
trans('texts.edit_client'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("clients/{$model->public_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('editByOwner', [ENTITY_CLIENT, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'--divider--', function(){return false;},
|
||||||
|
function ($model) {
|
||||||
|
$user = Auth::user();
|
||||||
|
return $user->can('editByOwner', [ENTITY_CLIENT, $model->user_id]) && ($user->can('create', ENTITY_TASK) || $user->can('create', ENTITY_INVOICE));
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.new_task'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("tasks/create/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('create', ENTITY_TASK);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.new_invoice'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("invoices/create/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('create', ENTITY_INVOICE);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.new_quote'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("quotes/create/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->hasFeature(FEATURE_QUOTES) && Auth::user()->can('create', ENTITY_INVOICE);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'--divider--', function(){return false;},
|
||||||
|
function ($model) {
|
||||||
|
$user = Auth::user();
|
||||||
|
return ($user->can('create', ENTITY_TASK) || $user->can('create', ENTITY_INVOICE)) && ($user->can('create', ENTITY_PAYMENT) || $user->can('create', ENTITY_CREDIT) || $user->can('create', ENTITY_EXPENSE));
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.enter_payment'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("payments/create/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('create', ENTITY_PAYMENT);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.enter_credit'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("credits/create/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('create', ENTITY_CREDIT);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.enter_expense'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("expenses/create/0/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('create', ENTITY_EXPENSE);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
66
app/Ninja/Datatables/CreditDatatable.php
Normal file
66
app/Ninja/Datatables/CreditDatatable.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class CreditDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_CREDIT;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'client_name',
|
||||||
|
function ($model) {
|
||||||
|
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
||||||
|
return Utils::getClientDisplayName($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model->client_public_id ? link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml() : '';
|
||||||
|
},
|
||||||
|
! $this->hideClient
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'amount',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id) . '<span '.Utils::getEntityRowClass($model).'/>';
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'balance',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'credit_date',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::fromSqlDate($model->credit_date);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'private_notes',
|
||||||
|
function ($model) {
|
||||||
|
return $model->private_notes;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
trans('texts.apply_credit'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("payments/create/{$model->client_public_id}") . '?paymentTypeId=1';
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('create', ENTITY_PAYMENT);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
24
app/Ninja/Datatables/EntityDatatable.php
Normal file
24
app/Ninja/Datatables/EntityDatatable.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
class EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType;
|
||||||
|
public $isBulkEdit;
|
||||||
|
public $hideClient;
|
||||||
|
|
||||||
|
public function __construct($isBulkEdit = true, $hideClient = false)
|
||||||
|
{
|
||||||
|
$this->isBulkEdit = $isBulkEdit;
|
||||||
|
$this->hideClient = $hideClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
134
app/Ninja/Datatables/ExpenseDatatable.php
Normal file
134
app/Ninja/Datatables/ExpenseDatatable.php
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class ExpenseDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_EXPENSE;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'vendor_name',
|
||||||
|
function ($model)
|
||||||
|
{
|
||||||
|
if ($model->vendor_public_id) {
|
||||||
|
if(!Auth::user()->can('viewByOwner', [ENTITY_VENDOR, $model->vendor_user_id])){
|
||||||
|
return $model->vendor_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return link_to("vendors/{$model->vendor_public_id}", $model->vendor_name)->toHtml();
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
! $this->hideClient
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'client_name',
|
||||||
|
function ($model)
|
||||||
|
{
|
||||||
|
if ($model->client_public_id) {
|
||||||
|
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
||||||
|
return Utils::getClientDisplayName($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
! $this->hideClient
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'expense_date',
|
||||||
|
function ($model) {
|
||||||
|
if(!Auth::user()->can('editByOwner', [ENTITY_EXPENSE, $model->user_id])){
|
||||||
|
return Utils::fromSqlDate($model->expense_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
return link_to("expenses/{$model->public_id}/edit", Utils::fromSqlDate($model->expense_date))->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'amount',
|
||||||
|
function ($model) {
|
||||||
|
// show both the amount and the converted amount
|
||||||
|
if ($model->exchange_rate != 1) {
|
||||||
|
$converted = round($model->amount * $model->exchange_rate, 2);
|
||||||
|
return Utils::formatMoney($model->amount, $model->expense_currency_id) . ' | ' .
|
||||||
|
Utils::formatMoney($converted, $model->invoice_currency_id);
|
||||||
|
} else {
|
||||||
|
return Utils::formatMoney($model->amount, $model->expense_currency_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'public_notes',
|
||||||
|
function ($model) {
|
||||||
|
return $model->public_notes != null ? substr($model->public_notes, 0, 100) : '';
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'expense_status_id',
|
||||||
|
function ($model) {
|
||||||
|
return self::getStatusLabel($model->invoice_id, $model->should_be_invoiced);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
trans('texts.edit_expense'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("expenses/{$model->public_id}/edit") ;
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('editByOwner', [ENTITY_EXPENSE, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.view_invoice'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("/invoices/{$model->invoice_public_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return $model->invoice_public_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->invoice_user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.invoice_expense'),
|
||||||
|
function ($model) {
|
||||||
|
return "javascript:invoiceEntity({$model->public_id})";
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return ! $model->invoice_id && (!$model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('create', ENTITY_INVOICE);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function getStatusLabel($invoiceId, $shouldBeInvoiced)
|
||||||
|
{
|
||||||
|
if ($invoiceId) {
|
||||||
|
$label = trans('texts.invoiced');
|
||||||
|
$class = 'success';
|
||||||
|
} elseif ($shouldBeInvoiced) {
|
||||||
|
$label = trans('texts.pending');
|
||||||
|
$class = 'warning';
|
||||||
|
} else {
|
||||||
|
$label = trans('texts.logged');
|
||||||
|
$class = 'primary';
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
193
app/Ninja/Datatables/InvoiceDatatable.php
Normal file
193
app/Ninja/Datatables/InvoiceDatatable.php
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class InvoiceDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_INVOICE;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
$entityType = $this->entityType;
|
||||||
|
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'invoice_number',
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
if(!Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id])){
|
||||||
|
return $model->invoice_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
return link_to("{$entityType}s/{$model->public_id}/edit", $model->invoice_number, ['class' => Utils::getEntityRowClass($model)])->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'client_name',
|
||||||
|
function ($model) {
|
||||||
|
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
||||||
|
return Utils::getClientDisplayName($model);
|
||||||
|
}
|
||||||
|
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
|
||||||
|
},
|
||||||
|
! $this->hideClient
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'invoice_date',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::fromSqlDate($model->invoice_date);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'amount',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'balance',
|
||||||
|
function ($model) {
|
||||||
|
return $model->partial > 0 ?
|
||||||
|
trans('texts.partial_remaining', [
|
||||||
|
'partial' => Utils::formatMoney($model->partial, $model->currency_id, $model->country_id),
|
||||||
|
'balance' => Utils::formatMoney($model->balance, $model->currency_id, $model->country_id)]
|
||||||
|
) :
|
||||||
|
Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
||||||
|
},
|
||||||
|
$entityType == ENTITY_INVOICE
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'due_date',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::fromSqlDate($model->due_date);
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'invoice_status_name',
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return $model->quote_invoice_id ? link_to("invoices/{$model->quote_invoice_id}/edit", trans('texts.converted'))->toHtml() : self::getStatusLabel($model);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
$entityType = $this->entityType;
|
||||||
|
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
trans("texts.edit_{$entityType}"),
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return URL::to("{$entityType}s/{$model->public_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans("texts.clone_{$entityType}"),
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return URL::to("{$entityType}s/{$model->public_id}/clone");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('create', ENTITY_INVOICE);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans("texts.view_history"),
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return URL::to("{$entityType}s/{$entityType}_history/{$model->public_id}");
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'--divider--', function(){return false;},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]) || Auth::user()->can('create', ENTITY_PAYMENT);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans("texts.mark_sent"),
|
||||||
|
function ($model) {
|
||||||
|
return "javascript:markEntity({$model->public_id})";
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return $model->invoice_status_id < INVOICE_STATUS_SENT && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.enter_payment'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("payments/create/{$model->client_public_id}/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return $entityType == ENTITY_INVOICE && $model->balance > 0 && Auth::user()->can('create', ENTITY_PAYMENT);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans("texts.view_quote"),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("quotes/{$model->quote_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return $entityType == ENTITY_INVOICE && $model->quote_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans("texts.view_invoice"),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("invoices/{$model->quote_invoice_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return $entityType == ENTITY_QUOTE && $model->quote_invoice_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans("texts.convert_to_invoice"),
|
||||||
|
function ($model) {
|
||||||
|
return "javascript:convertEntity({$model->public_id})";
|
||||||
|
},
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return $entityType == ENTITY_QUOTE && ! $model->quote_invoice_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getStatusLabel($model)
|
||||||
|
{
|
||||||
|
$entityType = $this->entityType;
|
||||||
|
|
||||||
|
// check if invoice is overdue
|
||||||
|
if (Utils::parseFloat($model->balance) && $model->due_date && $model->due_date != '0000-00-00') {
|
||||||
|
if (\DateTime::createFromFormat('Y-m-d', $model->due_date) < new \DateTime("now")) {
|
||||||
|
$label = $entityType == ENTITY_INVOICE ? trans('texts.overdue') : trans('texts.expired');
|
||||||
|
return "<h4><div class=\"label label-danger\">" . $label . "</div></h4>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$label = trans("texts.status_" . strtolower($model->invoice_status_name));
|
||||||
|
$class = 'default';
|
||||||
|
switch ($model->invoice_status_id) {
|
||||||
|
case INVOICE_STATUS_SENT:
|
||||||
|
$class = 'info';
|
||||||
|
break;
|
||||||
|
case INVOICE_STATUS_VIEWED:
|
||||||
|
$class = 'warning';
|
||||||
|
break;
|
||||||
|
case INVOICE_STATUS_APPROVED:
|
||||||
|
$class = 'success';
|
||||||
|
break;
|
||||||
|
case INVOICE_STATUS_PARTIAL:
|
||||||
|
$class = 'primary';
|
||||||
|
break;
|
||||||
|
case INVOICE_STATUS_PAID:
|
||||||
|
$class = 'success';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
158
app/Ninja/Datatables/PaymentDatatable.php
Normal file
158
app/Ninja/Datatables/PaymentDatatable.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
use App\Models\PaymentMethod;
|
||||||
|
|
||||||
|
class PaymentDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_PAYMENT;
|
||||||
|
|
||||||
|
protected static $refundableGateways = array(
|
||||||
|
GATEWAY_STRIPE,
|
||||||
|
GATEWAY_BRAINTREE,
|
||||||
|
GATEWAY_WEPAY,
|
||||||
|
);
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'invoice_number',
|
||||||
|
function ($model) {
|
||||||
|
if(!Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->invoice_user_id])){
|
||||||
|
return $model->invoice_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
return link_to("invoices/{$model->invoice_public_id}/edit", $model->invoice_number, ['class' => Utils::getEntityRowClass($model)])->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'client_name',
|
||||||
|
function ($model) {
|
||||||
|
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
||||||
|
return Utils::getClientDisplayName($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model->client_public_id ? link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml() : '';
|
||||||
|
},
|
||||||
|
! $this->hideClient
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'transaction_reference',
|
||||||
|
function ($model) {
|
||||||
|
return $model->transaction_reference ? $model->transaction_reference : '<i>Manual entry</i>';
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'payment_type',
|
||||||
|
function ($model) {
|
||||||
|
return ($model->payment_type && !$model->last4) ? $model->payment_type : ($model->account_gateway_id ? $model->gateway_name : '');
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'source',
|
||||||
|
function ($model) {
|
||||||
|
$code = str_replace(' ', '', strtolower($model->payment_type));
|
||||||
|
$card_type = trans("texts.card_" . $code);
|
||||||
|
if ($model->payment_type_id != PAYMENT_TYPE_ACH) {
|
||||||
|
if($model->last4) {
|
||||||
|
$expiration = trans('texts.card_expiration', array('expires' => Utils::fromSqlDate($model->expiration, false)->format('m/y')));
|
||||||
|
return '<img height="22" src="' . URL::to('/images/credit_cards/' . $code . '.png') . '" alt="' . htmlentities($card_type) . '"> •••' . $model->last4 . ' ' . $expiration;
|
||||||
|
} elseif ($model->email) {
|
||||||
|
return $model->email;
|
||||||
|
}
|
||||||
|
} elseif ($model->last4) {
|
||||||
|
$bankData = PaymentMethod::lookupBankData($model->routing_number);
|
||||||
|
if (is_object($bankData)) {
|
||||||
|
return $bankData->name.' •••' . $model->last4;
|
||||||
|
} elseif($model->last4) {
|
||||||
|
return '<img height="22" src="' . URL::to('/images/credit_cards/ach.png') . '" alt="' . htmlentities($card_type) . '"> •••' . $model->last4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'amount',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'payment_date',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::dateToString($model->payment_date);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'payment_status_name',
|
||||||
|
function ($model) {
|
||||||
|
return self::getStatusLabel($model);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
trans('texts.edit_payment'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("payments/{$model->public_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('editByOwner', [ENTITY_PAYMENT, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.refund_payment'),
|
||||||
|
function ($model) {
|
||||||
|
$max_refund = number_format($model->amount - $model->refunded, 2);
|
||||||
|
$formatted = Utils::formatMoney($max_refund, $model->currency_id, $model->country_id);
|
||||||
|
$symbol = Utils::getFromCache($model->currency_id ? $model->currency_id : 1, 'currencies')->symbol ;
|
||||||
|
return "javascript:showRefundModal({$model->public_id}, '{$max_refund}', '{$formatted}', '{$symbol}')";
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('editByOwner', [ENTITY_PAYMENT, $model->user_id]) && $model->payment_status_id >= PAYMENT_STATUS_COMPLETED &&
|
||||||
|
$model->refunded < $model->amount &&
|
||||||
|
(
|
||||||
|
($model->transaction_reference && in_array($model->gateway_id , static::$refundableGateways))
|
||||||
|
|| $model->payment_type_id == PAYMENT_TYPE_CREDIT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getStatusLabel($model)
|
||||||
|
{
|
||||||
|
$label = trans("texts.status_" . strtolower($model->payment_status_name));
|
||||||
|
$class = 'default';
|
||||||
|
switch ($model->payment_status_id) {
|
||||||
|
case PAYMENT_STATUS_PENDING:
|
||||||
|
$class = 'info';
|
||||||
|
break;
|
||||||
|
case PAYMENT_STATUS_COMPLETED:
|
||||||
|
$class = 'success';
|
||||||
|
break;
|
||||||
|
case PAYMENT_STATUS_FAILED:
|
||||||
|
$class = 'danger';
|
||||||
|
break;
|
||||||
|
case PAYMENT_STATUS_PARTIALLY_REFUNDED:
|
||||||
|
$label = trans('texts.status_partially_refunded_amount', [
|
||||||
|
'amount' => Utils::formatMoney($model->refunded, $model->currency_id, $model->country_id),
|
||||||
|
]);
|
||||||
|
$class = 'primary';
|
||||||
|
break;
|
||||||
|
case PAYMENT_STATUS_VOIDED:
|
||||||
|
case PAYMENT_STATUS_REFUNDED:
|
||||||
|
$class = 'default';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||||
|
}
|
||||||
|
}
|
55
app/Ninja/Datatables/ProductDatatable.php
Normal file
55
app/Ninja/Datatables/ProductDatatable.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
use Str;
|
||||||
|
|
||||||
|
class ProductDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_PRODUCT;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'product_key',
|
||||||
|
function ($model) {
|
||||||
|
return link_to('products/'.$model->public_id.'/edit', $model->product_key)->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'notes',
|
||||||
|
function ($model) {
|
||||||
|
return nl2br(Str::limit($model->notes, 100));
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'cost',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::formatMoney($model->cost);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'tax_rate',
|
||||||
|
function ($model) {
|
||||||
|
return $model->tax_rate ? ($model->tax_name . ' ' . $model->tax_rate . '%') : '';
|
||||||
|
},
|
||||||
|
Auth::user()->account->invoice_item_taxes
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
uctrans('texts.edit_product'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("products/{$model->public_id}/edit");
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
63
app/Ninja/Datatables/RecurringInvoiceDatatable.php
Normal file
63
app/Ninja/Datatables/RecurringInvoiceDatatable.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class RecurringInvoiceDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_RECURRING_INVOICE;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'frequency',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("invoices/{$model->public_id}", $model->frequency)->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'client_name',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
|
||||||
|
},
|
||||||
|
! $this->hideClient
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'start_date',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::fromSqlDate($model->start_date);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'end_date',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::fromSqlDate($model->end_date);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'amount',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
trans('texts.edit_invoice'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("invoices/{$model->public_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
113
app/Ninja/Datatables/TaskDatatable.php
Normal file
113
app/Ninja/Datatables/TaskDatatable.php
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
use App\Models\Task;
|
||||||
|
|
||||||
|
class TaskDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_TASK;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'client_name',
|
||||||
|
function ($model) {
|
||||||
|
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
||||||
|
return Utils::getClientDisplayName($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model->client_public_id ? link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml() : '';
|
||||||
|
},
|
||||||
|
! $this->hideClient
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'created_at',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("tasks/{$model->public_id}/edit", Task::calcStartTime($model))->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'time_log',
|
||||||
|
function($model) {
|
||||||
|
return Utils::formatTime(Task::calcDuration($model));
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'description',
|
||||||
|
function ($model) {
|
||||||
|
return $model->description;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'invoice_number',
|
||||||
|
function ($model) {
|
||||||
|
return self::getStatusLabel($model);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
trans('texts.edit_task'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to('tasks/'.$model->public_id.'/edit');
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return (!$model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('editByOwner', [ENTITY_TASK, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.view_invoice'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("/invoices/{$model->invoice_public_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return $model->invoice_number && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->invoice_user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.stop_task'),
|
||||||
|
function ($model) {
|
||||||
|
return "javascript:stopTask({$model->public_id})";
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return $model->is_running && Auth::user()->can('editByOwner', [ENTITY_TASK, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.invoice_task'),
|
||||||
|
function ($model) {
|
||||||
|
return "javascript:invoiceEntity({$model->public_id})";
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return ! $model->invoice_number && (!$model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('create', ENTITY_INVOICE);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getStatusLabel($model)
|
||||||
|
{
|
||||||
|
if ($model->invoice_number) {
|
||||||
|
$class = 'success';
|
||||||
|
$label = trans('texts.invoiced');
|
||||||
|
} elseif ($model->is_running) {
|
||||||
|
$class = 'primary';
|
||||||
|
$label = trans('texts.running');
|
||||||
|
} else {
|
||||||
|
$class = 'default';
|
||||||
|
$label = trans('texts.logged');
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
41
app/Ninja/Datatables/TaxRateDatatable.php
Normal file
41
app/Ninja/Datatables/TaxRateDatatable.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class TaxRateDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_TAX_RATE;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'name',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("tax_rates/{$model->public_id}/edit", $model->name)->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'rate',
|
||||||
|
function ($model) {
|
||||||
|
return $model->rate . '%';
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
uctrans('texts.edit_tax_rate'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("tax_rates/{$model->public_id}/edit");
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
41
app/Ninja/Datatables/TokenDatatable.php
Normal file
41
app/Ninja/Datatables/TokenDatatable.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class TokenDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_TOKEN;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'name',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("tokens/{$model->public_id}/edit", $model->name)->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'token',
|
||||||
|
function ($model) {
|
||||||
|
return $model->token;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
uctrans('texts.edit_token'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("tokens/{$model->public_id}/edit");
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
96
app/Ninja/Datatables/UserDatatable.php
Normal file
96
app/Ninja/Datatables/UserDatatable.php
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class UserDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_USER;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'first_name',
|
||||||
|
function ($model) {
|
||||||
|
return $model->public_id ? link_to('users/'.$model->public_id.'/edit', $model->first_name.' '.$model->last_name)->toHtml() : ($model->first_name.' '.$model->last_name);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'email',
|
||||||
|
function ($model) {
|
||||||
|
return $model->email;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'confirmed',
|
||||||
|
function ($model) {
|
||||||
|
if (!$model->public_id) {
|
||||||
|
return self::getStatusLabel(USER_STATE_OWNER);
|
||||||
|
} elseif ($model->deleted_at) {
|
||||||
|
return self::getStatusLabel(USER_STATE_DISABLED);
|
||||||
|
} elseif ($model->confirmed) {
|
||||||
|
if($model->is_admin){
|
||||||
|
return self::getStatusLabel(USER_STATE_ADMIN);
|
||||||
|
} else {
|
||||||
|
return self::getStatusLabel(USER_STATE_ACTIVE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return self::getStatusLabel(USER_STATE_PENDING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
uctrans('texts.edit_user'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("users/{$model->public_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return $model->public_id;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
uctrans('texts.send_invite'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("send_confirmation/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return $model->public_id && ! $model->confirmed;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getStatusLabel($state)
|
||||||
|
{
|
||||||
|
$label = trans("texts.{$state}");
|
||||||
|
$class = 'default';
|
||||||
|
switch ($state) {
|
||||||
|
case USER_STATE_PENDING:
|
||||||
|
$class = 'default';
|
||||||
|
break;
|
||||||
|
case USER_STATE_ACTIVE:
|
||||||
|
$class = 'info';
|
||||||
|
break;
|
||||||
|
case USER_STATE_DISABLED:
|
||||||
|
$class = 'warning';
|
||||||
|
break;
|
||||||
|
case USER_STATE_OWNER:
|
||||||
|
$class = 'success';
|
||||||
|
break;
|
||||||
|
case USER_STATE_ADMIN:
|
||||||
|
$class = 'primary';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
79
app/Ninja/Datatables/VendorDatatable.php
Normal file
79
app/Ninja/Datatables/VendorDatatable.php
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?php namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
use URL;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class VendorDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_VENDOR;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'name',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("vendors/{$model->public_id}", $model->name ?: '')->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'city',
|
||||||
|
function ($model) {
|
||||||
|
return $model->city;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'work_phone',
|
||||||
|
function ($model) {
|
||||||
|
return $model->work_phone;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'email',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("vendors/{$model->public_id}", $model->email ?: '')->toHtml();
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vendors.created_at',
|
||||||
|
function ($model) {
|
||||||
|
return Utils::timestampToDateString(strtotime($model->created_at));
|
||||||
|
}
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
trans('texts.edit_vendor'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("vendors/{$model->public_id}/edit");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('editByOwner', [ENTITY_VENDOR, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'--divider--', function(){return false;},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('editByOwner', [ENTITY_VENDOR, $model->user_id]) && Auth::user()->can('create', ENTITY_EXPENSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
[
|
||||||
|
trans('texts.enter_expense'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("expenses/create/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('create', ENTITY_EXPENSE);
|
||||||
|
}
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
use URL;
|
use URL;
|
||||||
use Utils;
|
use Utils;
|
||||||
use Laracasts\Presenter\Presenter;
|
|
||||||
|
|
||||||
class ClientPresenter extends Presenter {
|
class ClientPresenter extends EntityPresenter {
|
||||||
|
|
||||||
public function country()
|
public function country()
|
||||||
{
|
{
|
||||||
@ -28,14 +27,4 @@ class ClientPresenter extends Presenter {
|
|||||||
|
|
||||||
return "<span class=\"label label-{$class}\">{$text}</span>";
|
return "<span class=\"label label-{$class}\">{$text}</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function url()
|
|
||||||
{
|
|
||||||
return URL::to('/clients/' . $this->entity->public_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function link()
|
|
||||||
{
|
|
||||||
return link_to('/clients/' . $this->entity->public_id, $this->entity->getDisplayName());
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,9 +1,8 @@
|
|||||||
<?php namespace App\Ninja\Presenters;
|
<?php namespace App\Ninja\Presenters;
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Laracasts\Presenter\Presenter;
|
|
||||||
|
|
||||||
class CreditPresenter extends Presenter {
|
class CreditPresenter extends EntityPresenter {
|
||||||
|
|
||||||
public function client()
|
public function client()
|
||||||
{
|
{
|
||||||
|
25
app/Ninja/Presenters/EntityPresenter.php
Normal file
25
app/Ninja/Presenters/EntityPresenter.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php namespace App\Ninja\Presenters;
|
||||||
|
|
||||||
|
use URL;
|
||||||
|
use Laracasts\Presenter\Presenter;
|
||||||
|
|
||||||
|
class EntityPresenter extends Presenter {
|
||||||
|
|
||||||
|
public function url()
|
||||||
|
{
|
||||||
|
$type = $this->entity->getEntityType();
|
||||||
|
$id = $this->entity->public_id;
|
||||||
|
$link = sprintf('/%ss/%s', $type, $id);
|
||||||
|
|
||||||
|
return URL::to($link);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function link()
|
||||||
|
{
|
||||||
|
$name = $this->entity->getDisplayName();
|
||||||
|
$link = $this->url();
|
||||||
|
|
||||||
|
return link_to($link, $name)->toHtml();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
<?php namespace App\Ninja\Presenters;
|
<?php namespace App\Ninja\Presenters;
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Laracasts\Presenter\Presenter;
|
|
||||||
|
|
||||||
class ExpensePresenter extends Presenter {
|
class ExpensePresenter extends EntityPresenter {
|
||||||
|
|
||||||
// Expenses
|
// Expenses
|
||||||
public function vendor()
|
public function vendor()
|
||||||
@ -21,8 +20,4 @@ class ExpensePresenter extends Presenter {
|
|||||||
return $this->entity->invoice_id ? $this->entity->convertedAmount() : 0;
|
return $this->entity->invoice_id ? $this->entity->convertedAmount() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function link()
|
|
||||||
{
|
|
||||||
return link_to('/expenses/' . $this->entity->public_id, $this->entity->name);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
use URL;
|
use URL;
|
||||||
use Utils;
|
use Utils;
|
||||||
use Laracasts\Presenter\Presenter;
|
|
||||||
|
|
||||||
class InvoicePresenter extends Presenter {
|
class InvoicePresenter extends EntityPresenter {
|
||||||
|
|
||||||
public function client()
|
public function client()
|
||||||
{
|
{
|
||||||
@ -45,6 +44,8 @@ class InvoicePresenter extends Presenter {
|
|||||||
return trans('texts.deleted');
|
return trans('texts.deleted');
|
||||||
} elseif ($this->entity->trashed()) {
|
} elseif ($this->entity->trashed()) {
|
||||||
return trans('texts.archived');
|
return trans('texts.archived');
|
||||||
|
} elseif ($this->entity->is_recurring) {
|
||||||
|
return trans('texts.active');
|
||||||
} else {
|
} else {
|
||||||
$status = $this->entity->invoice_status ? $this->entity->invoice_status->name : 'draft';
|
$status = $this->entity->invoice_status ? $this->entity->invoice_status->name : 'draft';
|
||||||
$status = strtolower($status);
|
$status = strtolower($status);
|
||||||
@ -67,16 +68,6 @@ class InvoicePresenter extends Presenter {
|
|||||||
return $this->entity->frequency ? $this->entity->frequency->name : '';
|
return $this->entity->frequency ? $this->entity->frequency->name : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function url()
|
|
||||||
{
|
|
||||||
return URL::to('/invoices/' . $this->entity->public_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function link()
|
|
||||||
{
|
|
||||||
return link_to('/invoices/' . $this->entity->public_id, $this->entity->invoice_number);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function email()
|
public function email()
|
||||||
{
|
{
|
||||||
$client = $this->entity->client;
|
$client = $this->entity->client;
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
use URL;
|
use URL;
|
||||||
use Utils;
|
use Utils;
|
||||||
use Laracasts\Presenter\Presenter;
|
|
||||||
|
|
||||||
class PaymentPresenter extends Presenter {
|
class PaymentPresenter extends EntityPresenter {
|
||||||
|
|
||||||
public function client()
|
public function client()
|
||||||
{
|
{
|
||||||
@ -25,14 +24,4 @@ class PaymentPresenter extends Presenter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function url()
|
|
||||||
{
|
|
||||||
return URL::to('/payments/' . $this->entity->public_id . '/edit');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function link()
|
|
||||||
{
|
|
||||||
return link_to('/payments/' . $this->entity->public_id . '/edit', $this->entity->getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,9 +1,6 @@
|
|||||||
<?php namespace App\Ninja\Presenters;
|
<?php namespace App\Ninja\Presenters;
|
||||||
|
|
||||||
use Utils;
|
class TaskPresenter extends EntityPresenter {
|
||||||
use Laracasts\Presenter\Presenter;
|
|
||||||
|
|
||||||
class TaskPresenter extends Presenter {
|
|
||||||
|
|
||||||
public function client()
|
public function client()
|
||||||
{
|
{
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
<?php namespace App\Ninja\Presenters;
|
<?php namespace App\Ninja\Presenters;
|
||||||
|
|
||||||
use Utils;
|
class VendorPresenter extends EntityPresenter {
|
||||||
use Laracasts\Presenter\Presenter;
|
|
||||||
// vendor
|
|
||||||
class VendorPresenter extends Presenter {
|
|
||||||
|
|
||||||
public function country()
|
public function country()
|
||||||
{
|
{
|
||||||
return $this->entity->country ? $this->entity->country->name : '';
|
return $this->entity->country ? $this->entity->country->name : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function link()
|
|
||||||
{
|
|
||||||
return link_to('/vendors/' . $this->entity->public_id, $this->entity->name);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -91,6 +91,7 @@ class ActivityRepository
|
|||||||
'invoices.public_id as invoice_public_id',
|
'invoices.public_id as invoice_public_id',
|
||||||
'invoices.is_recurring',
|
'invoices.is_recurring',
|
||||||
'clients.name as client_name',
|
'clients.name as client_name',
|
||||||
|
'accounts.name as account_name',
|
||||||
'clients.public_id as client_public_id',
|
'clients.public_id as client_public_id',
|
||||||
'contacts.id as contact',
|
'contacts.id as contact',
|
||||||
'contacts.first_name as first_name',
|
'contacts.first_name as first_name',
|
||||||
|
@ -25,7 +25,7 @@ class ClientRepository extends BaseRepository
|
|||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find($filter = null)
|
public function find($filter = null, $userId = false)
|
||||||
{
|
{
|
||||||
$query = DB::table('clients')
|
$query = DB::table('clients')
|
||||||
->join('accounts', 'accounts.id', '=', 'clients.account_id')
|
->join('accounts', 'accounts.id', '=', 'clients.account_id')
|
||||||
@ -63,6 +63,10 @@ class ClientRepository extends BaseRepository
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($userId) {
|
||||||
|
$query->where('clients.user_id', '=', $userId);
|
||||||
|
}
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,22 +36,8 @@ class ExpenseRepository extends BaseRepository
|
|||||||
public function findVendor($vendorPublicId)
|
public function findVendor($vendorPublicId)
|
||||||
{
|
{
|
||||||
$vendorId = Vendor::getPrivateId($vendorPublicId);
|
$vendorId = Vendor::getPrivateId($vendorPublicId);
|
||||||
$accountid = \Auth::user()->account_id;
|
|
||||||
$query = DB::table('expenses')
|
$query = $this->find()->where('expenses.vendor_id', '=', $vendorId);
|
||||||
->join('accounts', 'accounts.id', '=', 'expenses.account_id')
|
|
||||||
->where('expenses.account_id', '=', $accountid)
|
|
||||||
->where('expenses.vendor_id', '=', $vendorId)
|
|
||||||
->select(
|
|
||||||
'expenses.id',
|
|
||||||
'expenses.expense_date',
|
|
||||||
'expenses.amount',
|
|
||||||
'expenses.public_notes',
|
|
||||||
'expenses.public_id',
|
|
||||||
'expenses.deleted_at',
|
|
||||||
'expenses.should_be_invoiced',
|
|
||||||
'expenses.created_at',
|
|
||||||
'expenses.user_id'
|
|
||||||
);
|
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php namespace App\Services;
|
<?php namespace App\Services;
|
||||||
|
|
||||||
use URL;
|
use URL;
|
||||||
use App\Models\Gateway;
|
|
||||||
use App\Models\AccountGateway;
|
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Ninja\Repositories\AccountGatewayRepository;
|
use App\Ninja\Repositories\AccountGatewayRepository;
|
||||||
|
use App\Ninja\Datatables\AccountGatewayDatatable;
|
||||||
|
|
||||||
class AccountGatewayService extends BaseService
|
class AccountGatewayService extends BaseService
|
||||||
{
|
{
|
||||||
@ -22,114 +21,11 @@ class AccountGatewayService extends BaseService
|
|||||||
return $this->accountGatewayRepo;
|
return $this->accountGatewayRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function save()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getDatatable($accountId)
|
public function getDatatable($accountId)
|
||||||
{
|
{
|
||||||
$query = $this->accountGatewayRepo->find($accountId);
|
$query = $this->accountGatewayRepo->find($accountId);
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_ACCOUNT_GATEWAY, $query, false);
|
return $this->datatableService->createDatatable(new AccountGatewayDatatable(false), $query);
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'name',
|
|
||||||
function ($model) {
|
|
||||||
if ($model->deleted_at) {
|
|
||||||
return $model->name;
|
|
||||||
} elseif ($model->gateway_id != GATEWAY_WEPAY) {
|
|
||||||
return link_to("gateways/{$model->public_id}/edit", $model->name)->toHtml();
|
|
||||||
} else {
|
|
||||||
$accountGateway = AccountGateway::find($model->id);
|
|
||||||
$config = $accountGateway->getConfig();
|
|
||||||
$endpoint = WEPAY_ENVIRONMENT == WEPAY_STAGE ? 'https://stage.wepay.com/' : 'https://www.wepay.com/';
|
|
||||||
$wepayAccountId = $config->accountId;
|
|
||||||
$wepayState = isset($config->state)?$config->state:null;
|
|
||||||
$linkText = $model->name;
|
|
||||||
$url = $endpoint.'account/'.$wepayAccountId;
|
|
||||||
$wepay = \Utils::setupWepay($accountGateway);
|
|
||||||
$html = link_to($url, $linkText, array('target'=>'_blank'))->toHtml();
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ($wepayState == 'action_required') {
|
|
||||||
$updateUri = $wepay->request('/account/get_update_uri', array(
|
|
||||||
'account_id' => $wepayAccountId,
|
|
||||||
'redirect_uri' => URL::to('gateways'),
|
|
||||||
));
|
|
||||||
|
|
||||||
$linkText .= ' <span style="color:#d9534f">('.trans('texts.action_required').')</span>';
|
|
||||||
$url = $updateUri->uri;
|
|
||||||
$html = "<a href=\"{$url}\">{$linkText}</a>";
|
|
||||||
$model->setupUrl = $url;
|
|
||||||
} elseif ($wepayState == 'pending') {
|
|
||||||
$linkText .= ' ('.trans('texts.resend_confirmation_email').')';
|
|
||||||
$model->resendConfirmationUrl = $url = URL::to("gateways/{$accountGateway->public_id}/resend_confirmation");
|
|
||||||
$html = link_to($url, $linkText)->toHtml();
|
|
||||||
}
|
|
||||||
} catch(\WePayException $ex){}
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'payment_type',
|
|
||||||
function ($model) {
|
|
||||||
return Gateway::getPrettyPaymentType($model->gateway_id);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
uctrans('texts.resend_confirmation_email'),
|
|
||||||
function ($model) {
|
|
||||||
return $model->resendConfirmationUrl;
|
|
||||||
},
|
|
||||||
function($model) {
|
|
||||||
return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY && !empty($model->resendConfirmationUrl);
|
|
||||||
}
|
|
||||||
], [
|
|
||||||
uctrans('texts.finish_setup'),
|
|
||||||
function ($model) {
|
|
||||||
return $model->setupUrl;
|
|
||||||
},
|
|
||||||
function($model) {
|
|
||||||
return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY && !empty($model->setupUrl);
|
|
||||||
}
|
|
||||||
] , [
|
|
||||||
uctrans('texts.edit_gateway'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("gateways/{$model->public_id}/edit");
|
|
||||||
},
|
|
||||||
function($model) {
|
|
||||||
return !$model->deleted_at;
|
|
||||||
}
|
|
||||||
], [
|
|
||||||
uctrans('texts.manage_wepay_account'),
|
|
||||||
function ($model) {
|
|
||||||
$accountGateway = AccountGateway::find($model->id);
|
|
||||||
$endpoint = WEPAY_ENVIRONMENT == WEPAY_STAGE ? 'https://stage.wepay.com/' : 'https://www.wepay.com/';
|
|
||||||
return array(
|
|
||||||
'url' => $endpoint.'account/'.$accountGateway->getConfig()->accountId,
|
|
||||||
'attributes' => 'target="_blank"'
|
|
||||||
);
|
|
||||||
},
|
|
||||||
function($model) {
|
|
||||||
return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY;
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ use Utils;
|
|||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Ninja\Repositories\ActivityRepository;
|
use App\Ninja\Repositories\ActivityRepository;
|
||||||
|
use App\Ninja\Datatables\ActivityDatatable;
|
||||||
|
|
||||||
class ActivityService extends BaseService
|
class ActivityService extends BaseService
|
||||||
{
|
{
|
||||||
@ -22,48 +23,7 @@ class ActivityService extends BaseService
|
|||||||
|
|
||||||
$query = $this->activityRepo->findByClientId($clientId);
|
$query = $this->activityRepo->findByClientId($clientId);
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_ACTIVITY, $query);
|
return $this->datatableService->createDatatable(new ActivityDatatable(false), $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'activities.id',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::timestampToDateTimeString(strtotime($model->created_at));
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'activity_type_id',
|
|
||||||
function ($model) {
|
|
||||||
$data = [
|
|
||||||
'client' => link_to('/clients/' . $model->client_public_id, Utils::getClientDisplayName($model))->toHtml(),
|
|
||||||
'user' => $model->is_system ? '<i>' . trans('texts.system') . '</i>' : Utils::getPersonDisplayName($model->user_first_name, $model->user_last_name, $model->user_email),
|
|
||||||
'invoice' => $model->invoice ? link_to('/invoices/' . $model->invoice_public_id, $model->is_recurring ? trans('texts.recurring_invoice') : $model->invoice)->toHtml() : null,
|
|
||||||
'quote' => $model->invoice ? link_to('/quotes/' . $model->invoice_public_id, $model->invoice)->toHtml() : null,
|
|
||||||
'contact' => $model->contact_id ? link_to('/clients/' . $model->client_public_id, Utils::getClientDisplayName($model))->toHtml() : Utils::getPersonDisplayName($model->user_first_name, $model->user_last_name, $model->user_email),
|
|
||||||
'payment' => $model->payment ?: '',
|
|
||||||
'credit' => $model->payment_amount ? Utils::formatMoney($model->credit, $model->currency_id, $model->country_id) : '',
|
|
||||||
'payment_amount' => $model->payment_amount ? Utils::formatMoney($model->payment_amount, $model->currency_id, $model->country_id) : null,
|
|
||||||
'adjustment' => $model->adjustment ? Utils::formatMoney($model->adjustment, $model->currency_id, $model->country_id) : null
|
|
||||||
];
|
|
||||||
|
|
||||||
return trans("texts.activity_{$model->activity_type_id}", $data);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'balance',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'adjustment',
|
|
||||||
function ($model) {
|
|
||||||
return $model->adjustment != 0 ? Utils::wrapAdjustment($model->adjustment, $model->currency_id, $model->country_id) : '';
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ use App\Services\BaseService;
|
|||||||
use App\Ninja\Repositories\BankAccountRepository;
|
use App\Ninja\Repositories\BankAccountRepository;
|
||||||
use App\Ninja\Repositories\ExpenseRepository;
|
use App\Ninja\Repositories\ExpenseRepository;
|
||||||
use App\Ninja\Repositories\VendorRepository;
|
use App\Ninja\Repositories\VendorRepository;
|
||||||
|
use App\Ninja\Datatables\BankAccountDatatable;
|
||||||
use App\Libraries\Finance;
|
use App\Libraries\Finance;
|
||||||
use App\Libraries\Login;
|
use App\Libraries\Login;
|
||||||
|
|
||||||
@ -241,36 +242,6 @@ class BankAccountService extends BaseService
|
|||||||
{
|
{
|
||||||
$query = $this->bankAccountRepo->find($accountId);
|
$query = $this->bankAccountRepo->find($accountId);
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_BANK_ACCOUNT, $query, false);
|
return $this->datatableService->createDatatable(new BankAccountDatatable(false), $query);
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'bank_name',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("bank_accounts/{$model->public_id}/edit", $model->bank_name)->toHtml();
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'bank_library_id',
|
|
||||||
function ($model) {
|
|
||||||
return 'OFX';
|
|
||||||
}
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
uctrans('texts.edit_bank_account'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("bank_accounts/{$model->public_id}/edit");
|
|
||||||
},
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,21 +30,4 @@ class BaseService
|
|||||||
return count($entities);
|
return count($entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createDatatable($entityType, $query, $showCheckbox = true, $hideClient = false, $orderColumns = [])
|
|
||||||
{
|
|
||||||
$columns = $this->getDatatableColumns($entityType, !$showCheckbox);
|
|
||||||
$actions = $this->getDatatableActions($entityType);
|
|
||||||
|
|
||||||
return $this->datatableService->createDatatable($entityType, $query, $columns, $actions, $showCheckbox, $orderColumns);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ use App\Models\Payment;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Ninja\Repositories\ClientRepository;
|
use App\Ninja\Repositories\ClientRepository;
|
||||||
use App\Ninja\Repositories\NinjaRepository;
|
use App\Ninja\Repositories\NinjaRepository;
|
||||||
|
use App\Ninja\Datatables\ClientDatatable;
|
||||||
|
|
||||||
class ClientService extends BaseService
|
class ClientService extends BaseService
|
||||||
{
|
{
|
||||||
@ -39,139 +40,13 @@ class ClientService extends BaseService
|
|||||||
return $this->clientRepo->save($data, $client);
|
return $this->clientRepo->save($data, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDatatable($search)
|
public function getDatatable($search, $userId)
|
||||||
{
|
{
|
||||||
$query = $this->clientRepo->find($search);
|
$datatable = new ClientDatatable();
|
||||||
|
|
||||||
if(!Utils::hasPermission('view_all')){
|
$query = $this->clientRepo->find($search, $userId);
|
||||||
$query->where('clients.user_id', '=', Auth::user()->id);
|
|
||||||
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_CLIENT, $query);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'name',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("clients/{$model->public_id}", $model->name ?: '')->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'first_name',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("clients/{$model->public_id}", $model->first_name.' '.$model->last_name)->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'email',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("clients/{$model->public_id}", $model->email ?: '')->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'clients.created_at',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::timestampToDateString(strtotime($model->created_at));
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'last_login',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::timestampToDateString(strtotime($model->last_login));
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'balance',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
trans('texts.edit_client'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("clients/{$model->public_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('editByOwner', [ENTITY_CLIENT, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'--divider--', function(){return false;},
|
|
||||||
function ($model) {
|
|
||||||
$user = Auth::user();
|
|
||||||
return $user->can('editByOwner', [ENTITY_CLIENT, $model->user_id]) && ($user->can('create', ENTITY_TASK) || $user->can('create', ENTITY_INVOICE));
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.new_task'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("tasks/create/{$model->public_id}");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('create', ENTITY_TASK);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.new_invoice'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("invoices/create/{$model->public_id}");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('create', ENTITY_INVOICE);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.new_quote'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("quotes/create/{$model->public_id}");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->hasFeature(FEATURE_QUOTES) && Auth::user()->can('create', ENTITY_INVOICE);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'--divider--', function(){return false;},
|
|
||||||
function ($model) {
|
|
||||||
$user = Auth::user();
|
|
||||||
return ($user->can('create', ENTITY_TASK) || $user->can('create', ENTITY_INVOICE)) && ($user->can('create', ENTITY_PAYMENT) || $user->can('create', ENTITY_CREDIT) || $user->can('create', ENTITY_EXPENSE));
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.enter_payment'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("payments/create/{$model->public_id}");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('create', ENTITY_PAYMENT);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.enter_credit'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("credits/create/{$model->public_id}");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('create', ENTITY_CREDIT);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.enter_expense'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("expenses/create/0/{$model->public_id}");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('create', ENTITY_EXPENSE);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use App\Services\BaseService;
|
|||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Ninja\Repositories\CreditRepository;
|
use App\Ninja\Repositories\CreditRepository;
|
||||||
|
use App\Ninja\Datatables\CreditDatatable;
|
||||||
|
|
||||||
class CreditService extends BaseService
|
class CreditService extends BaseService
|
||||||
{
|
{
|
||||||
@ -32,68 +32,14 @@ class CreditService extends BaseService
|
|||||||
|
|
||||||
public function getDatatable($clientPublicId, $search)
|
public function getDatatable($clientPublicId, $search)
|
||||||
{
|
{
|
||||||
|
// we don't support bulk edit and hide the client on the individual client page
|
||||||
|
$datatable = new CreditDatatable( ! $clientPublicId, $clientPublicId);
|
||||||
$query = $this->creditRepo->find($clientPublicId, $search);
|
$query = $this->creditRepo->find($clientPublicId, $search);
|
||||||
|
|
||||||
if(!Utils::hasPermission('view_all')){
|
if(!Utils::hasPermission('view_all')){
|
||||||
$query->where('credits.user_id', '=', Auth::user()->id);
|
$query->where('credits.user_id', '=', Auth::user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_CREDIT, $query, !$clientPublicId);
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'client_name',
|
|
||||||
function ($model) {
|
|
||||||
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
|
||||||
return Utils::getClientDisplayName($model);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $model->client_public_id ? link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml() : '';
|
|
||||||
},
|
|
||||||
! $hideClient
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'amount',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id) . '<span '.Utils::getEntityRowClass($model).'/>';
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'balance',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'credit_date',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::fromSqlDate($model->credit_date);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'private_notes',
|
|
||||||
function ($model) {
|
|
||||||
return $model->private_notes;
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
trans('texts.apply_credit'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("payments/create/{$model->client_public_id}") . '?paymentTypeId=1';
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('create', ENTITY_PAYMENT);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,15 +4,16 @@ use HtmlString;
|
|||||||
use Utils;
|
use Utils;
|
||||||
use Datatable;
|
use Datatable;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use App\Ninja\Datatables\EntityDatatable;
|
||||||
|
|
||||||
class DatatableService
|
class DatatableService
|
||||||
{
|
{
|
||||||
public function createDatatable($entityType, $query, $columns, $actions = null, $showCheckbox = true, $orderColumns = [])
|
public function createDatatable(EntityDatatable $datatable, $query)
|
||||||
{
|
{
|
||||||
$table = Datatable::query($query);
|
$table = Datatable::query($query);
|
||||||
$calculateOrderColumns = empty($orderColumns);
|
//$calculateOrderColumns = empty($orderColumns);
|
||||||
|
|
||||||
if ($actions && $showCheckbox) {
|
if ($datatable->isBulkEdit) {
|
||||||
$table->addColumn('checkbox', function ($model) {
|
$table->addColumn('checkbox', function ($model) {
|
||||||
$can_edit = Auth::user()->hasPermission('edit_all') || (isset($model->user_id) && Auth::user()->id == $model->user_id);
|
$can_edit = Auth::user()->hasPermission('edit_all') || (isset($model->user_id) && Auth::user()->id == $model->user_id);
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ class DatatableService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($columns as $column) {
|
foreach ($datatable->columns() as $column) {
|
||||||
// set visible to true by default
|
// set visible to true by default
|
||||||
if (count($column) == 2) {
|
if (count($column) == 2) {
|
||||||
$column[] = true;
|
$column[] = true;
|
||||||
@ -31,22 +32,26 @@ class DatatableService
|
|||||||
|
|
||||||
if ($visible) {
|
if ($visible) {
|
||||||
$table->addColumn($field, $value);
|
$table->addColumn($field, $value);
|
||||||
|
$orderColumns[] = $field;
|
||||||
|
/*
|
||||||
if ($calculateOrderColumns) {
|
if ($calculateOrderColumns) {
|
||||||
$orderColumns[] = $field;
|
$orderColumns[] = $field;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($actions) {
|
if (count($datatable->actions())) {
|
||||||
$this->createDropdown($entityType, $table, $actions);
|
$this->createDropdown($datatable, $table);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $table->orderColumns($orderColumns)->make();
|
return $table->orderColumns($orderColumns)->make();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createDropdown($entityType, $table, $actions)
|
//private function createDropdown($entityType, $table, $actions)
|
||||||
|
private function createDropdown(EntityDatatable $datatable, $table)
|
||||||
{
|
{
|
||||||
$table->addColumn('dropdown', function ($model) use ($entityType, $actions) {
|
$table->addColumn('dropdown', function ($model) use ($datatable) {
|
||||||
$hasAction = false;
|
$hasAction = false;
|
||||||
$str = '<center style="min-width:100px">';
|
$str = '<center style="min-width:100px">';
|
||||||
|
|
||||||
@ -64,7 +69,7 @@ class DatatableService
|
|||||||
|
|
||||||
$lastIsDivider = false;
|
$lastIsDivider = false;
|
||||||
if (!$model->deleted_at || $model->deleted_at == '0000-00-00') {
|
if (!$model->deleted_at || $model->deleted_at == '0000-00-00') {
|
||||||
foreach ($actions as $action) {
|
foreach ($datatable->actions() as $action) {
|
||||||
if (count($action)) {
|
if (count($action)) {
|
||||||
if (count($action) == 2) {
|
if (count($action) == 2) {
|
||||||
$action[] = function() {
|
$action[] = function() {
|
||||||
@ -104,20 +109,20 @@ class DatatableService
|
|||||||
$dropdown_contents .= "<li class=\"divider\"></li>";
|
$dropdown_contents .= "<li class=\"divider\"></li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($entityType != ENTITY_USER || $model->public_id) && $can_edit) {
|
if (($datatable->entityType != ENTITY_USER || $model->public_id) && $can_edit) {
|
||||||
$dropdown_contents .= "<li><a href=\"javascript:archiveEntity({$model->public_id})\">"
|
$dropdown_contents .= "<li><a href=\"javascript:archiveEntity({$model->public_id})\">"
|
||||||
. trans("texts.archive_{$entityType}") . "</a></li>";
|
. trans("texts.archive_{$datatable->entityType}") . "</a></li>";
|
||||||
}
|
}
|
||||||
} else if($can_edit) {
|
} else if($can_edit) {
|
||||||
if ($entityType != ENTITY_ACCOUNT_GATEWAY || Auth::user()->account->canAddGateway(\App\Models\Gateway::getPaymentType($model->gateway_id))) {
|
if ($datatable->entityType != ENTITY_ACCOUNT_GATEWAY || Auth::user()->account->canAddGateway(\App\Models\Gateway::getPaymentType($model->gateway_id))) {
|
||||||
$dropdown_contents .= "<li><a href=\"javascript:restoreEntity({$model->public_id})\">"
|
$dropdown_contents .= "<li><a href=\"javascript:restoreEntity({$model->public_id})\">"
|
||||||
. trans("texts.restore_{$entityType}") . "</a></li>";
|
. trans("texts.restore_{$datatable->entityType}") . "</a></li>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property_exists($model, 'is_deleted') && !$model->is_deleted && $can_edit) {
|
if (property_exists($model, 'is_deleted') && !$model->is_deleted && $can_edit) {
|
||||||
$dropdown_contents .= "<li><a href=\"javascript:deleteEntity({$model->public_id})\">"
|
$dropdown_contents .= "<li><a href=\"javascript:deleteEntity({$model->public_id})\">"
|
||||||
. trans("texts.delete_{$entityType}") . "</a></li>";
|
. trans("texts.delete_{$datatable->entityType}") . "</a></li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($dropdown_contents)) {
|
if (!empty($dropdown_contents)) {
|
||||||
@ -132,5 +137,4 @@ class DatatableService
|
|||||||
return $str.'</div></center>';
|
return $str.'</div></center>';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ use App\Models\Expense;
|
|||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Vendor;
|
use App\Models\Vendor;
|
||||||
|
use App\Ninja\Datatables\ExpenseDatatable;
|
||||||
|
|
||||||
class ExpenseService extends BaseService
|
class ExpenseService extends BaseService
|
||||||
{
|
{
|
||||||
@ -49,89 +50,22 @@ class ExpenseService extends BaseService
|
|||||||
$query->where('expenses.user_id', '=', Auth::user()->id);
|
$query->where('expenses.user_id', '=', Auth::user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_EXPENSE, $query);
|
return $this->datatableService->createDatatable(new ExpenseDatatable(), $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDatatableVendor($vendorPublicId)
|
public function getDatatableVendor($vendorPublicId)
|
||||||
{
|
{
|
||||||
|
$datatable = new ExpenseDatatable(false, true);
|
||||||
|
|
||||||
$query = $this->expenseRepo->findVendor($vendorPublicId);
|
$query = $this->expenseRepo->findVendor($vendorPublicId);
|
||||||
return $this->datatableService->createDatatable(ENTITY_EXPENSE,
|
|
||||||
$query,
|
if(!Utils::hasPermission('view_all')){
|
||||||
$this->getDatatableColumnsVendor(ENTITY_EXPENSE,false),
|
$query->where('expenses.user_id', '=', Auth::user()->id);
|
||||||
$this->getDatatableActionsVendor(ENTITY_EXPENSE),
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'vendor_name',
|
|
||||||
function ($model)
|
|
||||||
{
|
|
||||||
if ($model->vendor_public_id) {
|
|
||||||
if(!Auth::user()->can('viewByOwner', [ENTITY_VENDOR, $model->vendor_user_id])){
|
|
||||||
return $model->vendor_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return link_to("vendors/{$model->vendor_public_id}", $model->vendor_name)->toHtml();
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'client_name',
|
|
||||||
function ($model)
|
|
||||||
{
|
|
||||||
if ($model->client_public_id) {
|
|
||||||
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
|
||||||
return Utils::getClientDisplayName($model);
|
|
||||||
}
|
|
||||||
|
|
||||||
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'expense_date',
|
|
||||||
function ($model) {
|
|
||||||
if(!Auth::user()->can('editByOwner', [ENTITY_EXPENSE, $model->user_id])){
|
|
||||||
return Utils::fromSqlDate($model->expense_date);
|
|
||||||
}
|
|
||||||
|
|
||||||
return link_to("expenses/{$model->public_id}/edit", Utils::fromSqlDate($model->expense_date))->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'amount',
|
|
||||||
function ($model) {
|
|
||||||
// show both the amount and the converted amount
|
|
||||||
if ($model->exchange_rate != 1) {
|
|
||||||
$converted = round($model->amount * $model->exchange_rate, 2);
|
|
||||||
return Utils::formatMoney($model->amount, $model->expense_currency_id) . ' | ' .
|
|
||||||
Utils::formatMoney($converted, $model->invoice_currency_id);
|
|
||||||
} else {
|
|
||||||
return Utils::formatMoney($model->amount, $model->expense_currency_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'public_notes',
|
|
||||||
function ($model) {
|
|
||||||
return $model->public_notes != null ? substr($model->public_notes, 0, 100) : '';
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'expense_status_id',
|
|
||||||
function ($model) {
|
|
||||||
return self::getStatusLabel($model->invoice_id, $model->should_be_invoiced);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumnsVendor($entityType, $hideClient)
|
protected function getDatatableColumnsVendor($entityType, $hideClient)
|
||||||
{
|
{
|
||||||
@ -163,58 +97,9 @@ class ExpenseService extends BaseService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
trans('texts.edit_expense'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("expenses/{$model->public_id}/edit") ;
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('editByOwner', [ENTITY_EXPENSE, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.view_invoice'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("/invoices/{$model->invoice_public_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return $model->invoice_public_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->invoice_user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.invoice_expense'),
|
|
||||||
function ($model) {
|
|
||||||
return "javascript:invoiceEntity({$model->public_id})";
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return ! $model->invoice_id && (!$model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('create', ENTITY_INVOICE);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActionsVendor($entityType)
|
protected function getDatatableActionsVendor($entityType)
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getStatusLabel($invoiceId, $shouldBeInvoiced)
|
|
||||||
{
|
|
||||||
if ($invoiceId) {
|
|
||||||
$label = trans('texts.invoiced');
|
|
||||||
$class = 'success';
|
|
||||||
} elseif ($shouldBeInvoiced) {
|
|
||||||
$label = trans('texts.pending');
|
|
||||||
$class = 'warning';
|
|
||||||
} else {
|
|
||||||
$label = trans('texts.logged');
|
|
||||||
$class = 'primary';
|
|
||||||
}
|
|
||||||
|
|
||||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ use App\Models\Invitation;
|
|||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
|
use App\Ninja\Datatables\InvoiceDatatable;
|
||||||
|
|
||||||
class InvoiceService extends BaseService
|
class InvoiceService extends BaseService
|
||||||
{
|
{
|
||||||
@ -118,6 +119,7 @@ class InvoiceService extends BaseService
|
|||||||
|
|
||||||
public function getDatatable($accountId, $clientPublicId = null, $entityType, $search)
|
public function getDatatable($accountId, $clientPublicId = null, $entityType, $search)
|
||||||
{
|
{
|
||||||
|
$datatable = new InvoiceDatatable( ! $clientPublicId, $clientPublicId);
|
||||||
$query = $this->invoiceRepo->getInvoices($accountId, $clientPublicId, $entityType, $search)
|
$query = $this->invoiceRepo->getInvoices($accountId, $clientPublicId, $entityType, $search)
|
||||||
->where('invoices.is_quote', '=', $entityType == ENTITY_QUOTE ? true : false);
|
->where('invoices.is_quote', '=', $entityType == ENTITY_QUOTE ? true : false);
|
||||||
|
|
||||||
@ -125,182 +127,7 @@ class InvoiceService extends BaseService
|
|||||||
$query->where('invoices.user_id', '=', Auth::user()->id);
|
$query->where('invoices.user_id', '=', Auth::user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createDatatable($entityType, $query, !$clientPublicId);
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'invoice_number',
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
if(!Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id])){
|
|
||||||
return $model->invoice_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
return link_to("{$entityType}s/{$model->public_id}/edit", $model->invoice_number, ['class' => Utils::getEntityRowClass($model)])->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'client_name',
|
|
||||||
function ($model) {
|
|
||||||
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
|
||||||
return Utils::getClientDisplayName($model);
|
|
||||||
}
|
|
||||||
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
|
|
||||||
},
|
|
||||||
! $hideClient
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'invoice_date',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::fromSqlDate($model->invoice_date);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'amount',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'balance',
|
|
||||||
function ($model) {
|
|
||||||
return $model->partial > 0 ?
|
|
||||||
trans('texts.partial_remaining', [
|
|
||||||
'partial' => Utils::formatMoney($model->partial, $model->currency_id, $model->country_id),
|
|
||||||
'balance' => Utils::formatMoney($model->balance, $model->currency_id, $model->country_id)]
|
|
||||||
) :
|
|
||||||
Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
|
||||||
},
|
|
||||||
$entityType == ENTITY_INVOICE
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'due_date',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::fromSqlDate($model->due_date);
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'invoice_status_name',
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
return $model->quote_invoice_id ? link_to("invoices/{$model->quote_invoice_id}/edit", trans('texts.converted'))->toHtml() : self::getStatusLabel($entityType, $model);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
trans("texts.edit_{$entityType}"),
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
return URL::to("{$entityType}s/{$model->public_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans("texts.clone_{$entityType}"),
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
return URL::to("{$entityType}s/{$model->public_id}/clone");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('create', ENTITY_INVOICE);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans("texts.view_history"),
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
return URL::to("{$entityType}s/{$entityType}_history/{$model->public_id}");
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'--divider--', function(){return false;},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]) || Auth::user()->can('create', ENTITY_PAYMENT);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans("texts.mark_sent"),
|
|
||||||
function ($model) {
|
|
||||||
return "javascript:markEntity({$model->public_id})";
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return $model->invoice_status_id < INVOICE_STATUS_SENT && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.enter_payment'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("payments/create/{$model->client_public_id}/{$model->public_id}");
|
|
||||||
},
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
return $entityType == ENTITY_INVOICE && $model->balance > 0 && Auth::user()->can('create', ENTITY_PAYMENT);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans("texts.view_quote"),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("quotes/{$model->quote_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
return $entityType == ENTITY_INVOICE && $model->quote_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans("texts.view_invoice"),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("invoices/{$model->quote_invoice_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
return $entityType == ENTITY_QUOTE && $model->quote_invoice_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans("texts.convert_to_invoice"),
|
|
||||||
function ($model) {
|
|
||||||
return "javascript:convertEntity({$model->public_id})";
|
|
||||||
},
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
return $entityType == ENTITY_QUOTE && ! $model->quote_invoice_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getStatusLabel($entityType, $model)
|
|
||||||
{
|
|
||||||
// check if invoice is overdue
|
|
||||||
if (Utils::parseFloat($model->balance) && $model->due_date && $model->due_date != '0000-00-00') {
|
|
||||||
if (\DateTime::createFromFormat('Y-m-d', $model->due_date) < new \DateTime("now")) {
|
|
||||||
$label = $entityType == ENTITY_INVOICE ? trans('texts.overdue') : trans('texts.expired');
|
|
||||||
return "<h4><div class=\"label label-danger\">" . $label . "</div></h4>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$label = trans("texts.status_" . strtolower($model->invoice_status_name));
|
|
||||||
$class = 'default';
|
|
||||||
switch ($model->invoice_status_id) {
|
|
||||||
case INVOICE_STATUS_SENT:
|
|
||||||
$class = 'info';
|
|
||||||
break;
|
|
||||||
case INVOICE_STATUS_VIEWED:
|
|
||||||
$class = 'warning';
|
|
||||||
break;
|
|
||||||
case INVOICE_STATUS_APPROVED:
|
|
||||||
$class = 'success';
|
|
||||||
break;
|
|
||||||
case INVOICE_STATUS_PARTIAL:
|
|
||||||
$class = 'primary';
|
|
||||||
break;
|
|
||||||
case INVOICE_STATUS_PAID:
|
|
||||||
$class = 'success';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,13 @@ use App\Ninja\Repositories\PaymentRepository;
|
|||||||
use App\Ninja\Repositories\AccountRepository;
|
use App\Ninja\Repositories\AccountRepository;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Events\PaymentWasCreated;
|
use App\Events\PaymentWasCreated;
|
||||||
|
use App\Ninja\Datatables\PaymentDatatable;
|
||||||
|
|
||||||
class PaymentService extends BaseService
|
class PaymentService extends BaseService
|
||||||
{
|
{
|
||||||
public $lastError;
|
public $lastError;
|
||||||
protected $datatableService;
|
protected $datatableService;
|
||||||
|
|
||||||
protected static $refundableGateways = array(
|
|
||||||
GATEWAY_STRIPE,
|
|
||||||
GATEWAY_BRAINTREE,
|
|
||||||
GATEWAY_WEPAY,
|
|
||||||
);
|
|
||||||
|
|
||||||
public function __construct(PaymentRepository $paymentRepo, AccountRepository $accountRepo, DatatableService $datatableService)
|
public function __construct(PaymentRepository $paymentRepo, AccountRepository $accountRepo, DatatableService $datatableService)
|
||||||
{
|
{
|
||||||
$this->datatableService = $datatableService;
|
$this->datatableService = $datatableService;
|
||||||
@ -856,126 +851,16 @@ class PaymentService extends BaseService
|
|||||||
|
|
||||||
public function getDatatable($clientPublicId, $search)
|
public function getDatatable($clientPublicId, $search)
|
||||||
{
|
{
|
||||||
|
$datatable = new PaymentDatatable( ! $clientPublicId, $clientPublicId);
|
||||||
$query = $this->paymentRepo->find($clientPublicId, $search);
|
$query = $this->paymentRepo->find($clientPublicId, $search);
|
||||||
|
|
||||||
if(!Utils::hasPermission('view_all')){
|
if(!Utils::hasPermission('view_all')){
|
||||||
$query->where('payments.user_id', '=', Auth::user()->id);
|
$query->where('payments.user_id', '=', Auth::user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_PAYMENT, $query, !$clientPublicId, false,
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
['invoice_number', 'transaction_reference', 'payment_type', 'amount', 'payment_date']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'invoice_number',
|
|
||||||
function ($model) {
|
|
||||||
if(!Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->invoice_user_id])){
|
|
||||||
return $model->invoice_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
return link_to("invoices/{$model->invoice_public_id}/edit", $model->invoice_number, ['class' => Utils::getEntityRowClass($model)])->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'client_name',
|
|
||||||
function ($model) {
|
|
||||||
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
|
||||||
return Utils::getClientDisplayName($model);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $model->client_public_id ? link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml() : '';
|
|
||||||
},
|
|
||||||
! $hideClient
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'transaction_reference',
|
|
||||||
function ($model) {
|
|
||||||
return $model->transaction_reference ? $model->transaction_reference : '<i>Manual entry</i>';
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'payment_type',
|
|
||||||
function ($model) {
|
|
||||||
return ($model->payment_type && !$model->last4) ? $model->payment_type : ($model->account_gateway_id ? $model->gateway_name : '');
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'source',
|
|
||||||
function ($model) {
|
|
||||||
$code = str_replace(' ', '', strtolower($model->payment_type));
|
|
||||||
$card_type = trans("texts.card_" . $code);
|
|
||||||
if ($model->payment_type_id != PAYMENT_TYPE_ACH) {
|
|
||||||
if($model->last4) {
|
|
||||||
$expiration = trans('texts.card_expiration', array('expires' => Utils::fromSqlDate($model->expiration, false)->format('m/y')));
|
|
||||||
return '<img height="22" src="' . URL::to('/images/credit_cards/' . $code . '.png') . '" alt="' . htmlentities($card_type) . '"> •••' . $model->last4 . ' ' . $expiration;
|
|
||||||
} elseif ($model->email) {
|
|
||||||
return $model->email;
|
|
||||||
}
|
|
||||||
} elseif ($model->last4) {
|
|
||||||
$bankData = PaymentMethod::lookupBankData($model->routing_number);
|
|
||||||
if (is_object($bankData)) {
|
|
||||||
return $bankData->name.' •••' . $model->last4;
|
|
||||||
} elseif($model->last4) {
|
|
||||||
return '<img height="22" src="' . URL::to('/images/credit_cards/ach.png') . '" alt="' . htmlentities($card_type) . '"> •••' . $model->last4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'amount',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'payment_date',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::dateToString($model->payment_date);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'payment_status_name',
|
|
||||||
function ($model) use ($entityType) {
|
|
||||||
return self::getStatusLabel($entityType, $model);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
trans('texts.edit_payment'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("payments/{$model->public_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('editByOwner', [ENTITY_PAYMENT, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.refund_payment'),
|
|
||||||
function ($model) {
|
|
||||||
$max_refund = number_format($model->amount - $model->refunded, 2);
|
|
||||||
$formatted = Utils::formatMoney($max_refund, $model->currency_id, $model->country_id);
|
|
||||||
$symbol = Utils::getFromCache($model->currency_id ? $model->currency_id : 1, 'currencies')->symbol ;
|
|
||||||
return "javascript:showRefundModal({$model->public_id}, '{$max_refund}', '{$formatted}', '{$symbol}')";
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('editByOwner', [ENTITY_PAYMENT, $model->user_id]) && $model->payment_status_id >= PAYMENT_STATUS_COMPLETED &&
|
|
||||||
$model->refunded < $model->amount &&
|
|
||||||
(
|
|
||||||
($model->transaction_reference && in_array($model->gateway_id , static::$refundableGateways))
|
|
||||||
|| $model->payment_type_id == PAYMENT_TYPE_CREDIT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function bulk($ids, $action, $params = array())
|
public function bulk($ids, $action, $params = array())
|
||||||
{
|
{
|
||||||
@ -1002,34 +887,6 @@ class PaymentService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getStatusLabel($entityType, $model)
|
|
||||||
{
|
|
||||||
$label = trans("texts.status_" . strtolower($model->payment_status_name));
|
|
||||||
$class = 'default';
|
|
||||||
switch ($model->payment_status_id) {
|
|
||||||
case PAYMENT_STATUS_PENDING:
|
|
||||||
$class = 'info';
|
|
||||||
break;
|
|
||||||
case PAYMENT_STATUS_COMPLETED:
|
|
||||||
$class = 'success';
|
|
||||||
break;
|
|
||||||
case PAYMENT_STATUS_FAILED:
|
|
||||||
$class = 'danger';
|
|
||||||
break;
|
|
||||||
case PAYMENT_STATUS_PARTIALLY_REFUNDED:
|
|
||||||
$label = trans('texts.status_partially_refunded_amount', [
|
|
||||||
'amount' => Utils::formatMoney($model->refunded, $model->currency_id, $model->country_id),
|
|
||||||
]);
|
|
||||||
$class = 'primary';
|
|
||||||
break;
|
|
||||||
case PAYMENT_STATUS_VOIDED:
|
|
||||||
case PAYMENT_STATUS_REFUNDED:
|
|
||||||
$class = 'default';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function refund($payment, $amount = null) {
|
public function refund($payment, $amount = null) {
|
||||||
if ($amount) {
|
if ($amount) {
|
||||||
$amount = min($amount, $payment->amount - $payment->refunded);
|
$amount = min($amount, $payment->amount - $payment->refunded);
|
||||||
|
@ -25,10 +25,10 @@ class PaymentTermService extends BaseService
|
|||||||
{
|
{
|
||||||
$query = $this->paymentTermRepo->find();
|
$query = $this->paymentTermRepo->find();
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_PAYMENT_TERM, $query, false);
|
return $this->datatableService->createDatatable(ENTITY_PAYMENT_TERM, $query, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
public function columns($entityType, $hideClient)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
@ -46,7 +46,7 @@ class PaymentTermService extends BaseService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
public function actions($entityType)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<?php namespace App\Services;
|
<?php namespace App\Services;
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Str;
|
|
||||||
use DB;
|
use DB;
|
||||||
use Auth;
|
use Auth;
|
||||||
use URL;
|
use URL;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Ninja\Repositories\ProductRepository;
|
use App\Ninja\Repositories\ProductRepository;
|
||||||
|
use App\Ninja\Datatables\ProductDatatable;
|
||||||
|
|
||||||
class ProductService extends BaseService
|
class ProductService extends BaseService
|
||||||
{
|
{
|
||||||
@ -33,52 +33,10 @@ class ProductService extends BaseService
|
|||||||
|
|
||||||
public function getDatatable($accountId)
|
public function getDatatable($accountId)
|
||||||
{
|
{
|
||||||
|
$datatable = new ProductDatatable(false);
|
||||||
$query = $this->productRepo->find($accountId);
|
$query = $this->productRepo->find($accountId);
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_PRODUCT, $query, false);
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'product_key',
|
|
||||||
function ($model) {
|
|
||||||
return link_to('products/'.$model->public_id.'/edit', $model->product_key)->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'notes',
|
|
||||||
function ($model) {
|
|
||||||
return nl2br(Str::limit($model->notes, 100));
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'cost',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::formatMoney($model->cost);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'tax_rate',
|
|
||||||
function ($model) {
|
|
||||||
return $model->tax_rate ? ($model->tax_name . ' ' . $model->tax_rate . '%') : '';
|
|
||||||
},
|
|
||||||
Auth::user()->account->invoice_item_taxes
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
uctrans('texts.edit_product'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("products/{$model->public_id}/edit");
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,6 +5,7 @@ use Auth;
|
|||||||
use Utils;
|
use Utils;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Ninja\Repositories\InvoiceRepository;
|
use App\Ninja\Repositories\InvoiceRepository;
|
||||||
|
use App\Ninja\Datatables\RecurringInvoiceDatatable;
|
||||||
|
|
||||||
class RecurringInvoiceService extends BaseService
|
class RecurringInvoiceService extends BaseService
|
||||||
{
|
{
|
||||||
@ -19,64 +20,14 @@ class RecurringInvoiceService extends BaseService
|
|||||||
|
|
||||||
public function getDatatable($accountId, $clientPublicId = null, $entityType, $search)
|
public function getDatatable($accountId, $clientPublicId = null, $entityType, $search)
|
||||||
{
|
{
|
||||||
|
$datatable = new RecurringInvoiceDatatable( ! $clientPublicId, $clientPublicId);
|
||||||
$query = $this->invoiceRepo->getRecurringInvoices($accountId, $clientPublicId, $search);
|
$query = $this->invoiceRepo->getRecurringInvoices($accountId, $clientPublicId, $search);
|
||||||
|
|
||||||
if(!Utils::hasPermission('view_all')){
|
if(!Utils::hasPermission('view_all')){
|
||||||
$query->where('invoices.user_id', '=', Auth::user()->id);
|
$query->where('invoices.user_id', '=', Auth::user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_RECURRING_INVOICE, $query, !$clientPublicId);
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'frequency',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("invoices/{$model->public_id}", $model->frequency)->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'client_name',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
|
|
||||||
},
|
|
||||||
! $hideClient
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'start_date',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::fromSqlDate($model->start_date);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'end_date',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::fromSqlDate($model->end_date);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'amount',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
trans('texts.edit_invoice'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("invoices/{$model->public_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Ninja\Repositories\TaskRepository;
|
use App\Ninja\Repositories\TaskRepository;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
|
use App\Ninja\Datatables\TaskDatatable;
|
||||||
|
|
||||||
class TaskService extends BaseService
|
class TaskService extends BaseService
|
||||||
{
|
{
|
||||||
@ -34,112 +35,14 @@ class TaskService extends BaseService
|
|||||||
|
|
||||||
public function getDatatable($clientPublicId, $search)
|
public function getDatatable($clientPublicId, $search)
|
||||||
{
|
{
|
||||||
|
$datatable = new TaskDatatable( ! $clientPublicId, $clientPublicId);
|
||||||
$query = $this->taskRepo->find($clientPublicId, $search);
|
$query = $this->taskRepo->find($clientPublicId, $search);
|
||||||
|
|
||||||
if(!Utils::hasPermission('view_all')){
|
if(!Utils::hasPermission('view_all')){
|
||||||
$query->where('tasks.user_id', '=', Auth::user()->id);
|
$query->where('tasks.user_id', '=', Auth::user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_TASK, $query, !$clientPublicId);
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'client_name',
|
|
||||||
function ($model) {
|
|
||||||
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
|
|
||||||
return Utils::getClientDisplayName($model);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $model->client_public_id ? link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml() : '';
|
|
||||||
},
|
|
||||||
! $hideClient
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'created_at',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("tasks/{$model->public_id}/edit", Task::calcStartTime($model))->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'time_log',
|
|
||||||
function($model) {
|
|
||||||
return Utils::formatTime(Task::calcDuration($model));
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'description',
|
|
||||||
function ($model) {
|
|
||||||
return $model->description;
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'invoice_number',
|
|
||||||
function ($model) {
|
|
||||||
return self::getStatusLabel($model);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
trans('texts.edit_task'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to('tasks/'.$model->public_id.'/edit');
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return (!$model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('editByOwner', [ENTITY_TASK, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.view_invoice'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("/invoices/{$model->invoice_public_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return $model->invoice_number && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->invoice_user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.stop_task'),
|
|
||||||
function ($model) {
|
|
||||||
return "javascript:stopTask({$model->public_id})";
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return $model->is_running && Auth::user()->can('editByOwner', [ENTITY_TASK, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.invoice_task'),
|
|
||||||
function ($model) {
|
|
||||||
return "javascript:invoiceEntity({$model->public_id})";
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return ! $model->invoice_number && (!$model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('create', ENTITY_INVOICE);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getStatusLabel($model)
|
|
||||||
{
|
|
||||||
if ($model->invoice_number) {
|
|
||||||
$class = 'success';
|
|
||||||
$label = trans('texts.invoiced');
|
|
||||||
} elseif ($model->is_running) {
|
|
||||||
$class = 'primary';
|
|
||||||
$label = trans('texts.running');
|
|
||||||
} else {
|
|
||||||
$class = 'default';
|
|
||||||
$label = trans('texts.logged');
|
|
||||||
}
|
|
||||||
|
|
||||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ use URL;
|
|||||||
use Auth;
|
use Auth;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Ninja\Repositories\TaxRateRepository;
|
use App\Ninja\Repositories\TaxRateRepository;
|
||||||
|
use App\Ninja\Datatables\TaxRateDatatable;
|
||||||
|
|
||||||
class TaxRateService extends BaseService
|
class TaxRateService extends BaseService
|
||||||
{
|
{
|
||||||
@ -21,48 +22,12 @@ class TaxRateService extends BaseService
|
|||||||
return $this->taxRateRepo;
|
return $this->taxRateRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function save()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getDatatable($accountId)
|
public function getDatatable($accountId)
|
||||||
{
|
{
|
||||||
|
$datatable = new TaxRateDatatable(false);
|
||||||
$query = $this->taxRateRepo->find($accountId);
|
$query = $this->taxRateRepo->find($accountId);
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_TAX_RATE, $query, false);
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'name',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("tax_rates/{$model->public_id}/edit", $model->name)->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'rate',
|
|
||||||
function ($model) {
|
|
||||||
return $model->rate . '%';
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
uctrans('texts.edit_tax_rate'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("tax_rates/{$model->public_id}/edit");
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,6 +3,7 @@
|
|||||||
use URL;
|
use URL;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Ninja\Repositories\TokenRepository;
|
use App\Ninja\Repositories\TokenRepository;
|
||||||
|
use App\Ninja\Datatables\TokenDatatable;
|
||||||
|
|
||||||
class TokenService extends BaseService
|
class TokenService extends BaseService
|
||||||
{
|
{
|
||||||
@ -20,48 +21,12 @@ class TokenService extends BaseService
|
|||||||
return $this->tokenRepo;
|
return $this->tokenRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function save()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getDatatable($userId)
|
public function getDatatable($userId)
|
||||||
{
|
{
|
||||||
|
$datatable = new TokenDatatable(false);
|
||||||
$query = $this->tokenRepo->find($userId);
|
$query = $this->tokenRepo->find($userId);
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_TOKEN, $query, false);
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'name',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("tokens/{$model->public_id}/edit", $model->name)->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'token',
|
|
||||||
function ($model) {
|
|
||||||
return $model->token;
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
uctrans('texts.edit_token'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("tokens/{$model->public_id}/edit");
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,6 +3,7 @@
|
|||||||
use URL;
|
use URL;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Ninja\Repositories\UserRepository;
|
use App\Ninja\Repositories\UserRepository;
|
||||||
|
use App\Ninja\Datatables\UserDatatable;
|
||||||
|
|
||||||
class UserService extends BaseService
|
class UserService extends BaseService
|
||||||
{
|
{
|
||||||
@ -20,102 +21,12 @@ class UserService extends BaseService
|
|||||||
return $this->userRepo;
|
return $this->userRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function save()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getDatatable($accountId)
|
public function getDatatable($accountId)
|
||||||
{
|
{
|
||||||
|
$datatable = new UserDatatable(false);
|
||||||
$query = $this->userRepo->find($accountId);
|
$query = $this->userRepo->find($accountId);
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_USER, $query, false);
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideClient)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'first_name',
|
|
||||||
function ($model) {
|
|
||||||
return $model->public_id ? link_to('users/'.$model->public_id.'/edit', $model->first_name.' '.$model->last_name)->toHtml() : ($model->first_name.' '.$model->last_name);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'email',
|
|
||||||
function ($model) {
|
|
||||||
return $model->email;
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'confirmed',
|
|
||||||
function ($model) {
|
|
||||||
if (!$model->public_id) {
|
|
||||||
return self::getStatusLabel(USER_STATE_OWNER);
|
|
||||||
} elseif ($model->deleted_at) {
|
|
||||||
return self::getStatusLabel(USER_STATE_DISABLED);
|
|
||||||
} elseif ($model->confirmed) {
|
|
||||||
if($model->is_admin){
|
|
||||||
return self::getStatusLabel(USER_STATE_ADMIN);
|
|
||||||
} else {
|
|
||||||
return self::getStatusLabel(USER_STATE_ACTIVE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return self::getStatusLabel(USER_STATE_PENDING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
uctrans('texts.edit_user'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("users/{$model->public_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return $model->public_id;
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
uctrans('texts.send_invite'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("send_confirmation/{$model->public_id}");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return $model->public_id && ! $model->confirmed;
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getStatusLabel($state)
|
|
||||||
{
|
|
||||||
$label = trans("texts.{$state}");
|
|
||||||
$class = 'default';
|
|
||||||
switch ($state) {
|
|
||||||
case USER_STATE_PENDING:
|
|
||||||
$class = 'default';
|
|
||||||
break;
|
|
||||||
case USER_STATE_ACTIVE:
|
|
||||||
$class = 'info';
|
|
||||||
break;
|
|
||||||
case USER_STATE_DISABLED:
|
|
||||||
$class = 'warning';
|
|
||||||
break;
|
|
||||||
case USER_STATE_OWNER:
|
|
||||||
$class = 'success';
|
|
||||||
break;
|
|
||||||
case USER_STATE_ADMIN:
|
|
||||||
$class = 'primary';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ use App\Models\Expense;
|
|||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Ninja\Repositories\VendorRepository;
|
use App\Ninja\Repositories\VendorRepository;
|
||||||
use App\Ninja\Repositories\NinjaRepository;
|
use App\Ninja\Repositories\NinjaRepository;
|
||||||
|
use App\Ninja\Datatables\VendorDatatable;
|
||||||
|
|
||||||
class VendorService extends BaseService
|
class VendorService extends BaseService
|
||||||
{
|
{
|
||||||
@ -37,79 +38,14 @@ class VendorService extends BaseService
|
|||||||
|
|
||||||
public function getDatatable($search)
|
public function getDatatable($search)
|
||||||
{
|
{
|
||||||
|
$datatable = new VendorDatatable();
|
||||||
$query = $this->vendorRepo->find($search);
|
$query = $this->vendorRepo->find($search);
|
||||||
|
|
||||||
if(!Utils::hasPermission('view_all')){
|
if(!Utils::hasPermission('view_all')){
|
||||||
$query->where('vendors.user_id', '=', Auth::user()->id);
|
$query->where('vendors.user_id', '=', Auth::user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createDatatable(ENTITY_VENDOR, $query);
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDatatableColumns($entityType, $hideVendor)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'name',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("vendors/{$model->public_id}", $model->name ?: '')->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'city',
|
|
||||||
function ($model) {
|
|
||||||
return $model->city;
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'work_phone',
|
|
||||||
function ($model) {
|
|
||||||
return $model->work_phone;
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'email',
|
|
||||||
function ($model) {
|
|
||||||
return link_to("vendors/{$model->public_id}", $model->email ?: '')->toHtml();
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'vendors.created_at',
|
|
||||||
function ($model) {
|
|
||||||
return Utils::timestampToDateString(strtotime($model->created_at));
|
|
||||||
}
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getDatatableActions($entityType)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
trans('texts.edit_vendor'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("vendors/{$model->public_id}/edit");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('editByOwner', [ENTITY_VENDOR, $model->user_id]);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'--divider--', function(){return false;},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('editByOwner', [ENTITY_VENDOR, $model->user_id]) && Auth::user()->can('create', ENTITY_EXPENSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
[
|
|
||||||
trans('texts.enter_expense'),
|
|
||||||
function ($model) {
|
|
||||||
return URL::to("expenses/create/{$model->public_id}");
|
|
||||||
},
|
|
||||||
function ($model) {
|
|
||||||
return Auth::user()->can('create', ENTITY_EXPENSE);
|
|
||||||
}
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,22 +11,24 @@ class DateFormatsSeeder extends Seeder
|
|||||||
|
|
||||||
// Date formats
|
// Date formats
|
||||||
$formats = [
|
$formats = [
|
||||||
['format' => 'd/M/Y', 'picker_format' => 'dd/M/yyyy', 'label' => '10/Mar/2013'],
|
['format' => 'd/M/Y', 'picker_format' => 'dd/M/yyyy'],
|
||||||
['format' => 'd-M-Y', 'picker_format' => 'dd-M-yyyy', 'label' => '10-Mar-2013'],
|
['format' => 'd-M-Y', 'picker_format' => 'dd-M-yyyy'],
|
||||||
['format' => 'd/F/Y', 'picker_format' => 'dd/MM/yyyy', 'label' => '10/March/2013'],
|
['format' => 'd/F/Y', 'picker_format' => 'dd/MM/yyyy'],
|
||||||
['format' => 'd-F-Y', 'picker_format' => 'dd-MM-yyyy', 'label' => '10-March-2013'],
|
['format' => 'd-F-Y', 'picker_format' => 'dd-MM-yyyy'],
|
||||||
['format' => 'M j, Y', 'picker_format' => 'M d, yyyy', 'label' => 'Mar 10, 2013'],
|
['format' => 'M j, Y', 'picker_format' => 'M d, yyyy'],
|
||||||
['format' => 'F j, Y', 'picker_format' => 'MM d, yyyy', 'label' => 'March 10, 2013'],
|
['format' => 'F j, Y', 'picker_format' => 'MM d, yyyy'],
|
||||||
['format' => 'D M j, Y', 'picker_format' => 'D MM d, yyyy', 'label' => 'Mon March 10, 2013'],
|
['format' => 'D M j, Y', 'picker_format' => 'D MM d, yyyy'],
|
||||||
['format' => 'Y-m-d', 'picker_format' => 'yyyy-mm-dd', 'label' => '2013-03-10'],
|
['format' => 'Y-m-d', 'picker_format' => 'yyyy-mm-dd'],
|
||||||
['format' => 'd-m-Y', 'picker_format' => 'dd-mm-yyyy', 'label' => '20-03-2013'],
|
['format' => 'd-m-Y', 'picker_format' => 'dd-mm-yyyy'],
|
||||||
['format' => 'm/d/Y', 'picker_format' => 'mm/dd/yyyy', 'label' => '03/20/2013']
|
['format' => 'm/d/Y', 'picker_format' => 'mm/dd/yyyy'],
|
||||||
|
['format' => 'd.m.Y', 'picker_format' => 'dd.mm.yyyy'],
|
||||||
|
['format' => 'j. M. Y', 'picker_format' => 'd. M. yyyy'],
|
||||||
|
['format' => 'j. F Y', 'picker_format' => 'd. MM yyyy']
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($formats as $format) {
|
foreach ($formats as $format) {
|
||||||
$record = DateFormat::whereLabel($format['label'])->first();
|
$record = DateFormat::whereFormat($format['format'])->first();
|
||||||
if ($record) {
|
if ($record) {
|
||||||
$record->format = $format['format'];
|
|
||||||
$record->picker_format = $format['picker_format'];
|
$record->picker_format = $format['picker_format'];
|
||||||
$record->save();
|
$record->save();
|
||||||
} else {
|
} else {
|
||||||
@ -36,62 +38,24 @@ class DateFormatsSeeder extends Seeder
|
|||||||
|
|
||||||
// Date/time formats
|
// Date/time formats
|
||||||
$formats = [
|
$formats = [
|
||||||
[
|
['format' => 'd/M/Y g:i a', 'format_moment' => 'DD/MMM/YYYY h:mm:ss a'],
|
||||||
'format' => 'd/M/Y g:i a',
|
['format' => 'd-M-Y g:i a', 'format_moment' => 'DD-MMM-YYYY h:mm:ss a'],
|
||||||
'format_moment' => 'DD/MMM/YYYY h:mm:ss a',
|
['format' => 'd/F/Y g:i a', 'format_moment' => 'DD/MMMM/YYYY h:mm:ss a'],
|
||||||
'label' => '10/Mar/2013'
|
['format' => 'd-F-Y g:i a', 'format_moment' => 'DD-MMMM-YYYY h:mm:ss a'],
|
||||||
],
|
['format' => 'M j, Y g:i a', 'format_moment' => 'MMM D, YYYY h:mm:ss a'],
|
||||||
[
|
['format' => 'F j, Y g:i a', 'format_moment' => 'MMMM D, YYYY h:mm:ss a'],
|
||||||
'format' => 'd-M-Y g:i a',
|
['format' => 'D M jS, Y g:i a', 'format_moment' => 'ddd MMM Do, YYYY h:mm:ss a'],
|
||||||
'format_moment' => 'DD-MMM-YYYY h:mm:ss a',
|
['format' => 'Y-m-d g:i a', 'format_moment' => 'YYYY-MMM-DD h:mm:ss a'],
|
||||||
'label' => '10-Mar-2013'
|
['format' => 'd-m-Y g:i a', 'format_moment' => 'DD-MM-YYYY h:mm:ss a'],
|
||||||
],
|
['format' => 'm/d/Y g:i a', 'format_moment' => 'MM/DD/YYYY h:mm:ss a'],
|
||||||
[
|
['format' => 'd.m.Y g:i a', 'format_moment' => 'D.MM.YYYY h:mm:ss a'],
|
||||||
'format' => 'd/F/Y g:i a',
|
['format' => 'j. M. Y g:i a', 'format_moment' => 'DD. MMM. YYYY h:mm:ss a'],
|
||||||
'format_moment' => 'DD/MMMM/YYYY h:mm:ss a',
|
['format' => 'j. F Y g:i a', 'format_moment' => 'DD. MMMM YYYY h:mm:ss a']
|
||||||
'label' => '10/March/2013'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'format' => 'd-F-Y g:i a',
|
|
||||||
'format_moment' => 'DD-MMMM-YYYY h:mm:ss a',
|
|
||||||
'label' => '10-March-2013'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'format' => 'M j, Y g:i a',
|
|
||||||
'format_moment' => 'MMM D, YYYY h:mm:ss a',
|
|
||||||
'label' => 'Mar 10, 2013 6:15 pm'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'format' => 'F j, Y g:i a',
|
|
||||||
'format_moment' => 'MMMM D, YYYY h:mm:ss a',
|
|
||||||
'label' => 'March 10, 2013 6:15 pm'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'format' => 'D M jS, Y g:i a',
|
|
||||||
'format_moment' => 'ddd MMM Do, YYYY h:mm:ss a',
|
|
||||||
'label' => 'Mon March 10th, 2013 6:15 pm'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'format' => 'Y-m-d g:i a',
|
|
||||||
'format_moment' => 'YYYY-MMM-DD h:mm:ss a',
|
|
||||||
'label' => '2013-03-10 6:15 pm'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'format' => 'd-m-Y g:i a',
|
|
||||||
'format_moment' => 'DD-MM-YYYY h:mm:ss a',
|
|
||||||
'label' => '20-03-2013 6:15 pm'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'format' => 'm/d/Y g:i a',
|
|
||||||
'format_moment' => 'MM/DD/YYYY h:mm:ss a',
|
|
||||||
'label' => '03/20/2013 6:15 pm'
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($formats as $format) {
|
foreach ($formats as $format) {
|
||||||
$record = DatetimeFormat::whereLabel($format['label'])->first();
|
$record = DatetimeFormat::whereFormat($format['format'])->first();
|
||||||
if ($record) {
|
if ($record) {
|
||||||
$record->format = $format['format'];
|
|
||||||
$record->format_moment = $format['format_moment'];
|
$record->format_moment = $format['format_moment'];
|
||||||
$record->save();
|
$record->save();
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,7 +33,7 @@ class UserTableSeeder extends Seeder
|
|||||||
'invoice_terms' => $faker->text($faker->numberBetween(50, 300)),
|
'invoice_terms' => $faker->text($faker->numberBetween(50, 300)),
|
||||||
'work_phone' => $faker->phoneNumber,
|
'work_phone' => $faker->phoneNumber,
|
||||||
'work_email' => $faker->safeEmail,
|
'work_email' => $faker->safeEmail,
|
||||||
'invoice_design_id' => min(InvoiceDesign::all()->random()->id, 10),
|
'invoice_design_id' => InvoiceDesign::where('id', '<', CUSTOM_DESIGN)->get()->random()->id,
|
||||||
'header_font_id' => min(Font::all()->random()->id, 17),
|
'header_font_id' => min(Font::all()->random()->id, 17),
|
||||||
'body_font_id' => min(Font::all()->random()->id, 17),
|
'body_font_id' => min(Font::all()->random()->id, 17),
|
||||||
'primary_color' => $faker->hexcolor,
|
'primary_color' => $faker->hexcolor,
|
||||||
|
@ -1305,6 +1305,12 @@ $LANG = array(
|
|||||||
'canada' => 'Canada',
|
'canada' => 'Canada',
|
||||||
'accept_debit_cards' => 'Accept Debit Cards',
|
'accept_debit_cards' => 'Accept Debit Cards',
|
||||||
'debit_cards' => 'Debit Cards',
|
'debit_cards' => 'Debit Cards',
|
||||||
|
|
||||||
|
'warn_start_date_changed' => 'The next invoice will be sent on the new start date.',
|
||||||
|
'original_start_date' => 'Original start date',
|
||||||
|
'new_start_date' => 'New start date',
|
||||||
|
'security' => 'Security',
|
||||||
|
'see_whats_new' => 'See what\'s new in v:version',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
@ -30,9 +30,10 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">{!! trans('texts.client_portal') !!}</h3>
|
<h3 class="panel-title">{!! trans('texts.navigation') !!}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="col-md-10 col-md-offset-1">
|
<div class="col-md-10 col-md-offset-1">
|
||||||
@ -45,20 +46,29 @@
|
|||||||
->text(trans('texts.enable'))
|
->text(trans('texts.enable'))
|
||||||
->help(trans('texts.enable_client_portal_dashboard_help')) !!}
|
->help(trans('texts.enable_client_portal_dashboard_help')) !!}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">{!! trans('texts.security') !!}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
<div class="col-md-10 col-md-offset-1">
|
<div class="col-md-10 col-md-offset-1">
|
||||||
{!! Former::checkbox('enable_portal_password')
|
{!! Former::checkbox('enable_portal_password')
|
||||||
->text(trans('texts.enable_portal_password'))
|
->text(trans('texts.enable'))
|
||||||
->help(trans('texts.enable_portal_password_help'))
|
->help(trans('texts.enable_portal_password_help'))
|
||||||
->label(' ') !!}
|
->label(trans('texts.enable_portal_password')) !!}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-10 col-md-offset-1">
|
<div class="col-md-10 col-md-offset-1">
|
||||||
{!! Former::checkbox('send_portal_password')
|
{!! Former::checkbox('send_portal_password')
|
||||||
->text(trans('texts.send_portal_password'))
|
->text(trans('texts.enable'))
|
||||||
->help(trans('texts.send_portal_password_help'))
|
->help(trans('texts.send_portal_password_help'))
|
||||||
->label(' ') !!}
|
->label(trans('texts.send_portal_password')) !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (Utils::hasFeature(FEATURE_CLIENT_PORTAL_CSS))
|
@if (Utils::hasFeature(FEATURE_CLIENT_PORTAL_CSS))
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
|
@ -27,9 +27,9 @@
|
|||||||
{!! Former::select('timezone_id')->addOption('','')
|
{!! Former::select('timezone_id')->addOption('','')
|
||||||
->fromQuery($timezones, 'location', 'id') !!}
|
->fromQuery($timezones, 'location', 'id') !!}
|
||||||
{!! Former::select('date_format_id')->addOption('','')
|
{!! Former::select('date_format_id')->addOption('','')
|
||||||
->fromQuery($dateFormats, 'label', 'id') !!}
|
->fromQuery($dateFormats) !!}
|
||||||
{!! Former::select('datetime_format_id')->addOption('','')
|
{!! Former::select('datetime_format_id')->addOption('','')
|
||||||
->fromQuery($datetimeFormats, 'label', 'id') !!}
|
->fromQuery($datetimeFormats) !!}
|
||||||
{!! Former::checkbox('military_time')->text(trans('texts.enable')) !!}
|
{!! Former::checkbox('military_time')->text(trans('texts.enable')) !!}
|
||||||
{{-- Former::checkbox('show_currency_code')->text(trans('texts.enable')) --}}
|
{{-- Former::checkbox('show_currency_code')->text(trans('texts.enable')) --}}
|
||||||
|
|
||||||
|
@ -364,6 +364,12 @@
|
|||||||
|
|
||||||
@if (Auth::user()->account->hasFeature(FEATURE_DOCUMENTS))
|
@if (Auth::user()->account->hasFeature(FEATURE_DOCUMENTS))
|
||||||
function handleDocumentAdded(file){
|
function handleDocumentAdded(file){
|
||||||
|
// open document when clicked
|
||||||
|
if (file.url) {
|
||||||
|
file.previewElement.addEventListener("click", function() {
|
||||||
|
window.open(file.url, '_blank');
|
||||||
|
});
|
||||||
|
}
|
||||||
if(file.mock)return;
|
if(file.mock)return;
|
||||||
file.index = model.documents().length;
|
file.index = model.documents().length;
|
||||||
model.addDocument({name:file.name, size:file.size, type:file.type});
|
model.addDocument({name:file.name, size:file.size, type:file.type});
|
||||||
|
@ -527,7 +527,9 @@
|
|||||||
{!! Former::select('invoice_design_id')->style('display:inline;width:150px;background-color:white !important')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") !!}
|
{!! Former::select('invoice_design_id')->style('display:inline;width:150px;background-color:white !important')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") !!}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if ( ! $invoice->is_recurring)
|
||||||
{!! Button::primary(trans('texts.download_pdf'))->withAttributes(array('onclick' => 'onDownloadClick()'))->appendIcon(Icon::create('download-alt')) !!}
|
{!! Button::primary(trans('texts.download_pdf'))->withAttributes(array('onclick' => 'onDownloadClick()'))->appendIcon(Icon::create('download-alt')) !!}
|
||||||
|
@endif
|
||||||
|
|
||||||
@if ($invoice->isClientTrashed())
|
@if ($invoice->isClientTrashed())
|
||||||
<!-- do nothing -->
|
<!-- do nothing -->
|
||||||
@ -807,6 +809,7 @@
|
|||||||
var invoice = {!! $invoice !!};
|
var invoice = {!! $invoice !!};
|
||||||
ko.mapping.fromJS(invoice, model.invoice().mapping, model.invoice);
|
ko.mapping.fromJS(invoice, model.invoice().mapping, model.invoice);
|
||||||
model.invoice().is_recurring({{ $invoice->is_recurring ? '1' : '0' }});
|
model.invoice().is_recurring({{ $invoice->is_recurring ? '1' : '0' }});
|
||||||
|
model.invoice().start_date_orig(model.invoice().start_date());
|
||||||
|
|
||||||
@if ($invoice->id)
|
@if ($invoice->id)
|
||||||
var invitationContactIds = {!! json_encode($invitationContactIds) !!};
|
var invitationContactIds = {!! json_encode($invitationContactIds) !!};
|
||||||
@ -1182,21 +1185,40 @@
|
|||||||
if (!isEmailValid()) {
|
if (!isEmailValid()) {
|
||||||
alert("{!! trans('texts.provide_email') !!}");
|
alert("{!! trans('texts.provide_email') !!}");
|
||||||
return;
|
return;
|
||||||
}
|
8 }
|
||||||
|
|
||||||
if (confirm('{!! trans("texts.confirm_email_$entityType") !!}' + '\n\n' + getSendToEmails())) {
|
if (confirm('{!! trans("texts.confirm_email_$entityType") !!}' + '\n\n' + getSendToEmails())) {
|
||||||
|
var accountLanguageId = parseInt({{ $account->language_id ?: '0' }});
|
||||||
|
var clientLanguageId = parseInt(model.invoice().client().language_id()) || 0;
|
||||||
|
// if the client's language is different then we can't use the browser version of the PDF
|
||||||
|
if (clientLanguageId && clientLanguageId != accountLanguageId) {
|
||||||
|
submitAction('email');
|
||||||
|
} else {
|
||||||
preparePdfData('email');
|
preparePdfData('email');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onSaveClick() {
|
function onSaveClick() {
|
||||||
if (model.invoice().is_recurring() && {{ $invoice ? 'false' : 'true' }}) {
|
if (model.invoice().is_recurring()) {
|
||||||
|
// warn invoice will be emailed when saving new recurring invoice
|
||||||
|
if ({{ $invoice->exists() ? 'false' : 'true' }}) {
|
||||||
if (confirm("{!! trans("texts.confirm_recurring_email_$entityType") !!}" + '\n\n' + getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}")) {
|
if (confirm("{!! trans("texts.confirm_recurring_email_$entityType") !!}" + '\n\n' + getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}")) {
|
||||||
submitAction('');
|
submitAction('');
|
||||||
}
|
}
|
||||||
} else {
|
return;
|
||||||
preparePdfData('');
|
// warn invoice will be emailed again if start date is changed
|
||||||
|
} else if (model.invoice().start_date() != model.invoice().start_date_orig()) {
|
||||||
|
if (confirm("{!! trans("texts.warn_start_date_changed") !!}" + '\n\n'
|
||||||
|
+ "{!! trans("texts.original_start_date") !!}: " + model.invoice().start_date_orig() + '\n'
|
||||||
|
+ "{!! trans("texts.new_start_date") !!}: " + model.invoice().start_date())) {
|
||||||
|
submitAction('');
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
preparePdfData('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSendToEmails() {
|
function getSendToEmails() {
|
||||||
@ -1403,6 +1425,12 @@
|
|||||||
|
|
||||||
@if ($account->hasFeature(FEATURE_DOCUMENTS))
|
@if ($account->hasFeature(FEATURE_DOCUMENTS))
|
||||||
function handleDocumentAdded(file){
|
function handleDocumentAdded(file){
|
||||||
|
// open document when clicked
|
||||||
|
if (file.url) {
|
||||||
|
file.previewElement.addEventListener("click", function() {
|
||||||
|
window.open(file.url, '_blank');
|
||||||
|
});
|
||||||
|
}
|
||||||
if(file.mock)return;
|
if(file.mock)return;
|
||||||
file.index = model.invoice().documents().length;
|
file.index = model.invoice().documents().length;
|
||||||
model.invoice().addDocument({name:file.name, size:file.size, type:file.type});
|
model.invoice().addDocument({name:file.name, size:file.size, type:file.type});
|
||||||
|
@ -180,6 +180,7 @@ function InvoiceModel(data) {
|
|||||||
self.due_date = ko.observable('');
|
self.due_date = ko.observable('');
|
||||||
self.recurring_due_date = ko.observable('');
|
self.recurring_due_date = ko.observable('');
|
||||||
self.start_date = ko.observable('');
|
self.start_date = ko.observable('');
|
||||||
|
self.start_date_orig = ko.observable('');
|
||||||
self.end_date = ko.observable('');
|
self.end_date = ko.observable('');
|
||||||
self.last_sent_date = ko.observable('');
|
self.last_sent_date = ko.observable('');
|
||||||
self.tax_name1 = ko.observable();
|
self.tax_name1 = ko.observable();
|
||||||
|
2
resources/views/vendors/show.blade.php
vendored
2
resources/views/vendors/show.blade.php
vendored
@ -152,7 +152,7 @@
|
|||||||
trans('texts.expense_date'),
|
trans('texts.expense_date'),
|
||||||
trans('texts.amount'),
|
trans('texts.amount'),
|
||||||
trans('texts.public_notes'))
|
trans('texts.public_notes'))
|
||||||
->setUrl(url('api/expenseVendor/' . $vendor->public_id))
|
->setUrl(url('api/vendor_expense/' . $vendor->public_id))
|
||||||
->setCustomValues('entityType', 'expenses')
|
->setCustomValues('entityType', 'expenses')
|
||||||
->setOptions('sPaginationType', 'bootstrap')
|
->setOptions('sPaginationType', 'bootstrap')
|
||||||
->setOptions('bFilter', false)
|
->setOptions('bFilter', false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user