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()
|
||||
{
|
||||
if ( ! Utils::isNinja()) {
|
||||
if ( ! Utils::isNinjaProd()) {
|
||||
return true;
|
||||
} elseif ( ! $this->hasFeature(FEATURE_USERS)) {
|
||||
return false;
|
||||
@ -441,6 +441,12 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
||||
|
||||
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) {
|
||||
|
@ -46,7 +46,7 @@ class ExpenseDatatable extends EntityDatatable
|
||||
[
|
||||
'expense_date',
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ class InvoiceDatatable extends EntityDatatable
|
||||
[
|
||||
'invoice_number',
|
||||
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;
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ class InvoiceDatatable extends EntityDatatable
|
||||
$class = 'success';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class PaymentDatatable extends EntityDatatable
|
||||
[
|
||||
'invoice_number',
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,9 @@ class TaskDatatable extends EntityDatatable
|
||||
[
|
||||
'created_at',
|
||||
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();
|
||||
}
|
||||
],
|
||||
|
@ -171,26 +171,28 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<center class="buttons">
|
||||
{!! Button::normal(trans('texts.cancel'))
|
||||
->asLinkTo(URL::to('/expenses'))
|
||||
->appendIcon(Icon::create('remove-circle'))
|
||||
->large() !!}
|
||||
@if (Auth::user()->canCreateOrEdit(ENTITY_EXPENSE, $expense))
|
||||
<center class="buttons">
|
||||
{!! Button::normal(trans('texts.cancel'))
|
||||
->asLinkTo(URL::to('/expenses'))
|
||||
->appendIcon(Icon::create('remove-circle'))
|
||||
->large() !!}
|
||||
|
||||
@if (Auth::user()->hasFeature(FEATURE_EXPENSES))
|
||||
{!! Button::success(trans('texts.save'))
|
||||
->appendIcon(Icon::create('floppy-disk'))
|
||||
->large()
|
||||
->submit() !!}
|
||||
@if (Auth::user()->hasFeature(FEATURE_EXPENSES))
|
||||
{!! Button::success(trans('texts.save'))
|
||||
->appendIcon(Icon::create('floppy-disk'))
|
||||
->large()
|
||||
->submit() !!}
|
||||
|
||||
@if ($expense)
|
||||
{!! DropdownButton::normal(trans('texts.more_actions'))
|
||||
->withContents($actions)
|
||||
->large()
|
||||
->dropup() !!}
|
||||
@if ($expense)
|
||||
{!! DropdownButton::normal(trans('texts.more_actions'))
|
||||
->withContents($actions)
|
||||
->large()
|
||||
->dropup() !!}
|
||||
@endif
|
||||
@endif
|
||||
@endif
|
||||
</center>
|
||||
</center>
|
||||
@endif
|
||||
|
||||
{!! Former::close() !!}
|
||||
|
||||
@ -214,7 +216,11 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@if (Auth::user()->canCreateOrEdit(ENTITY_EXPENSE, $expense))
|
||||
return true;
|
||||
@else
|
||||
return false
|
||||
@endif
|
||||
}
|
||||
|
||||
function onClientChange() {
|
||||
|
@ -537,19 +537,21 @@
|
||||
->appendIcon(Icon::create('download-alt')) !!}
|
||||
@endif
|
||||
|
||||
@if ($invoice->isClientTrashed())
|
||||
<!-- do nothing -->
|
||||
@elseif ($invoice->trashed())
|
||||
{!! Button::success(trans('texts.restore'))->withAttributes(['onclick' => 'submitBulkAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!}
|
||||
@elseif (!$invoice->trashed())
|
||||
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
||||
{!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
|
||||
@if ($invoice->id)
|
||||
{!! DropdownButton::normal(trans('texts.more_actions'))
|
||||
->withContents($actions)
|
||||
->dropup() !!}
|
||||
@endif
|
||||
@endif
|
||||
@if (Auth::user()->canCreateOrEdit(ENTITY_INVOICE, $invoice))
|
||||
@if ($invoice->isClientTrashed())
|
||||
<!-- do nothing -->
|
||||
@elseif ($invoice->trashed())
|
||||
{!! Button::success(trans('texts.restore'))->withAttributes(['onclick' => 'submitBulkAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!}
|
||||
@elseif (!$invoice->trashed())
|
||||
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
||||
{!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
|
||||
@if ($invoice->id)
|
||||
{!! DropdownButton::normal(trans('texts.more_actions'))
|
||||
->withContents($actions)
|
||||
->dropup() !!}
|
||||
@endif
|
||||
@endif
|
||||
@endif
|
||||
|
||||
</div>
|
||||
<p> </p>
|
||||
@ -1337,7 +1339,11 @@
|
||||
|
||||
onPartialChange(true);
|
||||
|
||||
return true;
|
||||
@if (Auth::user()->canCreateOrEdit(ENTITY_INVOICE, $invoice))
|
||||
return true;
|
||||
@else
|
||||
return false;
|
||||
@endif
|
||||
}
|
||||
|
||||
function submitBulkAction(value) {
|
||||
|
@ -18,13 +18,15 @@
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@if ($errors->first('time_log'))
|
||||
<div class="alert alert-danger"><li>{{ trans('texts.task_errors') }} </li></div>
|
||||
@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)
|
||||
{!! Former::populate($task) !!}
|
||||
{!! Former::populateField('id', $task->public_id) !!}
|
||||
@ -126,32 +128,34 @@
|
||||
</div>
|
||||
|
||||
|
||||
<center class="buttons">
|
||||
@if (Auth::user()->hasFeature(FEATURE_TASKS))
|
||||
@if ($task && $task->is_running)
|
||||
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
||||
{!! Button::primary(trans('texts.stop'))->large()->appendIcon(Icon::create('stop'))->withAttributes(['id' => 'stop-button']) !!}
|
||||
@elseif ($task && $task->trashed())
|
||||
{!! 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')) !!}
|
||||
@if (Auth::user()->canCreateOrEdit(ENTITY_TASK, $task))
|
||||
<center class="buttons">
|
||||
@if (Auth::user()->hasFeature(FEATURE_TASKS))
|
||||
@if ($task && $task->is_running)
|
||||
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
||||
{!! Button::primary(trans('texts.stop'))->large()->appendIcon(Icon::create('stop'))->withAttributes(['id' => 'stop-button']) !!}
|
||||
@elseif ($task && $task->trashed())
|
||||
{!! 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
|
||||
{!! 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
|
||||
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/tasks'))->appendIcon(Icon::create('remove-circle')) !!}
|
||||
@endif
|
||||
</center>
|
||||
</center>
|
||||
@endif
|
||||
|
||||
{!! Former::close() !!}
|
||||
|
||||
@ -204,6 +208,14 @@
|
||||
timeLabels['{{ $period }}s'] = '{{ trans("texts.{$period}s") }}';
|
||||
@endforeach
|
||||
|
||||
function onFormSubmit(event) {
|
||||
@if (Auth::user()->canCreateOrEdit(ENTITY_TASK, $task))
|
||||
return true;
|
||||
@else
|
||||
return false
|
||||
@endif
|
||||
}
|
||||
|
||||
function tock(duration) {
|
||||
var str = convertDurationToString(duration);
|
||||
$('#duration-text').html(str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user