mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
fixed query, fixed no email logic, needs new markdown
This commit is contained in:
parent
c658a0fcb4
commit
8a0afae90f
|
@ -44,18 +44,30 @@ class SendAcceptanceReminder extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$acceptances = CheckoutAcceptance::pending()->where('checkoutable_type', 'App\Models\Asset')->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model', 'checkoutable.adminuser'])->get();
|
||||
$pending = CheckoutAcceptance::pending()->where('checkoutable_type', 'App\Models\Asset')
|
||||
->whereHas('checkoutable', function($query) {
|
||||
$query->where('archived', 0);
|
||||
})
|
||||
->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model', 'checkoutable.adminuser'])
|
||||
->get();
|
||||
|
||||
$count = 0;
|
||||
$unacceptedAssets = $acceptances
|
||||
$unacceptedAssets = $pending
|
||||
->filter(function($acceptance) {
|
||||
return $acceptance->checkoutable_type == 'App\Models\Asset';
|
||||
})
|
||||
->map(function($acceptance) {
|
||||
return ['assetItem' => $acceptance->checkoutable, 'acceptance' => $acceptance];
|
||||
})
|
||||
->groupBy(function($item) {
|
||||
return $item['acceptance']->assignedTo ? $item['acceptance']->assignedTo->id : '';
|
||||
});
|
||||
$no_mail_address = [];
|
||||
|
||||
foreach($unacceptedAssets as $unacceptedAsset) {
|
||||
if ($unacceptedAsset['acceptance']->assignedTo->email == ''){
|
||||
$no_mail_address[] = $unacceptedAsset['checkoutable']->assignedTo->present()->fullName;
|
||||
}
|
||||
if ($unacceptedAsset['acceptance']->assignedTo) {
|
||||
|
||||
if (!$unacceptedAsset['acceptance']->assignedTo->locale) {
|
||||
|
@ -73,8 +85,12 @@ class SendAcceptanceReminder extends Command
|
|||
}
|
||||
}
|
||||
|
||||
if ($unacceptedAsset['acceptance']->assignedTo->email == ''){
|
||||
return "no email";
|
||||
if (!empty($no_mail_address)) {
|
||||
foreach($no_mail_address as $user) {
|
||||
return $user.' has no email.';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
@component('mail::message')
|
||||
# {{ trans('mail.hello') }},
|
||||
|
||||
{{ $intro_text }}.
|
||||
|
||||
@component('mail::table')
|
||||
| | |
|
||||
| ------------- | ------------- |
|
||||
| **{{ trans('mail.user') }}** | {{ $assigned_to }} |
|
||||
@if (isset($accepted_date))
|
||||
| **{{ ucfirst(trans('general.accepted')) }}** | {{ $accepted_date }} |
|
||||
@endif
|
||||
@if (isset($declined_date))
|
||||
| **{{ ucfirst(trans('general.declined')) }}** | {{ $declined_date }} |
|
||||
@endif
|
||||
@if ((isset($item_tag)) && ($item_tag!=''))
|
||||
| **{{ trans('mail.asset_tag') }}** | {{ $item_tag }} |
|
||||
@endif
|
||||
@if ((isset($item_model)) && ($item_model!=''))
|
||||
| **{{ trans('mail.asset_name') }}** | {{ $item_model }} |
|
||||
@endif
|
||||
@if (isset($item->model))
|
||||
| **{{ trans('general.asset_model') }}** | {{ $item->model->name }} |
|
||||
@endif
|
||||
@if (isset($item_serial))
|
||||
| **{{ trans('mail.serial') }}** | {{ $item_serial }} |
|
||||
@endif
|
||||
@endcomponent
|
||||
|
||||
{{ trans('mail.best_regards') }}
|
||||
|
||||
{{ $snipeSettings->site_name }}
|
||||
|
||||
@endcomponent
|
Loading…
Reference in a new issue