1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 22:22:32 +01:00

Added public notes field to credits

This commit is contained in:
Hillel Coren 2017-03-30 11:46:52 +03:00
parent 062ecd540c
commit 441f4aa667
9 changed files with 43 additions and 7 deletions

View File

@ -523,7 +523,7 @@ class ClientPortalController extends BaseController
'account' => $account, 'account' => $account,
'title' => trans('texts.credits'), 'title' => trans('texts.credits'),
'entityType' => ENTITY_CREDIT, 'entityType' => ENTITY_CREDIT,
'columns' => Utils::trans(['credit_date', 'credit_amount', 'credit_balance']), 'columns' => Utils::trans(['credit_date', 'credit_amount', 'credit_balance', 'notes']),
]; ];
return response()->view('public_list', $data); return response()->view('public_list', $data);

View File

@ -23,6 +23,14 @@ class Credit extends EntityModel
*/ */
protected $presenter = 'App\Ninja\Presenters\CreditPresenter'; protected $presenter = 'App\Ninja\Presenters\CreditPresenter';
/**
* @var array
*/
protected $fillable = [
'public_notes',
'private_notes',
];
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */

View File

@ -47,6 +47,12 @@ class CreditDatatable extends EntityDatatable
return link_to("credits/{$model->public_id}/edit", Utils::fromSqlDate($model->credit_date_sql))->toHtml(); return link_to("credits/{$model->public_id}/edit", Utils::fromSqlDate($model->credit_date_sql))->toHtml();
}, },
], ],
[
'public_notes',
function ($model) {
return $model->public_notes;
},
],
[ [
'private_notes', 'private_notes',
function ($model) { function ($model) {

View File

@ -38,6 +38,7 @@ class CreditRepository extends BaseRepository
'contacts.last_name', 'contacts.last_name',
'contacts.email', 'contacts.email',
'credits.private_notes', 'credits.private_notes',
'credits.public_notes',
'credits.deleted_at', 'credits.deleted_at',
'credits.is_deleted', 'credits.is_deleted',
'credits.user_id' 'credits.user_id'
@ -74,7 +75,8 @@ class CreditRepository extends BaseRepository
DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'), DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'),
'credits.amount', 'credits.amount',
'credits.balance', 'credits.balance',
'credits.credit_date' 'credits.credit_date',
'credits.public_notes'
); );
$table = \Datatable::query($query) $table = \Datatable::query($query)
@ -87,6 +89,9 @@ class CreditRepository extends BaseRepository
->addColumn('balance', function ($model) { ->addColumn('balance', function ($model) {
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id); return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
}) })
->addColumn('public_notes', function ($model) {
return $model->public_notes;
})
->make(); ->make();
return $table; return $table;
@ -111,6 +116,7 @@ class CreditRepository extends BaseRepository
$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->private_notes = trim($input['private_notes']); $credit->private_notes = trim($input['private_notes']);
$credit->public_notes = trim($input['public_notes']);
$credit->save(); $credit->save();
return $credit; return $credit;

View File

@ -26,6 +26,7 @@ class CreditTransformer extends EntityTransformer
'credit_date' => $credit->credit_date, 'credit_date' => $credit->credit_date,
'credit_number' => $credit->credit_number, 'credit_number' => $credit->credit_number,
'private_notes' => $credit->private_notes, 'private_notes' => $credit->private_notes,
'public_notes' => $credit->public_notes,
]); ]);
} }
} }

View File

@ -31,6 +31,10 @@ class AddGatewayFeeLocation extends Migration
$table->integer('quote_number_counter')->default(1)->nullable(); $table->integer('quote_number_counter')->default(1)->nullable();
}); });
Schema::table('credits', function ($table) {
$table->text('public_notes')->nullable();
});
// update invoice_item_type_id for task invoice items // update invoice_item_type_id for task invoice items
DB::statement('update invoice_items DB::statement('update invoice_items
left join invoices on invoices.id = invoice_items.invoice_id left join invoices on invoices.id = invoice_items.invoice_id
@ -54,5 +58,9 @@ class AddGatewayFeeLocation extends Migration
$table->dropColumn('invoice_number_counter'); $table->dropColumn('invoice_number_counter');
$table->dropColumn('quote_number_counter'); $table->dropColumn('quote_number_counter');
}); });
Schema::table('credits', function ($table) {
$table->dropColumn('public_notes');
});
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -37,7 +37,9 @@
->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))
->addGroupClass('credit_date') ->addGroupClass('credit_date')
->append('<i class="glyphicon glyphicon-calendar"></i>') !!} ->append('<i class="glyphicon glyphicon-calendar"></i>') !!}
{!! Former::textarea('private_notes') !!}
{!! Former::textarea('public_notes')->rows(4) !!}
{!! Former::textarea('private_notes')->rows(4) !!}
</div> </div>
</div> </div>

View File

@ -6,6 +6,8 @@
<td>{{ trans('texts.amount') }}</td> <td>{{ trans('texts.amount') }}</td>
<td>{{ trans('texts.balance') }}</td> <td>{{ trans('texts.balance') }}</td>
<td>{{ trans('texts.credit_date') }}</td> <td>{{ trans('texts.credit_date') }}</td>
<td>{{ trans('texts.public_notes') }}</td>
<td>{{ trans('texts.private_notes') }}</td>
</tr> </tr>
@foreach ($credits as $credit) @foreach ($credits as $credit)
@ -18,6 +20,8 @@
<td>{{ $account->formatMoney($credit->amount, $credit->client) }}</td> <td>{{ $account->formatMoney($credit->amount, $credit->client) }}</td>
<td>{{ $account->formatMoney($credit->balance, $credit->client) }}</td> <td>{{ $account->formatMoney($credit->balance, $credit->client) }}</td>
<td>{{ $credit->present()->credit_date }}</td> <td>{{ $credit->present()->credit_date }}</td>
<td>{{ $credit->public_notes }}</td>
<td>{{ $credit->private_notes }}</td>
</tr> </tr>
@endif @endif
@endforeach @endforeach