Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/Http/Controllers/Assets/AssetCheckinController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use \Illuminate\Contracts\View\View;
use \Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Validator;
use Gate;

class AssetCheckinController extends Controller
{
Expand Down Expand Up @@ -152,7 +153,14 @@ function (Builder $query) use ($asset) {

if ($asset->save()) {

if(Gate::allows('audit',Asset::class)) {
if ($request->filled('log_audit') == "1") {
$asset->logAudit($request->input('note'), $request->input('location_id'));
}
}

event(new CheckoutableCheckedIn($asset, $target, auth()->user(), $request->input('note'), $checkin_at, $originalValues));

return Helper::getRedirectOption($request, $asset->id, 'Assets')
->with('success', trans('admin/hardware/message.checkin.success'));
}
Expand Down
9 changes: 9 additions & 0 deletions app/Http/Controllers/Assets/AssetCheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
use App\Http\Controllers\Controller;
use App\Http\Requests\AssetCheckoutRequest;
use App\Models\Asset;
use App\Http\Controllers\Assets\AssetsController;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Session;
use \Illuminate\Contracts\View\View;
use \Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Validator;
use Gate;

class AssetCheckoutController extends Controller
{
Expand Down Expand Up @@ -123,6 +125,13 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);

if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) {

if(Gate::allows('audit',Asset::class)) {
if ($request->filled('log_audit') == "1") {
$asset->logAudit($request->input('note'), $request->input('location_id'));
}
}

return Helper::getRedirectOption($request, $asset->id, 'Assets')
->with('success', trans('admin/hardware/message.checkout.success'));
}
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en-US/admin/settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@
'require_accept_signature_help_text' => 'Enabling this feature will require users to physically sign off on accepting an asset.',
'require_checkinout_notes' => 'Require Notes on Checkin/Checkout',
'require_checkinout_notes_help_text' => 'Enabling this feature will require the note fields to be populated when checking in or checking out an asset.',
'log_audit' => 'Log an audit',
'log_audit_help_text' => 'Enabling this feature will also log an audit in addition to this',
'left' => 'left',
'right' => 'right',
'top' => 'top',
Expand Down
22 changes: 19 additions & 3 deletions resources/views/hardware/checkin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,31 @@
</div>
</div>

<!-- Log an audit checkbox -->
@can('audit', \App\Models\Asset::class)
<div class="form-group">
<div class="col-sm-3 control-label" >
<label>
{{ trans('admin/settings/general.log_audit') }}
</label>
</div>
<div class="col-md-8">
<label class="form-control">
<input type="checkbox" value="1" name="log_audit" {{ (old('log_audit')) == '1' ? ' checked="checked"' : '' }} aria-label="log_audit">
{{ trans('general.yes') }}
</label>
<p class="help-block">{{ trans('admin/settings/general.log_audit_help_text') . " " . trans('general.checkin') . "." }}</p>
</div>
</div>
@endcan



<!-- Custom fields -->
@include("models/custom_fields_form", [
'model' => $asset->model,
'show_custom_fields_type' => 'checkin'
])


</div> <!--/.box-body-->
</div> <!--/.box-body-->

Expand All @@ -175,7 +192,6 @@
</form>

</div>
</div>
</div>

@stop
69 changes: 68 additions & 1 deletion resources/views/hardware/checkout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,25 @@
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>


<!-- Log an audit checkbox -->
@can('audit', \App\Models\Asset::class)
<div class="form-group">
<div class="col-sm-3 control-label" >
<label>
{{ trans('admin/settings/general.log_audit') }}
</label>
</div>
<div class="col-md-8">
<label class="form-control">
<input type="checkbox" value="1" name="log_audit" {{ (old('log_audit')) == '1' ? ' checked="checked"' : '' }} aria-label="log_audit">
{{ trans('general.yes') }}
</label>
<p class="help-block">{{ trans('admin/settings/general.log_audit_help_text') . " " . trans('general.checkout') . "." }}</p>
</div>
</div>
@endcan

<!-- Custom fields -->
@include("models/custom_fields_form", [
'model' => $asset->model,
Expand Down Expand Up @@ -222,4 +240,53 @@

@section('moar_scripts')
@include('partials/assets-assigned')

<script> //testing script
function auditCheckbox() {
// Get the checkbox
var checkBox = document.getElementById("auditcheckbox");
// Get the output text
var text = document.getElementById("audittext");
// If the checkbox is checked, display the fields
if (checkBox.checked == true) {
text.style.display = "block";
} else {
text.style.display = "none";
}
}
</script>

<script>
// Only display the audit fields if the checkbox is selected
$(".format").change(function(){
$(this).find("option:selected").each(function(){
if ($('.format').prop("selectedIndex") == 1) {
$("#custom_regex").show();
} else{
$("#custom_regex").hide();
}
});
}).change();
</script>

<script>
$(document).ready(function() {
$("#optional_info").on("click", function () {
$('#optional_details').fadeToggle(100);
$('#optional_info_icon').toggleClass('checkbox);
var optional_info_open = $('#optional_info_icon').hasClass('checkbox');
document.cookie = "optional_info_open=" + optional_info_open + '; path=/';
});
var all_cookies = document.cookie.split(';')
for (var i in all_cookies) {
var trimmed_cookie = all_cookies[i].trim(' ')
if (trimmed_cookie.startsWith('optional_info_open=')) {
elems = all_cookies[i].split('=', 2)
if (elems[1] == 'true') {
$('#optional_info').trigger('click');
}
}
}
});
</script>
@stop
Loading