Merge remote-tracking branch 'origin/develop'

Signed-off-by: snipe <snipe@snipe.net>

# Conflicts:
#	public/js/build/app.js
#	public/js/dist/all.js
#	public/mix-manifest.json
This commit is contained in:
snipe 2022-12-14 17:06:26 -08:00
commit b89979fbec
16 changed files with 69 additions and 5 deletions

View file

@ -12,6 +12,7 @@ use App\Models\Statuslabel;
use Crypt;
use Illuminate\Contracts\Encryption\DecryptException;
use Image;
use Carbon\Carbon;
class Helper
{
@ -1125,5 +1126,25 @@ class Helper
return $settings;
}
public static function AgeFormat($date) {
$year = Carbon::parse($date)
->diff(now())->y;
$month = Carbon::parse($date)
->diff(now())->m;
$days = Carbon::parse($date)
->diff(now())->d;
$age='';
if ($year) {
$age .= $year.'y ';
}
if ($month) {
$age .= $month.'m ';
}
if ($days) {
$age .= $days.'d';
}
return $age;
}
}

View file

@ -8,6 +8,7 @@ use App\Models\Setting;
use Gate;
use Illuminate\Database\Eloquent\Collection;
class AssetsTransformer
{
public function transformAssets(Collection $assets, $total)
@ -80,6 +81,7 @@ class AssetsTransformer
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date, 'date'),
'deleted_at' => Helper::getFormattedDateObject($asset->deleted_at, 'datetime'),
'purchase_date' => Helper::getFormattedDateObject($asset->purchase_date, 'date'),
'age' => $asset->purchase_date ? Helper::AgeFormat($asset->purchase_date) : '',
'last_checkout' => Helper::getFormattedDateObject($asset->last_checkout, 'datetime'),
'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'date'),
'purchase_cost' => Helper::formatCurrencyOutput($asset->purchase_cost),

View file

@ -77,6 +77,7 @@ abstract class Importer
'manager_first_name' => 'manager first name',
'manager_last_name' => 'manager last name',
'min_amt' => 'minimum quantity',
'remote' => 'remote',
];
/**
* Map of item fields->csv names
@ -288,6 +289,7 @@ abstract class Importer
'department_id' => '',
'username' => $this->findCsvMatch($row, 'username'),
'activated' => $this->fetchHumanBoolean($this->findCsvMatch($row, 'activated')),
'remote' => $this->fetchHumanBoolean(($this->findCsvMatch($row, 'remote'))),
];
// Maybe we're lucky and the user already exists.

View file

@ -57,6 +57,7 @@ class UserImporter extends ItemImporter
$this->item['employee_num'] = $this->findCsvMatch($row, 'employee_num');
$this->item['department_id'] = $this->createOrFetchDepartment($this->findCsvMatch($row, 'department'));
$this->item['manager_id'] = $this->fetchManager($this->findCsvMatch($row, 'manager_first_name'), $this->findCsvMatch($row, 'manager_last_name'));
$this->item['remote'] =($this->fetchHumanBoolean($this->findCsvMatch($row, 'remote')) ==1 ) ? '1' : 0;
$user_department = $this->findCsvMatch($row, 'department');
if ($this->shouldUpdateField($user_department)) {

View file

@ -338,6 +338,24 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
return $this->belongsToMany(\App\Models\License::class, 'license_seats', 'assigned_to', 'license_id')->withPivot('id');
}
/**
* Establishes a count of all items assigned
*
* @author J. Vinsmoke
* @since [v6.1]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
Public function allAssignedCount() {
$assetsCount = $this->assets()->count();
$licensesCount = $this->licenses()->count();
$accessoriesCount = $this->accessories()->count();
$consumablesCount = $this->consumables()->count();
$totalCount = $assetsCount + $licensesCount + $accessoriesCount + $consumablesCount;
return (int) $totalCount;
}
/**
* Establishes the user -> actionlogs relationship
*

View file

@ -140,6 +140,12 @@ class AssetPresenter extends Presenter
'visible' => false,
'title' => trans('general.purchase_date'),
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'age',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.age'),
], [
'field' => 'purchase_cost',
'searchable' => true,

View file

@ -24,7 +24,7 @@
"vue-template-compiler": "2.4.4"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.2.0",
"@fortawesome/fontawesome-free": "^6.2.1",
"acorn": "^8.8.0",
"acorn-import-assertions": "^1.8.0",
"admin-lte": "^2.4.18",

Binary file not shown.

BIN
public/js/dist/all.js vendored

Binary file not shown.

View file

@ -1,5 +1,5 @@
{
"/js/build/app.js": "/js/build/app.js?id=f19f6d7dd0a5a579589e538977255b18",
"/js/build/app.js": "/js/build/app.js?id=d9c0da9015392f9beb559c4b0b9935b2",
"/css/dist/skins/skin-blue.css": "/css/dist/skins/skin-blue.css?id=392cc93cfc0be0349bab9697669dd091",
"/css/build/overrides.css": "/css/build/overrides.css?id=e946ade78cda507ae99ecfaf10d43368",
"/css/build/app.css": "/css/build/app.css?id=41ec65bd0c0e3000a48af1893e313cc6",
@ -34,7 +34,7 @@
"/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=ee4896df8b8f008ce73a9a0c2549aefd",
"/js/build/vendor.js": "/js/build/vendor.js?id=47ecbb4bb3b0e02315f391caadbdf971",
"/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=14d9a2affec7b066d20fcba2e6e67ad2",
"/js/dist/all.js": "/js/dist/all.js?id=081efc7b07f9a7a308efad9108c8ec66",
"/js/dist/all.js": "/js/dist/all.js?id=56e75b479d84630e693031efed58e1ad",
"/css/dist/skins/skin-green.min.css": "/css/dist/skins/skin-green.min.css?id=b48f4d8af0e1ca5621c161e93951109f",
"/css/dist/skins/skin-green-dark.min.css": "/css/dist/skins/skin-green-dark.min.css?id=8f449de09e00c15481b144b44b1a7185",
"/css/dist/skins/skin-black.min.css": "/css/dist/skins/skin-black.min.css?id=1f33ca3d860461c1127ec465ab3ebb6b",

View file

@ -194,6 +194,7 @@
{id: 'state', text: 'State' },
{id: 'country', text: 'Country' },
{id: 'zip', text: 'ZIP' },
{id: 'remote', text: 'Remote'},
],
customFields: this.customFields,

View file

@ -15,6 +15,7 @@ return array(
'password_resets_sent' => 'The selected users who are activated and have a valid email addresses have been sent a password reset link.',
'password_reset_sent' => 'A password reset link has been sent to :email!',
'user_has_no_email' => 'This user does not have an email address in their profile.',
'user_has_no_assets_assigned' => 'This user does not have any assets assigned',
'success' => array(

View file

@ -11,6 +11,7 @@ return [
'admin' => 'Admin',
'administrator' => 'Administrator',
'add_seats' => 'Added seats',
'age' => "Age",
'all_assets' => 'All Assets',
'all' => 'All',
'archived' => 'Archived',

View file

@ -495,6 +495,9 @@
</div>
<div class="col-md-6">
{{ Helper::getFormattedDateObject($asset->purchase_date, 'date', false) }}
-
{{ Carbon::parse($asset->purchase_date)->diff(Carbon::now())->format('%y years, %m months and %d days')}}
</div>
</div>
@endif
@ -964,6 +967,7 @@
<th>{{ trans('general.name') }}</th>
<th>{{ trans('general.qty') }}</th>
<th>{{ trans('general.purchase_cost') }}</th>
<th>{{trans('admin/hardware/form.serial')}}</th>
</thead>
<tbody>
<?php $totalCost = 0; ?>
@ -977,6 +981,7 @@
</td>
<td>{{ $component->pivot->assigned_qty }}</td>
<td>{{ Helper::formatCurrencyOutput($component->purchase_cost) }} each</td>
<td>{{ $component->serial }}</td>
<?php $totalCost = $totalCost + ($component->purchase_cost *$component->pivot->assigned_qty) ?>
</tr>

View file

@ -80,7 +80,7 @@
<td class="col-md-1">@{{ currentFile.filesize }}</td>
<td class="col-md-1 text-right">
<button class="btn btn-sm btn-info" @click="toggleEvent(currentFile.id)">
<i class="fa-regular fa-retweet fa-fw" aria-hidden="true"></i>
<i class="fas fa-retweet fa-fw" aria-hidden="true"></i>
<span class="sr-only">{{ trans('general.import') }}</span>
</button>

View file

@ -179,17 +179,23 @@
@can('view', $user)
<div class="col-md-12" style="padding-top: 5px;">
@if($user->allAssignedCount() != '0')
<a href="{{ route('users.print', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print" target="_blank" rel="noopener">{{ trans('admin/users/general.print_assigned') }}</a>
@else
<button style="width: 100%;" class="btn btn-sm btn-primary hidden-print" rel="noopener" disabled title="{{ trans('admin/users/message.user_has_no_assets_assigned') }}">{{ trans('admin/users/general.print_assigned') }}</button>
@endif
</div>
@endcan
@can('view', $user)
<div class="col-md-12" style="padding-top: 5px;">
@if(!empty($user->email))
@if(!empty($user->email) && ($user->allAssignedCount() != '0'))
<form action="{{ route('users.email',['userId'=> $user->id]) }}" method="POST">
{{ csrf_field() }}
<button style="width: 100%;" class="btn btn-sm btn-primary hidden-print" rel="noopener">{{ trans('admin/users/general.email_assigned') }}</button>
</form>
@elseif(!empty($user->email) && ($user->allAssignedCount() == '0'))
<button style="width: 100%;" class="btn btn-sm btn-primary hidden-print" rel="noopener" disabled title="{{ trans('admin/users/message.user_has_no_assets_assigned') }}">{{ trans('admin/users/general.email_assigned') }}</button>
@else
<button style="width: 100%;" class="btn btn-sm btn-primary hidden-print" rel="noopener" disabled title="{{ trans('admin/users/message.user_has_no_email') }}">{{ trans('admin/users/general.email_assigned') }}</button>
@endif