mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Add model_no, item_no, and manufacturer to consumables
This commit is contained in:
parent
63f4bbe412
commit
e552c36a0a
|
@ -55,12 +55,14 @@ class ConsumablesController extends Controller
|
|||
$category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'consumable')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
$manufacturer_list = Helper::manufacturerList();
|
||||
|
||||
return View::make('consumables/edit')
|
||||
->with('consumable', new Consumable)
|
||||
->with('category_list', $category_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('location_list', $location_list);
|
||||
->with('location_list', $location_list)
|
||||
->with('manufacturer_list', $manufacturer_list);
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,6 +83,9 @@ class ConsumablesController extends Controller
|
|||
$consumable->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
|
||||
$consumable->order_number = e(Input::get('order_number'));
|
||||
$consumable->min_amt = e(Input::get('min_amt'));
|
||||
$consumable->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
$consumable->model_no = e(Input::get('model_no'));
|
||||
$consumable->item_no = e(Input::get('item_no'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
$consumable->purchase_date = null;
|
||||
|
@ -130,11 +135,13 @@ class ConsumablesController extends Controller
|
|||
$category_list = Helper::categoryList();
|
||||
$company_list = Helper::companyList();
|
||||
$location_list = Helper::locationsList();
|
||||
$manufacturer_list = Helper::manufacturerList();
|
||||
|
||||
return View::make('consumables/edit', compact('consumable'))
|
||||
->with('category_list', $category_list)
|
||||
->with('company_list', $company_list)
|
||||
->with('location_list', $location_list);
|
||||
->with('location_list', $location_list)
|
||||
->with('manufacturer_list', $manufacturer_list);
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,6 +168,9 @@ class ConsumablesController extends Controller
|
|||
$consumable->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
|
||||
$consumable->order_number = e(Input::get('order_number'));
|
||||
$consumable->min_amt = e(Input::get('min_amt'));
|
||||
$consumable->manufacturer_id = e(Input::get('manufacturer_id'));
|
||||
$consumable->model_no = e(Input::get('model_no'));
|
||||
$consumable->item_no = e(Input::get('item_no'));
|
||||
|
||||
if (e(Input::get('purchase_date')) == '') {
|
||||
$consumable->purchase_date = null;
|
||||
|
@ -407,7 +417,7 @@ class ConsumablesController extends Controller
|
|||
$limit = 50;
|
||||
}
|
||||
|
||||
$allowed_columns = ['id','name','order_number','min_amt','purchase_date','purchase_cost','companyName','category'];
|
||||
$allowed_columns = ['id','name','order_number','min_amt','purchase_date','purchase_cost','companyName','category','model_no', 'item_no', 'manufacturer'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
|
||||
|
||||
|
@ -418,6 +428,9 @@ class ConsumablesController extends Controller
|
|||
case 'location':
|
||||
$consumables = $consumables->OrderLocation($order);
|
||||
break;
|
||||
case 'manufacturer':
|
||||
$consumables = $consumables->OrderManufacturer($order);
|
||||
break;
|
||||
case 'companyName':
|
||||
$consumables = $consumables->OrderCompany($order);
|
||||
break;
|
||||
|
@ -441,6 +454,9 @@ class ConsumablesController extends Controller
|
|||
'location' => ($consumable->location) ? e($consumable->location->name) : '',
|
||||
'min_amt' => e($consumable->min_amt),
|
||||
'qty' => e($consumable->qty),
|
||||
'manufacturer' => ($consumable->manufacturer) ? e($consumable->manufacturer->name) : '',
|
||||
'model_no' => e($consumable->model_no),
|
||||
'item_no' => e($consumable->item_no),
|
||||
'category' => ($consumable->category) ? e($consumable->category->name) : 'Missing category',
|
||||
'order_number' => e($consumable->order_number),
|
||||
'purchase_date' => e($consumable->purchase_date),
|
||||
|
|
|
@ -64,6 +64,11 @@ class Consumable extends Model
|
|||
return $this->belongsTo('\App\Models\Company', 'company_id');
|
||||
}
|
||||
|
||||
public function manufacturer()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id');
|
||||
}
|
||||
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo('\App\Models\Location', 'location_id');
|
||||
|
@ -155,6 +160,10 @@ class Consumable extends Model
|
|||
$query->whereHas('location', function ($query) use ($search) {
|
||||
$query->where('locations.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere(function ($query) use ($search) {
|
||||
$query->whereHas('manufacturer', function ($query) use ($search) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})->orWhere('consumables.name', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('consumables.order_number', 'LIKE', '%'.$search.'%')
|
||||
->orWhere('consumables.purchase_cost', 'LIKE', '%'.$search.'%')
|
||||
|
@ -177,7 +186,7 @@ class Consumable extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on company
|
||||
* Query builder scope to order on location
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
|
@ -189,6 +198,19 @@ class Consumable extends Model
|
|||
return $query->leftJoin('locations', 'consumables.location_id', '=', 'locations.id')->orderBy('locations.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on manufacturer
|
||||
*
|
||||
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param text $order Order
|
||||
*
|
||||
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderManufacturer($query, $order)
|
||||
{
|
||||
return $query->leftJoin('manufacturers', 'consumables.manufacturer_id', '=', 'manufacturers.id')->orderBy('manufacturers.name', $order);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to order on company
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddModelMfgToConsumable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('consumables', function (Blueprint $table) {
|
||||
$table->integer('model_no')->nullable()->default(NULL);
|
||||
$table->integer('manufacturer_id')->nullable()->default(NULL);
|
||||
$table->string('item_no')->nullable()->default(NULL);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('consumables', function ($table) {
|
||||
$table->dropColumn(
|
||||
'model_no',
|
||||
'manufacturer_id',
|
||||
'item_no'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ return array(
|
|||
'cost' => 'Purchase Cost',
|
||||
'create' => 'Create Consumable',
|
||||
'date' => 'Purchase Date',
|
||||
'item_no' => 'Item No.',
|
||||
'order' => 'Order Number',
|
||||
'remaining' => 'Remaining',
|
||||
'total' => 'Total',
|
||||
|
|
|
@ -79,6 +79,18 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Manufacturer -->
|
||||
<div class="form-group {{ $errors->has('manufacturer_id') ? ' has-error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
{{ Form::label('manufacturer_id', trans('general.manufacturer')) }}
|
||||
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
{{ Form::select('manufacturer_id', $manufacturer_list , Input::old('manufacturer_id', $consumable->manufacturer_id), array('class'=>'select2', 'style'=>'width:100%')) }}
|
||||
{!! $errors->first('manufacturer_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Location -->
|
||||
<div class="form-group {{ $errors->has('location_id') ? ' has-error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
|
@ -91,6 +103,28 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Model Number -->
|
||||
<div class="form-group {{ $errors->has('model_no') ? ' has-error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
{{ Form::label('model_no', trans('general.model_no')) }}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<input class="form-control" type="text" name="model_no" id="model_no" value="{{ Input::old('model_no', $consumable->model_no) }}" />
|
||||
{!! $errors->first('model_no', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Item Number -->
|
||||
<div class="form-group {{ $errors->has('item_no') ? ' has-error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
{{ Form::label('item_no', trans('admin/consumables/general.item_no')) }}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<input class="form-control" type="text" name="item_no" id="item_no" value="{{ Input::old('item_no', $consumable->item_no) }}" />
|
||||
{!! $errors->first('item_no', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Order Number -->
|
||||
<div class="form-group {{ $errors->has('order_number') ? ' has-error' : '' }}">
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="qty"> {{ trans('admin/consumables/general.total') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="numRemaining"> {{ trans('admin/consumables/general.remaining') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="true" data-field="min_amt"> {{ trans('general.min_amt') }}</th>
|
||||
<th data-sortable="true" data-field="manufacturer" data-visible="false">{{ trans('general.manufacturer') }}</th>
|
||||
<th data-sortable="true" data-field="model_no" data-visible="false">{{ trans('general.model_no') }}</th>
|
||||
<th data-sortable="true" data-field="item_no" data-visible="false">{{ trans('admin/consumables/general.item_no') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="order_number" data-visible="false">{{ trans('admin/consumables/general.order') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="purchase_date" data-visible="false">{{ trans('admin/consumables/general.date') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="purchase_cost" data-visible="false">{{ trans('admin/consumables/general.cost') }}</th>
|
||||
|
|
|
@ -51,12 +51,18 @@
|
|||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
|
||||
<h4>{{ trans('admin/consumables/general.about_consumables_title') }}</h4>
|
||||
<p>{{ trans('admin/consumables/general.about_consumables_text') }} </p>
|
||||
|
||||
|
||||
@if ($consumable->purchase_date)
|
||||
<div class="col-md-12" style="padding-bottom: 5px;"><strong>{{ trans('admin/consumables/general.date') }}: </strong>
|
||||
{{ $consumable->purchase_date }} </div>
|
||||
|
@ -69,6 +75,21 @@
|
|||
{{ number_format($consumable->purchase_cost,2) }} </div>
|
||||
@endif
|
||||
|
||||
@if ($consumable->item_no)
|
||||
<div class="col-md-12" style="padding-bottom: 5px;"><strong>{{ trans('admin/consumables/general.item_no') }}:</strong>
|
||||
{{ $consumable->item_no }} </div>
|
||||
@endif
|
||||
|
||||
@if ($consumable->model_no)
|
||||
<div class="col-md-12" style="padding-bottom: 5px;"><strong>{{ trans('general.model_no') }}:</strong>
|
||||
{{ $consumable->model_no }} </div>
|
||||
@endif
|
||||
|
||||
@if ($consumable->manufacturer)
|
||||
<div class="col-md-12" style="padding-bottom: 5px;"><strong>{{ trans('general.manufacturer') }}:</strong>
|
||||
{{ $consumable->manufacturer->name }} </div>
|
||||
@endif
|
||||
|
||||
@if ($consumable->order_number)
|
||||
<div class="col-md-12" style="padding-bottom: 5px;"><strong>{{ trans('admin/consumables/general.order') }}:</strong>
|
||||
{{ $consumable->order_number }} </div>
|
||||
|
@ -78,14 +99,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<!-- side address column -->
|
||||
<div class="col-md-3">
|
||||
<h4>{{ trans('admin/consumables/general.about_consumables_title') }}</h4>
|
||||
<p>{{ trans('admin/consumables/general.about_consumables_text') }} </p>
|
||||
|
||||
</div>
|
||||
|
||||
@section('moar_scripts')
|
||||
<script src="{{ asset('assets/js/bootstrap-table.js') }}"></script>
|
||||
<script src="{{ asset('assets/js/extensions/cookie/bootstrap-table-cookie.js') }}"></script>
|
||||
|
|
Loading…
Reference in a new issue