Merge branch 'refs/heads/develop'

This commit is contained in:
snipe
2013-11-27 02:41:04 -05:00
16 changed files with 318 additions and 69 deletions
+25 -8
View File
@@ -278,9 +278,6 @@ class AssetsController 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'))->lists('full_name', 'id');
//print_r($users);
return View::make('backend/assets/checkout', compact('asset'))->with('users_list',$users_list);
@@ -303,7 +300,8 @@ class AssetsController extends AdminController {
// Declare the rules for the form validation
$rules = array(
'assigned_to' => 'required|min:1'
'assigned_to' => 'required|min:1',
'note' => 'alpha_space',
);
// Create a new validator instance from our validation rules
@@ -336,10 +334,9 @@ class AssetsController extends AdminController {
$logaction->asset_type = 'hardware';
$logaction->location_id = $assigned_to->location_id;
$logaction->user_id = Sentry::getUser()->id;
$logaction->note = e(Input::get('note'));
$log = $logaction->logaction('checkout');
// Redirect to the new asset page
return Redirect::to("admin")->with('success', Lang::get('admin/assets/message.checkout.success'));
}
@@ -348,6 +345,26 @@ class AssetsController extends AdminController {
return Redirect::to("assets/$assetId/checkout")->with('error', Lang::get('admin/assets/message.checkout.error'));
}
/**
* Check the asset back into inventory
*
* @param int $assetId
* @return View
**/
public function getCheckin($assetId)
{
// Check if the asset exists
if (is_null($asset = Asset::find($assetId)))
{
// Redirect to the asset management page with error
return Redirect::to('admin')->with('error', Lang::get('admin/assets/message.not_found'));
}
return View::make('backend/assets/checkin', compact('asset'));
}
/**
* Check in the item so that it can be checked out again to someone else
*
@@ -371,16 +388,16 @@ class AssetsController extends AdminController {
$logaction->checkedout_to = $asset->assigned_to;
// Update the asset data to null, since it's being checked in
$asset->assigned_to = '';
$asset->assigned_to = '0';
// Was the asset updated?
if($asset->save())
{
$logaction->asset_id = $asset->id;
$logaction->location_id = NULL;
$logaction->asset_type = 'hardware';
$logaction->note = e(Input::get('note'));
$logaction->user_id = Sentry::getUser()->id;
$log = $logaction->logaction('checkin from');
+40 -7
View File
@@ -258,7 +258,8 @@ class LicensesController extends AdminController {
// Declare the rules for the form validation
$rules = array(
'assigned_to' => 'required|integer|min:1'
'assigned_to' => 'required|integer|min:1',
'note' => 'alpha_space',
);
// Create a new validator instance from our validation rules
@@ -293,6 +294,7 @@ class LicensesController extends AdminController {
$logaction->location_id = $assigned_to->location_id;
$logaction->asset_type = 'software';
$logaction->user_id = Sentry::getUser()->id;
$logaction->note = e(Input::get('note'));
$log = $logaction->logaction('checkout');
// Redirect to the new asset page
@@ -303,6 +305,24 @@ class LicensesController extends AdminController {
return Redirect::to('admin/licenses/$assetId/checkout')->with('error', Lang::get('admin/licenses/message.create.error'))->with('license',new License);
}
/**
* Check the license back into inventory
**/
public function getCheckin($seatId)
{
// Check if the asset exists
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/licenses/message.not_found'));
}
return View::make('backend/licenses/checkin', compact('licenseseat'));
}
/**
* Check in the item so that it can be checked out again to someone else
**/
@@ -315,11 +335,26 @@ class LicensesController extends AdminController {
return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.not_found'));
}
// Declare the rules for the form validation
$rules = array(
'note' => 'alpha_space',
);
// Create a new validator instance from our validation rules
$validator = Validator::make(Input::all(), $rules);
// If validation fails, we'll exit the operation now.
if ($validator->fails())
{
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($validator);
}
$logaction = new Actionlog();
$logaction->checkedout_to = $licenseseat->assigned_to;
// Update the asset data
$licenseseat->assigned_to = '';
$licenseseat->assigned_to = '0';
// Was the asset updated?
if($licenseseat->save())
@@ -327,14 +362,15 @@ class LicensesController extends AdminController {
$logaction->asset_id = $licenseseat->id;
$logaction->location_id = NULL;
$logaction->asset_type = 'software';
$logaction->note = e(Input::get('note'));
$logaction->user_id = Sentry::getUser()->id;
$log = $logaction->logaction('checkin from');
// Redirect to the new asset page
// Redirect to the license page
return Redirect::to("admin/licenses")->with('success', Lang::get('admin/licenses/message.checkin.success'));
}
// Redirect to the asset management page with error
// Redirect to the license page with error
return Redirect::to("admin/licenses")->with('error', Lang::get('admin/licenses/message.checkin.error'));
}
@@ -357,10 +393,7 @@ class LicensesController extends AdminController {
// Redirect to the user management page
return Redirect::route('licenses')->with('error', $error);
}
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
class AddNoteToAssetLogsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::table('asset_logs', function($table)
{
$table->text('note')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::table('asset_logs', function($table)
{
$table->dropColumn('note');
});
}
}
+28 -24
View File
@@ -13,46 +13,50 @@ class ActionlogSeeder extends Seeder {
// Pending (status_id is null, assigned_to = 0)
$assetlog[] = array(
'user_id' => '1',
'user_id' => '1',
'action_type' => 'checkout',
'asset_id' => '1',
'checkedout_to' => '3',
'location_id' => '3',
'added_on' => $date->modify('-10 day'),
'asset_type' => 'hardware',
'asset_id' => '1',
'checkedout_to' => '3',
'location_id' => '3',
'added_on' => $date->modify('-10 day'),
'asset_type' => 'hardware',
'note' => NULL,
);
// Pending (status_id is null, assigned_to = 0)
$assetlog[] = array(
'user_id' => '1',
'user_id' => '1',
'action_type' => 'checkin from',
'asset_id' => '1',
'checkedout_to' => '3',
'location_id' => NULL,
'added_on' => $date->modify('-10 day'),
'asset_type' => 'hardware',
'asset_id' => '1',
'checkedout_to' => '3',
'location_id' => NULL,
'added_on' => $date->modify('-10 day'),
'asset_type' => 'hardware',
'note' => NULL,
);
// Pending (status_id is null, assigned_to = 0)
$assetlog[] = array(
'user_id' => '1',
'user_id' => '1',
'action_type' => 'checkout',
'asset_id' => '1',
'checkedout_to' => '3',
'location_id' => '3',
'added_on' => $date->modify('-10 day'),
'asset_type' => 'software',
'asset_id' => '1',
'checkedout_to' => '3',
'location_id' => '3',
'added_on' => $date->modify('-10 day'),
'asset_type' => 'software',
'note' => NULL,
);
// Pending (status_id is null, assigned_to = 0)
$assetlog[] = array(
'user_id' => '1',
'user_id' => '1',
'action_type' => 'checkin from',
'asset_id' => '1',
'checkedout_to' => '3',
'location_id' => NULL,
'added_on' => $date->modify('-10 day'),
'asset_type' => 'software',
'asset_id' => '1',
'checkedout_to' => '3',
'location_id' => NULL,
'added_on' => $date->modify('-10 day'),
'asset_type' => 'software',
'note' => NULL,
);
+1
View File
@@ -7,6 +7,7 @@ return array(
'currency' => '$',
'save' => 'Save',
'checkout' => 'Checkout',
'checkin' => 'Checkin',
'cancel' => 'Cancel'
);
+1
View File
@@ -10,6 +10,7 @@ class Asset extends Elegant {
'model_id' => 'required',
'serial' => 'required|alpha_dash|min:3',
'warranty_months' => 'integer|min:1',
'note' => 'alpha_space',
);
+1
View File
@@ -16,6 +16,7 @@ class License extends Elegant {
'serial' => 'required|alpha_dash|min:5',
'seats' => 'required|min:1|integer',
'license_email' => 'email',
'note' => 'alpha_space',
);
public function assignedusers()
+4 -2
View File
@@ -37,7 +37,8 @@ Route::group(array('prefix' => 'assets'), function()
Route::get('{assetId}/delete', array('as' => 'delete/asset', 'uses' => 'Controllers\Admin\AssetsController@getDelete'));
Route::get('{assetId}/checkout', array('as' => 'checkout/asset', 'uses' => 'Controllers\Admin\AssetsController@getCheckout'));
Route::post('{assetId}/checkout', 'Controllers\Admin\AssetsController@postCheckout');
Route::get('{assetId}/checkin', array('as' => 'checkin/asset', 'uses' => 'Controllers\Admin\AssetsController@postCheckin'));
Route::get('{assetId}/checkin', array('as' => 'checkin/asset', 'uses' => 'Controllers\Admin\AssetsController@getCheckin'));
Route::post('{assetId}/checkin', 'Controllers\Admin\AssetsController@postCheckin');
Route::get('{assetId}/view', array('as' => 'view/asset', 'uses' => 'Controllers\Admin\AssetsController@getView'));
@@ -70,7 +71,8 @@ Route::group(array('prefix' => 'admin'), function()
Route::get('{licenseId}/delete', array('as' => 'delete/license', 'uses' => 'Controllers\Admin\LicensesController@getDelete'));
Route::get('{licenseId}/checkout', array('as' => 'checkout/license', 'uses' => 'Controllers\Admin\LicensesController@getCheckout'));
Route::post('{licenseId}/checkout', 'Controllers\Admin\LicensesController@postCheckout');
Route::get('{licenseId}/checkin', array('as' => 'checkin/license', 'uses' => 'Controllers\Admin\LicensesController@postCheckin'));
Route::get('{licenseId}/checkin', array('as' => 'checkin/license', 'uses' => 'Controllers\Admin\LicensesController@getCheckin'));
Route::post('{licenseId}/checkin', 'Controllers\Admin\LicensesController@postCheckin');
Route::get('{licenseId}/view', array('as' => 'view/license', 'uses' => 'Controllers\Admin\LicensesController@getView'));
});
+1 -1
View File
@@ -2,5 +2,5 @@
Validator::extend('alpha_space', function($attribute,$value,$parameters)
{
return preg_match("/^[-_,. a-zA-Z0-9]+$/",$value);
return preg_match("/^[-_,!. a-zA-Z0-9]+$/",$value);
});
@@ -0,0 +1,66 @@
@extends('backend/layouts/default')
{{-- Page title --}}
@section('title')
@if ($asset->id)
Checkin Asset ::
@else
Checkin Asset ::
@endif
@parent
@stop
{{-- Page content --}}
@section('content')
<div class="page-header">
<h3>
Checkin Asset
<div class="pull-right">
<a href="{{ route('assets') }}" class="btn-flat gray"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
</div>
</h3>
</div>
<form class="form-horizontal" method="post" action="" autocomplete="off">
<!-- CSRF Token -->
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<!-- Asset Tag -->
<div class="control-group">
<label class="control-label" for="asset_tag">Asset Tag</label>
<div class="controls">
<input class="span4" readonly="readonly" type="text" name="asset_tag" id="asset_tag" value="{{ $asset->asset_tag }}" />
</div>
</div>
<!-- Asset Name -->
<div class="control-group">
<label class="control-label" for="name">Asset Name</label>
<div class="controls">
<input class="span4" readonly="readonly" type="text" name="name" id="asset_name" value="{{ $asset->name }}" />
</div>
</div>
<!-- Notes -->
<div class="control-group {{ $errors->has('note') ? 'error' : '' }}">
<label class="control-label" for="note">Notes</label>
<div class="controls">
<input class="span6" type="text" name="note" id="note" value="{{ Input::old('note', $asset->note) }}" />
{{ $errors->first('note', '<span class="help-inline"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
<!-- Form actions -->
<div class="control-group">
<div class="controls">
<a class="btn btn-link" href="{{ route('assets') }}">@lang('general.cancel')</a>
<button type="submit" class="btn-flat success"><i class="icon-ok icon-white"></i>@lang('general.checkin')</button>
</div>
</div>
</form>
@stop
+10 -1
View File
@@ -21,7 +21,7 @@
@endif
<div class="pull-right">
<a href="{{ route('assets') }}" class="btn btn-small btn-inverse"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
<a href="{{ route('assets') }}" class="btn-flat gray"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
</div>
</h3>
</div>
@@ -62,6 +62,15 @@
</div>
</div>
<!-- Notes -->
<div class="control-group {{ $errors->has('note') ? 'error' : '' }}">
<label class="control-label" for="note">Notes</label>
<div class="controls">
<input class="span6" type="text" name="note" id="note" value="{{ Input::old('notes', $asset->note) }}" />
{{ $errors->first('note', '<span class="help-inline"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
</div>
<!-- Form actions -->
+1 -1
View File
@@ -125,7 +125,7 @@
</div>
</div>
<!-- Depreciation -->
<!-- Status -->
<div class="control-group {{ $errors->has('status_id') ? 'error' : '' }}">
<label class="control-label" for="parent">Status</label>
<div class="controls">
+10 -6
View File
@@ -42,9 +42,10 @@ View Asset {{ $asset->asset_tag }} ::
<tr>
<th class="span1"></th>
<th class="span3"><span class="line"></span>Date</th>
<th class="span3"><span class="line"></span>Admin</th>
<th class="span3"><span class="line"></span>Action</th>
<th class="span3"><span class="line"></span>User</th>
<th class="span2"><span class="line"></span>Admin</th>
<th class="span2"><span class="line"></span>Action</th>
<th class="span2"><span class="line"></span>User</th>
<th class="span3"><span class="line"></span>Note</th>
</tr>
</thead>
<tbody>
@@ -63,7 +64,6 @@ View Asset {{ $asset->asset_tag }} ::
@endif
</td>
<td>{{ $log->action_type }}</td>
<td>
@if (isset($log->checkedout_to))
<a href="{{ route('view/user', $log->checkedout_to) }}">
@@ -71,6 +71,11 @@ View Asset {{ $asset->asset_tag }} ::
</a>
@endif
</td>
<td>
@if ($log->note)
{{ $log->note }}
@endif
</td>
</tr>
@endforeach
@endif
@@ -86,8 +91,7 @@ View Asset {{ $asset->asset_tag }} ::
</td>
<td>created asset</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
@@ -0,0 +1,69 @@
@extends('backend/layouts/default')
{{-- Page title --}}
@section('title')
Checkin License
@parent
@stop
{{-- Page content --}}
@section('content')
<div class="page-header">
<h3>Checkin License</h3>
<div class="pull-right">
<a href="{{ route('assets') }}" class="btn-flat gray"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
</div>
</h3>
</div>
<form class="form-horizontal" method="post" action="" autocomplete="off">
<!-- CSRF Token -->
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<!-- Asset Tag -->
<div class="control-group">
<label class="control-label" for="asset_tag">Asset Tag</label>
<div class="controls">
<input class="span4" readonly="readonly" type="text" name="asset_tag" id="asset_tag" value="{{ $licenseseat->license->asset_tag }}" />
</div>
</div>
<!-- Asset Name -->
<div class="control-group">
<label class="control-label" for="name">Asset Name</label>
<div class="controls">
<input class="span4" readonly="readonly" type="text" name="name" id="asset_name" value="{{ $licenseseat->license->name }}" />
</div>
</div>
<!-- Serial -->
<div class="control-group">
<label class="control-label" for="serial">Serial</label>
<div class="controls">
<input class="span4" readonly="readonly" type="text" name="serial" id="serial" value="{{ $licenseseat->license->serial }}" />
</div>
</div>
<!-- Notes -->
<div class="control-group {{ $errors->has('note') ? 'error' : '' }}">
<label class="control-label" for="note">Notes</label>
<div class="controls">
<input class="span6" type="text" name="note" id="note" value="{{ Input::old('note', $licenseseat->note) }}" />
{{ $errors->first('note', '<span class="help-inline"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
<!-- Form actions -->
<div class="control-group">
<div class="controls">
<a class="btn btn-link" href="{{ route('licenses') }}">@lang('general.cancel')</a>
<button type="submit" class="btn-flat success">@lang('general.checkin')</button>
</div>
</div>
</form>
@stop
+17 -17
View File
@@ -12,21 +12,15 @@
<h3>Checkout License to User</h3>
<div class="pull-right">
<a href="{{ route('assets') }}" class="btn btn-small btn-inverse"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
<a href="{{ route('assets') }}" class="btn-flat gray"><i class="icon-circle-arrow-left icon-white"></i> Back</a>
</div>
</h3>
</div>
<form class="form-horizontal" method="post" action="" autocomplete="off">
<!-- CSRF Token -->
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<!-- Tabs Content -->
<div class="tab-content">
<div class="tab-pane active" id="tab-general">
<!-- Asset Tag -->
<div class="control-group">
<label class="control-label" for="asset_tag">Asset Tag</label>
@@ -42,7 +36,7 @@
<input class="span4" readonly="readonly" type="text" name="name" id="asset_name" value="{{ $licenseseat->license->name }}" />
</div>
</div>
<!-- Asset Name -->
<!-- Serial -->
<div class="control-group">
<label class="control-label" for="serial">Serial</label>
<div class="controls">
@@ -50,7 +44,6 @@
</div>
</div>
<!-- User -->
<div class="control-group {{ $errors->has('assigned_to') ? 'error' : '' }}">
<label class="control-label" for="parent">Checkout to</label>
@@ -60,15 +53,22 @@
</div>
</div>
</div>
<!-- Notes -->
<div class="control-group {{ $errors->has('note') ? 'error' : '' }}">
<label class="control-label" for="note">Notes</label>
<div class="controls">
<input class="span6" type="text" name="note" id="note" value="{{ Input::old('notes', $licenseseat->note) }}" />
{{ $errors->first('note', '<span class="help-inline"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
<!-- Form actions -->
<div class="control-group">
<div class="controls">
<a class="btn btn-link" href="{{ route('licenses') }}">@lang('general.cancel')</a>
<button type="submit" class="btn-flat success">@lang('general.checkout')</button>
</div>
</div>
<!-- Form actions -->
<div class="control-group">
<div class="controls">
<a class="btn btn-link" href="{{ route('licenses') }}">@lang('general.cancel')</a>
<button type="submit" class="btn-flat success">@lang('general.checkout')</button>
</div>
</div>
</form>
+8 -2
View File
@@ -87,7 +87,8 @@ View License {{ $license->name }} ::
<th class="span3"><span class="line"></span>Date</th>
<th class="span3"><span class="line"></span>Admin</th>
<th class="span3"><span class="line"></span>Action</th>
<th class="span3"><span class="line"></span>User</th>
<th class="span3"><span class="line"></span>User</th>
<th class="span3"><span class="line"></span>Note</th>
</tr>
</thead>
<tbody>
@@ -114,7 +115,11 @@ View License {{ $license->name }} ::
</a>
@endif
</td>
<td>
@if ($log->note)
{{ $log->note }}
@endif
</td>
</tr>
@endforeach
@@ -131,6 +136,7 @@ View License {{ $license->name }} ::
</td>
<td>created asset</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>