Merge branch 'develop'

This commit is contained in:
snipe 2017-09-28 21:18:39 -07:00
commit e759a249bd
9 changed files with 104 additions and 62 deletions

View file

@ -274,7 +274,7 @@ class AccessoriesController extends Controller
$data['note'] = $logaction->note; $data['note'] = $logaction->note;
$data['require_acceptance'] = $accessory->requireAcceptance(); $data['require_acceptance'] = $accessory->requireAcceptance();
// TODO: Port this to new mail notifications // TODO: Port this to new mail notifications
if (($accessory->requireAcceptance()=='1') || ($accessory->getEula())) { if ((($accessory->requireAcceptance()=='1') || ($accessory->getEula())) && ($user->email!='')) {
Mail::send('emails.accept-accessory', $data, function ($m) use ($user) { Mail::send('emails.accept-accessory', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name); $m->to($user->email, $user->first_name . ' ' . $user->last_name);
@ -351,7 +351,7 @@ class AccessoriesController extends Controller
$data['item_tag'] = ''; $data['item_tag'] = '';
$data['note'] = e($logaction->note); $data['note'] = e($logaction->note);
if (($accessory->checkin_email()=='1')) { if ((($accessory->checkin_email()=='1')) && ($user->email!='')) {
Mail::send('emails.checkin-asset', $data, function ($m) use ($user) { Mail::send('emails.checkin-asset', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name); $m->to($user->email, $user->first_name . ' ' . $user->last_name);

View file

@ -129,9 +129,8 @@ class AccessoriesController extends Controller
{ {
$this->authorize('view', Accessory::class); $this->authorize('view', Accessory::class);
$accessory = Accessory::findOrFail($id)->with('users')->first(); $accessory = Accessory::findOrFail($id)->with('users')->first();
$accessories_users = $accessory->users; $total = $accessory->users->count();
$total = $accessories_users->count(); return (new AccessoriesTransformer)->transformCheckedoutAccessory($accessory, $total);
return (new AccessoriesTransformer)->transformCheckedoutAccessories($accessories_users, $total);
} }

View file

@ -59,13 +59,30 @@ class AccessoriesTransformer
} }
public function transformCheckedoutAccessories (Collection $accessories_users, $total) public function transformCheckedoutAccessory (Accessory $accessory, $total)
{ {
$array = array(); $array = array();
foreach ($accessories_users as $user) { foreach ($accessory->users as $user) {
$array[] = (new UsersTransformer)->transformUser($user); $array[] = [
'assigned_pivot_id' => $user->pivot->id,
'id' => (int) $user->id,
'username' => e($user->username),
'name' => e($user->getFullNameAttribute()),
'first_name'=> e($user->first_name),
'last_name'=> e($user->last_name),
'employee_number' => e($user->employee_num),
'type' => 'user',
'available_actions' => ['checkin' => true]
];
} }
return (new DatatablesTransformer)->transformDatatables($array, $total); return (new DatatablesTransformer)->transformDatatables($array, $total);
} }

View file

@ -33,7 +33,8 @@ class AssetsTransformer
'model_number' => ($asset->model) ? e($asset->model->model_number) : null, 'model_number' => ($asset->model) ? e($asset->model->model_number) : null,
'status_label' => ($asset->assetstatus) ? [ 'status_label' => ($asset->assetstatus) ? [
'id' => (int) $asset->assetstatus->id, 'id' => (int) $asset->assetstatus->id,
'name'=> e($asset->assetstatus->name) 'name'=> e($asset->assetstatus->name),
'status_type' => e($asset->assetstatus->getStatuslabelType()),
] : null, ] : null,
'category' => ($asset->model->category) ? [ 'category' => ($asset->model->category) ? [
'id' => (int) $asset->model->category->id, 'id' => (int) $asset->model->category->id,

View file

@ -2,59 +2,76 @@
{{-- Page title --}} {{-- Page title --}}
@section('title') @section('title')
{{ trans('admin/hardware/general.checkin') }} {{ trans('admin/accessories/general.checkin') }}
@parent @parent
@stop @stop
@section('header_right')
<a href="{{ URL::previous() }}" class="btn btn-primary pull-right">
{{ trans('general.back') }}</a>
@stop
{{-- Page content --}} {{-- Page content --}}
@section('content') @section('content')
<div class="row header">
<div class="col-md-12">
<a href="{{ URL::previous() }}" class="btn-flat gray pull-right"><i class="fa fa-arrow-left icon-white"></i> {{ trans('general.back') }}</a>
<h3> {{ trans('general.checkin') }}</h3>
</div>
</div>
<div class="row form-wrapper">
<!-- left column -->
<div class="col-md-10 column">
<form class="form-horizontal" method="post" action="" autocomplete="off"> <div class="row">
<!-- CSRF Token --> <div class="col-md-9">
<input type="hidden" name="_token" value="{{ csrf_token() }}" /> <form class="form-horizontal" method="post" action="" autocomplete="off">
<!-- CSRF Token -->
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
@if ($accessory->name) <div class="box box-default">
<!-- accessory name --> @if ($accessory->id)
<div class="form-group"> <div class="box-header with-border">
<label class="col-sm-2 control-label">{{ trans('admin/hardware/form.name') }}</label> <h3 class="box-title">{{ $accessory->name }}</h3>
<div class="col-md-6"> </div><!-- /.box-header -->
<p class="form-control-static">{{ $accessory->name }}</p> @endif
</div>
</div>
@endif
<!-- Note --> <div class="box-body">
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
<label for="note" class="col-md-2 control-label">{{ trans('admin/hardware/form.notes') }}</label> <form class="form-horizontal" method="post" action="" autocomplete="off">
<div class="col-md-7"> <!-- CSRF Token -->
<textarea class="col-md-6 form-control" id="note" name="note"> <input type="hidden" name="_token" value="{{ csrf_token() }}" />
{{ Input::old('note', $accessory->note) }}
</textarea> @if ($accessory->name)
{!! $errors->first('note', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!} <!-- accessory name -->
</div> <div class="form-group">
</div> <label class="col-sm-2 control-label">{{ trans('admin/hardware/form.name') }}</label>
<!-- Form actions --> <div class="col-md-6">
<div class="form-group"> <p class="form-control-static">{{ $accessory->name }}</p>
<label class="col-md-2 control-label"></label> </div>
<div class="col-md-7"> </div>
<a class="btn btn-link" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a> @endif
<button type="submit" class="btn btn-success"><i class="fa fa-check icon-white"></i>{{ trans('general.checkin') }}</button>
<!-- Note -->
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
<label for="note" class="col-md-2 control-label">{{ trans('admin/hardware/form.notes') }}</label>
<div class="col-md-7">
<textarea class="col-md-6 form-control" id="note" name="note">
{{ Input::old('note', $accessory->note) }}
</textarea>
{!! $errors->first('note', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
</div>
</div>
<!-- Form actions -->
<div class="form-group">
<label class="col-md-2 control-label"></label>
<div class="col-md-7">
<a class="btn btn-link" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>
<button type="submit" class="btn btn-success"><i class="fa fa-check icon-white"></i>{{ trans('general.checkin') }}</button>
</div>
</div>
</form>
</div> </div>
</div> <div class="box-footer text-right">
<button type="submit" class="btn btn-success"><i class="fa fa-check icon-white"></i> {{ trans('general.save') }}</button>
</form> </div>
</div> <!-- .col-md-10.column --> </div> <!-- .box.box-default -->
</div> <!-- .row.form-wrapper --> </form>
</div> <!-- .col-md-9-->
</div> <!-- .row -->
@stop @stop

View file

@ -2,7 +2,7 @@
{{-- Page title --}} {{-- Page title --}}
@section('title') @section('title')
{{ trans('admin/hardware/general.checkout') }} {{ trans('admin/accessories/general.checkout') }}
@parent @parent
@stop @stop
@section('header_right') @section('header_right')

View file

@ -57,15 +57,15 @@
name="accessory_users" name="accessory_users"
class="table table-striped snipe-table" class="table table-striped snipe-table"
id="table" id="table"
data-url="{{ route('api.accessories.show', $accessory->id) }}" data-url="{{ route('api.accessories.checkedout', $accessory->id) }}"
data-cookie="true" data-cookie="true"
data-click-to-select="true" data-click-to-select="true"
data-cookie-id-table="accessoryUsersTable" data-cookie-id-table="accessoryUsersTable"
> >
<thead> <thead>
<tr> <tr>
<th data-switchable="false" data-searchable="false" data-formatter="userLinkObjFormatter" data-sortable="false" data-field="name">{{ trans('general.user') }}</th> <th data-switchable="false" data-searchable="false" data-formatter="usersLinkFormatter" data-sortable="false" data-field="name">{{ trans('general.user') }}</th>
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions">{{ trans('table.actions') }}</th> <th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions" data-formatter="accessoriesInOutFormatter">{{ trans('table.actions') }}</th>
</tr> </tr>
</thead> </thead>
</table> </table>

View file

@ -87,8 +87,8 @@
&nbsp; &nbsp;</span> &nbsp; &nbsp;</span>
</span> </span>
@endif @endif
{{ $asset->present()->statusText() }} <a href="{{ route('statuslabels.show', $asset->assetstatus->id) }}">{{ $asset->present()->statusText() }}</a>
({{ $asset->assetstatus->getStatuslabelType() }}) <label class="label label-default">{{ $asset->assetstatus->getStatuslabelType() }}</label>
</td> </td>
</tr> </tr>
@endif @endif

View file

@ -139,7 +139,9 @@ $('.snipe-table').bootstrapTable({
// Use this when we're introspecting into a column object and need to link // Use this when we're introspecting into a column object and need to link
function genericColumnObjLinkFormatter(destination) { function genericColumnObjLinkFormatter(destination) {
return function (value,row) { return function (value,row) {
if ((value) && (value.name)) { if (value.status_type) {
return '<a href="{{ url('/') }}/' + destination + '/' + value.id + '"> ' + value.name + '</a> ' + '<label class="label label-default">'+ value.status_type + '</label>';
} else if ((value) && (value.name)) {
return '<a href="{{ url('/') }}/' + destination + '/' + value.id + '"> ' + value.name + '</a>'; return '<a href="{{ url('/') }}/' + destination + '/' + value.id + '"> ' + value.name + '</a>';
} }
}; };
@ -228,8 +230,14 @@ $('.snipe-table').bootstrapTable({
return '<div data-tooltip="true" title="This item has a status label that is undeployable and cannot be checked out at this time."><a class="btn btn-sm btn-primary disabled">{{ trans('general.checkout') }}</a></div>'; return '<div data-tooltip="true" title="This item has a status label that is undeployable and cannot be checked out at this time."><a class="btn btn-sm btn-primary disabled">{{ trans('general.checkout') }}</a></div>';
// The user is allowed to check items in // The user is allowed to check items in
} else if ((row.available_actions.checkin == true) && (row.assigned_to)) { } else if (row.available_actions.checkin == true) {
return '<nobr><a href="{{ url('/') }}/' + destination + '/' + row.id + '/checkin" class="btn btn-sm btn-primary" data-tooltip="true" title="Check this item in so it is available for re-imaging, re-issue, etc.">{{ trans('general.checkin') }}</a>'; if (row.assigned_to) {
return '<nobr><a href="{{ url('/') }}/' + destination + '/' + row.id + '/checkin" class="btn btn-sm btn-primary" data-tooltip="true" title="Check this item in so it is available for re-imaging, re-issue, etc.">{{ trans('general.checkin') }}</a>';
} else if (row.assigned_pivot_id) {
return '<nobr><a href="{{ url('/') }}/' + destination + '/' + row.assigned_pivot_id + '/checkin" class="btn btn-sm btn-primary" data-tooltip="true" title="Check this item in so it is available for re-imaging, re-issue, etc.">{{ trans('general.checkin') }}</a>';
}
} else {
} }