Merge pull request #14451 from Godmartinz/add_decline_note_to_acceptance

Adds a note text area to asset acceptances/declines
This commit is contained in:
snipe 2024-05-16 15:06:05 +01:00 committed by GitHub
commit de088d452f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 62 additions and 4 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

@ -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

@ -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');
});
}
}

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

@ -295,6 +295,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