Skip to content

Commit

Permalink
More license tweaks - view blade, asset log
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Nov 25, 2013
1 parent faae6a2 commit 0d91848
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 78 deletions.
26 changes: 13 additions & 13 deletions app/controllers/admin/LicensesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ public function getCheckout($assetId)
/**
* Check out the asset to a person
**/
public function postCheckout($assetId)
public function postCheckout($seatId)
{
// Check if the asset exists
if (is_null($license = License::find($assetId)))
if (is_null($licenseseat = LicenseSeat::find($seatId)))
{
// Redirect to the asset management page with error
return Redirect::to('admin/licenses')->with('error', Lang::get('admin/assets/message.not_found'));
return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.not_found'));
}

$assigned_to = e(Input::get('assigned_to'));
Expand Down Expand Up @@ -277,15 +277,15 @@ public function postCheckout($assetId)


// Update the asset data
$license->assigned_to = e(Input::get('assigned_to'));
$licenseseat->assigned_to = e(Input::get('assigned_to'));


// Was the asset updated?
if($license->save())
if($licenseseat->save())
{
$logaction = new Actionlog();
$logaction->asset_id = $license->id;
$logaction->checkedout_to = $license->assigned_to;
$logaction->asset_id = $licenseseat->id;
$logaction->checkedout_to = $licenseseat->assigned_to;
$logaction->location_id = $assigned_to->location_id;
$logaction->asset_type = 'software';
$logaction->user_id = Sentry::getUser()->id;
Expand All @@ -302,25 +302,25 @@ public function postCheckout($assetId)
/**
* Check in the item so that it can be checked out again to someone else
**/
public function postCheckin($assetId)
public function postCheckin($seatId)
{
// Check if the asset exists
if (is_null($license = License::find($assetId)))
if (is_null($licenseseat = LicenseSeat::find($seatId)))
{
// Redirect to the asset management page with error
return Redirect::to('admin/licenses')->with('error', Lang::get('admin/assets/message.not_found'));
}

$logaction = new Actionlog();
$logaction->checkedout_to = $license->assigned_to;
$logaction->checkedout_to = $licenseseat->assigned_to;

// Update the asset data
$license->assigned_to = '';
$licenseseat->assigned_to = '';

// Was the asset updated?
if($license->save())
if($licenseseat->save())
{
$logaction->asset_id = $license->id;
$logaction->asset_id = $licenseseat->id;
$logaction->location_id = NULL;
$logaction->asset_type = 'software';
$logaction->user_id = Sentry::getUser()->id;
Expand Down
6 changes: 5 additions & 1 deletion app/models/Actionlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ class ActionLog extends Eloquent {


public function assetlog() {
return $this->belongsTo('Asset','asset_id')->withTrashed();
return $this->belongsTo('Asset','asset_id');
}

public function licenselog() {
return $this->belongsTo('License','asset_id');
}

public function adminlog() {
Expand Down
2 changes: 1 addition & 1 deletion app/models/License.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function assetloc()
public function assetlog()
{
return $this->hasMany('Actionlog','asset_id')
->where('checkedout_to', '=', '0')
->where('asset_type', '=', 'software')
->orderBy('added_on', 'desc');
}

Expand Down
117 changes: 54 additions & 63 deletions app/views/backend/licenses/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,53 @@
</div>
</h3>

<div class="row-fluid profile">
<!-- bio, new note & orders column -->
<div class="span9 bio">
<div class="profile-box">
<br>
<!-- checked out assets table -->

<div class="span6 bio">
<div class="profile-box">
<br>
@if ($license->serial)
<p>Serial: {{ $license->serial }} <br>
@endif
@if ($license->license_name)
License Name: {{ $license->license_name }} <br>
@endif
@if ($license->license_email)
License Email: {{ $license->license_email }} <br>
@endif
@if ($license->purchase_date)
Purchase Date: {{ $license->purchase_date }} <br>
@endif
</p>
</div>
</div>
<h6>License Seats</h6>
<table class="table table-hover">
<thead>
<tr>


<th class="span6">User</th>
<th class="span2"><span class="line"></span> </th>
</tr>
</thead>
<tbody>
@if ($license->licenseseats)
@foreach ($license->licenseseats as $licensedto)

<tr>

<td>
@if ($licensedto->assigned_to)
<a href="{{ route('view/user', $licensedto->id) }}">
{{ $licensedto->user->fullName() }}
</a>
@endif
</td>
<td>
@if ($licensedto->assigned_to)
<a href="{{ route('checkin/license', $licensedto->id) }}" class="btn-flat info"> Checkin </a>
@else
<a href="{{ route('checkout/license', $licensedto->id) }}" class="btn-flat success">Checkout</a>
@endif
</td>

</tr>
@endforeach
@endif

<div class="row-fluid profile">
<!-- bio, new note & orders column -->
<div class="span9 bio">
<div class="profile-box">
<br>
<!-- checked out assets table -->

</tbody>
</table>
<br>
<h6>Checkout History</h6>

<table class="table table-hover">
<thead>
Expand Down Expand Up @@ -90,11 +106,13 @@
<td>{{ $log->action_type }}</td>

<td>
@if (isset($log->checkedout_to->id))
@if (isset($log->checkedout_to))
<a href="{{ route('view/user', $log->checkedout_to) }}">
{{ $log->userlog->fullName() }}

</a>
@endif

</td>
</tr>
@endforeach
Expand Down Expand Up @@ -122,48 +140,21 @@

<!-- side address column -->
<div class="span3 address pull-right">



@if ((isset($license->assigned_to ) && ($license->assigned_to > 0)))
<h6><br>Checked Out To:</h6>
<h6><br>License Info:</h6>
<ul>

<li><img src="{{ $license->assigneduser->gravatar() }}" class="img-circle" style="width: 100px; margin-right: 20px;" /><br /><br /></li>
<li><a href="{{ route('view/user', $license->assigned_to) }}">{{ $license->assigneduser->fullName() }}</a></li>


@if (isset($license->assetloc->address))
<li>{{ $license->assetloc->address }}
@if (isset($license->assetloc->address2))
{{ $license->assetloc->address2 }}
@endif
</li>
@if (isset($license->assetloc->city))
<li>{{ $license->assetloc->city }}, {{ $license->assetloc->state }} {{ $license->assetloc->zip }}</li>
@endif

@if ($license->serial)
<li>Serial: {{ $license->serial }} </li>
@endif



@if (isset($license->assigneduser->email))
<li><br /><i class="icon-envelope-alt"></i> <a href="mailto:{{ $license->assigneduser->email }}">{{ $license->assigneduser->email }}</a></li>
@if ($license->license_name)
<li>License Name: {{ $license->license_name }} </li>
@endif

@if (isset($license->assigneduser->phone))
<li><i class="icon-phone"></i> {{ $license->assigneduser->phone }}</li>
@if ($license->license_email)
<li>License Email: {{ $license->license_email }} </li>
@endif
@if ($license->purchase_date)
<li>Purchase Date: {{ $license->purchase_date }} </li>
@endif

<li><br /><a href="{{ route('checkin/license', $license->id) }}" class="btn-flat large info ">Checkin Asset</a></li>
</ul>

@else
<ul>
<li><br><br />This asset is not currently assigned to anyone. You may check it into inventory
using the button below, or mark it as lost/stolen using the menu above.</li>
<li><br><br /><a href="{{ route('checkout/license', $license->id) }}" class="btn-flat large success">Checkout Asset</a></li>
</ul>
@endif

</div>
@stop

0 comments on commit 0d91848

Please sign in to comment.