mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Prevent changing credit's client
This commit is contained in:
parent
280bf559b4
commit
9398c45b56
@ -71,13 +71,13 @@ class CreditController extends BaseController
|
|||||||
$credit->credit_date = Utils::fromSqlDate($credit->credit_date);
|
$credit->credit_date = Utils::fromSqlDate($credit->credit_date);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'client' => null,
|
'client' => $credit->client,
|
||||||
'clientPublicId' => $credit->client->public_id,
|
'clientPublicId' => $credit->client->public_id,
|
||||||
'credit' => $credit,
|
'credit' => $credit,
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'url' => 'credits/'.$publicId,
|
'url' => 'credits/'.$publicId,
|
||||||
'title' => 'Edit Credit',
|
'title' => 'Edit Credit',
|
||||||
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
|
'clients' => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
return View::make('credits.edit', $data);
|
return View::make('credits.edit', $data);
|
||||||
@ -102,7 +102,7 @@ class CreditController extends BaseController
|
|||||||
$message = $credit->wasRecentlyCreated ? trans('texts.created_credit') : trans('texts.updated_credit');
|
$message = $credit->wasRecentlyCreated ? trans('texts.created_credit') : trans('texts.updated_credit');
|
||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
|
|
||||||
return redirect()->to("credits/{$credit->public_id}/edit");
|
return redirect()->to("clients/{$credit->client->public_id}#credits");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function bulk()
|
public function bulk()
|
||||||
|
@ -20,7 +20,6 @@ class UpdateCreditRequest extends CreditRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'client' => 'required',
|
|
||||||
'amount' => 'required|positive',
|
'amount' => 'required|positive',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,11 @@ class CreditDatatable extends EntityDatatable
|
|||||||
[
|
[
|
||||||
'credit_date',
|
'credit_date',
|
||||||
function ($model) {
|
function ($model) {
|
||||||
return Utils::fromSqlDate($model->credit_date);
|
if ( ! Auth::user()->can('viewByOwner', [ENTITY_CREDIT, $model->user_id])){
|
||||||
|
return Utils::fromSqlDate($model->credit_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
return link_to("credits/{$model->public_id}/edit", Utils::fromSqlDate($model->credit_date))->toHtml();
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -94,9 +94,9 @@ class CreditRepository extends BaseRepository
|
|||||||
\Log::warning('Entity not set in credit repo save');
|
\Log::warning('Entity not set in credit repo save');
|
||||||
} else {
|
} else {
|
||||||
$credit = Credit::createNew();
|
$credit = Credit::createNew();
|
||||||
|
$credit->client_id = Client::getPrivateId($input['client']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$credit->client_id = Client::getPrivateId($input['client']);
|
|
||||||
$credit->credit_date = Utils::toSqlDate($input['credit_date']);
|
$credit->credit_date = Utils::toSqlDate($input['credit_date']);
|
||||||
$credit->amount = Utils::parseFloat($input['amount']);
|
$credit->amount = Utils::parseFloat($input['amount']);
|
||||||
$credit->balance = Utils::parseFloat($input['amount']);
|
$credit->balance = Utils::parseFloat($input['amount']);
|
||||||
|
@ -304,7 +304,8 @@
|
|||||||
window['load_' + target]();
|
window['load_' + target]();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var tab = localStorage.getItem('client_tab') || '';
|
|
||||||
|
var tab = window.location.hash || (localStorage.getItem('client_tab') || '');
|
||||||
var selector = '.nav-tabs a[href="#' + tab.replace('#', '') + '"]';
|
var selector = '.nav-tabs a[href="#' + tab.replace('#', '') + '"]';
|
||||||
if (tab && tab != 'activity' && $(selector).length) {
|
if (tab && tab != 'activity' && $(selector).length) {
|
||||||
$(selector).tab('show');
|
$(selector).tab('show');
|
||||||
|
@ -21,7 +21,12 @@
|
|||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
{!! Former::select('client')->addOption('', '')->addGroupClass('client-select') !!}
|
@if ($credit)
|
||||||
|
{!! Former::plaintext()->label('client')->value($client->present()->link) !!}
|
||||||
|
@else
|
||||||
|
{!! Former::select('client')->addOption('', '')->addGroupClass('client-select') !!}
|
||||||
|
@endif
|
||||||
|
|
||||||
{!! Former::text('amount') !!}
|
{!! Former::text('amount') !!}
|
||||||
{!! Former::text('credit_date')
|
{!! Former::text('credit_date')
|
||||||
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))
|
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))
|
||||||
@ -46,25 +51,27 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|
||||||
var clients = {!! $clients !!};
|
var clients = {!! $clients ?: 'false' !!};
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
var $clientSelect = $('select#client');
|
@if ( ! $credit)
|
||||||
for (var i=0; i<clients.length; i++) {
|
var $clientSelect = $('select#client');
|
||||||
var client = clients[i];
|
for (var i=0; i<clients.length; i++) {
|
||||||
var clientName = getClientDisplayName(client);
|
var client = clients[i];
|
||||||
if (!clientName) {
|
var clientName = getClientDisplayName(client);
|
||||||
continue;
|
if (!clientName) {
|
||||||
}
|
continue;
|
||||||
$clientSelect.append(new Option(clientName, client.public_id));
|
}
|
||||||
}
|
$clientSelect.append(new Option(clientName, client.public_id));
|
||||||
|
}
|
||||||
|
|
||||||
if ({{ $clientPublicId ? 'true' : 'false' }}) {
|
if ({{ $clientPublicId ? 'true' : 'false' }}) {
|
||||||
$clientSelect.val({{ $clientPublicId }});
|
$clientSelect.val({{ $clientPublicId }});
|
||||||
}
|
}
|
||||||
|
|
||||||
$clientSelect.combobox();
|
$clientSelect.combobox();
|
||||||
|
@endif
|
||||||
|
|
||||||
$('#currency_id').combobox();
|
$('#currency_id').combobox();
|
||||||
$('#credit_date').datepicker('update', '{{ $credit ? $credit->credit_date : 'new Date()' }}');
|
$('#credit_date').datepicker('update', '{{ $credit ? $credit->credit_date : 'new Date()' }}');
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (Auth::user()->can('create', $entityType))
|
@if (Auth::user()->can('create', $entityType))
|
||||||
{!! Button::primary(trans("texts.new_{$entityType}"))->asLinkTo(url(Utils::pluralizeEntityType($entityType) . '/create'))->appendIcon(Icon::create('plus-sign')) !!}
|
{!! Button::primary(trans("texts.new_{$entityType}"))->asLinkTo(url(Utils::pluralizeEntityType($entityType) . '/create/' . (isset($clientId) ? $clientId : '')))->appendIcon(Icon::create('plus-sign')) !!}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user