Skip to content
Open
12 changes: 11 additions & 1 deletion app/Http/Controllers/CustomFieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ public function store(CustomFieldRequest $request) : RedirectResponse

$show_in_email = $request->input("show_in_email", 0);
$display_in_user_view = $request->input("display_in_user_view", 0);
$display_on_print_assigned = $request->input('display_on_print_assigned', 0);

// Override the display settings if the field is encrypted
if ($request->input("field_encrypted") == '1') {
$show_in_email = '0';
$display_in_user_view = '0';
$display_on_print_assigned = '0';
}

$field = new CustomField([
Expand All @@ -107,7 +109,9 @@ public function store(CustomFieldRequest $request) : RedirectResponse
"display_checkin" => $request->input("display_checkin", 0),
"display_checkout" => $request->input("display_checkout", 0),
"display_audit" => $request->input("display_audit", 0),
"created_by" => auth()->id()
"display_on_print_assigned" => $display_on_print_assigned,

"created_by" => auth()->id()
]);


Expand Down Expand Up @@ -231,11 +235,14 @@ public function update(CustomFieldRequest $request, CustomField $field) : Redire
$this->authorize('update', $field);
$show_in_email = $request->get("show_in_email", 0);
$display_in_user_view = $request->get("display_in_user_view", 0);
$display_on_print_assigned = $request->input('display_on_print_assigned', 0);


// Override the display settings if the field is encrypted
if ($request->get("field_encrypted") == '1') {
$show_in_email = '0';
$display_in_user_view = '0';
$display_on_print_assigned = '0';
}

$field->name = trim($request->get("name"));
Expand All @@ -252,6 +259,9 @@ public function update(CustomFieldRequest $request, CustomField $field) : Redire
$field->display_checkin = $request->get("display_checkin", 0);
$field->display_checkout = $request->get("display_checkout", 0);
$field->display_audit = $request->get("display_audit", 0);
$field->display_on_print_assigned = $display_on_print_assigned;



if ($request->get('format') == 'CUSTOM REGEX') {
$field->format = $request->get('custom_format');
Expand Down
7 changes: 6 additions & 1 deletion app/Http/Controllers/Users/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Models\Actionlog;
use App\Models\Asset;
use App\Models\Company;
use App\Models\CustomField;
use App\Models\Group;
use App\Models\Setting;
use App\Models\User;
Expand Down Expand Up @@ -615,7 +616,11 @@ public function printInventory($id)

return view('users.print')
->with('users', [$user])
->with('settings', Setting::getSettings());
->with('settings', Setting::getSettings())
->with('printable_customfields', CustomField::all()->filter(function ($customfield) {
return $customfield->display_on_print_assigned && $customfield->field_encrypted == 0;
//This should make it to NOT show encrypted custom fields on the printout
}));
}

return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', compact('id')));
Expand Down
1 change: 1 addition & 0 deletions app/Models/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class CustomField extends Model
'display_checkin',
'display_audit',
'show_in_requestable_list',
'display_on_print_assigned',
];

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('custom_fields', function (Blueprint $table) {
$table->boolean('display_on_print_assigned')->nullable()->default(0);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('custom_fields', function (Blueprint $table) {
if (Schema::hasColumn('custom_fields', 'display_on_print_assigned')) {
$table->dropColumn('display_on_print_assigned');
}
});
}
};
1 change: 1 addition & 0 deletions resources/lang/en-US/admin/custom_fields/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
'display_checkin' => 'Display in checkin forms',
'display_checkout' => 'Display in checkout forms',
'display_audit' => 'Display in audit forms',
'display_on_print_assigned' => 'Display in the assigned assets print out',
'types' => [
'text' => 'Text Box',
'listbox' => 'List Box',
Expand Down
11 changes: 10 additions & 1 deletion resources/views/custom_fields/fields/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,17 @@ class="format form-control"
</label>
</div>

<!-- Show on Print Assigned Page -->
<!-- TODO: create if statement to show ONLY on assets? -->
<div class="col-md-9 col-md-offset-3" id="display_on_print_assigned" style="padding-bottom: 10px;">
<label class="form-control">
<input type="checkbox" name="display_on_print_assigned" aria-label="display_on_print_assigned" value="1" {{ (old('display_on_print_assigned') || $field->display_on_print_assigned) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.display_on_print_assigned') }}
</label>
</div>


<!-- Show in View All Assets profile view -->
<!-- Show in View All Assets profile view -->
<div class="col-md-9 col-md-offset-3" id="display_in_user_view">
<label class="form-control">
<input type="checkbox" name="display_in_user_view" aria-label="display_in_user_view" value="1" {{ (old('display_in_user_view') || $field->display_in_user_view) ? ' checked="checked"' : '' }}>
Expand Down
20 changes: 13 additions & 7 deletions resources/views/custom_fields/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,13 @@ class="table table-striped snipe-table"
<th data-sortable="true" data-searchable="true">{{ trans('admin/custom_fields/general.help_text')}}</th>
<th data-sortable="true" data-visible="false">{{ trans('admin/custom_fields/general.db_field') }}</th>
<th data-sortable="true" data-searchable="true">{{ trans('admin/custom_fields/general.field_format') }}</th>
<th data-sortable="true" data-tooltip="{{ trans('admin/custom_fields/general.encrypted') }}"><i
class="fa fa-lock" aria-hidden="true"></i>
<span class="hidden-xs hidden-sm hidden-md hidden-lg">{{ trans('admin/custom_fields/general.encrypted') }}</span>
<th data-sortable="true" data-tooltip="{{ trans('admin/custom_fields/general.encrypted') }}">
<i class="fa fa-lock" aria-hidden="true"></i>
<span class="hidden-xs hidden-sm hidden-md hidden-lg">{{ trans('admin/custom_fields/general.encrypted') }}</span>
</th>
<th data-sortable="true" class="text-center"
data-tooltip="{{ trans('admin/custom_fields/general.show_in_listview_short') }}"><i class="fa fa-list"
aria-hidden="true"></i>
<span class="hidden-xs hidden-sm hidden-md hidden-lg">{{ trans('admin/custom_fields/general.show_in_listview_short') }}</span>
<th data-sortable="true" class="text-center" data-tooltip="{{ trans('admin/custom_fields/general.show_in_listview_short') }}">
<i class="fa fa-list" aria-hidden="true"></i>
<span class="hidden-xs hidden-sm hidden-md hidden-lg">{{ trans('admin/custom_fields/general.show_in_listview_short') }}</span>
</th>
<th data-visible="false" data-sortable="true" class="text-center"
data-tooltip="{{ trans('admin/custom_fields/general.display_in_user_view_table') }}"><i
Expand All @@ -167,6 +166,12 @@ class="fa fa-laptop fa-fw" aria-hidden="true"><span
class="sr-only">{{ trans('admin/custom_fields/general.show_in_requestable_list_short') }}</span></i>
</th>

<th data-sortable="true" data-searchable="false" class="text-center"
data-tooltip="{{ trans('admin/custom_fields/general.display_on_print_assigned') }}"><i
class="fa fa-print fa-fw" aria-hidden="true"><span
class="sr-only">{{ trans('admin/custom_fields/general.display_on_print_assigned') }}</span></i>
</th>

<th data-sortable="true" data-searchable="false" class="text-center"
data-tooltip="{{ trans('admin/custom_fields/general.unique') }}"><i
class="fa-solid fa-fingerprint"><span
Expand Down Expand Up @@ -223,6 +228,7 @@ class="sr-only">{{ trans('admin/custom_fields/general.unique') }}</span></i></th
<td class="text-center">{!! ($field->display_in_user_view=='1' ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>') !!}</td>
<td class="text-center">{!! ($field->show_in_email=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td>
<td class="text-center">{!! ($field->show_in_requestable_list=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td>
<td class="text-center">{!! ($field->display_on_print_assigned=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td>
<td class="text-center">{!! ($field->is_unique=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td>
<td class="text-center">{!! ($field->display_checkin=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td>
<td class="text-center">{!! ($field->display_checkout=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td>
Expand Down
42 changes: 32 additions & 10 deletions resources/views/users/print.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,26 @@
</h4>
</div>



<table
class="snipe-table table table-striped inventory"
id="AssetsAssigned"
data-pagination="false"
data-id-table="AssetsAssigned"
data-toolbar="#assets-toolbar"
data-search="false"
data-id-table="AssetsAssigned"
data-side-pagination="client"
data-sortable="true"
data-toolbar="#assets-toolbar"
data-show-columns="true"
data-sort-order="desc"
data-sort-name="created_at"
data-show-columns="true"
data-cookie-id-table="AssetsAssigned">
<thead>
<th data-field="asset_id" data-sortable="false" data-visible="true" data-switchable="false">#</th>


<thead>
<th data-field="asset_id" data-sortable="true" data-visible="true" data-switchable="false">#</th>
<th data-field="asset_image" data-sortable="true" data-visible="false" data-switchable="true">{{ trans('general.image') }}</th>
<th data-field="asset_tag" data-sortable="true" data-visible="true" data-switchable="false">{{ trans('admin/hardware/table.asset_tag') }}</th>
<th data-field="asset_name" data-sortable="true" data-visible="true">{{ trans('general.name') }}</th>
Expand All @@ -126,8 +131,16 @@ class="snipe-table table table-striped inventory"
<th data-field="asset_location" data-sortable="true" data-visible="false">{{ trans('general.location') }}</th>
<th data-field="asset_serial" data-sortable="true" data-visible="true">{{ trans('admin/hardware/form.serial') }}</th>
<th data-field="asset_checkout_date" data-sortable="true" data-visible="true">{{ trans('admin/hardware/table.checkout_date') }}</th>

@foreach($printable_customfields as $customfield)
<th data-sortable="true" data-visible="true">
{{$customfield->name}}
</th>
@endforeach

<th data-field="signature" data-sortable="false" data-visible="true">{{ trans('general.signature') }}</th>
</thead>

</thead>
<tbody>
@foreach ($show_user->assets as $asset)
@php
Expand All @@ -149,11 +162,19 @@ class="snipe-table table table-striped inventory"
<td>{{ $asset->serial }}</td>
<td>
{{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }}</td>

@foreach($printable_customfields as $customfield)
<td>
{{ $asset->{$customfield->db_column} }}
</td>
@endforeach

<td>
@if ($asset->getLatestSignedAcceptance($show_user))
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $asset->getLatestSignedAcceptance($show_user)->accept_signature }}">
@endif
</td>

</tr>
@if ($settings->show_assigned_assets)
@php
Expand Down Expand Up @@ -493,12 +514,14 @@ classes: 'table table-responsive table-no-bordered',
paginationVAlign: 'both',
queryParams: function (params) {
var newParams = {};
for(var i in params) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this change about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, indenting

if(!keyBlocked(i)) { // only send the field if it's not in blockedFields
newParams[i] = params[i];
var keyBlocked = function () {
for (var i in params) {
if (!keyBlocked(i)) { // only send the field if it's not in blockedFields
newParams[i] = params[i];
}
}
return newParams;
}
return newParams;
},
formatLoadingMessage: function () {
return '<h2><i class="fas fa-spinner fa-spin" aria-hidden="true"></i> {{ trans('general.loading') }} </h2>';
Expand All @@ -523,6 +546,5 @@ classes: 'table table-responsive table-no-bordered',
});
});
</script>

</body>
</html>
Loading