Merge pull request #10774 from snipe/features/added_notes_to_accessories_etc

Fixed #6918 - added notes to accessories, components, consumables
This commit is contained in:
snipe 2022-03-03 20:41:18 -08:00 committed by GitHub
commit 3e22dce117
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 210 additions and 10 deletions

View file

@ -78,6 +78,8 @@ class AccessoriesController extends Controller
$accessory->qty = request('qty');
$accessory->user_id = Auth::user()->id;
$accessory->supplier_id = request('supplier_id');
$accessory->notes = request('notes');
$accessory = $request->handleImages($accessory);
@ -140,6 +142,7 @@ class AccessoriesController extends Controller
$accessory->purchase_cost = Helper::ParseCurrency(request('purchase_cost'));
$accessory->qty = request('qty');
$accessory->supplier_id = request('supplier_id');
$accessory->notes = request('notes');
$accessory = $request->handleImages($accessory);

View file

@ -39,7 +39,8 @@ class AccessoriesController extends Controller
'notes',
'created_at',
'min_amt',
'company_id'
'company_id',
'notes',
];
@ -69,6 +70,10 @@ class AccessoriesController extends Controller
$accessories->where('location_id','=',$request->input('location_id'));
}
if ($request->filled('notes')) {
$accessories->where('notes','=',$request->input('notes'));
}
// Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which
// case we override with the actual count, so we should return 0 items.
$offset = (($accessories) && ($request->get('offset') > $accessories->count())) ? $accessories->count() : $request->get('offset', 0);

View file

@ -40,6 +40,7 @@ class ComponentsController extends Controller
'purchase_cost',
'qty',
'image',
'notes',
];
@ -62,6 +63,10 @@ class ComponentsController extends Controller
$components->where('location_id','=',$request->input('location_id'));
}
if ($request->filled('notes')) {
$components->where('notes','=',$request->input('notes'));
}
// Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which
// case we override with the actual count, so we should return 0 items.
$offset = (($components) && ($request->get('offset') > $components->count())) ? $components->count() : $request->get('offset', 0);

View file

@ -42,6 +42,7 @@ class ConsumablesController extends Controller
'item_no',
'qty',
'image',
'notes',
];
@ -74,6 +75,10 @@ class ConsumablesController extends Controller
$consumables->where('location_id','=',$request->input('location_id'));
}
if ($request->filled('notes')) {
$consumables->where('notes','=',$request->input('notes'));
}
// Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which
// case we override with the actual count, so we should return 0 items.

View file

@ -78,6 +78,7 @@ class ComponentsController extends Controller
$component->purchase_cost = Helper::ParseCurrency($request->input('purchase_cost', null));
$component->qty = $request->input('qty');
$component->user_id = Auth::id();
$component->notes = $request->input('notes');
$component = $request->handleImages($component);
@ -147,6 +148,7 @@ class ComponentsController extends Controller
$component->purchase_date = $request->input('purchase_date');
$component->purchase_cost = Helper::ParseCurrency(request('purchase_cost'));
$component->qty = $request->input('qty');
$component->notes = $request->input('notes');
$component = $request->handleImages($component);

View file

@ -78,6 +78,8 @@ class ConsumablesController extends Controller
$consumable->purchase_cost = Helper::ParseCurrency($request->input('purchase_cost'));
$consumable->qty = $request->input('qty');
$consumable->user_id = Auth::id();
$consumable->notes = $request->input('notes');
$consumable = $request->handleImages($consumable);
@ -143,6 +145,7 @@ class ConsumablesController extends Controller
$consumable->purchase_date = $request->input('purchase_date');
$consumable->purchase_cost = Helper::ParseCurrency($request->input('purchase_cost'));
$consumable->qty = Helper::ParseFloat($request->input('qty'));
$consumable->notes = $request->input('notes');
$consumable = $request->handleImages($consumable);

View file

@ -43,6 +43,7 @@ class ComponentsTransformer
'id' => (int) $component->company->id,
'name' => e($component->company->name)
] : null,
'notes' => ($component->notes) ? e($component->notes) : null,
'created_at' => Helper::getFormattedDateObject($component->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($component->updated_at, 'datetime'),
'user_can_checkout' => ($component->numRemaining() > 0) ? 1 : 0,

View file

@ -37,6 +37,7 @@ class ConsumablesTransformer
'purchase_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost),
'purchase_date' => Helper::getFormattedDateObject($consumable->purchase_date, 'date'),
'qty' => (int) $consumable->qty,
'notes' => ($consumable->notes) ? e($consumable->notes) : null,
'created_at' => Helper::getFormattedDateObject($consumable->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($consumable->updated_at, 'datetime'),
];

View file

@ -35,7 +35,7 @@ class Accessory extends SnipeModel
*
* @var array
*/
protected $searchableAttributes = ['name', 'model_number', 'order_number', 'purchase_date'];
protected $searchableAttributes = ['name', 'model_number', 'order_number', 'purchase_date', 'notes'];
/**
* The relations and their attributes that should be included when searching the model.
@ -92,7 +92,8 @@ class Accessory extends SnipeModel
'image',
'qty',
'min_amt',
'requestable'
'requestable',
'notes',
];

View file

@ -60,6 +60,7 @@ class Component extends SnipeModel
'order_number',
'qty',
'serial',
'notes',
];
use Searchable;
@ -69,7 +70,7 @@ class Component extends SnipeModel
*
* @var array
*/
protected $searchableAttributes = ['name', 'order_number', 'serial', 'purchase_cost', 'purchase_date'];
protected $searchableAttributes = ['name', 'order_number', 'serial', 'purchase_cost', 'purchase_date', 'notes'];
/**
* The relations and their attributes that should be included when searching the model.

View file

@ -69,7 +69,8 @@ class Consumable extends SnipeModel
'purchase_date',
'qty',
'min_amt',
'requestable'
'requestable',
'notes',
];
use Searchable;
@ -79,7 +80,7 @@ class Consumable extends SnipeModel
*
* @var array
*/
protected $searchableAttributes = ['name', 'order_number', 'purchase_cost', 'purchase_date', 'item_no', 'model_number'];
protected $searchableAttributes = ['name', 'order_number', 'purchase_cost', 'purchase_date', 'item_no', 'model_number', 'notes'];
/**
* The relations and their attributes that should be included when searching the model.

View file

@ -109,7 +109,14 @@ class AccessoryPresenter extends Presenter
"sortable" => true,
"visible" => false,
"title" => trans('general.order_number'),
],[
], [
"field" => "notes",
"searchable" => true,
"sortable" => true,
"visible" => false,
"title" => trans('general.notes'),
"formatter" => "notesFormatter"
], [
"field" => "change",
"searchable" => false,
"sortable" => false,

View file

@ -104,7 +104,14 @@ class ComponentPresenter extends Presenter
"title" => trans('general.purchase_cost'),
"visible" => true,
"footerFormatter" => 'sumFormatter',
],
], [
"field" => "notes",
"searchable" => true,
"sortable" => true,
"visible" => false,
"title" => trans('general.notes'),
"formatter" => "notesFormatter"
]
];
$layout[] = [

View file

@ -118,13 +118,20 @@ class ConsumablePresenter extends Presenter
"visible" => true,
"footerFormatter" => 'sumFormatter',
],[
"field" => "notes",
"searchable" => true,
"sortable" => true,
"visible" => false,
"title" => trans('general.notes'),
"formatter" => "notesFormatter"
], [
"field" => "change",
"searchable" => false,
"sortable" => false,
"visible" => true,
"title" => trans('general.change'),
"formatter" => "consumablesInOutFormatter",
], [
], [
"field" => "actions",
"searchable" => false,
"sortable" => false,

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNotesToAccessories extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('accessories', function (Blueprint $table) {
$table->text("notes")->nullable()->default(null);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('accessories', function (Blueprint $table) {
if (Schema::hasColumn('accessories', 'notes')) {
$table->dropColumn('notes');
}
});
}
}

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNotesToComponents extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('components', function (Blueprint $table) {
$table->text("notes")->nullable()->default(null);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('components', function (Blueprint $table) {
if (Schema::hasColumn('components', 'notes')) {
$table->dropColumn('notes');
}
});
}
}

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNotesToConsumables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('consumables', function (Blueprint $table) {
$table->text("notes")->nullable()->default(null);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('consumables', function (Blueprint $table) {
if (Schema::hasColumn('consumables', 'notes')) {
$table->dropColumn('notes');
}
});
}
}

View file

@ -35,6 +35,8 @@
</div>
@endif
@include ('partials.forms.edit.notes')
@include ('partials.forms.edit.image-upload')
@stop

View file

@ -102,6 +102,20 @@
<a href="{{ route('checkout/accessory', $accessory->id) }}" style="margin-right:5px;" class="btn btn-primary btn-sm" {{ (($accessory->numRemaining() > 0 ) ? '' : ' disabled') }}>{{ trans('general.checkout') }}</a>
@endcan
</div>
@if ($accessory->notes)
<div class="col-md-12">
<strong>
{{ trans('general.notes') }}
</strong>
</div>
<div class="col-md-12">
{!! nl2br(e($accessory->notes)) !!}
</div>
</div>
@endif
</div>
</div>
@stop

View file

@ -33,6 +33,8 @@
</div>
@endif
@include ('partials.forms.edit.notes')
@include ('partials.forms.edit.image-upload')
@stop

View file

@ -135,6 +135,20 @@
<div class="col-md-12" style="padding-bottom: 5px;"><strong>{{ trans('general.order_number') }}:</strong>
{{ $component->order_number }} </div>
@endif
@if ($component->notes)
<div class="col-md-12">
<strong>
{{ trans('general.notes') }}
</strong>
</div>
<div class="col-md-12">
{!! nl2br(e($component->notes)) !!}
</div>
</div>
@endif
</div>
</div> <!-- .row-->

View file

@ -33,5 +33,7 @@
</div>
@endif
@include ('partials.forms.edit.notes')
@include ('partials.forms.edit.image-upload')
@stop

View file

@ -117,11 +117,26 @@
</div>
@endif
@can('checkout', \App\Models\Accessory::class)
@can('checkout', \App\Models\Consumable::class)
<div class="col-md-12">
<a href="{{ route('checkout/consumable', $consumable->id) }}" style="padding-bottom:5px;" class="btn btn-primary btn-sm" {{ (($consumable->numRemaining() > 0 ) ? '' : ' disabled') }}>{{ trans('general.checkout') }}</a>
</div>
@endcan
@if ($consumable->notes)
<div class="col-md-12">
<strong>
{{ trans('general.notes') }}
</strong>
</div>
<div class="col-md-12">
{!! nl2br(e($consumable->notes)) !!}
</div>
</div>
@endif
</div> <!-- /.col-md-3-->
</div> <!-- /.row-->