mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Enable users with 'View all' to see w/o editing
This commit is contained in:
parent
8c8affab9f
commit
c5b685d390
@ -425,7 +425,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
|||||||
|
|
||||||
public function caddAddUsers()
|
public function caddAddUsers()
|
||||||
{
|
{
|
||||||
if ( ! Utils::isNinja()) {
|
if ( ! Utils::isNinjaProd()) {
|
||||||
return true;
|
return true;
|
||||||
} elseif ( ! $this->hasFeature(FEATURE_USERS)) {
|
} elseif ( ! $this->hasFeature(FEATURE_USERS)) {
|
||||||
return false;
|
return false;
|
||||||
@ -441,6 +441,12 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
|||||||
|
|
||||||
return $numUsers < $company->num_users;
|
return $numUsers < $company->num_users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canCreateOrEdit($entityType, $entity = false)
|
||||||
|
{
|
||||||
|
return (($entity && $this->can('edit', $entity))
|
||||||
|
|| (!$entity && $this->can('create', $entityType)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
User::updating(function ($user) {
|
User::updating(function ($user) {
|
||||||
|
@ -46,7 +46,7 @@ class ExpenseDatatable extends EntityDatatable
|
|||||||
[
|
[
|
||||||
'expense_date',
|
'expense_date',
|
||||||
function ($model) {
|
function ($model) {
|
||||||
if(!Auth::user()->can('editByOwner', [ENTITY_EXPENSE, $model->user_id])){
|
if(!Auth::user()->can('viewByOwner', [ENTITY_EXPENSE, $model->user_id])){
|
||||||
return Utils::fromSqlDate($model->expense_date);
|
return Utils::fromSqlDate($model->expense_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class InvoiceDatatable extends EntityDatatable
|
|||||||
[
|
[
|
||||||
'invoice_number',
|
'invoice_number',
|
||||||
function ($model) use ($entityType) {
|
function ($model) use ($entityType) {
|
||||||
if(!Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id])){
|
if(!Auth::user()->can('viewByOwner', [ENTITY_INVOICE, $model->user_id])){
|
||||||
return $model->invoice_number;
|
return $model->invoice_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class InvoiceDatatable extends EntityDatatable
|
|||||||
$class = 'success';
|
$class = 'success';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class PaymentDatatable extends EntityDatatable
|
|||||||
[
|
[
|
||||||
'invoice_number',
|
'invoice_number',
|
||||||
function ($model) {
|
function ($model) {
|
||||||
if(!Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->invoice_user_id])){
|
if(!Auth::user()->can('viewByOwner', [ENTITY_INVOICE, $model->invoice_user_id])){
|
||||||
return $model->invoice_number;
|
return $model->invoice_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@ class TaskDatatable extends EntityDatatable
|
|||||||
[
|
[
|
||||||
'created_at',
|
'created_at',
|
||||||
function ($model) {
|
function ($model) {
|
||||||
|
if(!Auth::user()->can('viewByOwner', [ENTITY_EXPENSE, $model->user_id])){
|
||||||
|
return Task::calcStartTime($model);
|
||||||
|
}
|
||||||
return link_to("tasks/{$model->public_id}/edit", Task::calcStartTime($model))->toHtml();
|
return link_to("tasks/{$model->public_id}/edit", Task::calcStartTime($model))->toHtml();
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -171,26 +171,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<center class="buttons">
|
@if (Auth::user()->canCreateOrEdit(ENTITY_EXPENSE, $expense))
|
||||||
{!! Button::normal(trans('texts.cancel'))
|
<center class="buttons">
|
||||||
->asLinkTo(URL::to('/expenses'))
|
{!! Button::normal(trans('texts.cancel'))
|
||||||
->appendIcon(Icon::create('remove-circle'))
|
->asLinkTo(URL::to('/expenses'))
|
||||||
->large() !!}
|
->appendIcon(Icon::create('remove-circle'))
|
||||||
|
->large() !!}
|
||||||
|
|
||||||
@if (Auth::user()->hasFeature(FEATURE_EXPENSES))
|
@if (Auth::user()->hasFeature(FEATURE_EXPENSES))
|
||||||
{!! Button::success(trans('texts.save'))
|
{!! Button::success(trans('texts.save'))
|
||||||
->appendIcon(Icon::create('floppy-disk'))
|
->appendIcon(Icon::create('floppy-disk'))
|
||||||
->large()
|
->large()
|
||||||
->submit() !!}
|
->submit() !!}
|
||||||
|
|
||||||
@if ($expense)
|
@if ($expense)
|
||||||
{!! DropdownButton::normal(trans('texts.more_actions'))
|
{!! DropdownButton::normal(trans('texts.more_actions'))
|
||||||
->withContents($actions)
|
->withContents($actions)
|
||||||
->large()
|
->large()
|
||||||
->dropup() !!}
|
->dropup() !!}
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
@endif
|
</center>
|
||||||
</center>
|
@endif
|
||||||
|
|
||||||
{!! Former::close() !!}
|
{!! Former::close() !!}
|
||||||
|
|
||||||
@ -214,7 +216,11 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
@if (Auth::user()->canCreateOrEdit(ENTITY_EXPENSE, $expense))
|
||||||
|
return true;
|
||||||
|
@else
|
||||||
|
return false
|
||||||
|
@endif
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClientChange() {
|
function onClientChange() {
|
||||||
|
@ -537,19 +537,21 @@
|
|||||||
->appendIcon(Icon::create('download-alt')) !!}
|
->appendIcon(Icon::create('download-alt')) !!}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if ($invoice->isClientTrashed())
|
@if (Auth::user()->canCreateOrEdit(ENTITY_INVOICE, $invoice))
|
||||||
<!-- do nothing -->
|
@if ($invoice->isClientTrashed())
|
||||||
@elseif ($invoice->trashed())
|
<!-- do nothing -->
|
||||||
{!! Button::success(trans('texts.restore'))->withAttributes(['onclick' => 'submitBulkAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!}
|
@elseif ($invoice->trashed())
|
||||||
@elseif (!$invoice->trashed())
|
{!! Button::success(trans('texts.restore'))->withAttributes(['onclick' => 'submitBulkAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!}
|
||||||
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
@elseif (!$invoice->trashed())
|
||||||
{!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
|
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
||||||
@if ($invoice->id)
|
{!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
|
||||||
{!! DropdownButton::normal(trans('texts.more_actions'))
|
@if ($invoice->id)
|
||||||
->withContents($actions)
|
{!! DropdownButton::normal(trans('texts.more_actions'))
|
||||||
->dropup() !!}
|
->withContents($actions)
|
||||||
@endif
|
->dropup() !!}
|
||||||
@endif
|
@endif
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
@ -1337,7 +1339,11 @@
|
|||||||
|
|
||||||
onPartialChange(true);
|
onPartialChange(true);
|
||||||
|
|
||||||
return true;
|
@if (Auth::user()->canCreateOrEdit(ENTITY_INVOICE, $invoice))
|
||||||
|
return true;
|
||||||
|
@else
|
||||||
|
return false;
|
||||||
|
@endif
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitBulkAction(value) {
|
function submitBulkAction(value) {
|
||||||
|
@ -18,13 +18,15 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
@if ($errors->first('time_log'))
|
@if ($errors->first('time_log'))
|
||||||
<div class="alert alert-danger"><li>{{ trans('texts.task_errors') }} </li></div>
|
<div class="alert alert-danger"><li>{{ trans('texts.task_errors') }} </li></div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
{!! Former::open($url)
|
||||||
|
->addClass('col-md-10 col-md-offset-1 warn-on-exit task-form')
|
||||||
|
->onsubmit('return onFormSubmit(event)')
|
||||||
|
->method($method) !!}
|
||||||
|
|
||||||
{!! Former::open($url)->addClass('col-md-10 col-md-offset-1 warn-on-exit task-form')->method($method)->rules(array()) !!}
|
|
||||||
@if ($task)
|
@if ($task)
|
||||||
{!! Former::populate($task) !!}
|
{!! Former::populate($task) !!}
|
||||||
{!! Former::populateField('id', $task->public_id) !!}
|
{!! Former::populateField('id', $task->public_id) !!}
|
||||||
@ -126,32 +128,34 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<center class="buttons">
|
@if (Auth::user()->canCreateOrEdit(ENTITY_TASK, $task))
|
||||||
@if (Auth::user()->hasFeature(FEATURE_TASKS))
|
<center class="buttons">
|
||||||
@if ($task && $task->is_running)
|
@if (Auth::user()->hasFeature(FEATURE_TASKS))
|
||||||
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
@if ($task && $task->is_running)
|
||||||
{!! Button::primary(trans('texts.stop'))->large()->appendIcon(Icon::create('stop'))->withAttributes(['id' => 'stop-button']) !!}
|
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
||||||
@elseif ($task && $task->trashed())
|
{!! Button::primary(trans('texts.stop'))->large()->appendIcon(Icon::create('stop'))->withAttributes(['id' => 'stop-button']) !!}
|
||||||
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/tasks'))->appendIcon(Icon::create('remove-circle')) !!}
|
@elseif ($task && $task->trashed())
|
||||||
{!! Button::success(trans('texts.restore'))->large()->withAttributes(['onclick' => 'submitAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!}
|
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/tasks'))->appendIcon(Icon::create('remove-circle')) !!}
|
||||||
|
{!! Button::success(trans('texts.restore'))->large()->withAttributes(['onclick' => 'submitAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!}
|
||||||
|
@else
|
||||||
|
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/tasks'))->appendIcon(Icon::create('remove-circle')) !!}
|
||||||
|
@if ($task)
|
||||||
|
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
||||||
|
{!! Button::primary(trans('texts.resume'))->large()->appendIcon(Icon::create('play'))->withAttributes(['id' => 'resume-button']) !!}
|
||||||
|
{!! DropdownButton::normal(trans('texts.more_actions'))
|
||||||
|
->withContents($actions)
|
||||||
|
->large()
|
||||||
|
->dropup() !!}
|
||||||
|
@else
|
||||||
|
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
||||||
|
{!! Button::success(trans('texts.start'))->large()->appendIcon(Icon::create('play'))->withAttributes(['id' => 'start-button']) !!}
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
@else
|
@else
|
||||||
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/tasks'))->appendIcon(Icon::create('remove-circle')) !!}
|
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/tasks'))->appendIcon(Icon::create('remove-circle')) !!}
|
||||||
@if ($task)
|
|
||||||
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
|
||||||
{!! Button::primary(trans('texts.resume'))->large()->appendIcon(Icon::create('play'))->withAttributes(['id' => 'resume-button']) !!}
|
|
||||||
{!! DropdownButton::normal(trans('texts.more_actions'))
|
|
||||||
->withContents($actions)
|
|
||||||
->large()
|
|
||||||
->dropup() !!}
|
|
||||||
@else
|
|
||||||
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
|
||||||
{!! Button::success(trans('texts.start'))->large()->appendIcon(Icon::create('play'))->withAttributes(['id' => 'start-button']) !!}
|
|
||||||
@endif
|
|
||||||
@endif
|
@endif
|
||||||
@else
|
</center>
|
||||||
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/tasks'))->appendIcon(Icon::create('remove-circle')) !!}
|
@endif
|
||||||
@endif
|
|
||||||
</center>
|
|
||||||
|
|
||||||
{!! Former::close() !!}
|
{!! Former::close() !!}
|
||||||
|
|
||||||
@ -204,6 +208,14 @@
|
|||||||
timeLabels['{{ $period }}s'] = '{{ trans("texts.{$period}s") }}';
|
timeLabels['{{ $period }}s'] = '{{ trans("texts.{$period}s") }}';
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
function onFormSubmit(event) {
|
||||||
|
@if (Auth::user()->canCreateOrEdit(ENTITY_TASK, $task))
|
||||||
|
return true;
|
||||||
|
@else
|
||||||
|
return false
|
||||||
|
@endif
|
||||||
|
}
|
||||||
|
|
||||||
function tock(duration) {
|
function tock(duration) {
|
||||||
var str = convertDurationToString(duration);
|
var str = convertDurationToString(duration);
|
||||||
$('#duration-text').html(str);
|
$('#duration-text').html(str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user