From 02e5333101f4d3f829402738a9a972d02b151970 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 08:21:12 -0500 Subject: [PATCH 01/14] Add address fields to Location edit form --- app/models/Location.php | 4 +++- app/views/backend/locations/edit.blade.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/models/Location.php b/app/models/Location.php index 22e55e4b12..a7053358b1 100644 --- a/app/models/Location.php +++ b/app/models/Location.php @@ -7,10 +7,12 @@ class Location extends Elegant { protected $table = 'locations'; protected $rules = array( 'name' => 'required|alpha_space|min:3', + 'address' => 'required|alpha_space|min:5', + 'address2' => 'optional|alpha_space|min:5', 'city' => 'required|alpha_space|min:3', 'state' => 'required|alpha|min:2|max:2', 'country' => 'required|alpha|min:2|max:2', - 'zip' => 'alpha_dash|min:5', + 'zip' => 'alpha_dash|min:5', ); public function has_users() diff --git a/app/views/backend/locations/edit.blade.php b/app/views/backend/locations/edit.blade.php index f4d1ebe5bc..d7f1c39c8f 100755 --- a/app/views/backend/locations/edit.blade.php +++ b/app/views/backend/locations/edit.blade.php @@ -45,6 +45,20 @@ {{ $errors->first('name', ':message') }} +
+ +
+ + {{ $errors->first('address', ':message') }} +
+
+
+ +
+ + {{ $errors->first('address2', ':message') }} +
+
From bed78dd935cc5b95995b4296bf75c4c4d05c1193 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 08:28:00 -0500 Subject: [PATCH 02/14] Remove erroneous rule from address2 --- app/models/Location.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/Location.php b/app/models/Location.php index a7053358b1..922207ce21 100644 --- a/app/models/Location.php +++ b/app/models/Location.php @@ -8,7 +8,7 @@ class Location extends Elegant { protected $rules = array( 'name' => 'required|alpha_space|min:3', 'address' => 'required|alpha_space|min:5', - 'address2' => 'optional|alpha_space|min:5', + 'address2' => 'alpha_space|min:5', 'city' => 'required|alpha_space|min:3', 'state' => 'required|alpha|min:2|max:2', 'country' => 'required|alpha|min:2|max:2', From 1314a1ffea48e768c502a7c073ffbc4c96b5b722 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 08:30:51 -0500 Subject: [PATCH 03/14] Add location address values to controller save methods... --- app/controllers/admin/LocationsController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/admin/LocationsController.php b/app/controllers/admin/LocationsController.php index a788205b50..4bb3716f5f 100644 --- a/app/controllers/admin/LocationsController.php +++ b/app/controllers/admin/LocationsController.php @@ -63,6 +63,8 @@ class LocationsController extends AdminController { // Save the location data $location->name = e(Input::get('name')); + $location->address = e(Input::get('address')); + $location->address2 = e(Input::get('address2')); $location->city = e(Input::get('city')); $location->state = e(Input::get('state')); $location->country = e(Input::get('country')); @@ -139,6 +141,8 @@ class LocationsController extends AdminController { // Update the location data $location->name = e(Input::get('name')); + $location->address = e(Input::get('address')); + $location->address2 = e(Input::get('address2')); $location->city = e(Input::get('city')); $location->state = e(Input::get('state')); $location->country = e(Input::get('country')); From 8d3d337820a952691e7a30a315cdfeb4ae133ab3 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 08:41:03 -0500 Subject: [PATCH 04/14] Change input type to email where relevant (better mobile support) --- app/views/backend/users/create.blade.php | 2 +- app/views/backend/users/edit.blade.php | 2 +- app/views/frontend/account/change-email.blade.php | 4 ++-- app/views/frontend/account/change-password.blade.php | 4 ++-- app/views/frontend/auth/forgot-password.blade.php | 2 +- app/views/frontend/auth/signin.blade.php | 2 +- app/views/frontend/auth/signup.blade.php | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/backend/users/create.blade.php b/app/views/backend/users/create.blade.php index 46c0c83e47..3b603d13fe 100755 --- a/app/views/backend/users/create.blade.php +++ b/app/views/backend/users/create.blade.php @@ -83,7 +83,7 @@ Create a User ::
- + {{ $errors->first('email', ':message') }}
diff --git a/app/views/backend/users/edit.blade.php b/app/views/backend/users/edit.blade.php index d2c6cc3961..36f3638d00 100755 --- a/app/views/backend/users/edit.blade.php +++ b/app/views/backend/users/edit.blade.php @@ -84,7 +84,7 @@ Update User {{ $user->fullName() }} ::
- + {{ $errors->first('email', ':message') }}
diff --git a/app/views/frontend/account/change-email.blade.php b/app/views/frontend/account/change-email.blade.php index f9f50ac88f..d834dde848 100755 --- a/app/views/frontend/account/change-email.blade.php +++ b/app/views/frontend/account/change-email.blade.php @@ -22,7 +22,7 @@ Change your Email
- + {{ $errors->first('email', ':message') }}
@@ -31,7 +31,7 @@ Change your Email
- + {{ $errors->first('email_confirm', ':message') }}
diff --git a/app/views/frontend/account/change-password.blade.php b/app/views/frontend/account/change-password.blade.php index d8f983f750..a48d15825d 100755 --- a/app/views/frontend/account/change-password.blade.php +++ b/app/views/frontend/account/change-password.blade.php @@ -90,7 +90,7 @@ Change your Password
- + {{ $errors->first('email', ':message') }}
@@ -99,7 +99,7 @@ Change your Password
- + {{ $errors->first('email_confirm', ':message') }}
diff --git a/app/views/frontend/auth/forgot-password.blade.php b/app/views/frontend/auth/forgot-password.blade.php index f46ff7baa3..bf4453cece 100755 --- a/app/views/frontend/auth/forgot-password.blade.php +++ b/app/views/frontend/auth/forgot-password.blade.php @@ -19,7 +19,7 @@ Forgot Password ::
- + {{ $errors->first('email', ':message') }}
diff --git a/app/views/frontend/auth/signin.blade.php b/app/views/frontend/auth/signin.blade.php index c88bb4e9c4..b44b666d50 100755 --- a/app/views/frontend/auth/signin.blade.php +++ b/app/views/frontend/auth/signin.blade.php @@ -20,7 +20,7 @@ Account Sign in ::
- + {{ $errors->first('email', ':message') }}
diff --git a/app/views/frontend/auth/signup.blade.php b/app/views/frontend/auth/signup.blade.php index 21f7513848..7c18e9400b 100755 --- a/app/views/frontend/auth/signup.blade.php +++ b/app/views/frontend/auth/signup.blade.php @@ -38,7 +38,7 @@ Account Sign up ::
- + {{ $errors->first('email', ':message') }}
@@ -47,7 +47,7 @@ Account Sign up ::
- + {{ $errors->first('email_confirm', ':message') }}
From b5a0da03a8a50ab1b0b729563d1b9eff1daaeebf Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:06:36 -0500 Subject: [PATCH 05/14] Add manufacturer to edit form --- app/controllers/admin/ModelsController.php | 1 + app/views/backend/models/edit.blade.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 1dea8dd9f9..0b841a9ed2 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -38,6 +38,7 @@ class ModelsController extends AdminController { { // Show the page $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + $manufacturer_list = array('' => 'N/A') + Manufacturer::lists('name', 'id'); $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); return View::make('backend/models/edit')->with('category_list',$category_list)->with('depreciation_list',$depreciation_list)->with('model',new Model); } diff --git a/app/views/backend/models/edit.blade.php b/app/views/backend/models/edit.blade.php index 7288d48cc7..e5456361de 100755 --- a/app/views/backend/models/edit.blade.php +++ b/app/views/backend/models/edit.blade.php @@ -50,6 +50,14 @@
+ +
+ +
+ {{ Form::select('manufacturer_id', $manufacturer_list , Input::old('manufacturer_id', $model->manufacturer_id), array('class'=>'select2', 'style'=>'width:250px')) }} + {{ $errors->first('manufacturer_id', ':message') }} +
+
From c2d889de12a9290bda02526d6c0ee6695d799739 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:18:15 -0500 Subject: [PATCH 06/14] Add necessary use statements, clean up the run-on return statement that was forming... --- app/controllers/admin/ModelsController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 0b841a9ed2..627937e49f 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -9,6 +9,7 @@ use Setting; use Sentry; use DB; use Depreciation; +use Manufacturer; use Str; use Validator; use View; @@ -40,7 +41,12 @@ class ModelsController extends AdminController { $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); $manufacturer_list = array('' => 'N/A') + Manufacturer::lists('name', 'id'); $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); - return View::make('backend/models/edit')->with('category_list',$category_list)->with('depreciation_list',$depreciation_list)->with('model',new Model); + $view = View::make('backend/models/edit') + $view->with('category_list',$category_list); + $view->with('depreciation_list',$depreciation_list); + $view->with('manufacturer_list',$manufacturer_list); + $view->with('model',new Model); + return $view; } From 996458dde3b38645e63bee132f0b86ae1ce03579 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:18:43 -0500 Subject: [PATCH 07/14] missing semicolon --- app/controllers/admin/ModelsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 627937e49f..f4dd64f505 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -41,7 +41,7 @@ class ModelsController extends AdminController { $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); $manufacturer_list = array('' => 'N/A') + Manufacturer::lists('name', 'id'); $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); - $view = View::make('backend/models/edit') + $view = View::make('backend/models/edit'); $view->with('category_list',$category_list); $view->with('depreciation_list',$depreciation_list); $view->with('manufacturer_list',$manufacturer_list); From 6f59617546bda2a923bc1e900e03147a214eb6cd Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:23:11 -0500 Subject: [PATCH 08/14] Add to controller's edit method too... --- app/controllers/admin/ModelsController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index f4dd64f505..50810dfa10 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -111,8 +111,14 @@ class ModelsController extends AdminController { } $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + $manufacturer_list = array('' => 'N/A') + Manufacturer::lists('name', 'id'); $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); - return View::make('backend/models/edit', compact('model'))->with('category_list',$category_list)->with('depreciation_list',$depreciation_list); + $view = View::make('backend/models/edit', compact('model')); + $view->with('category_list',$category_list); + $view->with('depreciation_list',$depreciation_list); + $view->with('manufacturer_list',$manufacturer_list); + $view->with('model',new Model); + return $view; } From b7579a14206a83f93003143e4dfa48cd662b1905 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:25:25 -0500 Subject: [PATCH 09/14] Copy/Paste Error --- app/controllers/admin/ModelsController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 50810dfa10..f40d48e2af 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -117,7 +117,6 @@ class ModelsController extends AdminController { $view->with('category_list',$category_list); $view->with('depreciation_list',$depreciation_list); $view->with('manufacturer_list',$manufacturer_list); - $view->with('model',new Model); return $view; } From 9f19792985992a256ddb824f18342029381d8b5c Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:32:50 -0500 Subject: [PATCH 10/14] Save manufacturer ID --- app/controllers/admin/ModelsController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index f40d48e2af..790bf4f987 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -72,6 +72,7 @@ class ModelsController extends AdminController { $model->name = e(Input::get('name')); $model->modelno = e(Input::get('modelno')); $model->depreciation_id = e(Input::get('depreciation_id')); + $model->manufacturer_id = e(Input::get('manufacturer_id')); $model->category_id = e(Input::get('category_id')); $model->user_id = Sentry::getId(); @@ -106,7 +107,7 @@ class ModelsController extends AdminController { // Check if the model exists if (is_null($model = Model::find($modelId))) { - // Redirect to the blogs management page + // Redirect to the model management page return Redirect::to('assets/models')->with('error', Lang::get('admin/models/message.does_not_exist')); } @@ -147,6 +148,7 @@ class ModelsController extends AdminController { $model->name = e(Input::get('name')); $model->modelno = e(Input::get('modelno')); $model->depreciation_id = e(Input::get('depreciation_id')); + $model->manufacturer_id = e(Input::get('manufacturer_id')); $model->category_id = e(Input::get('category_id')); From 9aa6b519c92c9f531397bee577f0bd346668964b Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 27 Nov 2013 10:34:51 -0500 Subject: [PATCH 11/14] Wider display for address field in index blade --- app/views/backend/locations/index.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/backend/locations/index.blade.php b/app/views/backend/locations/index.blade.php index abc3387243..3032c94207 100755 --- a/app/views/backend/locations/index.blade.php +++ b/app/views/backend/locations/index.blade.php @@ -22,8 +22,8 @@ Locations :: - - + + From d6ba98252d5f9e7f3ae50be61a8a4448d37f3ea3 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 11:37:02 -0500 Subject: [PATCH 12/14] Change N/A to Select One --- app/controllers/admin/ModelsController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 790bf4f987..038c104bfc 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -39,7 +39,7 @@ class ModelsController extends AdminController { { // Show the page $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); - $manufacturer_list = array('' => 'N/A') + Manufacturer::lists('name', 'id'); + $manufacturer_list = array('' => 'Select One') + Manufacturer::lists('name', 'id'); $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); $view = View::make('backend/models/edit'); $view->with('category_list',$category_list); @@ -112,7 +112,7 @@ class ModelsController extends AdminController { } $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); - $manufacturer_list = array('' => 'N/A') + Manufacturer::lists('name', 'id'); + $manufacturer_list = array('' => 'Select One') + Manufacturer::lists('name', 'id'); $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); $view = View::make('backend/models/edit', compact('model')); $view->with('category_list',$category_list); @@ -197,9 +197,6 @@ class ModelsController extends AdminController { // Redirect to the models management page return Redirect::to('assets/models')->with('success', Lang::get('admin/models/message.delete.success')); } - - - } @@ -227,5 +224,4 @@ class ModelsController extends AdminController { } - } From 301ef3fddb77111274feb2d0fb1f3d02e595d08c Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 11:37:22 -0500 Subject: [PATCH 13/14] Add Manufacturer and Model info to asset page --- app/models/Asset.php | 4 ++++ app/views/backend/assets/view.blade.php | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/app/models/Asset.php b/app/models/Asset.php index 8d90d42702..2b8b1ac562 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -145,5 +145,9 @@ class Asset extends Elegant { return $this->belongsTo('Depreciation','id'); } + public function model() + { + return $this->belongsTo('Model','model_id'); + } } diff --git a/app/views/backend/assets/view.blade.php b/app/views/backend/assets/view.blade.php index b6aafe1a20..d11b90dfbd 100644 --- a/app/views/backend/assets/view.blade.php +++ b/app/views/backend/assets/view.blade.php @@ -105,6 +105,14 @@ View Asset {{ $asset->asset_tag }} ::

More Info:
    + @if ($asset->model->manufacturer) +
  • Manufacturer: {{ $asset->model->manufacturer->name }}
  • +
  • Model: {{ $asset->model->name }} / {{ $asset->model->modelno }}
  • + @endif + + @if ($asset->purchase_date) +
  • Purchased On: {{ $asset->purchase_date }}
  • + @endif @if ($asset->purchase_date)
  • Purchased On: {{ $asset->purchase_date }}
  • From 6552401fd869fd285aef5e217438f4f055b53ab6 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 27 Nov 2013 12:25:48 -0500 Subject: [PATCH 14/14] Fixes #77 --- app/validators.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/validators.php b/app/validators.php index 2232752018..046eebd898 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); });
@lang('admin/locations/table.name')Address@lang('admin/locations/table.name')Address @lang('admin/locations/table.city'), @lang('admin/locations/table.state') @lang('admin/locations/table.country')