Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2025-02-26 20:55:57 +00:00
commit 44dd061619
3 changed files with 25 additions and 5 deletions

View file

@ -64,6 +64,7 @@ class SendAcceptanceReminder extends Command
->groupBy(function($item) {
return $item['acceptance']->assignedTo ? $item['acceptance']->assignedTo->id : '';
});
$no_email_list= [];
foreach($unacceptedAssetGroups as $unacceptedAssetGroup) {
// The [0] is weird, but it allows for the item_count to work and grabs the appropriate info for each user.
@ -72,7 +73,10 @@ class SendAcceptanceReminder extends Command
$locale = $acceptance->assignedTo?->locale;
$email = $acceptance->assignedTo?->email;
if(!$email){
$this->info($acceptance->assignedTo?->present()->fullName().' has no email address.');
$no_email_list[] = [
'id' => $acceptance->assignedTo->id,
'name' => $acceptance->assignedTo->present()->fullName(),
];
}
$item_count = $unacceptedAssetGroup->count();
@ -86,6 +90,14 @@ class SendAcceptanceReminder extends Command
}
$this->info($count.' users notified.');
$headers = ['ID', 'Name'];
$rows = [];
foreach ($no_email_list as $user) {
$rows[] = [$user['id'], $user['name']];
}
$this->info("The following users do not have an email address:");
$this->table($headers, $rows);
return 0;
}

View file

@ -358,7 +358,11 @@ class BulkAssetsController extends Controller
* to someone/something.
*/
if ($request->filled('status_id')) {
$updated_status = Statuslabel::find($request->input('status_id'));
try {
$updated_status = Statuslabel::findOrFail($request->input('status_id'));
} catch (ModelNotFoundException $e) {
return redirect($bulk_back_url)->with('error', trans('admin/statuslabels/message.does_not_exist'));
}
// We cannot assign a non-deployable status type if the asset is already assigned.
// This could probably be added to a form request.
@ -366,7 +370,7 @@ class BulkAssetsController extends Controller
// Otherwise we need to make sure the status type is still a deployable one.
if (
($asset->assigned_to == '')
|| ($updated_status->deployable == '1') && ($asset->assetstatus->deployable == '1')
|| ($updated_status->deployable == '1') && ($asset->assetstatus?->deployable == '1')
) {
$this->update_array['status_id'] = $updated_status->id;
}

View file

@ -43,9 +43,13 @@ class SendAcceptanceReminderTest extends TestCase
CheckoutAcceptance::factory()->pending()->create([
'assigned_to_id' => $userA->id,
]);
$headers = ['ID', 'Name'];
$rows = [
[$userA->id, $userA->present()->fullName()],
];
$this->artisan('snipeit:acceptance-reminder')
->expectsOutput($userA->present()->fullName().' has no email address.')
->expectsOutput("The following users do not have an email address:")
->expectsTable($headers, $rows)
->assertExitCode(0);
Mail::assertNotSent(UnacceptedAssetReminderMail::class);