Skip to content

Commit

Permalink
Merge pull request #14451 from Godmartinz/add_decline_note_to_acceptance
Browse files Browse the repository at this point in the history
Adds a note text area to asset acceptances/declines
  • Loading branch information
snipe committed May 16, 2024
2 parents 2f18430 + 08f9aae commit de088d4
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 4 deletions.
7 changes: 5 additions & 2 deletions app/Http/Controllers/Account/AcceptanceController.php
Original file line number Diff line number Diff line change
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'));
$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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
'user' => 'User',
'accepted' => 'accepted',
'declined' => 'declined',
'declined_note' => 'Declined Notes',
'unassigned' => 'Unassigned',
'unaccepted_asset_report' => 'Unaccepted Assets',
'users' => 'Users',
Expand Down
10 changes: 10 additions & 0 deletions resources/views/account/accept/create.blade.php
Original file line number Diff line number Diff line change
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 @@ -133,5 +142,6 @@ function resizeCanvas() {
}
});
</script>
@stop
Original file line number Diff line number Diff line change
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

0 comments on commit de088d4

Please sign in to comment.