Skip to content
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

Adds a note text area to asset acceptances/declines #14451

Merged
merged 15 commits into from May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/Http/Controllers/Account/AcceptanceController.php
Expand Up @@ -223,6 +223,7 @@ public function store(Request $request, $id)
'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,
Expand All @@ -238,7 +239,7 @@ public function store(Request $request, $id)
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));

Expand Down Expand Up @@ -306,10 +307,12 @@ public function store(Request $request, $id)
$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,
Expand All @@ -323,7 +326,7 @@ public function store(Request $request, $id)
Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output());
}

$acceptance->decline($sig_filename);
$acceptance->decline($sig_filename, $request->input('note'));
Godmartinz marked this conversation as resolved.
Show resolved Hide resolved
$acceptance->notify(new AcceptanceAssetDeclinedNotification($data));
event(new CheckoutDeclined($acceptance));
$return_msg = trans('admin/users/message.declined');
Expand Down
2 changes: 2 additions & 0 deletions app/Listeners/LogListener.php
Expand Up @@ -62,6 +62,7 @@ public function onCheckoutAccepted(CheckoutAccepted $event)
$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
Expand All @@ -78,6 +79,7 @@ public function onCheckoutDeclined(CheckoutDeclined $event)
$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
Expand Down
6 changes: 4 additions & 2 deletions app/Models/CheckoutAcceptance.php
Expand Up @@ -80,12 +80,13 @@ public function isCheckedOutTo(User $user)
*
* @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();

/**
Expand All @@ -99,9 +100,10 @@ public function accept($signature_filename, $eula = null, $filename = null)
*
* @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();

Expand Down
2 changes: 2 additions & 0 deletions app/Notifications/AcceptanceAssetAcceptedNotification.php
Expand Up @@ -26,6 +26,7 @@ public function __construct($params)
$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();

Expand Down Expand Up @@ -64,6 +65,7 @@ public function toMail()
'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,
Expand Down
2 changes: 2 additions & 0 deletions app/Notifications/AcceptanceAssetDeclinedNotification.php
Expand Up @@ -25,6 +25,7 @@ public function __construct($params)
$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();
Expand Down Expand Up @@ -62,6 +63,7 @@ public function toMail($notifiable)
'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,
Expand Down
@@ -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');
});
}
}
1 change: 1 addition & 0 deletions resources/lang/en-US/admin/settings/general.php
Expand Up @@ -49,6 +49,7 @@
'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',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en-US/general.php
Expand Up @@ -293,6 +293,7 @@
'user' => 'User',
'accepted' => 'accepted',
'declined' => 'declined',
'declined_note' => 'Declined Notes',
'unassigned' => 'Unassigned',
'unaccepted_asset_report' => 'Unaccepted Assets',
'users' => 'Users',
Expand Down
11 changes: 11 additions & 0 deletions resources/views/account/accept/create.blade.php
Expand Up @@ -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">
Expand Down Expand Up @@ -94,6 +103,7 @@
@section('moar_scripts')

<script nonce="{{ csrf_token() }}">

var wrapper = document.getElementById("signature-pad"),
clearButton = wrapper.querySelector("[data-action=clear]"),
saveButton = wrapper.querySelector("[data-action=save]"),
Expand Down Expand Up @@ -131,5 +141,6 @@ function resizeCanvas() {
}
});


</script>
@stop
Expand Up @@ -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
Expand Down