From af69467bea2d4272877a7b4a34482162fa3246a3 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 27 Nov 2013 01:29:57 -0500 Subject: [PATCH 1/2] Added notes to log table --- ...27_062510_add_note_to_asset_logs_table.php | 36 +++++++++++++ app/database/seeds/ActionlogSeeder.php | 52 ++++++++++--------- 2 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 app/database/migrations/2013_11_27_062510_add_note_to_asset_logs_table.php diff --git a/app/database/migrations/2013_11_27_062510_add_note_to_asset_logs_table.php b/app/database/migrations/2013_11_27_062510_add_note_to_asset_logs_table.php new file mode 100644 index 0000000000..5e5c398bb3 --- /dev/null +++ b/app/database/migrations/2013_11_27_062510_add_note_to_asset_logs_table.php @@ -0,0 +1,36 @@ +text('note')->nullable(); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::table('asset_logs', function($table) + { + $table->dropColumn('note'); + }); + } + +} \ No newline at end of file diff --git a/app/database/seeds/ActionlogSeeder.php b/app/database/seeds/ActionlogSeeder.php index 443a438004..12293429d8 100644 --- a/app/database/seeds/ActionlogSeeder.php +++ b/app/database/seeds/ActionlogSeeder.php @@ -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, ); From aa38d83ba6369215451d905e599492214e9f4b8b Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 27 Nov 2013 02:38:16 -0500 Subject: [PATCH 2/2] Fixes #63 and #70 --- app/controllers/admin/AssetsController.php | 33 ++++++--- app/controllers/admin/LicensesController.php | 47 +++++++++++-- app/lang/en/general.php | 1 + app/models/Asset.php | 1 + app/models/License.php | 1 + app/routes.php | 6 +- app/validators.php | 2 +- app/views/backend/assets/checkin.blade.php | 66 ++++++++++++++++++ app/views/backend/assets/checkout.blade.php | 11 ++- app/views/backend/assets/edit.blade.php | 2 +- app/views/backend/assets/view.blade.php | 16 +++-- app/views/backend/licenses/checkin.blade.php | 69 +++++++++++++++++++ app/views/backend/licenses/checkout.blade.php | 34 ++++----- app/views/backend/licenses/view.blade.php | 10 ++- 14 files changed, 254 insertions(+), 45 deletions(-) create mode 100644 app/views/backend/assets/checkin.blade.php create mode 100644 app/views/backend/licenses/checkin.blade.php diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index ba83802acf..0c2fbf4d9f 100644 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -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'); diff --git a/app/controllers/admin/LicensesController.php b/app/controllers/admin/LicensesController.php index b022ba3be7..c6dcd6f453 100644 --- a/app/controllers/admin/LicensesController.php +++ b/app/controllers/admin/LicensesController.php @@ -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); } - - } - } diff --git a/app/lang/en/general.php b/app/lang/en/general.php index 4494daefdd..eeb0dbd10f 100755 --- a/app/lang/en/general.php +++ b/app/lang/en/general.php @@ -7,6 +7,7 @@ return array( 'currency' => '$', 'save' => 'Save', 'checkout' => 'Checkout', + 'checkin' => 'Checkin', 'cancel' => 'Cancel' ); diff --git a/app/models/Asset.php b/app/models/Asset.php index db01fba4e5..d156a403c5 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -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', ); diff --git a/app/models/License.php b/app/models/License.php index 3cbc405303..8a6e7a1aef 100644 --- a/app/models/License.php +++ b/app/models/License.php @@ -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() diff --git a/app/routes.php b/app/routes.php index befc84b117..af222ba1ce 100755 --- a/app/routes.php +++ b/app/routes.php @@ -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')); }); diff --git a/app/validators.php b/app/validators.php index 8b53512d3e..2232752018 100644 --- a/app/validators.php +++ b/app/validators.php @@ -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); }); diff --git a/app/views/backend/assets/checkin.blade.php b/app/views/backend/assets/checkin.blade.php new file mode 100644 index 0000000000..6b0a19e4e0 --- /dev/null +++ b/app/views/backend/assets/checkin.blade.php @@ -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') + + +
+ + + + + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ + {{ $errors->first('note', ' :message') }} +
+
+ + +
+
+ @lang('general.cancel') + +
+
+ +
+ + +@stop diff --git a/app/views/backend/assets/checkout.blade.php b/app/views/backend/assets/checkout.blade.php index 3db6fcc756..a17445056c 100644 --- a/app/views/backend/assets/checkout.blade.php +++ b/app/views/backend/assets/checkout.blade.php @@ -21,7 +21,7 @@ @endif @@ -62,6 +62,15 @@ + +
+ +
+ + {{ $errors->first('note', ' :message') }} +
+
+ diff --git a/app/views/backend/assets/edit.blade.php b/app/views/backend/assets/edit.blade.php index f62f525270..f672ce8d4a 100755 --- a/app/views/backend/assets/edit.blade.php +++ b/app/views/backend/assets/edit.blade.php @@ -125,7 +125,7 @@ - +
diff --git a/app/views/backend/assets/view.blade.php b/app/views/backend/assets/view.blade.php index f37e018e24..098c556e15 100644 --- a/app/views/backend/assets/view.blade.php +++ b/app/views/backend/assets/view.blade.php @@ -42,9 +42,10 @@ View Asset {{ $asset->asset_tag }} :: Date - Admin - Action - User + Admin + Action + User + Note @@ -63,7 +64,6 @@ View Asset {{ $asset->asset_tag }} :: @endif {{ $log->action_type }} - @if (isset($log->checkedout_to)) @@ -71,6 +71,11 @@ View Asset {{ $asset->asset_tag }} :: @endif + + @if ($log->note) + {{ $log->note }} + @endif + @endforeach @endif @@ -86,8 +91,7 @@ View Asset {{ $asset->asset_tag }} :: created asset - - + diff --git a/app/views/backend/licenses/checkin.blade.php b/app/views/backend/licenses/checkin.blade.php new file mode 100644 index 0000000000..c60b2d60fa --- /dev/null +++ b/app/views/backend/licenses/checkin.blade.php @@ -0,0 +1,69 @@ +@extends('backend/layouts/default') + +{{-- Page title --}} +@section('title') + Checkin License +@parent +@stop + +{{-- Page content --}} +@section('content') + + + +
+ + + + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ +
+ + {{ $errors->first('note', ' :message') }} +
+
+ + + + +
+
+ @lang('general.cancel') + +
+
+
+ + +@stop diff --git a/app/views/backend/licenses/checkout.blade.php b/app/views/backend/licenses/checkout.blade.php index cfbce63fbd..4422b57633 100644 --- a/app/views/backend/licenses/checkout.blade.php +++ b/app/views/backend/licenses/checkout.blade.php @@ -12,21 +12,15 @@

Checkout License to User

-
- -
- -
-
@@ -42,7 +36,7 @@
- +
@@ -50,7 +44,6 @@
-
@@ -60,15 +53,22 @@
-
+ +
+ +
+ + {{ $errors->first('note', ' :message') }} +
+
- -
-
- @lang('general.cancel') - -
-
+ +
+
+ @lang('general.cancel') + +
+
diff --git a/app/views/backend/licenses/view.blade.php b/app/views/backend/licenses/view.blade.php index 91a2df42dc..4c0faa82ca 100644 --- a/app/views/backend/licenses/view.blade.php +++ b/app/views/backend/licenses/view.blade.php @@ -87,7 +87,8 @@ View License {{ $license->name }} :: Date Admin Action - User + User + Note @@ -114,7 +115,11 @@ View License {{ $license->name }} :: @endif - + + + @if ($log->note) + {{ $log->note }} + @endif @endforeach @@ -131,6 +136,7 @@ View License {{ $license->name }} :: created asset +