Updated MVC for #140, ability to assign software to asset (incomplete)

This commit is contained in:
snipe
2014-07-17 08:33:30 -04:00
parent 7d04ded02a
commit aa8bbb88e9
9 changed files with 140 additions and 41 deletions
+8 -1
View File
@@ -1,5 +1,6 @@
<?php namespace Controllers\Admin;
use Assets;
use AdminController;
use Input;
use Lang;
@@ -17,6 +18,7 @@ use Str;
use Validator;
use View;
class LicensesController extends AdminController
{
/**
@@ -44,6 +46,7 @@ class LicensesController extends AdminController
{
// Show the page
$license_options = array('0' => 'Top Level') + License::lists('name', 'id');
// Show the page
$depreciation_list = array('0' => Lang::get('admin/licenses/form.no_depreciation')) + Depreciation::lists('name', 'id');
return View::make('backend/licenses/edit')->with('license_options',$license_options)->with('depreciation_list',$depreciation_list)->with('license',new License);
@@ -79,6 +82,7 @@ class LicensesController extends AdminController
$license->purchase_date = e(Input::get('purchase_date'));
$license->purchase_cost = e(Input::get('purchase_cost'));
$license->depreciation_id = e(Input::get('depreciation_id'));
$license->asset_id = e(Input::get('asset_id'));
$license->user_id = Sentry::getId();
if (($license->purchase_date == "") || ($license->purchase_date == "0000-00-00")) {
@@ -182,6 +186,7 @@ class LicensesController extends AdminController
$license->notes = e(Input::get('notes'));
$license->order_number = e(Input::get('order_number'));
$license->depreciation_id = e(Input::get('depreciation_id'));
$license->asset_id = e(Input::get('asset_id'));
// Update the asset data
if ( e(Input::get('purchase_date')) == '') {
@@ -317,8 +322,10 @@ class LicensesController extends AdminController
// Get the dropdown of users and then pass it to the checkout view
$users_list = array('' => 'Select a User') + DB::table('users')->select(DB::raw('concat (first_name," ",last_name) as full_name, id'))->whereNull('deleted_at')->lists('full_name', 'id');
$asset_list = array('' => '') + Asset::orderBy('name', 'asc')->lists('name', 'id');
//print_r($users);
return View::make('backend/licenses/checkout', compact('licenseseat'))->with('users_list',$users_list);
return View::make('backend/licenses/checkout', compact('licenseseat'))->with('users_list',$users_list)->with('asset_list',$asset_list);
}
+45 -38
View File
@@ -14,72 +14,79 @@ class LicenseSeatsSeeder extends Seeder
$license_seats[] = array(
'license_id' => '1',
'assigned_to' => '1',
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'),
'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
);
$license_seats[] = array(
'license_id' => '1',
'assigned_to' => '0',
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
);
$license_seats[] = array(
'license_id' => '1',
'assigned_to' => '0',
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
);
$license_seats[] = array(
'license_id' => '1',
'assigned_to' => '0',
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
'asset_id' => '1',
);
$license_seats[] = array(
'license_id' => '1',
'assigned_to' => '2',
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'),
'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
'asset_id' => '2',
);
$license_seats[] = array(
'license_id' => '1',
'assigned_to' => '3',
'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'),
'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
'asset_id' => '3',
);
$license_seats[] = array(
'license_id' => '1',
'assigned_to' => '0',
'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'),
'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
'asset_id' => NULL,
);
$license_seats[] = array(
'license_id' => '1',
'assigned_to' => '2',
'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'),
'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
'asset_id' => NULL,
);
$license_seats[] = array(
'license_id' => '2',
'assigned_to' => '1',
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'),
'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
'asset_id' => NULL,
);
// Pending (status_id is null, assigned_to = 0)
$license_seats[] = array(
'license_id' => '2',
'assigned_to' => '0',
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'created_at' => $date->modify('-10 day')->format('Y-m-d H:i:s'),
'updated_at' => $date->modify('-3 day')->format('Y-m-d H:i:s'),
'deleted_at' => NULL,
'notes' => '',
'user_id' => '1',
'asset_id' => NULL,
);
+1
View File
@@ -2,6 +2,7 @@
return array(
'asset' => 'Asset',
'checkin' => 'Checkin',
'checkin' => 'Checkin',
'cost' => 'Purchase Cost',
+19
View File
@@ -149,6 +149,25 @@ class Asset extends Elegant
return $this->belongsTo('Model','model_id');
}
/**
* Get the license seat information
**/
public function licenseseats()
{
return $this->hasMany('LicenseSeat','id')->withTrashed();
}
/**
* Info on the license seat's parent licenses
* ?????????
**/
public function licenses()
{
return LicenseSeat::license();
// return $this->belongsTo('LicenseSeat','id')->withTrashed();
}
public function supplier()
{
return $this->belongsTo('Supplier','supplier_id');
-1
View File
@@ -24,7 +24,6 @@ class License extends Elegant
}
/**
* Get asset logs for this asset
*/
+5
View File
@@ -15,4 +15,9 @@ class LicenseSeat extends Elegant
return $this->belongsTo('User','assigned_to')->withTrashed();
}
public function asset()
{
return $this->belongsTo('Asset','asset_id')->withTrashed();
}
}
+42
View File
@@ -128,8 +128,50 @@
@endif
@if ($asset->licenses)
<div class="col-md-6"><strong>@lang('admin/hardware/form.licenses'): </strong>
{{{ $asset->licenses->id }}}
</div>
@endif
</div>
<!-- Licenses assets table -->
<h6>Software Assigned to {{{ $asset->name }}}</h6>
<br>
<!-- checked out assets table -->
@if (count($asset->licenseseats) > 0)
<table class="table table-hover">
<thead>
<tr>
<th class="col-md-4"><span class="line"></span>@lang('general.name')</th>
<th class="col-md-1"><span class="line"></span>@lang('table.actions')</th>
</tr>
</thead>
<tbody>
@foreach ($asset->licenseseats as $license)
<tr>
<td><a href="{{ route('view/license', $license->license_id) }}">{{{ $license->license_id->license()->name }}}</a></td>
<td> <a href="{{ route('checkin/license', $license->id) }}" class="btn-flat info">@lang('general.checkin')</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<div class="col-md-12">
<div class="alert alert-info alert-block">
<i class="icon-info-sign"></i>
@lang('general.no_results')
</div>
</div>
@endif
<!-- checked out assets table -->
@@ -54,6 +54,17 @@
</div>
</div>
<!-- Asset -->
<div class="form-group {{ $errors->has('asset_id') ? ' has-error' : '' }}">
<label for="asset_id" class="col-md-2 control-label">@lang('admin/licenses/form.asset')
</label>
</label>
<div class="col-md-7">
{{ Form::select('asset_id', $asset_list , Input::old('asset_id', $licenseseat->asset_id), array('class'=>'select2', 'style'=>'min-width:350px')) }}
{{ $errors->first('asset_id', '<span class="alert-msg"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
<!-- Note -->
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
<label for="note" class="col-md-2 control-label">@lang('admin/hardware/form.notes')</label>
+9 -1
View File
@@ -69,7 +69,8 @@
<thead>
<tr>
<th class="col-md-2">@lang('admin/licenses/general.seat')</th>
<th class="col-md-6">@lang('admin/licenses/general.user')</th>
<th class="col-md-2">@lang('admin/licenses/general.user')</th>
<th class="col-md-4">@lang('admin/licenses/form.asset')</th>
<th class="col-md-2"></th>
</tr>
</thead>
@@ -88,6 +89,13 @@
@endif
</td>
<td>
@if ($licensedto->asset_id)
<a href="{{ route('view/hardware', $licensedto->asset_id) }}">
{{ $licensedto->asset->name }} {{ $licensedto->asset->asset_tag }}
</a>
@endif
</td>
<td>
@if ($licensedto->assigned_to)
<a href="{{ route('checkin/license', $licensedto->id) }}" class="btn-flat info"> @lang('general.checkin') </a>
@else