mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 06:47:46 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
39810f9ba5
|
@ -183,6 +183,7 @@ REPORT_TIME_LIMIT=12000
|
||||||
REQUIRE_SAML=false
|
REQUIRE_SAML=false
|
||||||
API_THROTTLE_PER_MINUTE=120
|
API_THROTTLE_PER_MINUTE=120
|
||||||
CSV_ESCAPE_FORMULAS=true
|
CSV_ESCAPE_FORMULAS=true
|
||||||
|
LIVEWIRE_URL_PREFIX=null
|
||||||
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# OPTIONAL: HASHING
|
# OPTIONAL: HASHING
|
||||||
|
|
105
app/Console/Commands/SendAcceptanceReminder.php
Normal file
105
app/Console/Commands/SendAcceptanceReminder.php
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\CheckoutAcceptance;
|
||||||
|
use App\Models\Setting;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Notifications\CheckoutAssetNotification;
|
||||||
|
use App\Notifications\CurrentInventory;
|
||||||
|
use App\Notifications\UnacceptedAssetReminderNotification;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
|
||||||
|
class SendAcceptanceReminder extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'snipeit:acceptance-reminder';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'This will resend users with unaccepted assets a reminder to accept or decline them.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$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;
|
||||||
|
$unacceptedAssetGroups = $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($unacceptedAssetGroups as $unacceptedAssetGroup) {
|
||||||
|
$item_count = $unacceptedAssetGroup->count();
|
||||||
|
foreach ($unacceptedAssetGroup as $unacceptedAsset) {
|
||||||
|
// if ($unacceptedAsset['acceptance']->assignedTo->email == ''){
|
||||||
|
// $no_mail_address[] = $unacceptedAsset['checkoutable']->assignedTo->present()->fullName;
|
||||||
|
// }
|
||||||
|
if ($unacceptedAsset['acceptance']->assignedTo) {
|
||||||
|
|
||||||
|
if (!$unacceptedAsset['acceptance']->assignedTo->locale) {
|
||||||
|
Notification::locale(Setting::getSettings()->locale)->send(
|
||||||
|
$unacceptedAsset['acceptance']->assignedTo,
|
||||||
|
new UnacceptedAssetReminderNotification($unacceptedAsset['assetItem'], $count)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Notification::send(
|
||||||
|
$unacceptedAsset['acceptance']->assignedTo,
|
||||||
|
new UnacceptedAssetReminderNotification($unacceptedAsset, $item_count)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($no_mail_address)) {
|
||||||
|
foreach($no_mail_address as $user) {
|
||||||
|
return $user.' has no email.';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$this->info($count.' users notified.');
|
||||||
|
}
|
||||||
|
}
|
|
@ -378,7 +378,7 @@ class ReportsController extends Controller
|
||||||
|
|
||||||
|
|
||||||
$csv = implode("\n", $rows);
|
$csv = implode("\n", $rows);
|
||||||
$response = Response::make($csv, 200);
|
$response = response()->make($csv, 200);
|
||||||
$response->header('Content-Type', 'text/csv');
|
$response->header('Content-Type', 'text/csv');
|
||||||
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
||||||
|
|
||||||
|
@ -1069,7 +1069,7 @@ class ReportsController extends Controller
|
||||||
|
|
||||||
// spit out a csv
|
// spit out a csv
|
||||||
$csv = implode("\n", $rows);
|
$csv = implode("\n", $rows);
|
||||||
$response = Response::make($csv, 200);
|
$response = response()->make($csv, 200);
|
||||||
$response->header('Content-Type', 'text/csv');
|
$response->header('Content-Type', 'text/csv');
|
||||||
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
||||||
|
|
||||||
|
@ -1249,7 +1249,7 @@ class ReportsController extends Controller
|
||||||
|
|
||||||
// spit out a csv
|
// spit out a csv
|
||||||
$csv = implode("\n", $rows);
|
$csv = implode("\n", $rows);
|
||||||
$response = Response::make($csv, 200);
|
$response = response()->make($csv, 200);
|
||||||
$response->header('Content-Type', 'text/csv');
|
$response->header('Content-Type', 'text/csv');
|
||||||
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
$response->header('Content-disposition', 'attachment;filename=report.csv');
|
||||||
|
|
||||||
|
|
73
app/Notifications/UnacceptedAssetReminderNotification.php
Normal file
73
app/Notifications/UnacceptedAssetReminderNotification.php
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
class UnacceptedAssetReminderNotification extends Notification
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($checkout_info, $count)
|
||||||
|
{
|
||||||
|
$this->count = $count;
|
||||||
|
$this->target = $checkout_info['acceptance']->assignedTo;
|
||||||
|
$this->acceptance = $checkout_info['acceptance'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function via()
|
||||||
|
{
|
||||||
|
return ['mail'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
public function toMail()
|
||||||
|
{
|
||||||
|
$accept_url = route('account.accept');
|
||||||
|
$message = (new MailMessage)->markdown('notifications.markdown.asset-reminder',
|
||||||
|
[
|
||||||
|
'count' => $this->count,
|
||||||
|
'assigned_to' => $this->target->present()->fullName,
|
||||||
|
'link' => route('account.accept'),
|
||||||
|
'accept_url' => $accept_url,
|
||||||
|
])
|
||||||
|
->subject(trans('mail.unaccepted_asset_reminder'));
|
||||||
|
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($notifiable)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
32
app/Providers/LivewireServiceProvider.php
Normal file
32
app/Providers/LivewireServiceProvider.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
|
||||||
|
class LivewireServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
Livewire::setUpdateRoute(function ($handle) {
|
||||||
|
return Route::post('/' . config('livewire.url_prefix') . '/livewire/update', $handle);
|
||||||
|
});
|
||||||
|
|
||||||
|
Livewire::setScriptRoute(function ($handle) {
|
||||||
|
return Route::get('/' . config('livewire.url_prefix') . '/livewire/livewire.js', $handle);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -311,8 +311,9 @@ return [
|
||||||
App\Providers\ValidationServiceProvider::class,
|
App\Providers\ValidationServiceProvider::class,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Custom service provider
|
* Custom Service Providers...
|
||||||
*/
|
*/
|
||||||
|
App\Providers\LivewireServiceProvider::class,
|
||||||
App\Providers\MacroServiceProvider::class,
|
App\Providers\MacroServiceProvider::class,
|
||||||
App\Providers\SamlServiceProvider::class,
|
App\Providers\SamlServiceProvider::class,
|
||||||
|
|
||||||
|
|
|
@ -157,4 +157,21 @@ return [
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'pagination_theme' => 'tailwind',
|
'pagination_theme' => 'tailwind',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| URL Prefix
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default, Livewire sends network requests to {app.com}/livewire/update
|
||||||
|
| while javascript assets are served via {app.com}/livewire/livewire.js
|
||||||
|
| If you need to adjust the prefix of those urls you can do it below.
|
||||||
|
|
|
||||||
|
| Defining a prefix will result in the following url
|
||||||
|
| {app.com}/{prefix}/livewire/{update|livewire.js}
|
||||||
|
| Note: do not include the leading or trailing /
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'url_prefix' => env('LIVEWIRE_URL_PREFIX', null),
|
||||||
];
|
];
|
||||||
|
|
|
@ -56,6 +56,7 @@ return [
|
||||||
'i_have_read' => 'I have read and agree to the terms of use, and have received this item.',
|
'i_have_read' => 'I have read and agree to the terms of use, and have received this item.',
|
||||||
'inventory_report' => 'Inventory Report',
|
'inventory_report' => 'Inventory Report',
|
||||||
'item' => 'Item:',
|
'item' => 'Item:',
|
||||||
|
'item_checked_reminder' => 'This is a reminder that you currently have :count items checked out to you that you have not accepted or declined. Please click the link below to confirm your decision.',
|
||||||
'license_expiring_alert' => 'There is :count license expiring in the next :threshold days.|There are :count licenses expiring in the next :threshold days.',
|
'license_expiring_alert' => 'There is :count license expiring in the next :threshold days.|There are :count licenses expiring in the next :threshold days.',
|
||||||
'link_to_update_password' => 'Please click on the following link to update your :web password:',
|
'link_to_update_password' => 'Please click on the following link to update your :web password:',
|
||||||
'login' => 'Login:',
|
'login' => 'Login:',
|
||||||
|
@ -86,6 +87,7 @@ return [
|
||||||
'upcoming-audits' => 'There is :count asset that is coming up for audit within :threshold days.|There are :count assets that are coming up for audit within :threshold days.',
|
'upcoming-audits' => 'There is :count asset that is coming up for audit within :threshold days.|There are :count assets that are coming up for audit within :threshold days.',
|
||||||
'user' => 'User',
|
'user' => 'User',
|
||||||
'username' => 'Username',
|
'username' => 'Username',
|
||||||
|
'unaccepted_asset_reminder' => 'You have Unaccepted Assets.',
|
||||||
'welcome' => 'Welcome :name',
|
'welcome' => 'Welcome :name',
|
||||||
'welcome_to' => 'Welcome to :web!',
|
'welcome_to' => 'Welcome to :web!',
|
||||||
'your_assets' => 'View Your Assets',
|
'your_assets' => 'View Your Assets',
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
@component('mail::message')
|
||||||
|
# {{ trans('mail.hello') }} {{ $assigned_to}},
|
||||||
|
|
||||||
|
{{trans('mail.item_checked_reminder', ['count' => $count])}}
|
||||||
|
[{{ trans('general.click_here')}}]({{$accept_url}})
|
||||||
|
|
||||||
|
{{ trans('mail.best_regards') }}
|
||||||
|
|
||||||
|
{{ $snipeSettings->site_name }}
|
||||||
|
|
||||||
|
@endcomponent
|
Loading…
Reference in a new issue