Merge branch 'develop' into fixes/add_next_audit_date_to_assets_form

This commit is contained in:
snipe 2024-05-16 16:13:21 +01:00 committed by GitHub
commit 81efaa7481
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 98 additions and 31 deletions

View file

@ -223,6 +223,7 @@ class AcceptanceController extends Controller
'item_model' => $display_model,
'item_serial' => $item->serial,
'eula' => $item->getEula(),
'note' => $request->input('note'),
'check_out_date' => Carbon::parse($acceptance->created_at)->format('Y-m-d'),
'accepted_date' => Carbon::parse($acceptance->accepted_at)->format('Y-m-d'),
'assigned_to' => $assigned_to,
@ -238,7 +239,7 @@ class AcceptanceController extends Controller
Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output());
}
$acceptance->accept($sig_filename, $item->getEula(), $pdf_filename);
$acceptance->accept($sig_filename, $item->getEula(), $pdf_filename, $request->input('note'));
$acceptance->notify(new AcceptanceAssetAcceptedNotification($data));
event(new CheckoutAccepted($acceptance));
@ -306,10 +307,12 @@ class AcceptanceController extends Controller
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
break;
}
$data = [
'item_tag' => $item->asset_tag,
'item_model' => $display_model,
'item_serial' => $item->serial,
'note' => $request->input('note'),
'declined_date' => Carbon::parse($acceptance->declined_at)->format('Y-m-d'),
'signature' => ($sig_filename) ? storage_path() . '/private_uploads/signatures/' . $sig_filename : null,
'assigned_to' => $assigned_to,
@ -323,7 +326,7 @@ class AcceptanceController extends Controller
Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output());
}
$acceptance->decline($sig_filename);
$acceptance->decline($sig_filename, $request->input('note'));
$acceptance->notify(new AcceptanceAssetDeclinedNotification($data));
event(new CheckoutDeclined($acceptance));
$return_msg = trans('admin/users/message.declined');

View file

@ -71,7 +71,6 @@ class AssetModelsFilesController extends Controller
$file = 'private_uploads/assetmodels/'.$log->filename;
if (! Storage::exists($file)) {
return response('File '.$file.' not found on server', 404)
->header('Content-Type', 'text/plain');

View file

@ -62,7 +62,7 @@ class AssetCheckoutController extends Controller
$this->authorize('checkout', $asset);
$admin = Auth::user();
$target = $this->determineCheckoutTarget($asset);
$target = $this->determineCheckoutTarget();
$asset = $this->updateAssetLocation($asset, $target);

View file

@ -293,8 +293,15 @@ class UsersController extends Controller
$user->password = bcrypt($request->input('password'));
}
// Update the location of any assets checked out to this user
Asset::where('assigned_type', User::class)
->where('assigned_to', $user->id)
->update(['location_id' => $user->location_id]);
$permissions_array = $request->input('permission');
// Strip out the superuser permission if the user isn't a superadmin
if (! Auth::user()->isSuperUser()) {
unset($permissions_array['superuser']);

View file

@ -86,12 +86,8 @@ class ImageUploadRequest extends Request
if ($this->offsetGet($form_fieldname) instanceof UploadedFile) {
$image = $this->offsetGet($form_fieldname);
\Log::debug('Image is an instance of UploadedFile');
} elseif ($this->hasFile($form_fieldname)) {
$image = $this->file($form_fieldname);
\Log::debug('Just use regular upload for '.$form_fieldname);
} else {
\Log::debug('No image found for form fieldname: '.$form_fieldname);
}
if (isset($image)) {

View file

@ -85,20 +85,23 @@ class ActionlogsTransformer
$enc_old = '';
$enc_new = '';
try {
$enc_old = \Crypt::decryptString($this->clean_field($fieldata->old));
} catch (\Exception $e) {
\Log::debug('Could not decrypt field - maybe the key changed?');
if ($this->clean_field($fieldata->old!='')) {
try {
$enc_old = \Crypt::decryptString($this->clean_field($fieldata->old));
} catch (\Exception $e) {
\Log::debug('Could not decrypt old field value - maybe the key changed?');
}
}
try {
$enc_new = \Crypt::decryptString($this->clean_field($fieldata->new));
} catch (\Exception $e) {
\Log::debug('Could not decrypt field - maybe the key changed?');
if ($this->clean_field($fieldata->new!='')) {
try {
$enc_new = \Crypt::decryptString($this->clean_field($fieldata->new));
} catch (\Exception $e) {
\Log::debug('Could not decrypt new field value - maybe the key changed?');
}
}
if ($enc_old != $enc_new) {
\Log::debug('custom fields do not match');
$clean_meta[$fieldname]['old'] = "************";
$clean_meta[$fieldname]['new'] = "************";

View file

@ -62,6 +62,7 @@ class LogListener
$logaction->target()->associate($event->acceptance->assignedTo);
$logaction->accept_signature = $event->acceptance->signature_filename;
$logaction->filename = $event->acceptance->stored_eula_file;
$logaction->note = $event->acceptance->note;
$logaction->action_type = 'accepted';
// TODO: log the actual license seat that was checked out
@ -78,6 +79,7 @@ class LogListener
$logaction->item()->associate($event->acceptance->checkoutable);
$logaction->target()->associate($event->acceptance->assignedTo);
$logaction->accept_signature = $event->acceptance->signature_filename;
$logaction->note = $event->acceptance->note;
$logaction->action_type = 'declined';
// TODO: log the actual license seat that was checked out

View file

@ -80,12 +80,13 @@ class CheckoutAcceptance extends Model
*
* @param string $signature_filename
*/
public function accept($signature_filename, $eula = null, $filename = null)
public function accept($signature_filename, $eula = null, $filename = null, $note = null)
{
$this->accepted_at = now();
$this->signature_filename = $signature_filename;
$this->stored_eula = $eula;
$this->stored_eula_file = $filename;
$this->note = $note;
$this->save();
/**
@ -99,9 +100,10 @@ class CheckoutAcceptance extends Model
*
* @param string $signature_filename
*/
public function decline($signature_filename)
public function decline($signature_filename, $note = null)
{
$this->declined_at = now();
$this->note = $note;
$this->signature_filename = $signature_filename;
$this->save();

View file

@ -262,7 +262,6 @@ final class Company extends SnipeModel
if (! static::isFullMultipleCompanySupportEnabled() || (Auth::check() && Auth::user()->isSuperUser()) || (! Auth::check())) {
return $query;
} else {
\Log::debug('Fire scopeCompanyablesDirectly.');
return static::scopeCompanyablesDirectly($query, $column, $table_name);
}
}
@ -275,7 +274,6 @@ final class Company extends SnipeModel
{
// Get the company ID of the logged in user, or set it to null if there is no company assicoated with the user
if (Auth::user()) {
\Log::debug('Admin company is: '.Auth::user()->company_id);
$company_id = Auth::user()->company_id;
} else {
$company_id = null;
@ -283,9 +281,6 @@ final class Company extends SnipeModel
// Dynamically get the table name if it's not passed in, based on the model we're querying against
$table = ($table_name) ? $table_name."." : $query->getModel()->getTable().".";
\Log::debug('Model is: '.$query->getModel());
\Log::debug('Table is: '.$table);
// If the column exists in the table, use it to scope the query
if (\Schema::hasColumn($query->getModel()->getTable(), $column)) {

View file

@ -26,6 +26,7 @@ class AcceptanceAssetAcceptedNotification extends Notification
$this->item_serial = $params['item_serial'];
$this->accepted_date = Helper::getFormattedDateObject($params['accepted_date'], 'date', false);
$this->assigned_to = $params['assigned_to'];
$this->note = $params['note'];
$this->company_name = $params['company_name'];
$this->settings = Setting::getSettings();
@ -64,6 +65,7 @@ class AcceptanceAssetAcceptedNotification extends Notification
'item_tag' => $this->item_tag,
'item_model' => $this->item_model,
'item_serial' => $this->item_serial,
'note' => $this->note,
'accepted_date' => $this->accepted_date,
'assigned_to' => $this->assigned_to,
'company_name' => $this->company_name,

View file

@ -25,6 +25,7 @@ class AcceptanceAssetDeclinedNotification extends Notification
$this->item_model = $params['item_model'];
$this->item_serial = $params['item_serial'];
$this->declined_date = Helper::getFormattedDateObject($params['declined_date'], 'date', false);
$this->note = $params['note'];
$this->assigned_to = $params['assigned_to'];
$this->company_name = $params['company_name'];
$this->settings = Setting::getSettings();
@ -62,6 +63,7 @@ class AcceptanceAssetDeclinedNotification extends Notification
'item_tag' => $this->item_tag,
'item_model' => $this->item_model,
'item_serial' => $this->item_serial,
'note' => $this->note,
'declined_date' => $this->declined_date,
'assigned_to' => $this->assigned_to,
'company_name' => $this->company_name,

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNoteToCheckoutAcceptanceTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('checkout_acceptances', function (Blueprint $table) {
$table->text('note')->after('signature_filename')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('checkout_acceptances', function (Blueprint $table) {
$table->dropColumn('note');
});
}
}

6
package-lock.json generated
View file

@ -2379,9 +2379,9 @@
}
},
"alpinejs": {
"version": "3.13.5",
"resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.13.5.tgz",
"integrity": "sha512-1d2XeNGN+Zn7j4mUAKXtAgdc4/rLeadyTMWeJGXF5DzwawPBxwTiBhFFm6w/Ei8eJxUZeyNWWSD9zknfdz1kEw==",
"version": "3.13.10",
"resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.13.10.tgz",
"integrity": "sha512-86RB307VWICex0vG15Eq0x058cNNsvS57ohrjN6n/TJAVSFV+zXOK/E34nNHDHc6Poq+yTNCLqEzPqEkRBTMRQ==",
"requires": {
"@vue/reactivity": "~3.1.1"
}

View file

@ -33,7 +33,7 @@
"acorn-import-assertions": "^1.9.0",
"admin-lte": "^2.4.18",
"ajv": "^6.12.6",
"alpinejs": "3.13.5",
"alpinejs": "^3.13.10",
"blueimp-file-upload": "^9.34.0",
"bootstrap": "^3.4.1",
"bootstrap-colorpicker": "^2.5.3",

View file

@ -0,0 +1,7 @@
Contact: mailto:security@snipeitapp.com
Expires: 2025-05-16T11:30:00.000Z
Acknowledgments: https://snipeitapp.com/thanks
Preferred-Languages: en-US, pt-PT, de-DE
Canonical: https://github.com/snipe/snipe-it/blob/master/public/.well-known/security.txt
Policy: https://snipeitapp.com/security
Hiring: https://snipeitapp.com/company/careers

Binary file not shown.

View file

@ -33,7 +33,7 @@
"/js/build/vendor.js": "/js/build/vendor.js?id=a2b971da417306a63385c8098acfe4af",
"/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=e3bde6c62806c5ae510c964de17cd610",
"/js/dist/all.js": "/js/dist/all.js?id=13bdb521e0c745d7f81dae3fb110b650",
"/js/dist/all-defer.js": "/js/dist/all-defer.js?id=19ccc62a8f1ea103dede4808837384d4",
"/js/dist/all-defer.js": "/js/dist/all-defer.js?id=75d841799f917cbcacf6b87698379726",
"/css/dist/skins/skin-green.min.css": "/css/dist/skins/skin-green.min.css?id=0a82a6ae6bb4e58fe62d162c4fb50397",
"/css/dist/skins/skin-green-dark.min.css": "/css/dist/skins/skin-green-dark.min.css?id=ec0a01609bec55e90f0692d86cb81625",
"/css/dist/skins/skin-black.min.css": "/css/dist/skins/skin-black.min.css?id=76482123f6c70e866d6b971ba91de7bb",

View file

@ -49,6 +49,7 @@ return [
'default_eula_text' => 'Default EULA',
'default_language' => 'Default Language',
'default_eula_help_text' => 'You can also associate custom EULAs to specific asset categories.',
'acceptance_note' => 'Add a note for your decision (Optional)',
'display_asset_name' => 'Display Asset Name',
'display_checkout_date' => 'Display Checkout Date',
'display_eol' => 'Display EOL in table view',

View file

@ -297,6 +297,7 @@ return [
'user' => 'User',
'accepted' => 'accepted',
'declined' => 'declined',
'declined_note' => 'Declined Notes',
'unassigned' => 'Unassigned',
'unaccepted_asset_report' => 'Unaccepted Assets',
'users' => 'Users',

View file

@ -64,6 +64,15 @@
</label>
</div>
<div class="col-md-12">
<br>
<div class="col-md-12" style="display:block;">
<label id="note_label" for="note" style="text-align:center;" >{{trans('admin/settings/general.acceptance_note')}}</label>
</div>
<div class="col-md-12">
<textarea id="note" name="note" rows="4" cols="50" value="note" style="width:100%" ></textarea>
</div>
</div>
@if ($snipeSettings->require_accept_signature=='1')
<div class="col-md-12">
@ -133,5 +142,6 @@
}
});
</script>
@stop

View file

@ -13,6 +13,9 @@
@if (isset($declined_date))
| **{{ ucfirst(trans('general.declined')) }}** | {{ $declined_date }} |
@endif
@if (isset($note))
| **{{ trans('general.notes') }}** | {{ $note }} |
@endif
@if ((isset($item_tag)) && ($item_tag!=''))
| **{{ trans('mail.asset_tag') }}** | {{ $item_tag }} |
@endif

View file

@ -209,7 +209,9 @@
array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
},
get valueString() { return this.toString(this.fields); },
get valueString() {
return this.getCombinedString(this.fields);
},
onTest: function(a) {
console.log('test', a);
},
@ -229,7 +231,7 @@
})
}));
},
toString: function(fields) {
getCombinedString: function (fields) {
return fields
.map(field => field.options
.map(option => option.label + '=' + option.datasource)