diff --git a/README.md b/README.md index cd4c7088fe..391e29e7d9 100644 --- a/README.md +++ b/README.md @@ -74,11 +74,11 @@ Use the following command to create your default user, user groups and run all t You'll need to make sure that the app/storage directory is writable by your webserver, since caches and log files get written there. You should use the minimum permissions available for writing, based on how you've got your webserver configured. - chown -R 755 app/storage + chmod -R 755 app/storage If you still run into a permissions error, you may need to increase the permissions to 775, or twiddle your user/group permissions on your server. - chown -R 775 app/storage + chmod -R 775 app/storage ----- diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index ca33e3815d..ec93eadbec 100644 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -4,6 +4,7 @@ use AdminController; use Input; use Lang; use Asset; +use Statuslabel; use User; use Redirect; use DB; @@ -48,7 +49,10 @@ class AssetsController extends AdminController { $model_list = array('' => '') + Model::lists('name', 'id'); $depreciation_list = array('' => '') + Depreciation::lists('name', 'id'); - return View::make('backend/assets/edit')->with('model_list',$model_list)->with('depreciation_list',$depreciation_list)->with('asset',new Asset); + // Grab the dropdown list of status + $statuslabel_list = array('' => 'Ready to Deploy') + Statuslabel::lists('name', 'id'); + + return View::make('backend/assets/edit')->with('model_list',$model_list)->with('statuslabel_list',$statuslabel_list)->with('depreciation_list',$depreciation_list)->with('asset',new Asset); } @@ -80,6 +84,7 @@ class AssetsController extends AdminController { $asset->order_number = e(Input::get('order_number')); $asset->notes = e(Input::get('notes')); $asset->asset_tag = e(Input::get('asset_tag')); + $asset->status_id = e(Input::get('status_id')); $asset->user_id = Sentry::getId(); $asset->physical = '1'; @@ -122,9 +127,13 @@ class AssetsController extends AdminController { // Grab the dropdown list of models $model_list = array('' => '') + Model::lists('name', 'id'); + // Grab the dropdown list of status + $statuslabel_list = array('' => '') + Statuslabel::lists('name', 'id'); + // get depreciation list $depreciation_list = array('' => '') + Depreciation::lists('name', 'id'); - return View::make('backend/assets/edit', compact('asset'))->with('model_list',$model_list)->with('depreciation_list',$depreciation_list); + + return View::make('backend/assets/edit', compact('asset'))->with('model_list',$model_list)->with('depreciation_list',$depreciation_list)->with('statuslabel_list',$statuslabel_list); } @@ -171,6 +180,7 @@ class AssetsController extends AdminController { $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->status_id = e(Input::get('status_id')); $asset->notes = e(Input::get('notes')); $asset->physical = '1'; @@ -202,11 +212,19 @@ class AssetsController extends AdminController { return Redirect::to('admin')->with('error', Lang::get('admin/assets/message.not_found')); } - // Delete the asset - $asset->delete(); + if (isset($asset->assigneduser->id) && ($asset->assigneduser->id!=0)) { + // Redirect to the asset management page + return Redirect::to('admin')->with('error', Lang::get('admin/assets/message.assoc_users')); + } else { + // Delete the asset + $asset->delete(); + + // Redirect to the asset management page + return Redirect::to('admin')->with('success', Lang::get('admin/assets/message.delete.success')); + } + + - // Redirect to the asset management page - return Redirect::to('admin')->with('success', Lang::get('admin/assets/message.delete.success')); } /** @@ -224,6 +242,9 @@ 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); diff --git a/app/controllers/admin/CategoriesController.php b/app/controllers/admin/CategoriesController.php index 803f380c1a..54e7e46b1b 100644 --- a/app/controllers/admin/CategoriesController.php +++ b/app/controllers/admin/CategoriesController.php @@ -169,11 +169,20 @@ class CategoriesController extends AdminController { return Redirect::to('admin/settings/categories')->with('error', Lang::get('admin/categories/message.not_found')); } - // Delete the blog post - $category->delete(); - // Redirect to the blog posts management page - return Redirect::to('admin/settings/categories')->with('success', Lang::get('admin/categories/message.delete.success')); + if ($category->has_models() > 0) { + + // Redirect to the asset management page + return Redirect::to('admin/settings/categories')->with('error', Lang::get('admin/categories/message.assoc_users')); + } else { + + $category->delete(); + + // Redirect to the locations management page + return Redirect::to('admin/settings/categories')->with('success', Lang::get('admin/categories/message.delete.success')); + } + + } diff --git a/app/controllers/admin/DepreciationsController.php b/app/controllers/admin/DepreciationsController.php index bc1842c9c8..72aee62e87 100644 --- a/app/controllers/admin/DepreciationsController.php +++ b/app/controllers/admin/DepreciationsController.php @@ -170,11 +170,18 @@ class DepreciationsController extends AdminController { return Redirect::to('admin/settings/depreciations')->with('error', Lang::get('admin/depreciations/message.not_found')); } - // Delete the depreciation - $depreciation->delete(); + if ($depreciation->has_models() > 0) { + + // Redirect to the asset management page + return Redirect::to('admin/settings/depreciations')->with('error', Lang::get('admin/depreciations/message.assoc_users')); + } else { + + $depreciation->delete(); + + // Redirect to the depreciations management page + return Redirect::to('admin/settings/depreciations')->with('success', Lang::get('admin/depreciations/message.delete.success')); + } - // Redirect to the depreciations management page - return Redirect::to('admin/settings/depreciations')->with('success', Lang::get('admin/depreciations/message.delete.success')); } diff --git a/app/controllers/admin/LicensesController.php b/app/controllers/admin/LicensesController.php index 4a3d7c7148..99a7c099d6 100644 --- a/app/controllers/admin/LicensesController.php +++ b/app/controllers/admin/LicensesController.php @@ -187,11 +187,18 @@ class LicensesController extends AdminController { return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.not_found')); } - // Delete the license - $license->delete(); + if (isset($license->assigneduser->id) && ($license->assigneduser->id!=0)) { + // Redirect to the asset management page + return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.assoc_users')); + } else { + // Delete the license + $license->delete(); + + // Redirect to the licenses management page + return Redirect::to('admin/licenses')->with('success', Lang::get('admin/licenses/message.delete.success')); + } + - // Redirect to the licenses management page - return Redirect::to('admin/licenses')->with('success', Lang::get('admin/licenses/message.delete.success')); } diff --git a/app/controllers/admin/LocationsController.php b/app/controllers/admin/LocationsController.php index 42c202e824..9a3760318b 100644 --- a/app/controllers/admin/LocationsController.php +++ b/app/controllers/admin/LocationsController.php @@ -53,7 +53,7 @@ class LocationsController extends AdminController { // get the POST data $new = Input::all(); - // create a new model instance + // create a new location instance $location = new Location(); // attempt validation @@ -175,11 +175,21 @@ class LocationsController extends AdminController { return Redirect::to('admin/settings/locations')->with('error', Lang::get('admin/locations/message.not_found')); } - // Delete the location - $location->delete(); - // Redirect to the locations management page - return Redirect::to('admin/settings/locations')->with('success', Lang::get('admin/locations/message.delete.success')); + if ($location->has_users() > 0) { + + // Redirect to the asset management page + return Redirect::to('admin/settings/locations')->with('error', Lang::get('admin/locations/message.assoc_users')); + } else { + + $location->delete(); + + // Redirect to the locations management page + return Redirect::to('admin/settings/locations')->with('success', Lang::get('admin/locations/message.delete.success')); + } + + + } diff --git a/app/controllers/admin/ManufacturersController.php b/app/controllers/admin/ManufacturersController.php index 01221a423e..d7f0056f39 100644 --- a/app/controllers/admin/ManufacturersController.php +++ b/app/controllers/admin/ManufacturersController.php @@ -159,11 +159,24 @@ class ManufacturersController extends AdminController { return Redirect::to('admin/settings/manufacturers')->with('error', Lang::get('admin/manufacturers/message.not_found')); } - // Delete the manufacturer - $manufacturer->delete(); + if ($manufacturer->has_models() > 0) { - // Redirect to the manufacturers management page + // Redirect to the asset management page + return Redirect::to('admin/settings/manufacturers')->with('error', Lang::get('admin/manufacturers/message.assoc_users')); + } else { + + // Delete the manufacturer + $manufacturer->delete(); + + // Redirect to the manufacturers management page return Redirect::to('admin/settings/manufacturers')->with('success', Lang::get('admin/manufacturers/message.delete.success')); + } + + + + + + } diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 406f53d292..dcaa7f31ad 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -168,11 +168,20 @@ class ModelsController extends AdminController { return Redirect::to('assets/models')->with('error', Lang::get('admin/models/message.not_found')); } - // Delete the model - $model->delete(); + if ($model->assets->count() > 0) { + // Throw an error that this model is associated with assets + return Redirect::to('assets/models')->with('error', Lang::get('admin/models/message.assoc_users')); + + } else { + // Delete the model + $model->delete(); + + // Redirect to the models management page + return Redirect::to('assets/models')->with('success', Lang::get('admin/models/message.delete.success')); + } + + - // Redirect to the models management page - return Redirect::to('assets/models')->with('success', Lang::get('admin/models/message.delete.success')); } diff --git a/app/controllers/admin/SettingsController.php b/app/controllers/admin/SettingsController.php new file mode 100644 index 0000000000..fe355729ae --- /dev/null +++ b/app/controllers/admin/SettingsController.php @@ -0,0 +1,89 @@ +paginate(10); + + // Show the page + return View::make('backend/settings/index', compact('settings')); + } + + + /** + * Setting update. + * + * @param int $settingId + * @return View + */ + public function getEdit() + { + $settings = Setting::orderBy('created_at', 'DESC')->paginate(10); + return View::make('backend/settings/edit', compact('settings')); + } + + + /** + * Setting update form processing page. + * + * @param int $settingId + * @return Redirect + */ + public function postEdit() + { + + $new = Input::all(); + + // create a new model instance + $setting = new Location(); + + // attempt validation + if ($setting->validate($new)) + { + + // Update the setting data + $setting->option_value = e(Input::get('name')); + + + // Was the asset created? + 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')); + } + } + 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')); + + } + + + + +} diff --git a/app/controllers/admin/StatuslabelsController.php b/app/controllers/admin/StatuslabelsController.php new file mode 100644 index 0000000000..8479bc52d1 --- /dev/null +++ b/app/controllers/admin/StatuslabelsController.php @@ -0,0 +1,187 @@ +paginate(10); + + // Show the page + return View::make('backend/statuslabels/index', compact('statuslabels')); + } + + + /** + * Statuslabel create. + * + * @return View + */ + public function getCreate() + { + // Show the page + return View::make('backend/statuslabels/edit')->with('statuslabel',new Statuslabel); + } + + + /** + * Statuslabel create form processing. + * + * @return Redirect + */ + public function postCreate() + { + + // get the POST data + $new = Input::all(); + + // create a new model instance + $statuslabel = new Statuslabel(); + + // attempt validation + if ($statuslabel->validate($new)) + { + + // Save the Statuslabel data + $statuslabel->name = e(Input::get('name')); + $statuslabel->user_id = Sentry::getId(); + + // Was the asset created? + if($statuslabel->save()) + { + // Redirect to the new Statuslabel page + return Redirect::to("admin/settings/statuslabels")->with('success', Lang::get('admin/statuslabels/message.create.success')); + } + } + else + { + // failure + $errors = $statuslabel->errors(); + return Redirect::back()->withInput()->withErrors($errors); + } + + // Redirect to the Statuslabel create page + return Redirect::to('admin/settings/statuslabels/create')->with('error', Lang::get('admin/statuslabels/message.create.error')); + + } + + + /** + * Statuslabel update. + * + * @param int $statuslabelId + * @return View + */ + public function getEdit($statuslabelId = null) + { + // Check if the Statuslabel exists + if (is_null($statuslabel = Statuslabel::find($statuslabelId))) + { + // Redirect to the blogs management page + return Redirect::to('admin/settings/statuslabels')->with('error', Lang::get('admin/statuslabels/message.does_not_exist')); + } + + + return View::make('backend/statuslabels/edit', compact('statuslabel')); + } + + + /** + * Statuslabel update form processing page. + * + * @param int $statuslabelId + * @return Redirect + */ + public function postEdit($statuslabelId = null) + { + // Check if the Statuslabel exists + if (is_null($statuslabel = Statuslabel::find($statuslabelId))) + { + // Redirect to the blogs management page + return Redirect::to('admin/settings/statuslabels')->with('error', Lang::get('admin/statuslabels/message.does_not_exist')); + } + + + + // get the POST data + $new = Input::all(); + + + // attempt validation + if ($statuslabel->validate($new)) + { + + // Update the Statuslabel data + $statuslabel->name = e(Input::get('name')); + + // Was the asset created? + if($statuslabel->save()) + { + // Redirect to the saved Statuslabel page + return Redirect::to("admin/settings/statuslabels/$statuslabelId/edit")->with('success', Lang::get('admin/statuslabels/message.update.success')); + } + } + else + { + // failure + $errors = $statuslabel->errors(); + return Redirect::back()->withInput()->withErrors($errors); + } + + // Redirect to the Statuslabel management page + return Redirect::to("admin/settings/statuslabels/$statuslabelId/edit")->with('error', Lang::get('admin/statuslabels/message.update.error')); + + } + + /** + * Delete the given Statuslabel. + * + * @param int $statuslabelId + * @return Redirect + */ + public function getDelete($statuslabelId) + { + // Check if the Statuslabel exists + if (is_null($statuslabel = Statuslabel::find($statuslabelId))) + { + // Redirect to the blogs management page + return Redirect::to('admin/settings/statuslabels')->with('error', Lang::get('admin/statuslabels/message.not_found')); + } + + + if ($statuslabel->has_assets() > 0) { + + // Redirect to the asset management page + return Redirect::to('admin/settings/statuslabels')->with('error', Lang::get('admin/statuslabels/message.assoc_users')); + } else { + + $statuslabel->delete(); + + // Redirect to the statuslabels management page + return Redirect::to('admin/settings/statuslabels')->with('success', Lang::get('admin/statuslabels/message.delete.success')); + } + + + + } + + + +} diff --git a/app/database/migrations/2013_11_17_055126_create_settings_table.php b/app/database/migrations/2013_11_17_055126_create_settings_table.php index 0ba18031be..c253da5c18 100644 --- a/app/database/migrations/2013_11_17_055126_create_settings_table.php +++ b/app/database/migrations/2013_11_17_055126_create_settings_table.php @@ -29,7 +29,7 @@ class CreateSettingsTable extends Migration { */ public function down() { - // + Schema::drop('settings'); } } \ No newline at end of file diff --git a/app/database/migrations/2013_11_20_121404_add_soft_delete_on_locations.php b/app/database/migrations/2013_11_20_121404_add_soft_delete_on_locations.php new file mode 100644 index 0000000000..12883989e4 --- /dev/null +++ b/app/database/migrations/2013_11_20_121404_add_soft_delete_on_locations.php @@ -0,0 +1,30 @@ +softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_20_123137_add_soft_delete_on_manufacturers.php b/app/database/migrations/2013_11_20_123137_add_soft_delete_on_manufacturers.php new file mode 100644 index 0000000000..edad42e584 --- /dev/null +++ b/app/database/migrations/2013_11_20_123137_add_soft_delete_on_manufacturers.php @@ -0,0 +1,30 @@ +softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_20_123725_add_soft_delete_on_categories.php b/app/database/migrations/2013_11_20_123725_add_soft_delete_on_categories.php new file mode 100644 index 0000000000..3ba4868d64 --- /dev/null +++ b/app/database/migrations/2013_11_20_123725_add_soft_delete_on_categories.php @@ -0,0 +1,30 @@ +softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_20_130248_create_status_labels.php b/app/database/migrations/2013_11_20_130248_create_status_labels.php new file mode 100644 index 0000000000..40b851b299 --- /dev/null +++ b/app/database/migrations/2013_11_20_130248_create_status_labels.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('name',100); + $table->integer('user_id'); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('status_labels'); + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_20_130830_add_status_id_on_assets_table.php b/app/database/migrations/2013_11_20_130830_add_status_id_on_assets_table.php new file mode 100644 index 0000000000..d52fafb0a8 --- /dev/null +++ b/app/database/migrations/2013_11_20_130830_add_status_id_on_assets_table.php @@ -0,0 +1,33 @@ +integer('status_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('assets', function($table) + { + $table->dropColumn('status_id'); + }); + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_20_131544_add_status_type_on_status_labels.php b/app/database/migrations/2013_11_20_131544_add_status_type_on_status_labels.php new file mode 100644 index 0000000000..c5f51e39f8 --- /dev/null +++ b/app/database/migrations/2013_11_20_131544_add_status_type_on_status_labels.php @@ -0,0 +1,33 @@ +boolean('deployable'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('status_labels', function($table) + { + $table->dropColumn('deployable'); + }); + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_20_134103_add_archived_to_assets.php b/app/database/migrations/2013_11_20_134103_add_archived_to_assets.php new file mode 100644 index 0000000000..63df7b13db --- /dev/null +++ b/app/database/migrations/2013_11_20_134103_add_archived_to_assets.php @@ -0,0 +1,33 @@ +boolean('archived'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('assets', function($table) + { + $table->dropColumn('archived'); + }); + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_21_002321_add_uploads_table.php b/app/database/migrations/2013_11_21_002321_add_uploads_table.php new file mode 100644 index 0000000000..2a0e10c5a3 --- /dev/null +++ b/app/database/migrations/2013_11_21_002321_add_uploads_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->integer('user_id'); + $table->string('filename'); + $table->integer('asset_id'); + $table->string('filenotes')->nullable; + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('asset_uploads'); + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_21_024531_remove_deployable_boolean_from_status_labels.php b/app/database/migrations/2013_11_21_024531_remove_deployable_boolean_from_status_labels.php new file mode 100644 index 0000000000..966c5eb19d --- /dev/null +++ b/app/database/migrations/2013_11_21_024531_remove_deployable_boolean_from_status_labels.php @@ -0,0 +1,33 @@ +dropColumn('deployable'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('status_labels', function($table) + { + $table->boolean('deployable'); + }); + } + +} \ No newline at end of file diff --git a/app/database/migrations/2013_11_22_075308_add_option_label_to_settings_table.php b/app/database/migrations/2013_11_22_075308_add_option_label_to_settings_table.php new file mode 100644 index 0000000000..97b45288da --- /dev/null +++ b/app/database/migrations/2013_11_22_075308_add_option_label_to_settings_table.php @@ -0,0 +1,33 @@ +string('option_label','80')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('settings', function($table) + { + $table->dropColumn('option_label'); + }); + } + +} \ No newline at end of file diff --git a/app/database/seeds/AssetsSeeder.php b/app/database/seeds/AssetsSeeder.php index dab589766d..e12a58ed73 100644 --- a/app/database/seeds/AssetsSeeder.php +++ b/app/database/seeds/AssetsSeeder.php @@ -23,8 +23,10 @@ class AssetsSeeder extends Seeder { 'user_id' => 1, 'assigned_to' => 1, 'physical' => 1, + 'archived' => 0, 'license_name' => NULL, 'license_email' => NULL, + 'status_id' => NULL, ); $asset[] = array( @@ -40,8 +42,10 @@ class AssetsSeeder extends Seeder { 'user_id' => 1, 'assigned_to' => 1, 'physical' => 1, + 'archived' => 0, 'license_name' => NULL, 'license_email' => NULL, + 'status_id' => NULL, ); $asset[] = array( @@ -57,8 +61,10 @@ class AssetsSeeder extends Seeder { 'user_id' => 2, 'assigned_to' => 2, 'physical' => 1, + 'archived' => 0, 'license_name' => NULL, 'license_email' => NULL, + 'status_id' => NULL, ); $asset[] = array( @@ -74,8 +80,10 @@ class AssetsSeeder extends Seeder { 'user_id' => 2, 'assigned_to' => 2, 'physical' => 0, + 'archived' => 0, 'license_name' => 'Alison Giasnotto', 'license_email' => 'snipe@snipe.net', + 'status_id' => NULL, ); $asset[] = array( @@ -91,8 +99,10 @@ class AssetsSeeder extends Seeder { 'user_id' => 2, 'assigned_to' => 2, 'physical' => 0, + 'archived' => 0, 'license_name' => 'Alison Giasnotto', 'license_email' => 'me@example.com', + 'status_id' => NULL, ); $asset[] = array( @@ -108,8 +118,10 @@ class AssetsSeeder extends Seeder { 'user_id' => 2, 'assigned_to' => 2, 'physical' => 1, + 'archived' => 0, 'license_name' => NULL, 'license_email' => NULL, + 'status_id' => NULL, ); $asset[] = array( @@ -125,10 +137,90 @@ class AssetsSeeder extends Seeder { 'user_id' => 2, 'assigned_to' => 2, 'physical' => 1, + 'archived' => 0, 'license_name' => NULL, 'license_email' => NULL, + 'status_id' => NULL, ); + $asset[] = array( + 'name' => 'Broke-Ass Laptop', + 'asset_tag' => 'NNY67567775', + 'model_id' => 2, + 'serial' => 'WS89080890', + 'purchase_date' => '2012-01-02', + 'purchase_cost' => '1999.99', + 'order_number' => '657756', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 2, + 'assigned_to' => NULL, + 'physical' => 1, + 'archived' => 0, + 'license_name' => NULL, + 'license_email' => NULL, + 'status_id' => '3', + ); + + $asset[] = array( + 'name' => 'Maybe Broke-Ass Laptop', + 'asset_tag' => 'NNY6755667775', + 'model_id' => 2, + 'serial' => 'WS45689080890', + 'purchase_date' => '2012-01-02', + 'purchase_cost' => '1999.99', + 'order_number' => '657756', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + 'assigned_to' => NULL, + 'physical' => 1, + 'archived' => 0, + 'license_name' => NULL, + 'license_email' => NULL, + 'status_id' => '2', + ); + + + $asset[] = array( + 'name' => 'Completely Facacta Laptop', + 'asset_tag' => 'NNY6564567775', + 'model_id' => 2, + 'serial' => 'WS99689080890', + 'purchase_date' => '2012-01-02', + 'purchase_cost' => '1999.99', + 'order_number' => '657756', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + 'assigned_to' => NULL, + 'physical' => 1, + 'archived' => 1, + 'license_name' => NULL, + 'license_email' => NULL, + 'status_id' => '4', + ); + + $asset[] = array( + 'name' => 'Drunken Shanenigans Laptop', + 'asset_tag' => 'NNY6564567775', + 'model_id' => 2, + 'serial' => 'WS99689080890', + 'purchase_date' => '2012-01-02', + 'purchase_cost' => '1999.99', + 'order_number' => '657756', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + 'assigned_to' => NULL, + 'physical' => 1, + 'archived' => 1, + 'license_name' => NULL, + 'license_email' => NULL, + 'status_id' => '5', + ); + + // Delete all the old data diff --git a/app/database/seeds/DatabaseSeeder.php b/app/database/seeds/DatabaseSeeder.php index 0e309f1c27..e2e075090a 100755 --- a/app/database/seeds/DatabaseSeeder.php +++ b/app/database/seeds/DatabaseSeeder.php @@ -17,6 +17,8 @@ class DatabaseSeeder extends Seeder { $this->call('ManufacturersSeeder'); $this->call('ModelsSeeder'); $this->call('DepreciationsSeeder'); + $this->call('StatuslabelsSeeder'); + $this->call('SettingsSeeder'); } } diff --git a/app/database/seeds/SettingsSeeder.php b/app/database/seeds/SettingsSeeder.php new file mode 100644 index 0000000000..cc16064825 --- /dev/null +++ b/app/database/seeds/SettingsSeeder.php @@ -0,0 +1,41 @@ + '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', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + ); + + + // Delete all the old data + DB::table('settings')->truncate(); + + // Insert the new posts + Setting::insert($setting); + } + +} + + diff --git a/app/database/seeds/StatuslabelsSeeder.php b/app/database/seeds/StatuslabelsSeeder.php new file mode 100644 index 0000000000..b967c3db8b --- /dev/null +++ b/app/database/seeds/StatuslabelsSeeder.php @@ -0,0 +1,55 @@ + 'Out for Diagnostics', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + ); + + + $status[] = array( + 'name' => 'Out for Repair', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + ); + + + $status[] = array( + 'name' => 'Broken - Not Fixable', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + ); + + $status[] = array( + 'name' => 'Lost/Stolen', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + ); + + + + // Delete all the old data + DB::table('status_labels')->truncate(); + + // Insert the new posts + Statuslabel::insert($status); + } + +} + + diff --git a/app/lang/en/admin/assets/message.php b/app/lang/en/admin/assets/message.php index d6164f1df0..5a0c37d686 100755 --- a/app/lang/en/admin/assets/message.php +++ b/app/lang/en/admin/assets/message.php @@ -3,6 +3,7 @@ return array( 'does_not_exist' => 'Asset does not exist.', + 'assoc_users' => 'This asset is currently checked out to a user and cannot be deleted. Please check the asset in first, and then try deleting again. ', 'create' => array( 'error' => 'Asset was not created, please try again. :(', diff --git a/app/lang/en/admin/categories/message.php b/app/lang/en/admin/categories/message.php index 9a08c18cb5..82fc4f4018 100755 --- a/app/lang/en/admin/categories/message.php +++ b/app/lang/en/admin/categories/message.php @@ -3,6 +3,7 @@ return array( 'does_not_exist' => 'Category does not exist.', + 'assoc_users' => 'This category is currently associated with at least one model and cannot be deleted. Please update your models to no longer reference this category and try again. ', 'create' => array( 'error' => 'Category was not created, please try again.', diff --git a/app/lang/en/admin/depreciations/message.php b/app/lang/en/admin/depreciations/message.php index faf054b2fe..0fc9b07301 100755 --- a/app/lang/en/admin/depreciations/message.php +++ b/app/lang/en/admin/depreciations/message.php @@ -3,6 +3,8 @@ return array( 'does_not_exist' => 'Depreciation class does not exist.', + 'assoc_users' => 'This depreciation is currently associated with one or more models and cannot be deleted. Please delete the models, and then try deleting again. ', + 'create' => array( 'error' => 'Depreciation class was not created, please try again. :(', diff --git a/app/lang/en/admin/licenses/message.php b/app/lang/en/admin/licenses/message.php index 0ba7afe8d8..943ede9494 100755 --- a/app/lang/en/admin/licenses/message.php +++ b/app/lang/en/admin/licenses/message.php @@ -4,6 +4,8 @@ return array( 'does_not_exist' => 'License does not exist.', 'user_does_not_exist' => 'User does not exist.', + 'assoc_users' => 'This license is currently checked out to a user and cannot be deleted. Please check the license in first, and then try deleting again. ', + 'create' => array( 'error' => 'License was not created, please try again.', diff --git a/app/lang/en/admin/locations/message.php b/app/lang/en/admin/locations/message.php index b7a346098a..626fb6bbfb 100755 --- a/app/lang/en/admin/locations/message.php +++ b/app/lang/en/admin/locations/message.php @@ -3,6 +3,8 @@ return array( 'does_not_exist' => 'Location does not exist.', + 'assoc_users' => 'This location is currently associated with at least one user and cannot be deleted. Please update your users to no longer reference this location and try again. ', + 'create' => array( 'error' => 'Location was not created, please try again.', diff --git a/app/lang/en/admin/manufacturers/message.php b/app/lang/en/admin/manufacturers/message.php index 5ae15966b8..e292c39599 100755 --- a/app/lang/en/admin/manufacturers/message.php +++ b/app/lang/en/admin/manufacturers/message.php @@ -3,6 +3,7 @@ return array( 'does_not_exist' => 'Manufacturer does not exist.', + 'assoc_users' => 'This manufacturer is currently associated with at least one model and cannot be deleted. Please update your models to no longer reference this manufacturer and try again. ', 'create' => array( 'error' => 'Manufacturer was not created, please try again.', diff --git a/app/lang/en/admin/models/message.php b/app/lang/en/admin/models/message.php index 497fd2bd12..3b87420f8e 100755 --- a/app/lang/en/admin/models/message.php +++ b/app/lang/en/admin/models/message.php @@ -3,6 +3,8 @@ return array( 'does_not_exist' => 'Model does not exist.', + 'assoc_users' => 'This model is currently associated with one or more assets and cannot be deleted. Please delete the assets, and then try deleting again. ', + 'create' => array( 'error' => 'Model was not created, please try again.', diff --git a/app/lang/en/admin/statuslabels/message.php b/app/lang/en/admin/statuslabels/message.php new file mode 100755 index 0000000000..626fb6bbfb --- /dev/null +++ b/app/lang/en/admin/statuslabels/message.php @@ -0,0 +1,24 @@ + 'Location does not exist.', + 'assoc_users' => 'This location is currently associated with at least one user and cannot be deleted. Please update your users to no longer reference this location and try again. ', + + + 'create' => array( + 'error' => 'Location was not created, please try again.', + 'success' => 'Location created successfully.' + ), + + 'update' => array( + 'error' => 'Location was not updated, please try again', + 'success' => 'Location updated successfully.' + ), + + 'delete' => array( + 'error' => 'There was an issue deleting the location. Please try again.', + 'success' => 'The location was deleted successfully.' + ) + +); diff --git a/app/lang/en/admin/statuslabels/table.php b/app/lang/en/admin/statuslabels/table.php new file mode 100755 index 0000000000..09abfd2937 --- /dev/null +++ b/app/lang/en/admin/statuslabels/table.php @@ -0,0 +1,11 @@ + 'ID', + 'name' => 'Name', + 'city' => 'City', + 'state' => 'State', + 'country' => 'Country', + +); diff --git a/app/models/Actionlog.php b/app/models/Actionlog.php index 018fe50fc3..d7c4402697 100644 --- a/app/models/Actionlog.php +++ b/app/models/Actionlog.php @@ -7,7 +7,7 @@ class ActionLog extends Eloquent { public function assetlog() { - return $this->belongsTo('Asset','asset_id'); + return $this->belongsTo('Asset','asset_id')->withTrashed(); } public function adminlog() { diff --git a/app/models/Asset.php b/app/models/Asset.php index f45e1bc626..ae239f8db5 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -71,7 +71,7 @@ class Asset extends Elegant { */ public function adminuser() { - return $this->belongsTo('User','id'); + return $this->belongsTo('User','user_id'); } /** @@ -94,6 +94,7 @@ class Asset extends Elegant { return DB::table('assets') ->where('physical', '=', '1') ->where('assigned_to', '=', '0') + ->whereNull('status_id','and') ->whereNull('deleted_at','and') ->count(); diff --git a/app/models/Category.php b/app/models/Category.php index 449880f467..fc5e117358 100644 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -2,6 +2,8 @@ class Category extends Elegant { + protected $softDelete = true; + /** * Category validation rules */ @@ -19,6 +21,10 @@ class Category extends Elegant { return $this->belongsTo('Category','parent'); } + public function has_models() + { + return $this->hasMany('Model', 'category_id')->count(); + } diff --git a/app/models/Depreciation.php b/app/models/Depreciation.php index 8413364801..940dd35b5b 100644 --- a/app/models/Depreciation.php +++ b/app/models/Depreciation.php @@ -8,5 +8,9 @@ class Depreciation extends Elegant { 'months' => 'required|min:1|integer', ); + public function has_models() + { + return $this->hasMany('Model', 'depreciation_id')->count(); + } } diff --git a/app/models/License.php b/app/models/License.php index 85325e3f57..e6be056409 100644 --- a/app/models/License.php +++ b/app/models/License.php @@ -30,7 +30,7 @@ class License extends Elegant { } /** - * Get action logs for this asset + * Get asset logs for this asset */ public function assetlog() { @@ -38,7 +38,7 @@ class License extends Elegant { } /** - * Get action logs for this asset + * Get admin user for this asset */ public function adminuser() { diff --git a/app/models/Location.php b/app/models/Location.php index 2030057631..b72c2417c0 100644 --- a/app/models/Location.php +++ b/app/models/Location.php @@ -2,6 +2,8 @@ class Location extends Elegant { + + protected $softDelete = true; protected $table = 'locations'; protected $rules = array( 'name' => 'required|min:3', @@ -10,4 +12,9 @@ class Location extends Elegant { 'country' => 'required|alpha|min:2|max:2', ); + public function has_users() + { + return $this->hasMany('User', 'location_id')->count(); + } + } diff --git a/app/models/Manufacturer.php b/app/models/Manufacturer.php index e9bf470d17..6d53c1018d 100644 --- a/app/models/Manufacturer.php +++ b/app/models/Manufacturer.php @@ -1,9 +1,15 @@ 'required|min:2', ); + public function has_models() + { + return $this->hasMany('Model', 'manufacturer_id')->count(); + } + } diff --git a/app/models/Setting.php b/app/models/Setting.php new file mode 100644 index 0000000000..98d9c43b6e --- /dev/null +++ b/app/models/Setting.php @@ -0,0 +1,17 @@ + 'required|min:3', + "option_value['per_page']" => 'required|min:1|numeric', + ); + + public function getsettings() + { + $foo = Setting::all(); + print_r($foo); + } + +} diff --git a/app/models/Statuslabel.php b/app/models/Statuslabel.php new file mode 100644 index 0000000000..e484d577ae --- /dev/null +++ b/app/models/Statuslabel.php @@ -0,0 +1,16 @@ + 'required|min:2', + ); + + public function has_assets() + { + return $this->hasMany('Asset', 'status_id')->count(); + } + +} diff --git a/app/routes.php b/app/routes.php index 2512d19b2d..7ac1b6ee6f 100755 --- a/app/routes.php +++ b/app/routes.php @@ -54,6 +54,7 @@ Route::group(array('prefix' => 'assets'), function() Route::group(array('prefix' => 'admin'), function() { + # Licenses Route::group(array('prefix' => 'licenses'), function() { @@ -77,6 +78,15 @@ Route::group(array('prefix' => 'admin'), function() # Admin Settings Routes (for categories, maufactureres, etc) Route::group(array('prefix' => 'settings'), function() { + + # Settings + Route::group(array('prefix' => 'app'), function() + { + Route::get('/', array('as' => 'app', 'uses' => 'Controllers\Admin\SettingsController@getIndex')); + Route::get('edit', array('as' => 'edit/settings', 'uses' => 'Controllers\Admin\SettingsController@getEdit')); + Route::post('edit', 'Controllers\Admin\SettingsController@postEdit'); + }); + # Manufacturers Route::group(array('prefix' => 'manufacturers'), function() { @@ -121,6 +131,18 @@ Route::group(array('prefix' => 'admin'), function() Route::get('{locationId}/delete', array('as' => 'delete/location', 'uses' => 'Controllers\Admin\LocationsController@getDelete')); }); + # Status Labels + Route::group(array('prefix' => 'statuslabels'), function() + { + Route::get('/', array('as' => 'statuslabels', 'uses' => 'Controllers\Admin\StatuslabelsController@getIndex')); + Route::get('create', array('as' => 'create/statuslabel', 'uses' => 'Controllers\Admin\StatuslabelsController@getCreate')); + Route::post('create', 'Controllers\Admin\StatuslabelsController@postCreate'); + Route::get('{statuslabelId}/edit', array('as' => 'update/statuslabel', 'uses' => 'Controllers\Admin\StatuslabelsController@getEdit')); + Route::post('{statuslabelId}/edit', 'Controllers\Admin\StatuslabelsController@postEdit'); + Route::get('{statuslabelId}/delete', array('as' => 'delete/statuslabel', 'uses' => 'Controllers\Admin\StatuslabelsController@getDelete')); + }); + + }); diff --git a/app/views/backend/assets/edit.blade.php b/app/views/backend/assets/edit.blade.php index ebf8d0f9cd..853565cf9a 100755 --- a/app/views/backend/assets/edit.blade.php +++ b/app/views/backend/assets/edit.blade.php @@ -105,8 +105,6 @@ - -
@@ -118,6 +116,18 @@
+ +
+ +
+
+ {{ Form::select('status_id', $statuslabel_list , Input::old('status_id', $asset->status_id), array('class'=>'select2', 'style'=>'width:250px')) }} + {{ $errors->first('depreciation_id', ':message') }} +
+
+
+ +
@@ -136,7 +146,7 @@
Cancel - +
diff --git a/app/views/backend/assets/index.blade.php b/app/views/backend/assets/index.blade.php index aa490f45d0..940a834678 100755 --- a/app/views/backend/assets/index.blade.php +++ b/app/views/backend/assets/index.blade.php @@ -42,15 +42,15 @@ Assets :: {{ $asset->name }} {{ $asset->serial }} - @if ($asset->assigned_to != 0) + @if ($asset->assigneduser) {{ $asset->assigneduser->fullName() }} @endif - @if (($asset->assigned_to > 0) && ($asset->assigneduser->location_id > 0)) - {{ Location::find($asset->assigneduser->location_id)->name }} + @if ($asset->assigneduser && $asset->assetloc) + {{ $asset->assetloc->name }} @endif diff --git a/app/views/backend/assets/view.blade.php b/app/views/backend/assets/view.blade.php index cbb077d360..cdd83df4a7 100644 --- a/app/views/backend/assets/view.blade.php +++ b/app/views/backend/assets/view.blade.php @@ -12,7 +12,6 @@ View Asset {{ $asset->asset_tag }} ::

History for {{ $asset->asset_tag }} ({{ $asset->name }}) -
- -

- - - - -
@@ -90,7 +78,7 @@ View Asset {{ $asset->asset_tag }} :: {{ $asset->created_at }} - @if (isset($asset->adminuser->id)) + @if ($asset->adminuser->id) {{ $asset->adminuser->fullName() }} @else Unknown Admin diff --git a/app/views/backend/layouts/default.blade.php b/app/views/backend/layouts/default.blade.php index 6c8a610c51..7d3a77a869 100755 --- a/app/views/backend/layouts/default.blade.php +++ b/app/views/backend/layouts/default.blade.php @@ -92,7 +92,7 @@
diff --git a/app/views/backend/locations/index.blade.php b/app/views/backend/locations/index.blade.php index 6a43a6c257..5d6c23593a 100755 --- a/app/views/backend/locations/index.blade.php +++ b/app/views/backend/locations/index.blade.php @@ -2,7 +2,7 @@ {{-- Page title --}} @section('title') -Asset Depreciations :: +Locations :: @parent @stop diff --git a/app/views/backend/settings/edit.blade.php b/app/views/backend/settings/edit.blade.php new file mode 100755 index 0000000000..4cb50ff827 --- /dev/null +++ b/app/views/backend/settings/edit.blade.php @@ -0,0 +1,63 @@ +@extends('backend/layouts/default') + +{{-- Page title --}} +@section('title') + Update Settings :: +@parent +@stop + +{{-- Page content --}} +@section('content') +