diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index 1f6d182e20..ea4b731d3b 100644 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -7,6 +7,7 @@ use Asset; use Redirect; use DB; use Model; +use Depreciation; use Sentry; use Str; use Validator; @@ -39,7 +40,8 @@ class AssetsController extends AdminController { { // Grab the dropdown list of models $model_list = array('0' => 'Select') + Model::lists('name', 'id'); - return View::make('backend/assets/create')->with('model_list',$model_list); + $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + return View::make('backend/assets/create')->with('model_list',$model_list)->with('depreciation_list',$depreciation_list); } @@ -77,11 +79,11 @@ class AssetsController extends AdminController { $asset->name = e(Input::get('name')); $asset->serial = e(Input::get('serial')); $asset->model_id = e(Input::get('model_id')); - $asset->purchase_date = e(Input::get('purchase_date')); - $asset->purchase_cost = e(Input::get('purchase_cost')); + $asset->purchase_date = e(Input::get('purchase_date')); + $asset->purchase_cost = e(Input::get('purchase_cost')); $asset->order_number = e(Input::get('order_number')); $asset->notes = e(Input::get('notes')); - $asset->asset_tag = e(Input::get('asset_tag')); + $asset->asset_tag = e(Input::get('asset_tag')); $asset->user_id = Sentry::getId(); @@ -113,7 +115,8 @@ class AssetsController extends AdminController { // Grab the dropdown list of models $model_list = array('0' => 'Select') + Model::lists('name', 'id'); - return View::make('backend/assets/edit', compact('asset'))->with('model_list',$model_list); + $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + return View::make('backend/assets/edit', compact('asset'))->with('model_list',$model_list)->with('depreciation_list',$depreciation_list); } @@ -154,10 +157,10 @@ class AssetsController extends AdminController { $asset->name = e(Input::get('name')); $asset->serial = e(Input::get('serial')); $asset->model_id = e(Input::get('model_id')); - $asset->purchase_date = e(Input::get('purchase_date')); - $asset->purchase_cost = e(Input::get('purchase_cost')); + $asset->purchase_date = e(Input::get('purchase_date')); + $asset->purchase_cost = e(Input::get('purchase_cost')); $asset->order_number = e(Input::get('order_number')); - $asset->asset_tag = e(Input::get('asset_tag')); + $asset->asset_tag = e(Input::get('asset_tag')); $asset->notes = e(Input::get('notes')); diff --git a/app/controllers/admin/DepreciationsController.php b/app/controllers/admin/DepreciationsController.php new file mode 100644 index 0000000000..3107922a5a --- /dev/null +++ b/app/controllers/admin/DepreciationsController.php @@ -0,0 +1,178 @@ +paginate(10); + + // Show the page + return View::make('backend/depreciations/index', compact('depreciations')); + } + + + /** + * Depreciation create. + * + * @return View + */ + public function getCreate() + { + // Show the page + $depreciation_options = array('0' => 'Top Level') + Depreciation::lists('name', 'id'); + return View::make('backend/depreciations/create')->with('depreciation_options',$depreciation_options); + } + + + /** + * Depreciation create form processing. + * + * @return Redirect + */ + public function postCreate() + { + // Declare the rules for the form validation + $rules = array( + 'name' => 'required|min:3', + ); + + // 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); + } + + // Create a new depreciation + $depreciation = new Depreciation; + + // Update the depreciation data + $depreciation->name = e(Input::get('name')); + $depreciation->months = e(Input::get('months')); + $depreciation->user_id = Sentry::getId(); + + // Was the depreciation created? + if($depreciation->save()) + { + // Redirect to the new depreciation page + return Redirect::to("admin/settings/depreciations")->with('success', Lang::get('admin/depreciations/message.create.success')); + } + + // Redirect to the depreciation create page + return Redirect::to('admin/settings/depreciations/create')->with('error', Lang::get('admin/depreciations/message.create.error')); + } + + /** + * Depreciation update. + * + * @param int $depreciationId + * @return View + */ + public function getEdit($depreciationId = null) + { + // Check if the depreciation exists + if (is_null($depreciation = Depreciation::find($depreciationId))) + { + // Redirect to the blogs management page + return Redirect::to('admin/settings/depreciations')->with('error', Lang::get('admin/depreciations/message.does_not_exist')); + } + + // Show the page + //$depreciation_options = array('' => 'Top Level') + Depreciation::lists('name', 'id'); + + $depreciation_options = array('' => 'Top Level') + DB::table('depreciations')->where('id', '!=', $depreciationId)->lists('name', 'id'); + return View::make('backend/depreciations/edit', compact('depreciation'))->with('depreciation_options',$depreciation_options); + } + + + /** + * Depreciation update form processing page. + * + * @param int $depreciationId + * @return Redirect + */ + public function postEdit($depreciationId = null) + { + // Check if the blog post exists + if (is_null($depreciation = Depreciation::find($depreciationId))) + { + // Redirect to the blogs management page + return Redirect::to('admin/settings/depreciations')->with('error', Lang::get('admin/depreciations/message.does_not_exist')); + } + + // Declare the rules for the form validation + $rules = array( + 'name' => 'required|min:3', + ); + + // 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 depreciation data + $depreciation->name = e(Input::get('name')); + $depreciation->months = e(Input::get('months')); + + // Was the depreciation updated? + if($depreciation->save()) + { + // Redirect to the new depreciation page + return Redirect::to("admin/settings/depreciations/$depreciationId/edit")->with('success', Lang::get('admin/depreciations/message.update.success')); + } + + // Redirect to the depreciation management page + return Redirect::to("admin/settings/depreciations/$depreciationID/edit")->with('error', Lang::get('admin/depreciations/message.update.error')); + } + + /** + * Delete the given depreciation. + * + * @param int $depreciationId + * @return Redirect + */ + public function getDelete($depreciationId) + { + // Check if the blog post exists + if (is_null($depreciation = Depreciation::find($depreciationId))) + { + // Redirect to the blogs management page + return Redirect::to('admin/settings/depreciations')->with('error', Lang::get('admin/depreciations/message.not_found')); + } + + // Delete the blog post + $depreciation->delete(); + + // Redirect to the blog posts management page + return Redirect::to('admin/settings/depreciations')->with('success', Lang::get('admin/depreciations/message.delete.success')); + } + + + +} diff --git a/app/database/migrations/2013_11_15_190357_create_licenses_table.php b/app/database/migrations/2013_11_15_190357_create_licenses_table.php index 5e6512603f..78fd9e3591 100644 --- a/app/database/migrations/2013_11_15_190357_create_licenses_table.php +++ b/app/database/migrations/2013_11_15_190357_create_licenses_table.php @@ -18,6 +18,7 @@ class CreateLicensesTable extends Migration { $table->integer('model_id'); $table->string('serial'); $table->string('license_email'); + $table->string('license_name'); $table->date('purchase_date')->nullable(); $table->decimal('purchase_cost', 8, 2)->nullable(); $table->string('order_number'); diff --git a/app/database/migrations/2013_11_15_201848_add_license_name_to_licenses.php b/app/database/migrations/2013_11_15_201848_add_license_name_to_licenses.php index f3634c1b6a..ef08878332 100644 --- a/app/database/migrations/2013_11_15_201848_add_license_name_to_licenses.php +++ b/app/database/migrations/2013_11_15_201848_add_license_name_to_licenses.php @@ -11,10 +11,7 @@ class AddLicenseNameToLicenses extends Migration { */ public function up() { - Schema::table('licenses', function($table) - { - $table->string('license_name'); - }); + } /** diff --git a/app/database/migrations/2013_11_16_040323_create_depreciations_table.php b/app/database/migrations/2013_11_16_040323_create_depreciations_table.php new file mode 100644 index 0000000000..7929242309 --- /dev/null +++ b/app/database/migrations/2013_11_16_040323_create_depreciations_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('name'); + $table->integer('months'); + $table->timestamps(); + $table->integer('user_id'); + //$table->foreign('user_id')->references('id')->on('users'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('depreciations'); + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_16_042851_add_depreciation_id_to_models.php b/app/database/migrations/2013_11_16_042851_add_depreciation_id_to_models.php new file mode 100644 index 0000000000..21a491494b --- /dev/null +++ b/app/database/migrations/2013_11_16_042851_add_depreciation_id_to_models.php @@ -0,0 +1,30 @@ +integer('depreciation_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } + +} \ No newline at end of file diff --git a/app/lang/en/admin/depreciations/message.php b/app/lang/en/admin/depreciations/message.php new file mode 100755 index 0000000000..faf054b2fe --- /dev/null +++ b/app/lang/en/admin/depreciations/message.php @@ -0,0 +1,22 @@ + 'Depreciation class does not exist.', + + 'create' => array( + 'error' => 'Depreciation class was not created, please try again. :(', + 'success' => 'Depreciation class created successfully. :)' + ), + + 'update' => array( + 'error' => 'Depreciation class was not updated, please try again', + 'success' => 'Depreciation class updated successfully.' + ), + + 'delete' => array( + 'error' => 'There was an issue deleting the depreciation class. Please try again.', + 'success' => 'The depreciation class was deleted successfully.' + ) + +); diff --git a/app/lang/en/admin/depreciations/table.php b/app/lang/en/admin/depreciations/table.php new file mode 100755 index 0000000000..4830b311bf --- /dev/null +++ b/app/lang/en/admin/depreciations/table.php @@ -0,0 +1,10 @@ + 'ID', + 'title' => 'Name ', + 'months' => 'Months', + 'term' => 'Term', + +); diff --git a/app/models/Depreciation.php b/app/models/Depreciation.php new file mode 100644 index 0000000000..da4a7e29e1 --- /dev/null +++ b/app/models/Depreciation.php @@ -0,0 +1,23 @@ + 'admin'), function() Route::get('{categoryId}/delete', array('as' => 'delete/category', 'uses' => 'Controllers\Admin\CategoriesController@getDelete')); }); + # Depreciations + Route::group(array('prefix' => 'depreciations'), function() + { + Route::get('/', array('as' => 'depreciations', 'uses' => 'Controllers\Admin\DepreciationsController@getIndex')); + Route::get('create', array('as' => 'create/depreciations', 'uses' => 'Controllers\Admin\DepreciationsController@getCreate')); + Route::post('create', 'Controllers\Admin\DepreciationsController@postCreate'); + Route::get('{depreciationId}/edit', array('as' => 'update/depreciations', 'uses' => 'Controllers\Admin\DepreciationsController@getEdit')); + Route::post('{depreciationId}/edit', 'Controllers\Admin\DepreciationsController@postEdit'); + Route::get('{depreciationId}/delete', array('as' => 'delete/depreciations', 'uses' => 'Controllers\Admin\DepreciationsController@getDelete')); + }); + + diff --git a/app/views/backend/assets/create.blade.php b/app/views/backend/assets/create.blade.php index 846920c231..a0f317c003 100755 --- a/app/views/backend/assets/create.blade.php +++ b/app/views/backend/assets/create.blade.php @@ -89,6 +89,15 @@ Create a New Asset :: + +
| @lang('admin/assets/table.title') | @lang('admin/assets/table.asset_tag') | +@lang('admin/assets/table.title') | @lang('admin/assets/table.serial') | @lang('admin/assets/table.status') | @lang('admin/assets/table.purchase_date') | @@ -36,8 +36,8 @@ Assets ::
|---|---|---|---|---|---|
| {{ $asset->name }} | {{ $asset->asset_tag }} | +{{ $asset->name }} | {{ $asset->serial }} | {{ $asset->status }} | {{ $asset->purchase_date }} | diff --git a/app/views/backend/depreciations/create.blade.php b/app/views/backend/depreciations/create.blade.php new file mode 100755 index 0000000000..12265d74d4 --- /dev/null +++ b/app/views/backend/depreciations/create.blade.php @@ -0,0 +1,58 @@ +@extends('backend/layouts/default') + +{{-- Page title --}} +@section('title') +Create a New Depreciation Class :: +@parent +@stop + +{{-- Page content --}} +@section('content') +