Skip to content

Feature: Editing Custom Fields on Checkout #15074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions app/Http/Controllers/Assets/AssetCheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons
}
}

if (($asset->model->fieldset)) {
foreach ($asset->model->fieldset->fields as $field) {
if ($field->field_encrypted == '1') {
if (Gate::allows('admin')) {
if (is_array($request->input($field->db_column))) {
$asset->{$field->db_column} = Crypt::encrypt(implode(', ', $request->input($field->db_column)));
} else {
$asset->{$field->db_column} = Crypt::encrypt($request->input($field->db_column));
}
}
} else {
if (is_array($request->input($field->db_column))) {
$asset->{$field->db_column} = implode(', ', $request->input($field->db_column));
} else {
$asset->{$field->db_column} = $request->input($field->db_column);
}
}
}
}

$settings = \App\Models\Setting::getSettings();

// We have to check whether $target->company_id is null here since locations don't have a company yet
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Assets/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ public function auditStore(UploadFileRequest $request, $id)
if ($request->input('update_location') == '1') {
$asset->location_id = $request->input('location_id');
}


/**
* Invoke Watson Validating to check the asset itself and check to make sure it saved correctly.
Expand Down
42 changes: 42 additions & 0 deletions resources/views/hardware/checkout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,26 @@
</div>
</div>

<!-- Custom fields -->
@can('assets.edit')
<div class="form-group">
<label class="col-md-3 control-label"></label>
<div class="col-md-9 col-sm-9 col-md-offset-3">
<a id="optional_info" class="dropdown-toggle">
<i class="fa fa-2x fa-caret-right" id="optional_info_icon"></i>
<strong>{{ trans('admin/custom_fields/general.custom_fields') }}</strong>
</a>
</div>
<div class="col-md-12">
<ul class="treeview-menu" style="display: none; padding-top: 10px;" id="optional_details">
<li>
@include("models/custom_fields_form",["model" => $asset->model, "item"=>$asset])
</li>
</ul>
</div>
</div>
@endcan

<!-- Note -->
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
<label for="note" class="col-md-3 control-label">
Expand Down Expand Up @@ -203,4 +223,26 @@


</script>

<script>
$(document).ready(function() {
$("#optional_info").on("click", function () {
$('#optional_details').fadeToggle(100);
$('#optional_info_icon').toggleClass('fa-caret-right fa-caret-down');
var optional_info_open = $('#optional_info_icon').hasClass('fa-caret-down');
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