diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index 3983c7143a..f7fea069c1 100644 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -413,7 +413,6 @@ class AssetsController extends AdminController { return Redirect::route('assets')->with('error', $error); } - } diff --git a/app/controllers/admin/CategoriesController.php b/app/controllers/admin/CategoriesController.php index 2750eb24f9..245e950c02 100644 --- a/app/controllers/admin/CategoriesController.php +++ b/app/controllers/admin/CategoriesController.php @@ -38,8 +38,7 @@ class CategoriesController extends AdminController { public function getCreate() { // Show the page - $category_options = array('0' => 'Top Level') + Category::lists('name', 'id'); - return View::make('backend/categories/edit')->with('category_options',$category_options)->with('category',new Category); + return View::make('backend/categories/edit')->with('category',new Category); } @@ -63,7 +62,6 @@ class CategoriesController extends AdminController { // Update the category data $category->name = e(Input::get('name')); - $category->parent = e(Input::get('parent')); $category->user_id = Sentry::getId(); // Was the asset created? @@ -134,7 +132,6 @@ class CategoriesController extends AdminController { // Update the category data $category->name = e(Input::get('name')); - $category->parent = e(Input::get('parent')); // Was the asset created? if($category->save()) diff --git a/app/controllers/admin/LicensesController.php b/app/controllers/admin/LicensesController.php index 92d7a3161d..8a91ae534b 100644 --- a/app/controllers/admin/LicensesController.php +++ b/app/controllers/admin/LicensesController.php @@ -10,6 +10,7 @@ use Actionlog; use DB; use Redirect; use LicenseSeat; +use Depreciation; use Setting; use Sentry; use Str; @@ -43,7 +44,9 @@ class LicensesController extends AdminController { { // Show the page $license_options = array('0' => 'Top Level') + License::lists('name', 'id'); - return View::make('backend/licenses/edit')->with('license_options',$license_options)->with('license',new License); + // Show the page + $depreciation_list = array('0' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + return View::make('backend/licenses/edit')->with('license_options',$license_options)->with('depreciation_list',$depreciation_list)->with('license',new License); } @@ -128,7 +131,8 @@ class LicensesController extends AdminController { // Show the page $license_options = array('' => 'Top Level') + DB::table('assets')->where('id', '!=', $licenseId)->lists('name', 'id'); - return View::make('backend/licenses/edit', compact('license'))->with('license_options',$license_options); + $depreciation_list = array('0' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + return View::make('backend/licenses/edit', compact('license'))->with('license_options',$license_options)->with('depreciation_list',$depreciation_list); } diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index cdfc0eb956..a7dac6e3e7 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -187,4 +187,29 @@ class ModelsController extends AdminController { } + /** + * Get the asset information to present to the model view page + * + * @param int $assetId + * @return View + **/ + public function getView($modelId = null) + { + $model = Model::find($modelId); + + if (isset($model->id)) { + return View::make('backend/models/view', compact('model')); + } else { + // Prepare the error message + $error = Lang::get('admin/models/message.does_not_exist', compact('id')); + + // Redirect to the user management page + return Redirect::route('models')->with('error', $error); + } + + + } + + + } diff --git a/app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php b/app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php new file mode 100644 index 0000000000..be8d754a8d --- /dev/null +++ b/app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php @@ -0,0 +1,30 @@ +dropColumn('parent'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_25_151920_add_depreciate_to_assets.php b/app/database/migrations/2013_11_25_151920_add_depreciate_to_assets.php new file mode 100644 index 0000000000..7d6ce6b301 --- /dev/null +++ b/app/database/migrations/2013_11_25_151920_add_depreciate_to_assets.php @@ -0,0 +1,38 @@ +boolean('depreciate'); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('assets', function($table) + { + $table->dropColumn('depreciate'); + }); + + + + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_25_152903_add_depreciate_to_licenses_table.php b/app/database/migrations/2013_11_25_152903_add_depreciate_to_licenses_table.php new file mode 100644 index 0000000000..078c356767 --- /dev/null +++ b/app/database/migrations/2013_11_25_152903_add_depreciate_to_licenses_table.php @@ -0,0 +1,38 @@ +boolean('depreciate'); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('licenses', function($table) + { + $table->dropColumn('depreciate'); + }); + + + + } + +} \ No newline at end of file diff --git a/app/models/Asset.php b/app/models/Asset.php index 08ff6fbf40..a249854be6 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -16,7 +16,7 @@ class Asset extends Elegant { /** * Handle depreciation */ - public function depreciation() + public function depreciate() { $depreciation_id = Model::find($this->model_id)->depreciation_id; if (isset($depreciation_id)) { @@ -108,12 +108,16 @@ class Asset extends Elegant { public function warrantee_expires() { - $date = date_create($this->purchase_date); date_add($date, date_interval_create_from_date_string($this->warranty_months.' months')); return date_format($date, 'Y-m-d'); } + public function depreciation() + { + return $this->belongsTo('Depreciation','id'); + } + } diff --git a/app/models/Category.php b/app/models/Category.php index fc5e117358..2c6943e444 100644 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -12,20 +12,17 @@ class Category extends Elegant { ); - - /** - * Get the parent category name - */ - public function parentname() - { - return $this->belongsTo('Category','parent'); - } - public function has_models() { return $this->hasMany('Model', 'category_id')->count(); } + public function models() + { + return $this->hasMany('Model', 'category_id'); + + } + } diff --git a/app/models/License.php b/app/models/License.php index c258fe09ab..bd48dd1f6a 100644 --- a/app/models/License.php +++ b/app/models/License.php @@ -104,5 +104,10 @@ class License extends Elegant { return $this->hasMany('LicenseSeat'); } + public function depreciation() + { + return $this->belongsTo('Depreciation','id'); + } + } diff --git a/app/models/Model.php b/app/models/Model.php index 6508caed4a..ea0dbcc6e5 100644 --- a/app/models/Model.php +++ b/app/models/Model.php @@ -10,7 +10,28 @@ class Model extends Elegant { public function assets() { return $this->hasMany('Asset', 'model_id'); - } + public function category() + { + return $this->belongsTo('Category', 'category_id'); + } + + public function depreciation() + { + return $this->belongsTo('Depreciation','id'); + } + + public function adminuser() + { + return $this->belongsTo('User','user_id'); + } + + public function manufacturer() + { + return $this->belongsTo('Manufacturer','manufacturer_id'); + } + + + } diff --git a/app/routes.php b/app/routes.php index 7ac1b6ee6f..a853d63b58 100755 --- a/app/routes.php +++ b/app/routes.php @@ -23,6 +23,7 @@ Route::group(array('prefix' => 'assets'), function() Route::get('{modelId}/edit', array('as' => 'update/model', 'uses' => 'Controllers\Admin\ModelsController@getEdit')); Route::post('{modelId}/edit', 'Controllers\Admin\ModelsController@postEdit'); Route::get('{modelId}/delete', array('as' => 'delete/model', 'uses' => 'Controllers\Admin\ModelsController@getDelete')); + Route::get('{modelId}/view', array('as' => 'view/model', 'uses' => 'Controllers\Admin\ModelsController@getView')); }); Route::get('/', array('as' => 'assets', 'uses' => 'Controllers\Admin\AssetsController@getIndex')); diff --git a/app/views/backend/assets/view.blade.php b/app/views/backend/assets/view.blade.php index 1b7cb6328c..d69dbe1d81 100644 --- a/app/views/backend/assets/view.blade.php +++ b/app/views/backend/assets/view.blade.php @@ -114,6 +114,11 @@ View Asset {{ $asset->asset_tag }} ::