Merge pull request #17883 from akemidx/purchasepricereportfilter
FEATURE: Purchase Cost Report Filter
This commit is contained in:
@@ -685,6 +685,14 @@ class ReportsController extends Controller
|
||||
$assets->whereBetween('assets.purchase_date', [$request->input('purchase_start'), $request->input('purchase_end')]);
|
||||
}
|
||||
|
||||
if ($request->filled('purchase_cost_start')) {
|
||||
if ($request->filled('purchase_cost_end')) {
|
||||
$assets->whereBetween('assets.purchase_cost', [$request->input('purchase_cost_start'), $request->input('purchase_cost_end')]);
|
||||
} else {
|
||||
$assets->where('assets.purchase_cost', ">", $request->input('purchase_cost_start'));
|
||||
}
|
||||
}
|
||||
|
||||
if (($request->filled('created_start')) && ($request->filled('created_end'))) {
|
||||
$created_start = Carbon::parse($request->input('created_start'))->startOfDay();
|
||||
$created_end = Carbon::parse($request->input('created_end'))->endOfDay();
|
||||
|
||||
@@ -14,6 +14,15 @@ class CustomAssetReportRequest extends Request
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
if($this->filled('purchase_cost_end') && !$this->filled('purchase_cost_start')){
|
||||
$this->merge(['purchase_cost_start' => 0 ]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@@ -24,6 +33,7 @@ class CustomAssetReportRequest extends Request
|
||||
return [
|
||||
'purchase_start' => 'date|date_format:Y-m-d|nullable',
|
||||
'purchase_end' => 'date|date_format:Y-m-d|nullable',
|
||||
'purchase_cost_end' => 'numeric|nullable|gte:purchase_cost_start',
|
||||
'created_start' => 'date|date_format:Y-m-d|nullable',
|
||||
'created_end' => 'date|date_format:Y-m-d|nullable',
|
||||
'checkout_date_start' => 'date|date_format:Y-m-d|nullable',
|
||||
|
||||
@@ -426,7 +426,25 @@
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Created Date -->
|
||||
<!-- Purchase Cost -->
|
||||
<div class="form-group purchase-range{{ ($errors->has('purchase_cost_start') || $errors->has('purchase_cost_end')) ? ' has-error' : '' }}">
|
||||
<label for="purchase_cost_start" class="col-md-3 control-label">{{ trans('admin/hardware/form.cost') }}</label>
|
||||
<div class="input-group col-md-7">
|
||||
<input type="number" min="0" step="0.01" class="form-control" name="purchase_cost_start" aria-label="purchase_cost_start" value="{{ $template->textValue('purchase_cost_start', old('purchase_cost_start')) }}">
|
||||
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
|
||||
<input type="number" min="0" step="0.01" class="form-control" name="purchase_cost_end" aria-label="purchase_cost_end" value="{{ $template->textValue('purchase_cost_end', old('purchase_cost_end')) }}">
|
||||
</div>
|
||||
|
||||
@if ($errors->has('purchase_cost_start') || $errors->has('purchase_cost_end'))
|
||||
<div class="col-md-9 col-lg-offset-3">
|
||||
{!! $errors->first('purchase_cost_start', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
{!! $errors->first('purchase_cost_end', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Created Date -->
|
||||
<div class="form-group created-range{{ ($errors->has('created_start') || $errors->has('created_end')) ? ' has-error' : '' }}">
|
||||
<label for="created_start" class="col-md-3 control-label">{{ trans('general.created_at') }} </label>
|
||||
<div class="input-daterange input-group col-md-7" id="created-range-datepicker">
|
||||
|
||||
Reference in New Issue
Block a user