Compare commits

...

4 Commits

Author SHA1 Message Date
snipe
e92beec679 Added audit type to API controller
Signed-off-by: snipe <snipe@snipe.net>
2023-02-23 18:40:19 -08:00
snipe
c275c35460 Fixed typo
Signed-off-by: snipe <snipe@snipe.net>
2023-02-23 17:30:22 -08:00
snipe
c284d8d436 Added strings, variables to the controllers
Signed-off-by: snipe <snipe@snipe.net>
2023-02-23 15:24:58 -08:00
snipe
7851e7c0b0 Added migration
Signed-off-by: snipe <snipe@snipe.net>
2023-02-23 15:24:58 -08:00
8 changed files with 60 additions and 16 deletions

View File

@@ -987,10 +987,14 @@ class AssetsController extends Controller
$asset->unsetEventDispatcher();
$asset->next_audit_date = $dt;
if ($request->filled('audit_type')) {
$asset->audit_type = $request->input('audit_type');
}
if ($request->filled('next_audit_date')) {
$asset->next_audit_date = $request->input('next_audit_date');
}
// Check to see if they checked the box to update the physical location,
// not just note it in the audit notes
if ($request->input('update_location') == '1') {

View File

@@ -851,11 +851,11 @@ class AssetsController extends Controller
$asset->next_audit_date = $request->input('next_audit_date');
$asset->last_audit_date = date('Y-m-d H:i:s');
$asset->audit_type = $request->input('audit_type');
// Check to see if they checked the box to update the physical location,
// not just note it in the audit notes
if ($request->input('update_location') == '1') {
\Log::debug('update location in audit');
$asset->location_id = $request->input('location_id');
}
@@ -874,8 +874,7 @@ class AssetsController extends Controller
Storage::putFileAs($path, $upload, $file_name);
}
$asset->logAudit($request->input('note'), $request->input('location_id'), $file_name);
$asset->logAudit($request->input('note'), $request->input('location_id'), $file_name, $request->input('audit_type'));
return redirect()->route('assets.audit.due')->with('success', trans('admin/hardware/message.audit.success'));
}
}

View File

@@ -1148,7 +1148,6 @@ class Asset extends Depreciable
return $query->whereNotNull('assets.next_audit_date')
->whereRaw('DATE_SUB('.DB::getTablePrefix()."assets.next_audit_date, INTERVAL $interval DAY) <= '".Carbon::now()."'")
->where('assets.archived', '=', 0)
->NotArchived();
}

View File

@@ -169,7 +169,7 @@ trait Loggable
* @since [v4.0]
* @return \App\Models\Actionlog
*/
public function logAudit($note, $location_id, $filename = null)
public function logAudit($note, $location_id, $filename = null, $audit_type = null)
{
$log = new Actionlog;
$location = Location::find($location_id);
@@ -184,6 +184,7 @@ trait Loggable
$log->note = $note;
$log->user_id = Auth::user()->id;
$log->filename = $filename;
$log->audit_type = $audit_type;
$log->logaction('audit');
$params = [

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAuditTypeToActionLogs extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('action_logs', function (Blueprint $table) {
$table->tinyText('audit_type')->nullable()->default(null);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('action_logs', function (Blueprint $table) {
if (Schema::hasColumn('action_logs', 'audit_type')) {
$table->dropColumn('audit_type');
}
});
}
}

View File

@@ -42,5 +42,6 @@ return [
'error_messages' => 'Error messages:',
'success_messages' => 'Success messages:',
'alert_details' => 'Please see below for details.',
'custom_export' => 'Custom Export'
'custom_export' => 'Custom Export',
'audit_type_physical' => 'This asset was physically audited',
];

View File

@@ -14,21 +14,14 @@ return [
*/
'more_info_title' => 'More Info',
'audit_help' => 'Checking this box will edit the asset record to reflect this new location. Leaving it unchecked will simply note the location in the audit log.<br><br>Note that is this asset is checked out, it will not change the location of the person, asset or location it is checked out to.',
'audit_help' => 'Checking this box will edit the asset record to reflect this new location. Leaving it unchecked will simply note the location in the audit log.<br><br>Note that if this asset is checked out, it will not change the location of the person, asset or location it is checked out to.',
'assets' => 'Assets are items tracked by serial number or asset tag. They tend to be higher value items where identifying a specific item matters.',
'categories' => 'Categories help you organize your items. Some example categories might be &quot;Desktops&quot;, &quot;Laptops&quot;, &quot;Mobile Phones&quot;, &quot;Tablets&quot;, and so on, but you can use categories any way that makes sense for you.',
'accessories' => 'Accessories are anything you issue to users but that do not have a serial number (or you do not care about tracking them uniquely). For example, computer mice or keyboards.',
'companies' => 'Companies can be used as a simple identifier field, or can be used to limit visibility of assets, users, etc if full company support is enabled in your Admin settings.',
'components' => 'Components are items that are part of an asset, for example HDD, RAM, etc.',
'consumables' => 'Consumables are anything purchased that will be used up over time. For example, printer ink or copier paper.',
'depreciations' => 'You can set up asset depreciations to depreciate assets based on straight-line depreciation.',
'physical_audit_help' => 'This box should be checked if the asset was physically examined by staff (versus self-auditing for remote users)',
];

View File

@@ -53,6 +53,19 @@
<!-- Locations -->
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label for="audit_type">
{{ Form::checkbox('audit_type', 'physical', true, ['class' => 'minimal']) }}
{{ trans('admin/hardware/general.audit_type_physical') }}
</label>
@include ('partials.more-info', ['helpText' => trans('help.physical_audit_help'), 'helpPosition' => 'right'])
</div>
</div> <!--/form-group-->
<!-- Update location -->
<div class="form-group">
<div class="col-sm-offset-3 col-md-9">