mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
6cb6beb6c7
|
@ -121,7 +121,6 @@ class AcceptanceController extends Controller
|
||||||
$pdf_filename = 'accepted-eula-'.date('Y-m-d-h-i-s').'.pdf';
|
$pdf_filename = 'accepted-eula-'.date('Y-m-d-h-i-s').'.pdf';
|
||||||
$sig_filename='';
|
$sig_filename='';
|
||||||
|
|
||||||
|
|
||||||
if ($request->input('asset_acceptance') == 'accepted') {
|
if ($request->input('asset_acceptance') == 'accepted') {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -153,7 +152,6 @@ class AcceptanceController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// this is horrible
|
// this is horrible
|
||||||
switch($acceptance->checkoutable_type){
|
switch($acceptance->checkoutable_type){
|
||||||
case 'App\Models\Asset':
|
case 'App\Models\Asset':
|
||||||
|
@ -170,7 +168,7 @@ class AcceptanceController extends Controller
|
||||||
$pdf_view_route ='account.accept.accept-accessory-eula';
|
$pdf_view_route ='account.accept.accept-accessory-eula';
|
||||||
$accessory = Accessory::find($item->id);
|
$accessory = Accessory::find($item->id);
|
||||||
$display_model = $accessory->name;
|
$display_model = $accessory->name;
|
||||||
$assigned_to = User::find($item->assignedTo);
|
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'App\Models\LicenseSeat':
|
case 'App\Models\LicenseSeat':
|
||||||
|
@ -253,11 +251,15 @@ class AcceptanceController extends Controller
|
||||||
// This is the most horriblest
|
// This is the most horriblest
|
||||||
switch($acceptance->checkoutable_type){
|
switch($acceptance->checkoutable_type){
|
||||||
case 'App\Models\Asset':
|
case 'App\Models\Asset':
|
||||||
|
$asset_model = AssetModel::find($item->model_id);
|
||||||
|
$display_model = $asset_model->name;
|
||||||
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'App\Models\Accessory':
|
case 'App\Models\Accessory':
|
||||||
$assigned_to = User::find($item->assignedTo);
|
$accessory = Accessory::find($item->id);
|
||||||
|
$display_model = $accessory->name;
|
||||||
|
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'App\Models\LicenseSeat':
|
case 'App\Models\LicenseSeat':
|
||||||
|
@ -269,6 +271,8 @@ class AcceptanceController extends Controller
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'App\Models\Consumable':
|
case 'App\Models\Consumable':
|
||||||
|
$consumable = Consumable::find($item->id);
|
||||||
|
$display_model = $consumable->name;
|
||||||
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -573,9 +573,6 @@ class AssetsController extends Controller
|
||||||
// Update custom fields in the database.
|
// Update custom fields in the database.
|
||||||
// Validation for these fields is handled through the AssetRequest form request
|
// Validation for these fields is handled through the AssetRequest form request
|
||||||
$model = AssetModel::find($request->get('model_id'));
|
$model = AssetModel::find($request->get('model_id'));
|
||||||
if (!$model) {
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/models/message.does_not_exist')), 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($model) && ($model->fieldset)) {
|
if (($model) && ($model->fieldset)) {
|
||||||
foreach ($model->fieldset->fields as $field) {
|
foreach ($model->fieldset->fields as $field) {
|
||||||
|
|
|
@ -67,7 +67,6 @@ class Importer extends Component
|
||||||
'location' => 'Location',
|
'location' => 'Location',
|
||||||
'maintained' => 'Maintained',
|
'maintained' => 'Maintained',
|
||||||
'manufacturer' => 'Manufacturer',
|
'manufacturer' => 'Manufacturer',
|
||||||
'notes' => 'Notes',
|
|
||||||
'order_number' => 'Order Number',
|
'order_number' => 'Order Number',
|
||||||
'purchase_cost' => 'Purchase Cost',
|
'purchase_cost' => 'Purchase Cost',
|
||||||
'purchase_date' => 'Purchase Date',
|
'purchase_date' => 'Purchase Date',
|
||||||
|
@ -81,11 +80,14 @@ class Importer extends Component
|
||||||
|
|
||||||
static $accessories = [
|
static $accessories = [
|
||||||
'model_number' => 'Model Number',
|
'model_number' => 'Model Number',
|
||||||
|
'notes' => 'Notes',
|
||||||
];
|
];
|
||||||
|
|
||||||
static $assets = [
|
static $assets = [
|
||||||
'asset_tag' => 'Asset Tag',
|
'asset_tag' => 'Asset Tag',
|
||||||
'asset_model' => 'Model Name',
|
'asset_model' => 'Model Name',
|
||||||
|
'asset_notes' => 'Asset Notes',
|
||||||
|
'model_notes' => 'Model Notes',
|
||||||
'byod' => 'BYOD',
|
'byod' => 'BYOD',
|
||||||
'checkout_class' => 'Checkout Type',
|
'checkout_class' => 'Checkout Type',
|
||||||
'checkout_location' => 'Checkout Location',
|
'checkout_location' => 'Checkout Location',
|
||||||
|
@ -99,6 +101,7 @@ class Importer extends Component
|
||||||
static $consumables = [
|
static $consumables = [
|
||||||
'item_no' => "Item Number",
|
'item_no' => "Item Number",
|
||||||
'model_number' => "Model Number",
|
'model_number' => "Model Number",
|
||||||
|
'notes' => 'Notes',
|
||||||
'min_amt' => "Minimum Quantity",
|
'min_amt' => "Minimum Quantity",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -111,12 +114,14 @@ class Importer extends Component
|
||||||
'purchase_order' => 'Purchase Order',
|
'purchase_order' => 'Purchase Order',
|
||||||
'reassignable' => 'Reassignable',
|
'reassignable' => 'Reassignable',
|
||||||
'seats' => 'Seats',
|
'seats' => 'Seats',
|
||||||
|
'notes' => 'Notes',
|
||||||
];
|
];
|
||||||
|
|
||||||
static $users = [
|
static $users = [
|
||||||
'employee_num' => 'Employee Number',
|
'employee_num' => 'Employee Number',
|
||||||
'first_name' => 'First Name',
|
'first_name' => 'First Name',
|
||||||
'last_name' => 'Last Name',
|
'last_name' => 'Last Name',
|
||||||
|
'notes' => 'Notes',
|
||||||
'jobtitle' => 'Job Title',
|
'jobtitle' => 'Job Title',
|
||||||
'phone_number' => 'Phone Number',
|
'phone_number' => 'Phone Number',
|
||||||
'manager_first_name' => 'Manager First Name',
|
'manager_first_name' => 'Manager First Name',
|
||||||
|
@ -144,6 +149,7 @@ class Importer extends Component
|
||||||
'manager_username' => 'Manager Username',
|
'manager_username' => 'Manager Username',
|
||||||
'manager' => 'Manager',
|
'manager' => 'Manager',
|
||||||
'parent_location' => 'Parent Location',
|
'parent_location' => 'Parent Location',
|
||||||
|
'notes' => 'Notes',
|
||||||
];
|
];
|
||||||
|
|
||||||
//array of "real fieldnames" to a list of aliases for that field
|
//array of "real fieldnames" to a list of aliases for that field
|
||||||
|
|
|
@ -90,7 +90,7 @@ class Asset extends Depreciable
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'name' => 'max:255|nullable',
|
'name' => 'max:255|nullable',
|
||||||
'model_id' => 'required|integer|exists:models,id',
|
'model_id' => 'required|integer|exists:models,id,deleted_at,NULL',
|
||||||
'status_id' => 'required|integer|exists:status_labels,id',
|
'status_id' => 'required|integer|exists:status_labels,id',
|
||||||
'company_id' => 'integer|nullable',
|
'company_id' => 'integer|nullable',
|
||||||
'warranty_months' => 'numeric|nullable|digits_between:0,240',
|
'warranty_months' => 'numeric|nullable|digits_between:0,240',
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
class CheckoutAcceptance extends Model
|
class CheckoutAcceptance extends Model
|
||||||
{
|
{
|
||||||
use SoftDeletes, Notifiable;
|
use HasFactory, SoftDeletes, Notifiable;
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'accepted_at' => 'datetime',
|
'accepted_at' => 'datetime',
|
||||||
|
|
41
database/factories/CheckoutAcceptanceFactory.php
Normal file
41
database/factories/CheckoutAcceptanceFactory.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\Accessory;
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class CheckoutAcceptanceFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'checkoutable_type' => Asset::class,
|
||||||
|
'checkoutable_id' => Asset::factory(),
|
||||||
|
'assigned_to_id' => User::factory(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function forAccessory()
|
||||||
|
{
|
||||||
|
return $this->state([
|
||||||
|
'checkoutable_type' => Accessory::class,
|
||||||
|
'checkoutable_id' => Accessory::factory(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pending()
|
||||||
|
{
|
||||||
|
return $this->state([
|
||||||
|
'accepted_at' => null,
|
||||||
|
'declined_at' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,7 @@
|
||||||
| **{{ ucfirst(trans('general.accepted')) }}** | {{ $accepted_date }} |
|
| **{{ ucfirst(trans('general.accepted')) }}** | {{ $accepted_date }} |
|
||||||
@endif
|
@endif
|
||||||
@if (isset($declined_date))
|
@if (isset($declined_date))
|
||||||
| **{{ trans('general.declined') }}** | {{ $declined_date }} |
|
| **{{ ucfirst(trans('general.declined')) }}** | {{ $declined_date }} |
|
||||||
@endif
|
@endif
|
||||||
@if ((isset($item_tag)) && ($item_tag!=''))
|
@if ((isset($item_tag)) && ($item_tag!=''))
|
||||||
| **{{ trans('mail.asset_tag') }}** | {{ $item_tag }} |
|
| **{{ trans('mail.asset_tag') }}** | {{ $item_tag }} |
|
||||||
|
|
|
@ -291,7 +291,8 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
|
||||||
Route::get('accept/{id}', [Account\AcceptanceController::class, 'create'])
|
Route::get('accept/{id}', [Account\AcceptanceController::class, 'create'])
|
||||||
->name('account.accept.item');
|
->name('account.accept.item');
|
||||||
|
|
||||||
Route::post('accept/{id}', [Account\AcceptanceController::class, 'store']);
|
Route::post('accept/{id}', [Account\AcceptanceController::class, 'store'])
|
||||||
|
->name('account.store-acceptance');
|
||||||
|
|
||||||
Route::get(
|
Route::get(
|
||||||
'print',
|
'print',
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\CheckoutAcceptances;
|
||||||
|
|
||||||
|
use App\Models\Accessory;
|
||||||
|
use App\Models\CheckoutAcceptance;
|
||||||
|
use App\Notifications\AcceptanceAssetAcceptedNotification;
|
||||||
|
use App\Notifications\AcceptanceAssetDeclinedNotification;
|
||||||
|
use Notification;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AccessoryAcceptanceTest extends TestCase
|
||||||
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can be absorbed into a bigger test
|
||||||
|
*/
|
||||||
|
public function testUsersNameIsIncludedInAccessoryAcceptedNotification()
|
||||||
|
{
|
||||||
|
Notification::fake();
|
||||||
|
|
||||||
|
$this->settings->enableAlertEmail();
|
||||||
|
|
||||||
|
$acceptance = CheckoutAcceptance::factory()
|
||||||
|
->pending()
|
||||||
|
->for(Accessory::factory()->appleMouse(), 'checkoutable')
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$this->actingAs($acceptance->assignedTo)
|
||||||
|
->post(route('account.store-acceptance', $acceptance), ['asset_acceptance' => 'accepted'])
|
||||||
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
|
$this->assertNotNull($acceptance->fresh()->accepted_at);
|
||||||
|
|
||||||
|
Notification::assertSentTo(
|
||||||
|
$acceptance,
|
||||||
|
function (AcceptanceAssetAcceptedNotification $notification) use ($acceptance) {
|
||||||
|
$this->assertStringContainsString(
|
||||||
|
$acceptance->assignedTo->present()->fullName,
|
||||||
|
$notification->toMail()->render()
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can be absorbed into a bigger test
|
||||||
|
*/
|
||||||
|
public function testUsersNameIsIncludedInAccessoryDeclinedNotification()
|
||||||
|
{
|
||||||
|
Notification::fake();
|
||||||
|
|
||||||
|
$this->settings->enableAlertEmail();
|
||||||
|
|
||||||
|
$acceptance = CheckoutAcceptance::factory()
|
||||||
|
->pending()
|
||||||
|
->for(Accessory::factory()->appleMouse(), 'checkoutable')
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$this->actingAs($acceptance->assignedTo)
|
||||||
|
->post(route('account.store-acceptance', $acceptance), ['asset_acceptance' => 'declined'])
|
||||||
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
|
$this->assertNotNull($acceptance->fresh()->declined_at);
|
||||||
|
|
||||||
|
Notification::assertSentTo(
|
||||||
|
$acceptance,
|
||||||
|
function (AcceptanceAssetDeclinedNotification $notification) use ($acceptance) {
|
||||||
|
$this->assertStringContainsString(
|
||||||
|
$acceptance->assignedTo->present()->fullName,
|
||||||
|
$notification->toMail($acceptance)->render()
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,16 @@ class Settings
|
||||||
return new self();
|
return new self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function enableAlertEmail(string $email = 'notifications@afcrichmond.com'): Settings
|
||||||
|
{
|
||||||
|
return $this->update(['alert_email' => $email]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disableAlertEmail(): Settings
|
||||||
|
{
|
||||||
|
return $this->update(['alert_email' => null]);
|
||||||
|
}
|
||||||
|
|
||||||
public function enableMultipleFullCompanySupport(): Settings
|
public function enableMultipleFullCompanySupport(): Settings
|
||||||
{
|
{
|
||||||
return $this->update(['full_multiple_companies_support' => 1]);
|
return $this->update(['full_multiple_companies_support' => 1]);
|
||||||
|
|
Loading…
Reference in a new issue