mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
9924553da5
|
@ -70,23 +70,26 @@ class SendAcceptanceReminder extends Command
|
||||||
// The [0] is weird, but it allows for the item_count to work and grabs the appropriate info for each user.
|
// The [0] is weird, but it allows for the item_count to work and grabs the appropriate info for each user.
|
||||||
// Collapsing and flattening the collection doesn't work above.
|
// Collapsing and flattening the collection doesn't work above.
|
||||||
$acceptance = $unacceptedAssetGroup[0]['acceptance'];
|
$acceptance = $unacceptedAssetGroup[0]['acceptance'];
|
||||||
|
|
||||||
$locale = $acceptance->assignedTo?->locale;
|
$locale = $acceptance->assignedTo?->locale;
|
||||||
$email = $acceptance->assignedTo?->email;
|
$email = $acceptance->assignedTo?->email;
|
||||||
|
|
||||||
if(!$email){
|
if(!$email){
|
||||||
$no_email_list[] = [
|
$no_email_list[] = [
|
||||||
'id' => $acceptance->assignedTo->id,
|
'id' => $acceptance->assignedTo?->id,
|
||||||
'name' => $acceptance->assignedTo->present()->fullName(),
|
'name' => $acceptance->assignedTo?->present()->fullName(),
|
||||||
];
|
];
|
||||||
|
} else {
|
||||||
|
$count++;
|
||||||
}
|
}
|
||||||
$item_count = $unacceptedAssetGroup->count();
|
$item_count = $unacceptedAssetGroup->count();
|
||||||
|
|
||||||
if ($locale && $email) {
|
if ($locale && $email) {
|
||||||
Mail::to($email)->send((new UnacceptedAssetReminderMail($acceptance, $item_count))->locale($locale));
|
Mail::to($email)->send((new UnacceptedAssetReminderMail($acceptance, $item_count))->locale($locale));
|
||||||
|
|
||||||
} elseif ($email) {
|
} elseif ($email) {
|
||||||
Mail::to($email)->send((new UnacceptedAssetReminderMail($acceptance, $item_count)));
|
Mail::to($email)->send((new UnacceptedAssetReminderMail($acceptance, $item_count)));
|
||||||
}
|
}
|
||||||
$count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info($count.' users notified.');
|
$this->info($count.' users notified.');
|
||||||
|
|
|
@ -1175,18 +1175,13 @@ class ReportsController extends Controller
|
||||||
}
|
}
|
||||||
$email = $assetItem->assignedTo?->email;
|
$email = $assetItem->assignedTo?->email;
|
||||||
$locale = $assetItem->assignedTo?->locale;
|
$locale = $assetItem->assignedTo?->locale;
|
||||||
// Only send notification if assigned
|
|
||||||
if ($locale && $email) {
|
|
||||||
Mail::to($email)->send((new CheckoutAssetMail($assetItem, $assetItem->assignedTo, $logItem->user, $acceptance, $logItem->note))->locale($locale));
|
|
||||||
|
|
||||||
} elseif ($email) {
|
if (is_null($email) || $email === '') {
|
||||||
Mail::to($email)->send((new CheckoutAssetMail($assetItem, $assetItem->assignedTo, $logItem->user, $acceptance, $logItem->note)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($email == ''){
|
|
||||||
return redirect()->route('reports/unaccepted_assets')->with('error', trans('general.no_email'));
|
return redirect()->route('reports/unaccepted_assets')->with('error', trans('general.no_email'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mail::to($email)->send((new CheckoutAssetMail($assetItem, $assetItem->assignedTo, $logItem->user, $acceptance, $logItem->note, firstTimeSending: false))->locale($locale));
|
||||||
|
|
||||||
return redirect()->route('reports/unaccepted_assets')->with('success', trans('admin/reports/general.reminder_sent'));
|
return redirect()->route('reports/unaccepted_assets')->with('success', trans('admin/reports/general.reminder_sent'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,12 @@ class CheckoutAssetMail extends Mailable
|
||||||
{
|
{
|
||||||
use Queueable, SerializesModels;
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
private bool $firstTimeSending;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* Create a new message instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(Asset $asset, $checkedOutTo, User $checkedOutBy, $acceptance, $note)
|
public function __construct(Asset $asset, $checkedOutTo, User $checkedOutBy, $acceptance, $note, bool $firstTimeSending = true)
|
||||||
{
|
{
|
||||||
$this->item = $asset;
|
$this->item = $asset;
|
||||||
$this->admin = $checkedOutBy;
|
$this->admin = $checkedOutBy;
|
||||||
|
@ -36,6 +38,8 @@ class CheckoutAssetMail extends Mailable
|
||||||
$this->last_checkout = '';
|
$this->last_checkout = '';
|
||||||
$this->expected_checkin = '';
|
$this->expected_checkin = '';
|
||||||
|
|
||||||
|
$this->firstTimeSending = $firstTimeSending;
|
||||||
|
|
||||||
if ($this->item->last_checkout) {
|
if ($this->item->last_checkout) {
|
||||||
$this->last_checkout = Helper::getFormattedDateObject($this->item->last_checkout, 'date',
|
$this->last_checkout = Helper::getFormattedDateObject($this->item->last_checkout, 'date',
|
||||||
false);
|
false);
|
||||||
|
@ -56,7 +60,7 @@ class CheckoutAssetMail extends Mailable
|
||||||
|
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
from: $from,
|
from: $from,
|
||||||
subject: trans('mail.Asset_Checkout_Notification'),
|
subject: $this->getSubject(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,4 +111,13 @@ class CheckoutAssetMail extends Mailable
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getSubject(): string
|
||||||
|
{
|
||||||
|
if ($this->firstTimeSending) {
|
||||||
|
return trans('mail.Asset_Checkout_Notification');
|
||||||
|
}
|
||||||
|
|
||||||
|
return trans('mail.unaccepted_asset_reminder');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,10 @@ class UnacceptedAssetReminderMail extends Mailable
|
||||||
*/
|
*/
|
||||||
public function __construct($checkout_info, $count)
|
public function __construct($checkout_info, $count)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->count = $count;
|
$this->count = $count;
|
||||||
$this->target = $checkout_info['acceptance']?->assignedTo;
|
$this->target = $checkout_info?->assignedTo;
|
||||||
$this->acceptance = $checkout_info['acceptance'];
|
$this->acceptance = $checkout_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,10 @@ class CheckoutAcceptanceFactory extends Factory
|
||||||
public function configure(): static
|
public function configure(): static
|
||||||
{
|
{
|
||||||
return $this->afterCreating(function (CheckoutAcceptance $acceptance) {
|
return $this->afterCreating(function (CheckoutAcceptance $acceptance) {
|
||||||
|
if ($acceptance->checkoutable instanceof Asset) {
|
||||||
|
$this->createdAssociatedActionLogEntry($acceptance);
|
||||||
|
}
|
||||||
|
|
||||||
if ($acceptance->checkoutable instanceof Asset && $acceptance->assignedTo instanceof User) {
|
if ($acceptance->checkoutable instanceof Asset && $acceptance->assignedTo instanceof User) {
|
||||||
$acceptance->checkoutable->update([
|
$acceptance->checkoutable->update([
|
||||||
'assigned_to' => $acceptance->assigned_to_id,
|
'assigned_to' => $acceptance->assigned_to_id,
|
||||||
|
@ -51,4 +55,23 @@ class CheckoutAcceptanceFactory extends Factory
|
||||||
'declined_at' => null,
|
'declined_at' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function accepted()
|
||||||
|
{
|
||||||
|
return $this->state([
|
||||||
|
'accepted_at' => now()->subDay(),
|
||||||
|
'declined_at' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createdAssociatedActionLogEntry(CheckoutAcceptance $acceptance): void
|
||||||
|
{
|
||||||
|
$acceptance->checkoutable->assetlog()->create([
|
||||||
|
'action_type' => 'checkout',
|
||||||
|
'target_id' => $acceptance->assigned_to_id,
|
||||||
|
'target_type' => get_class($acceptance->assignedTo),
|
||||||
|
'item_id' => $acceptance->checkoutable_id,
|
||||||
|
'item_type' => $acceptance->checkoutable_type,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ return [
|
||||||
'info' => 'Select the options you want for your asset report.',
|
'info' => 'Select the options you want for your asset report.',
|
||||||
'deleted_user' => 'Deleted user',
|
'deleted_user' => 'Deleted user',
|
||||||
'send_reminder' => 'Send reminder',
|
'send_reminder' => 'Send reminder',
|
||||||
|
'cannot_send_reminder' => 'User has been deleted or does not have an email address so cannot receive a reminder',
|
||||||
'reminder_sent' => 'Reminder sent',
|
'reminder_sent' => 'Reminder sent',
|
||||||
'acceptance_deleted' => 'Acceptance request deleted',
|
'acceptance_deleted' => 'Acceptance request deleted',
|
||||||
'acceptance_request' => 'Acceptance request',
|
'acceptance_request' => 'Acceptance request',
|
||||||
|
|
|
@ -79,13 +79,18 @@
|
||||||
<nobr>
|
<nobr>
|
||||||
@if(!$item['acceptance']->trashed())
|
@if(!$item['acceptance']->trashed())
|
||||||
<form method="post" class="white-space: nowrap;" action="{{ route('reports/unaccepted_assets_sent_reminder') }}">
|
<form method="post" class="white-space: nowrap;" action="{{ route('reports/unaccepted_assets_sent_reminder') }}">
|
||||||
@if ($item['acceptance']->assignedTo)
|
@if (($item['acceptance']->assignedTo) && ($item['acceptance']->assignedTo->email))
|
||||||
@csrf
|
@csrf
|
||||||
<input type="hidden" name="acceptance_id" value="{{ $item['acceptance']->id }}">
|
<input type="hidden" name="acceptance_id" value="{{ $item['acceptance']->id }}">
|
||||||
<button class="btn btn-sm btn-warning" data-tooltip="true" data-title="{{ trans('admin/reports/general.send_reminder') }}">
|
<button class="btn btn-sm btn-warning" data-tooltip="true" data-title="{{ trans('admin/reports/general.send_reminder') }}">
|
||||||
<i class="fa fa-repeat" aria-hidden="true"></i>
|
<i class="fa fa-repeat" aria-hidden="true"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@else
|
||||||
|
<span data-tooltip="true" data-title="{{ trans('admin/reports/general.cannot_send_reminder') }}">
|
||||||
|
<a class="btn btn-sm btn-warning disabled" href="#">
|
||||||
|
<i class="fa fa-repeat" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
@endif
|
@endif
|
||||||
<a href="{{ route('reports/unaccepted_assets_delete', ['acceptanceId' => $item['acceptance']->id]) }}" class="btn btn-sm btn-danger delete-asset" data-tooltip="true" data-toggle="modal" data-content="{{ trans('general.delete_confirm', ['item' =>trans('admin/reports/general.acceptance_request')]) }}" data-title="{{ trans('general.delete') }}" onClick="return false;"><i class="fa fa-trash"></i></a>
|
<a href="{{ route('reports/unaccepted_assets_delete', ['acceptanceId' => $item['acceptance']->id]) }}" class="btn btn-sm btn-danger delete-asset" data-tooltip="true" data-toggle="modal" data-content="{{ trans('general.delete_confirm', ['item' =>trans('admin/reports/general.acceptance_request')]) }}" data-title="{{ trans('general.delete') }}" onClick="return false;"><i class="fa fa-trash"></i></a>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -135,7 +135,7 @@
|
||||||
|
|
||||||
<div class="col-md-9 col-md-offset-3">
|
<div class="col-md-9 col-md-offset-3">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('restore_default_avatar', '1', old('restore_default_avatar', $setting->restore_default_avatar)) }}
|
<input type="checkbox" name="restore_default_avatar" value="1" @checked(old('restore_default_avatar', $setting->restore_default_avatar)) />
|
||||||
<span>{!! trans('admin/settings/general.restore_default_avatar', ['default_avatar'=> Storage::disk('public')->url('default.png')]) !!}</span>
|
<span>{!! trans('admin/settings/general.restore_default_avatar', ['default_avatar'=> Storage::disk('public')->url('default.png')]) !!}</span>
|
||||||
</label>
|
</label>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('load_remote', '1', old('load_remote', $setting->load_remote)) }}
|
<input type="checkbox" name="load_remote" value="1" @checked(old('load_remote', $setting->load_remote)) />
|
||||||
{{ trans('general.yes') }}
|
{{ trans('general.yes') }}
|
||||||
{!! $errors->first('load_remote', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('load_remote', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
</label>
|
</label>
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('logo_print_assets', '1', old('logo_print_assets', $setting->logo_print_assets),array('aria-label'=>'logo_print_assets')) }}
|
<input type="checkbox" name="logo_print_assets" value="1" @checked(old('logo_print_assets', $setting->logo_print_assets)) aria-label="logo_print_assets"/>
|
||||||
{{ trans('admin/settings/general.logo_print_assets_help') }}
|
{{ trans('admin/settings/general.logo_print_assets_help') }}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('show_url_in_emails', '1', old('show_url_in_emails', $setting->show_url_in_emails),array('aria-label'=>'show_url_in_emails')) }}
|
<input type="checkbox" name="show_url_in_emails" value="1" @checked(old('show_url_in_emails', $setting->show_url_in_emails)) aria-label="show_url_in_emails" />
|
||||||
{{ trans('general.yes') }}
|
{{ trans('general.yes') }}
|
||||||
</label>
|
</label>
|
||||||
<p class="help-block">{{ trans('admin/settings/general.show_url_in_emails_help_text') }}</p>
|
<p class="help-block">{{ trans('admin/settings/general.show_url_in_emails_help_text') }}</p>
|
||||||
|
@ -228,7 +228,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('allow_user_skin', '1', old('allow_user_skin', $setting->allow_user_skin)) }}
|
<input type="checkbox" name="allow_user_skin" value="1" @checked(old('allow_user_skin', $setting->allow_user_skin))/>
|
||||||
{{ trans('general.yes') }}
|
{{ trans('general.yes') }}
|
||||||
</label>
|
</label>
|
||||||
<p class="help-block">{{ trans('admin/settings/general.allow_user_skin_help_text') }}</p>
|
<p class="help-block">{{ trans('admin/settings/general.allow_user_skin_help_text') }}</p>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('full_multiple_companies_support', '1', old('full_multiple_companies_support', $setting->full_multiple_companies_support),array('aria-label'=>'full_multiple_companies_support')) }}
|
<input type="checkbox" name="full_multiple_companies_support" value="1" @checked(old('full_multiple_companies_support', $setting->full_multiple_companies_support)) aria-label="full_multiple_companies_support" />
|
||||||
{{ trans('admin/settings/general.full_multiple_companies_support_text') }}
|
{{ trans('admin/settings/general.full_multiple_companies_support_text') }}
|
||||||
</label>
|
</label>
|
||||||
{!! $errors->first('full_multiple_companies_support', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('full_multiple_companies_support', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('require_accept_signature', '1', old('require_accept_signature', $setting->require_accept_signature)) }}
|
<input type="checkbox" name="require_accept_signature" value="1" @checked(old('require_accept_signature', $setting->require_accept_signature)) />
|
||||||
{{ trans('general.yes') }}
|
{{ trans('general.yes') }}
|
||||||
</label>
|
</label>
|
||||||
{!! $errors->first('require_accept_signature', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('require_accept_signature', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('show_images_in_email', '1', old('show_images_in_email', $setting->show_images_in_email)) }}
|
<input type="checkbox" name="show_images_in_email" value="1" @checked(old('show_images_in_email', $setting->show_images_in_email)) />
|
||||||
{{ trans('general.yes') }}
|
{{ trans('general.yes') }}
|
||||||
{!! $errors->first('show_images_in_email', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('show_images_in_email', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
</label>
|
</label>
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('unique_serial', '1', old('unique_serial', $setting->unique_serial),array('class' => 'minimal')) }}
|
<input type="checkbox" name="unique_serial" value="1" @checked(old('unique_serial', $setting->unique_serial)) />
|
||||||
{{ trans('general.yes') }}
|
{{ trans('general.yes') }}
|
||||||
{!! $errors->first('unique_serial', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('unique_serial', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
</label>
|
</label>
|
||||||
|
@ -311,7 +311,7 @@
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
|
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('show_archived_in_list', '1', old('show_archived_in_list', $setting->show_archived_in_list),array('aria-label'=>'show_archived_in_list')) }}
|
<input type="checkbox" name="show_archived_in_list" value="1" @checked(old('show_archived_in_list', $setting->show_archived_in_list)) aria-label="show_archived_in_list" />
|
||||||
{{ trans('admin/settings/general.show_archived_in_list_text') }}
|
{{ trans('admin/settings/general.show_archived_in_list_text') }}
|
||||||
</label>
|
</label>
|
||||||
{!! $errors->first('show_archived_in_list', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('show_archived_in_list', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
|
@ -325,7 +325,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('show_assigned_assets', '1', old('show_assigned_assets', $setting->show_assigned_assets),array('class' => 'minimal')) }}
|
<input type="checkbox" name="show_assigned_assets" value="1" @checked(old('show_assigned_assets', $setting->show_assigned_assets)) />
|
||||||
{{ trans('general.yes') }}
|
{{ trans('general.yes') }}
|
||||||
</label>
|
</label>
|
||||||
<p class="help-block">{{ trans('admin/settings/general.show_assigned_assets_help') }}</p>
|
<p class="help-block">{{ trans('admin/settings/general.show_assigned_assets_help') }}</p>
|
||||||
|
@ -340,15 +340,19 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('show_in_model_list[]', 'image', old('show_in_model_list', $snipeSettings->modellistCheckedValue('image')),array('class' => 'minimal', 'aria-label'=>'show_in_model_list' )) }} {{ trans('general.image') }}
|
<input type="checkbox" name="show_in_model_list[]" value="image" @checked(old('show_in_model_list', $snipeSettings->modellistCheckedValue('image'))) aria-label="show_in_model_list"/>
|
||||||
|
{{ trans('general.image') }}
|
||||||
</label>
|
</label>
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('show_in_model_list[]', 'category', old('show_in_model_list', $snipeSettings->modellistCheckedValue('category')),array('class' => 'minimal', 'aria-label'=>'show_in_model_list' )) }} {{ trans('general.category') }}
|
<input type="checkbox" name="show_in_model_list[]" value="category" @checked(old('show_in_model_list', $snipeSettings->modellistCheckedValue('category'))) aria-label="show_in_model_list"/>
|
||||||
|
{{ trans('general.category') }}
|
||||||
</label>
|
</label>
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('show_in_model_list[]', 'manufacturer', old('show_in_model_list', $snipeSettings->modellistCheckedValue('manufacturer')),array('class' => 'minimal', 'aria-label'=>'show_in_model_list' )) }} {{ trans('general.manufacturer') }} </label>
|
<input type="checkbox" name="show_in_model_list[]" value="manufacturer" @checked(old('show_in_model_list', $snipeSettings->modellistCheckedValue('manufacturer'))) aria-label="show_in_model_list"/>
|
||||||
|
{{ trans('general.manufacturer') }} </label>
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('show_in_model_list[]', 'model_number', old('show_in_model_list', $snipeSettings->modellistCheckedValue('model_number')),array('class' => 'minimal', 'aria-label'=>'show_in_model_list' )) }} {{ trans('general.model_no') }}
|
<input type="checkbox" name="show_in_model_list[]" value="model_number" @checked(old('show_in_model_list', $snipeSettings->modellistCheckedValue('model_number'))) aria-label="show_in_model_list"/>
|
||||||
|
{{ trans('general.model_no') }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -144,7 +144,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-md-9 col-md-offset-3">
|
<div class="col-md-9 col-md-offset-3">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('alt_barcode_enabled', '1', old('alt_barcode_enabled', $setting->alt_barcode_enabled),array( 'aria-label'=>'alt_barcode_enabled')) }}
|
<input type="checkbox" name="alt_barcode_enabled" value="1" @checked(old('alt_barcode_enabled', $setting->alt_barcode_enabled)) aria-label="alt_barcode_enabled"/>
|
||||||
{{ trans('admin/settings/general.display_alt_barcode') }}
|
{{ trans('admin/settings/general.display_alt_barcode') }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -189,7 +189,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-md-9 col-md-offset-3">
|
<div class="col-md-9 col-md-offset-3">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('qr_code', '1', old('qr_code', $setting->qr_code),array('aria-label'=>'qr_code')) }}
|
<input type="checkbox" name="qr_code" value="1" @checked(old('qr_code', $setting->qr_code)) aria-label="qr_code" />
|
||||||
{{ trans('admin/settings/general.display_qr') }}
|
{{ trans('admin/settings/general.display_qr') }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -480,23 +480,23 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('labels_display_name', '1', old('labels_display_name', $setting->labels_display_name),['class' => 'minimal', 'aria-label'=>'labels_display_name']) }}
|
<input type="checkbox" name="labels_display_name" value="1" @checked(old('labels_display_name', $setting->labels_display_name)) aria-label="labels_display_name" />
|
||||||
{{ trans('admin/hardware/form.name') }}
|
{{ trans('admin/hardware/form.name') }}
|
||||||
</label>
|
</label>
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('labels_display_serial', '1', old('labels_display_serial', $setting->labels_display_serial),['class' => 'minimal', 'aria-label'=>'labels_display_serial']) }}
|
<input type="checkbox" name="labels_display_serial" value="1" @checked(old('labels_display_serial', $setting->labels_display_serial)) aria-label="labels_display_serial" />
|
||||||
{{ trans('admin/hardware/form.serial') }}
|
{{ trans('admin/hardware/form.serial') }}
|
||||||
</label>
|
</label>
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('labels_display_tag', '1', old('labels_display_tag', $setting->labels_display_tag),['class' => 'minimal', 'aria-label'=>'labels_display_tag']) }}
|
<input type="checkbox" name="labels_display_tag" value="1" @checked(old('labels_display_tag', $setting->labels_display_tag)) aria-label="labels_display_tag" />
|
||||||
{{ trans('admin/hardware/form.tag') }}
|
{{ trans('admin/hardware/form.tag') }}
|
||||||
</label>
|
</label>
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('labels_display_model', '1', old('labels_display_model', $setting->labels_display_model),['class' => 'minimal', 'aria-label'=>'labels_display_model']) }}
|
<input type="checkbox" name="labels_display_model" value="1" @checked(old('labels_display_model', $setting->labels_display_model)) aria-label="labels_display_model" />
|
||||||
{{ trans('admin/hardware/form.model') }}
|
{{ trans('admin/hardware/form.model') }}
|
||||||
</label>
|
</label>
|
||||||
<label class="form-control">
|
<label class="form-control">
|
||||||
{{ Form::checkbox('labels_display_company_name', '1', old('labels_display_company_name', $setting->labels_display_company_name),['class' => 'minimal', 'aria-label'=>'labels_display_company_name']) }}
|
<input type="checkbox" name="labels_display_company_name" value="1" @checked(old('labels_display_company_name', $setting->labels_display_company_name)) aria-label="labels_display_company_name"/>
|
||||||
{{ trans('admin/companies/table.name') }}
|
{{ trans('admin/companies/table.name') }}
|
||||||
</label>
|
</label>
|
||||||
</div> <!--/.col-md-9-->
|
</div> <!--/.col-md-9-->
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Notifications\Email;
|
||||||
|
|
||||||
|
use App\Mail\CheckoutAssetMail;
|
||||||
|
use App\Models\CheckoutAcceptance;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AssetAcceptanceReminderTest extends TestCase
|
||||||
|
{
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Mail::fake();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMustHavePermissionToSendReminder()
|
||||||
|
{
|
||||||
|
$checkoutAcceptance = CheckoutAcceptance::factory()->pending()->create();
|
||||||
|
$userWithoutPermission = User::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs($userWithoutPermission)
|
||||||
|
->post($this->routeFor($checkoutAcceptance))
|
||||||
|
->assertForbidden();
|
||||||
|
|
||||||
|
Mail::assertNotSent(CheckoutAssetMail::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReminderNotSentIfAcceptanceDoesNotExist()
|
||||||
|
{
|
||||||
|
$this->actingAs(User::factory()->canViewReports()->create())
|
||||||
|
->post(route('reports/unaccepted_assets_sent_reminder', [
|
||||||
|
'acceptance_id' => 999999,
|
||||||
|
]));
|
||||||
|
|
||||||
|
Mail::assertNotSent(CheckoutAssetMail::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReminderNotSentIfAcceptanceAlreadyAccepted()
|
||||||
|
{
|
||||||
|
$checkoutAcceptanceAlreadyAccepted = CheckoutAcceptance::factory()->accepted()->create();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->canViewReports()->create())
|
||||||
|
->post($this->routeFor($checkoutAcceptanceAlreadyAccepted));
|
||||||
|
|
||||||
|
Mail::assertNotSent(CheckoutAssetMail::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function CheckoutAcceptancesToUsersWithoutEmailAddresses()
|
||||||
|
{
|
||||||
|
yield 'User with null email address' => [
|
||||||
|
function () {
|
||||||
|
return CheckoutAcceptance::factory()
|
||||||
|
->pending()
|
||||||
|
->forAssignedTo(['email' => null])
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
yield 'User with empty string email address' => [
|
||||||
|
function () {
|
||||||
|
return CheckoutAcceptance::factory()
|
||||||
|
->pending()
|
||||||
|
->forAssignedTo(['email' => ''])
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
#[DataProvider('CheckoutAcceptancesToUsersWithoutEmailAddresses')]
|
||||||
|
public function testUserWithoutEmailAddressHandledGracefully($callback)
|
||||||
|
{
|
||||||
|
$checkoutAcceptance = $callback();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->canViewReports()->create())
|
||||||
|
->post($this->routeFor($checkoutAcceptance))
|
||||||
|
// check we didn't crash...
|
||||||
|
->assertRedirect();
|
||||||
|
|
||||||
|
Mail::assertNotSent(CheckoutAssetMail::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReminderIsSentToUser()
|
||||||
|
{
|
||||||
|
$checkoutAcceptance = CheckoutAcceptance::factory()->pending()->create();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->canViewReports()->create())
|
||||||
|
->post($this->routeFor($checkoutAcceptance))
|
||||||
|
->assertRedirect(route('reports/unaccepted_assets'));
|
||||||
|
|
||||||
|
Mail::assertSent(CheckoutAssetMail::class, 1);
|
||||||
|
Mail::assertSent(CheckoutAssetMail::class, function (CheckoutAssetMail $mail) use ($checkoutAcceptance) {
|
||||||
|
return $mail->hasTo($checkoutAcceptance->assignedTo->email)
|
||||||
|
&& $mail->hasSubject(trans('mail.unaccepted_asset_reminder'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function routeFor(CheckoutAcceptance $checkoutAcceptance): string
|
||||||
|
{
|
||||||
|
return route('reports/unaccepted_assets_sent_reminder', [
|
||||||
|
'acceptance_id' => $checkoutAcceptance->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,9 +7,7 @@ use App\Models\Asset;
|
||||||
use App\Models\AssetModel;
|
use App\Models\AssetModel;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Notifications\CheckoutAssetNotification;
|
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Facades\Notification;
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class NotificationTest extends TestCase
|
class NotificationTest extends TestCase
|
||||||
|
@ -33,8 +31,8 @@ class NotificationTest extends TestCase
|
||||||
|
|
||||||
Mail::fake();
|
Mail::fake();
|
||||||
$asset->checkOut($user, $admin->id);
|
$asset->checkOut($user, $admin->id);
|
||||||
Mail::assertSent(CheckoutAssetMail::class, function ($mail) use ($user) {
|
Mail::assertSent(CheckoutAssetMail::class, function (CheckoutAssetMail $mail) use ($user) {
|
||||||
return $mail->hasTo($user->email);
|
return $mail->hasTo($user->email) && $mail->hasSubject(trans('mail.Asset_Checkout_Notification'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public function testDefaultEulaIsSentWhenSetInCategory()
|
public function testDefaultEulaIsSentWhenSetInCategory()
|
||||||
|
|
Loading…
Reference in a new issue