diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index d6f18837a1..25d0e0eded 100644 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -6,6 +6,7 @@ use Lang; use Asset; use Statuslabel; use User; +use Setting; use Redirect; use DB; use Actionlog; @@ -51,7 +52,7 @@ class AssetsController extends AdminController { } // Paginate the users - $assets = $assets->paginate(10) + $assets = $assets->paginate(Setting::getSettings()->per_page) ->appends(array( 'Pending' => Input::get('Pending'), 'RTD' => Input::get('RTD'), diff --git a/app/controllers/admin/CategoriesController.php b/app/controllers/admin/CategoriesController.php index 54e7e46b1b..2750eb24f9 100644 --- a/app/controllers/admin/CategoriesController.php +++ b/app/controllers/admin/CategoriesController.php @@ -5,6 +5,7 @@ use Input; use Lang; use Category; use Redirect; +use Setting; use DB; use Sentry; use Str; @@ -22,7 +23,7 @@ class CategoriesController extends AdminController { public function getIndex() { // Grab all the categories - $categories = Category::orderBy('created_at', 'DESC')->paginate(10); + $categories = Category::orderBy('created_at', 'DESC')->paginate(Setting::getSettings()->per_page); // Show the page return View::make('backend/categories/index', compact('categories')); diff --git a/app/controllers/admin/DepreciationsController.php b/app/controllers/admin/DepreciationsController.php index 72aee62e87..5d49df3be4 100644 --- a/app/controllers/admin/DepreciationsController.php +++ b/app/controllers/admin/DepreciationsController.php @@ -5,6 +5,7 @@ use Input; use Lang; use Depreciation; use Redirect; +use Setting; use DB; use Sentry; use Str; @@ -22,7 +23,7 @@ class DepreciationsController extends AdminController { public function getIndex() { // Grab all the depreciations - $depreciations = Depreciation::orderBy('created_at', 'DESC')->paginate(10); + $depreciations = Depreciation::orderBy('created_at', 'DESC')->paginate(Setting::getSettings()->per_page); // Show the page return View::make('backend/depreciations/index', compact('depreciations')); diff --git a/app/controllers/admin/GroupsController.php b/app/controllers/admin/GroupsController.php index e872beb60b..56dc76bb03 100755 --- a/app/controllers/admin/GroupsController.php +++ b/app/controllers/admin/GroupsController.php @@ -8,6 +8,7 @@ use Config; use Input; use Lang; use Redirect; +use Setting; use Sentry; use Validator; use View; diff --git a/app/controllers/admin/LicensesController.php b/app/controllers/admin/LicensesController.php index 99a7c099d6..bdc987fbec 100644 --- a/app/controllers/admin/LicensesController.php +++ b/app/controllers/admin/LicensesController.php @@ -9,6 +9,7 @@ use User; use Actionlog; use DB; use Redirect; +use Setting; use Sentry; use Str; use Validator; @@ -25,7 +26,7 @@ class LicensesController extends AdminController { public function getIndex() { // Grab all the licenses - $licenses = License::orderBy('created_at', 'DESC')->where('physical', '=', 0)->paginate(10); + $licenses = License::orderBy('created_at', 'DESC')->where('physical', '=', 0)->paginate(Setting::getSettings()->per_page); // Show the page return View::make('backend/licenses/index', compact('licenses')); diff --git a/app/controllers/admin/LocationsController.php b/app/controllers/admin/LocationsController.php index 9a3760318b..a64fe9ac83 100644 --- a/app/controllers/admin/LocationsController.php +++ b/app/controllers/admin/LocationsController.php @@ -5,6 +5,7 @@ use Input; use Lang; use Location; use Redirect; +use Setting; use DB; use Sentry; use Str; @@ -22,7 +23,7 @@ class LocationsController extends AdminController { public function getIndex() { // Grab all the locations - $locations = Location::orderBy('created_at', 'DESC')->paginate(10); + $locations = Location::orderBy('created_at', 'DESC')->paginate(Setting::getSettings()->per_page); // Show the page return View::make('backend/locations/index', compact('locations')); diff --git a/app/controllers/admin/ManufacturersController.php b/app/controllers/admin/ManufacturersController.php index d7f0056f39..32f12793e6 100644 --- a/app/controllers/admin/ManufacturersController.php +++ b/app/controllers/admin/ManufacturersController.php @@ -5,6 +5,7 @@ use Input; use Lang; use Manufacturer; use Redirect; +use Setting; use Sentry; use Str; use Validator; @@ -20,7 +21,7 @@ class ManufacturersController extends AdminController { public function getIndex() { // Grab all the manufacturers - $manufacturers = Manufacturer::orderBy('created_at', 'DESC')->paginate(10); + $manufacturers = Manufacturer::orderBy('created_at', 'DESC')->paginate(Setting::getSettings()->per_page); // Show the page return View::make('backend/manufacturers/index', compact('manufacturers')); diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index dcaa7f31ad..d186f2f9d2 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -5,6 +5,7 @@ use Input; use Lang; use Model; use Redirect; +use Setting; use Sentry; use DB; use Depreciation; @@ -22,7 +23,7 @@ class ModelsController extends AdminController { public function getIndex() { // Grab all the models - $models = Model::orderBy('created_at', 'DESC')->paginate(10); + $models = Model::orderBy('created_at', 'DESC')->paginate(Setting::getSettings()->per_page); // Show the page return View::make('backend/models/index', compact('models')); diff --git a/app/controllers/admin/SettingsController.php b/app/controllers/admin/SettingsController.php index fe355729ae..2f67ecd6fc 100644 --- a/app/controllers/admin/SettingsController.php +++ b/app/controllers/admin/SettingsController.php @@ -22,7 +22,7 @@ class SettingsController extends AdminController { public function getIndex() { // Grab all the settings - $settings = Setting::orderBy('created_at', 'DESC')->paginate(10); + $settings = Setting::all(); // Show the page return View::make('backend/settings/index', compact('settings')); @@ -51,35 +51,47 @@ class SettingsController extends AdminController { public function postEdit() { + // Check if the asset exists + if (is_null($setting = Setting::find(1))) + { + // Redirect to the asset management page with error + return Redirect::to('admin')->with('error', Lang::get('admin/settings/message.update.error')); + } + $new = Input::all(); - // create a new model instance - $setting = new Location(); - // attempt validation - if ($setting->validate($new)) + // Declare the rules for the form validation + $rules = array( + "site_name" => 'required|min:3', + "per_page" => 'required|min:1|numeric', + ); + + // 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); + } - // Update the setting data - $setting->option_value = e(Input::get('name')); + // Update the asset data + $setting->id = '1'; + $setting->site_name = e(Input::get('site_name')); + $setting->per_page = e(Input::get('per_page')); - - // Was the asset created? + // Was the asset updated? if($setting->save()) { - // Redirect to the saved setting page - return Redirect::to("admin/settings/app/$settingId/edit")->with('success', Lang::get('admin/settings/message.update.success')); + // Redirect to the settings page + return Redirect::to("admin/settings/app")->with('success', Lang::get('admin/settings/message.update.success')); } - } - else - { - // failure - $errors = $setting->errors(); - return Redirect::back()->withInput()->withErrors($errors); - } - // Redirect to the setting management page - return Redirect::to("admin/settings/app/$settingId/edit")->with('error', Lang::get('admin/settings/message.update.error')); + // Redirect to the setting management page + return Redirect::to("admin/settings/app/edit")->with('error', Lang::get('admin/settings/message.update.error')); } diff --git a/app/controllers/admin/StatuslabelsController.php b/app/controllers/admin/StatuslabelsController.php index 8479bc52d1..e45cb61e78 100644 --- a/app/controllers/admin/StatuslabelsController.php +++ b/app/controllers/admin/StatuslabelsController.php @@ -7,6 +7,7 @@ use Statuslabel; use Redirect; use DB; use Sentry; +use Setting; use Str; use Validator; use View; diff --git a/app/controllers/admin/UsersController.php b/app/controllers/admin/UsersController.php index 0849f72a97..1ebf7daaef 100755 --- a/app/controllers/admin/UsersController.php +++ b/app/controllers/admin/UsersController.php @@ -13,6 +13,7 @@ use Asset; use Lang; use Actionlog; use Location; +use Setting; use Redirect; use Sentry; use Validator; diff --git a/app/database/seeds/SettingsSeeder.php b/app/database/seeds/SettingsSeeder.php index cc16064825..43838a1b70 100644 --- a/app/database/seeds/SettingsSeeder.php +++ b/app/database/seeds/SettingsSeeder.php @@ -11,18 +11,8 @@ class SettingsSeeder extends Seeder { $date = new DateTime; $setting[] = array( - 'option_name' => 'per_page', - 'option_label' => 'Results Per Page', - 'option_value' => '50', - 'created_at' => $date->modify('-10 day'), - 'updated_at' => $date->modify('-3 day'), - 'user_id' => 1, - ); - - $setting[] = array( - 'option_name' => 'site_name', - 'option_label' => 'Site Name', - 'option_value' => 'Snipe IT Asset Management System', + 'per_page' => '50', + 'site_name' => 'Snipe IT Asset Management', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, diff --git a/app/lang/en/admin/settings/message.php b/app/lang/en/admin/settings/message.php new file mode 100755 index 0000000000..107da1f8d1 --- /dev/null +++ b/app/lang/en/admin/settings/message.php @@ -0,0 +1,11 @@ + array( + 'error' => 'An error has occurred while updating. ', + 'success' => 'Settings updated successfully.' + ), + +); diff --git a/app/models/Setting.php b/app/models/Setting.php index eb443e6eee..9894c22cdf 100644 --- a/app/models/Setting.php +++ b/app/models/Setting.php @@ -2,16 +2,10 @@ class Setting extends Elegant { - protected $table = 'settings'; - protected $rules = array( - "option_value['site_name']" => 'required|min:3', - "option_value['per_page']" => 'required|min:1|numeric', - ); - public function getsettings() + public static function getSettings() { - //$foo = Setting::all(); - //print_r($foo); + return Setting::find(1); } } diff --git a/app/views/backend/assets/index.blade.php b/app/views/backend/assets/index.blade.php index 0548720224..52fd7396cc 100755 --- a/app/views/backend/assets/index.blade.php +++ b/app/views/backend/assets/index.blade.php @@ -56,7 +56,7 @@ Assets ::

-@if ($assets && $assets->getTotal() && $assets->getTotal() > 10) +@if ($assets && $assets->getTotal() && $assets->getTotal() > Setting::getSettings()->per_page) {{ $assets->links() }} @endif @@ -147,7 +147,7 @@ Assets :: -@if ($assets && $assets->getTotal() && $assets->getTotal() > 10) +@if ($assets && $assets->getTotal() && $assets->getTotal() > Setting::getSettings()->per_page) {{ $assets->links() }} @endif @stop diff --git a/app/views/backend/categories/index.blade.php b/app/views/backend/categories/index.blade.php index a93ab5a5f4..24b62781da 100755 --- a/app/views/backend/categories/index.blade.php +++ b/app/views/backend/categories/index.blade.php @@ -17,7 +17,7 @@ Asset Categories :: -@if ($categories->getTotal() > 10) +@if ($categories->getTotal() > Setting::getSettings()->per_page) {{ $categories->links() }} @endif
@@ -51,7 +51,7 @@ Asset Categories ::
-@if ($categories->getTotal() > 10) +@if ($categories->getTotal() > Setting::getSettings()->per_page) {{ $categories->links() }} @endif @stop diff --git a/app/views/backend/depreciations/index.blade.php b/app/views/backend/depreciations/index.blade.php index f4f7cdc846..e2f5b7d465 100755 --- a/app/views/backend/depreciations/index.blade.php +++ b/app/views/backend/depreciations/index.blade.php @@ -18,7 +18,7 @@ Asset Depreciations :: -@if ($depreciations->getTotal() > 10) +@if ($depreciations->getTotal() > Setting::getSettings()->per_page) {{ $depreciations->links() }} @endif @@ -46,7 +46,7 @@ Asset Depreciations :: -@if ($depreciations->getTotal() > 10) +@if ($depreciations->getTotal() > Setting::getSettings()->per_page) {{ $depreciations->links() }} @endif diff --git a/app/views/backend/groups/index.blade.php b/app/views/backend/groups/index.blade.php index 5431627636..6e5fae37da 100755 --- a/app/views/backend/groups/index.blade.php +++ b/app/views/backend/groups/index.blade.php @@ -18,7 +18,7 @@ Group Management :: -@if (count($groups) > 10) +@if (count($groups) > Setting::getSettings()->per_page) {{ $groups->links() }} @endif @@ -56,7 +56,7 @@ Group Management :: -@if (count($groups) > 10) +@if (count($groups) > Setting::getSettings()->per_page) {{ $groups->links() }} @endif diff --git a/app/views/backend/layouts/default.blade.php b/app/views/backend/layouts/default.blade.php index 001ce645ec..598458d61d 100755 --- a/app/views/backend/layouts/default.blade.php +++ b/app/views/backend/layouts/default.blade.php @@ -74,7 +74,7 @@ - Snipe IT Asset Management + {{ Setting::getSettings()->site_name }} diff --git a/app/views/backend/licenses/index.blade.php b/app/views/backend/licenses/index.blade.php index 49bf776707..003c60ac78 100755 --- a/app/views/backend/licenses/index.blade.php +++ b/app/views/backend/licenses/index.blade.php @@ -16,7 +16,7 @@ Licenses :: -@if ($licenses->getTotal() > 10) +@if ($licenses->getTotal() > Setting::getSettings()->per_page) {{ $licenses->links() }} @endif
@@ -59,9 +59,6 @@ Licenses :: @lang('button.edit') @lang('button.delete') - - - @endforeach @@ -69,7 +66,7 @@ Licenses ::
-@if ($licenses->getTotal() > 10) +@if ($licenses->getTotal() > Setting::getSettings()->per_page) {{ $licenses->links() }} @endif @stop diff --git a/app/views/backend/manufacturers/index.blade.php b/app/views/backend/manufacturers/index.blade.php index 4da51c70bb..1b5751cc75 100755 --- a/app/views/backend/manufacturers/index.blade.php +++ b/app/views/backend/manufacturers/index.blade.php @@ -18,7 +18,7 @@ Asset Manufacturers :: -@if ($manufacturers->getTotal() > 10) +@if ($manufacturers->getTotal() > Setting::getSettings()->per_page) {{ $manufacturers->links() }} @endif @@ -44,7 +44,7 @@ Asset Manufacturers :: -@if ($manufacturers->getTotal() > 10) +@if ($manufacturers->getTotal() > Setting::getSettings()->per_page) {{ $manufacturers->links() }} @endif diff --git a/app/views/backend/models/index.blade.php b/app/views/backend/models/index.blade.php index 57530306d9..1115b8e589 100755 --- a/app/views/backend/models/index.blade.php +++ b/app/views/backend/models/index.blade.php @@ -17,7 +17,7 @@ Asset Models :: -@if ($models->getTotal() > 10) +@if ($models->getTotal() > Setting::getSettings()->per_page) {{ $models->links() }} @endif @@ -50,7 +50,7 @@ Asset Models :: -@if ($models->getTotal() > 10) +@if ($models->getTotal() > Setting::getSettings()->per_page) {{ $models->links() }} @endif diff --git a/app/views/backend/settings/edit.blade.php b/app/views/backend/settings/edit.blade.php index 4cb50ff827..253ae89197 100755 --- a/app/views/backend/settings/edit.blade.php +++ b/app/views/backend/settings/edit.blade.php @@ -28,14 +28,24 @@
+ @foreach ($settings as $setting) -
- + +
+
- - {{ $errors->first('option_value', ':message') }} + + {{ $errors->first('site_name', ':message') }}
+
+ +
+ + {{ $errors->first('per_page', ':message') }} +
+
+ @endforeach diff --git a/app/views/backend/settings/index.blade.php b/app/views/backend/settings/index.blade.php index 301957f7c7..7c8cb8cef9 100755 --- a/app/views/backend/settings/index.blade.php +++ b/app/views/backend/settings/index.blade.php @@ -12,7 +12,7 @@ Settings ::

Settings

@@ -27,16 +27,19 @@ Settings :: - - + + @foreach ($settings as $setting) - - - + + + + + + @endforeach diff --git a/app/views/backend/statuslabels/index.blade.php b/app/views/backend/statuslabels/index.blade.php index 5e54640b55..0737e91f57 100755 --- a/app/views/backend/statuslabels/index.blade.php +++ b/app/views/backend/statuslabels/index.blade.php @@ -49,7 +49,7 @@ Status Labels
-

+

About Status Labels

Status labels are used to describe the various reasons why an asset cannot be deployed.

diff --git a/app/views/backend/users/index.blade.php b/app/views/backend/users/index.blade.php index 9f9d6655b7..3111df4854 100755 --- a/app/views/backend/users/index.blade.php +++ b/app/views/backend/users/index.blade.php @@ -22,7 +22,7 @@ User Management :: Include Only Deleted Users

-@if ($users->getTotal() > 10) +@if ($users->getTotal() > Setting::getSettings()->per_page) {{ $users->links() }} @endif @@ -71,8 +71,7 @@ User Management :: @else @lang('button.edit') @if (Sentry::getId() !== $user->id) - @lang('button.delete') - + @lang('button.delete') @else @lang('button.delete') @endif @@ -94,7 +93,7 @@ User Management ::
@endif -@if ($users->getTotal() > 10) +@if ($users->getTotal() > Setting::getSettings()->per_page) {{ $users->links() }} @endif
SettingValueSettingValue
{{ $setting->option_label }}{{ $setting->option_value }} Site Name{{ $setting->site_name }}
Per Page{{ $setting->per_page }}