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 7 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
4 changes: 3 additions & 1 deletion app/Http/Controllers/Account/AcceptanceController.php
Expand Up @@ -306,10 +306,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 +325,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
1 change: 1 addition & 0 deletions app/Listeners/LogListener.php
Expand Up @@ -78,6 +78,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
3 changes: 2 additions & 1 deletion app/Models/CheckoutAcceptance.php
Expand Up @@ -99,9 +99,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/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 AddDeclineMsgToCheckoutAcceptanceTable extends Migration
Godmartinz marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* 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.',
'decline_message' => 'Add details to why you can\'t accept this (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
28 changes: 28 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.decline_message')}}</label>
Godmartinz marked this conversation as resolved.
Show resolved Hide resolved
</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,24 @@
@section('moar_scripts')

<script nonce="{{ csrf_token() }}">
$(document).ready(function(){

$('#note').hide();
$('#note_label').hide();


$('input[id="declined"]').change(function(){

if($(this).is(':checked')){
$('#note_label').show();
$('#note').show();
}
else {
$('#note_label').hide();
$('#note').hide();
}
});
});
Godmartinz marked this conversation as resolved.
Show resolved Hide resolved
var wrapper = document.getElementById("signature-pad"),
clearButton = wrapper.querySelector("[data-action=clear]"),
saveButton = wrapper.querySelector("[data-action=save]"),
Expand Down Expand Up @@ -131,5 +158,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.declined_note') }}** | {{ $note }} |
Godmartinz marked this conversation as resolved.
Show resolved Hide resolved
@endif
@if ((isset($item_tag)) && ($item_tag!=''))
| **{{ trans('mail.asset_tag') }}** | {{ $item_tag }} |
@endif
Expand Down