diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index de4f040f83..32df7dce2a 100755 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -46,6 +46,8 @@ class AssetsController extends AdminController $assets->RTD(); } elseif (Input::get('Undeployable')) { $assets->Undeployable(); + } elseif (Input::get('Archived')) { + $assets->Archived(); } elseif (Input::get('Deployed')) { $assets->Deployed(); } @@ -93,7 +95,7 @@ class AssetsController extends AdminController // Grab the dropdown list of status - $statuslabel_list = array('' => Lang::get('general.pending')) + array('0' => Lang::get('general.ready_to_deploy')) + Statuslabel::orderBy('name', 'asc')->lists('name', 'id'); + $statuslabel_list = Statuslabel::orderBy('name', 'asc')->lists('name', 'id'); $view = View::make('backend/hardware/edit'); $view->with('supplier_list',$supplier_list); @@ -238,7 +240,7 @@ class AssetsController extends AdminController $location_list = array('' => '') + Location::orderBy('name', 'asc')->lists('name', 'id'); // Grab the dropdown list of status - $statuslabel_list = array('' => Lang::get('general.pending')) + array('0' => Lang::get('general.ready_to_deploy')) + Statuslabel::orderBy('name', 'asc')->lists('name', 'id'); + $statuslabel_list = Statuslabel::orderBy('name', 'asc')->lists('name', 'id'); return View::make('backend/hardware/edit', compact('asset'))->with('model_list',$model_list)->with('supplier_list',$supplier_list)->with('location_list',$location_list)->with('statuslabel_list',$statuslabel_list); } @@ -589,7 +591,7 @@ class AssetsController extends AdminController $model_list = array('' => '') + Model::lists('name', 'id'); // Grab the dropdown list of status - $statuslabel_list = array('' => 'Pending') + array('0' => 'Ready to Deploy') + Statuslabel::lists('name', 'id'); + $statuslabel_list = Statuslabel::lists('name', 'id'); $location_list = array('' => '') + Location::lists('name', 'id'); diff --git a/app/controllers/admin/StatuslabelsController.php b/app/controllers/admin/StatuslabelsController.php index 9e6868c495..0185052e43 100755 --- a/app/controllers/admin/StatuslabelsController.php +++ b/app/controllers/admin/StatuslabelsController.php @@ -38,7 +38,12 @@ class StatuslabelsController extends AdminController public function getCreate() { // Show the page - return View::make('backend/statuslabels/edit')->with('statuslabel',new Statuslabel); + $statuslabel = new Statuslabel; + $use_statuslabel_type = $statuslabel->getStatuslabelType(); + + $statuslabel_types = array('' => Lang::get('admin/hardware/form.select_statustype')) + array('undeployable' => Lang::get('admin/hardware/general.undeployable')) + array('pending' => Lang::get('admin/hardware/general.pending')) + array('archived' => Lang::get('admin/hardware/general.archived')) + array('deployable' => Lang::get('admin/hardware/general.deployable')); + + return View::make('backend/statuslabels/edit', compact('statuslabel_types','statuslabel'))->with('use_statuslabel_type',$use_statuslabel_type); } @@ -59,9 +64,15 @@ class StatuslabelsController extends AdminController // attempt validation if ($statuslabel->validate($new)) { + $statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types')); + // Save the Statuslabel data $statuslabel->name = e(Input::get('name')); $statuslabel->user_id = Sentry::getId(); + $statuslabel->notes = e(Input::get('notes')); + $statuslabel->deployable = $statustype['deployable']; + $statuslabel->pending = $statustype['pending']; + $statuslabel->archived = $statustype['archived']; // Was the asset created? if($statuslabel->save()) { @@ -94,8 +105,11 @@ class StatuslabelsController extends AdminController return Redirect::to('admin/settings/statuslabels')->with('error', Lang::get('admin/statuslabels/message.does_not_exist')); } + $use_statuslabel_type = $statuslabel->getStatuslabelType(); - return View::make('backend/statuslabels/edit', compact('statuslabel')); + $statuslabel_types = array('' => Lang::get('admin/hardware/form.select_statustype')) + array('undeployable' => Lang::get('admin/hardware/general.undeployable')) + array('pending' => Lang::get('admin/hardware/general.pending')) + array('archived' => Lang::get('admin/hardware/general.archived')) + array('deployable' => Lang::get('admin/hardware/general.deployable')); + + return View::make('backend/statuslabels/edit', compact('statuslabel','statuslabel_types'))->with('use_statuslabel_type',$use_statuslabel_type); } @@ -118,20 +132,27 @@ class StatuslabelsController extends AdminController if ($validator->fails()) { - // The given data did not pass validation + // The given data did not pass validation return Redirect::back()->withInput()->withErrors($validator->messages()); } // attempt validation else { // Update the Statuslabel data + $statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types')); + $statuslabel->name = e(Input::get('name')); + $statuslabel->notes = e(Input::get('notes')); + $statuslabel->deployable = $statustype['deployable']; + $statuslabel->pending = $statustype['pending']; + $statuslabel->archived = $statustype['archived']; + // Was the asset created? if($statuslabel->save()) { // Redirect to the saved Statuslabel page return Redirect::to("admin/settings/statuslabels/")->with('success', Lang::get('admin/statuslabels/message.update.success')); } - } + } // Redirect to the Statuslabel management page return Redirect::to("admin/settings/statuslabels/$statuslabelId/edit")->with('error', Lang::get('admin/statuslabels/message.update.error')); diff --git a/app/database/migrations/2015_02_10_040958_fix_bad_assigned_to_ids.php b/app/database/migrations/2015_02_10_040958_fix_bad_assigned_to_ids.php new file mode 100644 index 0000000000..5ca94c54a2 --- /dev/null +++ b/app/database/migrations/2015_02_10_040958_fix_bad_assigned_to_ids.php @@ -0,0 +1,48 @@ +boolean('deployable')->default(0); + $table->boolean('pending')->default(0); + $table->boolean('archived')->default(0); + $table->text('notes')->nullable(); + }); + + DB::statement('INSERT into ' . DB::getTablePrefix() . 'status_labels (user_id, name, deployable, pending, archived, notes) VALUES (1,"Pending",0,1,0,"These assets are not yet ready to be deployed, usually because of configuration or waiting on parts.")'); + DB::statement('INSERT into ' . DB::getTablePrefix() . 'status_labels (user_id, name, deployable, pending, archived, notes) VALUES (1,"Ready to Deploy",1,0,0,"These assets are ready to deploy.")'); + DB::statement('INSERT into ' . DB::getTablePrefix() . 'status_labels (user_id, name, deployable, pending, archived, notes) VALUES (1,"Archived",0,0,1,"These assets are no longer in circulation or viable.")'); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::table('status_labels', function ($table) { + $table->dropColumn('deployable'); + $table->dropColumn('pending'); + $table->dropColumn('archived'); + $table->dropColumn('notes'); + + }); + } + +} diff --git a/app/database/migrations/2015_02_10_053310_migrate_data_to_new_statuses.php b/app/database/migrations/2015_02_10_053310_migrate_data_to_new_statuses.php new file mode 100644 index 0000000000..66cb6609df --- /dev/null +++ b/app/database/migrations/2015_02_10_053310_migrate_data_to_new_statuses.php @@ -0,0 +1,60 @@ +name =="Pending") { + $pending_id = array($status->id); + } elseif ($status->name =="Ready to Deploy") { + $rtd_id = array($status->id); + } + } + + // Pending + $pendings = DB::select('select * from ' . DB::getTablePrefix() . 'assets where status_id IS NULL AND physical=1 '); + + foreach ($pendings as $pending) { + DB::update('update ' . DB::getTablePrefix() . 'assets set status_id = ? where status_id IS NULL AND physical=1',$pending_id); + + } + + + // Ready to Deploy + $rtds = DB::select('select * from ' . DB::getTablePrefix() . 'assets where status_id = 0 AND physical=1 '); + + foreach ($rtds as $rtd) { + //DB::update('update users set votes = 100 where name = ?', array('John')); + DB::update('update ' . DB::getTablePrefix() . 'assets set status_id = ? where status_id = 0 AND physical=1',$rtd_id); + + } + + + + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } + +} diff --git a/app/database/seeds/AssetsSeeder.php b/app/database/seeds/AssetsSeeder.php index 693dbfce17..ac20850cf3 100755 --- a/app/database/seeds/AssetsSeeder.php +++ b/app/database/seeds/AssetsSeeder.php @@ -22,10 +22,10 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 0, - 'status_id' => NULL, + 'status_id' => 1, 'notes' => '', 'deleted_at' => NULL, 'archived' => '0', @@ -45,10 +45,10 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 0, - 'status_id' => NULL, + 'status_id' => 1, 'notes' => '', 'deleted_at' => NULL, 'archived' => '0', @@ -69,10 +69,10 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 0, - 'status_id' => 0, + 'status_id' => 2, 'notes' => '', 'deleted_at' => NULL, 'archived' => '0', @@ -92,10 +92,10 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 0, - 'status_id' => 0, + 'status_id' => 1, 'notes' => '', 'deleted_at' => NULL, 'archived' => '0', @@ -115,10 +115,10 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 2, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 0, - 'status_id' => 0, + 'status_id' => 2, 'notes' => '', 'deleted_at' => NULL, 'archived' => '0', @@ -142,7 +142,7 @@ class AssetsSeeder extends Seeder 'assigned_to' => 2, 'physical' => 1, 'archived' => 0, - 'status_id' => 0, + 'status_id' => 1, 'notes' => '', 'deleted_at' => NULL, 'archived' => '0', @@ -165,7 +165,7 @@ class AssetsSeeder extends Seeder 'assigned_to' => 2, 'physical' => 1, 'archived' => 0, - 'status_id' => 0, + 'status_id' => 1, 'notes' => '', 'deleted_at' => NULL, 'archived' => '0', @@ -185,7 +185,7 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 2, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 0, 'status_id' => '3', @@ -208,7 +208,7 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 0, 'status_id' => '2', @@ -231,7 +231,7 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 1, 'status_id' => '4', @@ -254,7 +254,7 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 1, 'status_id' => '3', @@ -277,10 +277,10 @@ class AssetsSeeder extends Seeder 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 2, - 'assigned_to' => 0, + 'assigned_to' => NULL, 'physical' => 1, 'archived' => 0, - 'status_id' => 0, + 'status_id' => 1, 'notes' => '', 'deleted_at' => NULL, 'archived' => '0', diff --git a/app/database/seeds/StatuslabelsSeeder.php b/app/database/seeds/StatuslabelsSeeder.php index abedf39a30..5ec3bf2cd8 100755 --- a/app/database/seeds/StatuslabelsSeeder.php +++ b/app/database/seeds/StatuslabelsSeeder.php @@ -10,12 +10,53 @@ class StatuslabelsSeeder extends Seeder $date = new DateTime; + $status[] = array( + 'name' => 'Ready to Deploy', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + 'deleted_at' => NULL, + 'deployable' => 1, + 'pending' => 0, + 'archived' => 0, + 'notes' => '' + ); + + $status[] = array( + 'name' => 'Pending', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + 'deleted_at' => NULL, + 'deployable' => 0, + 'pending' => 1, + 'archived' => 0, + 'notes' => '' + ); + + $status[] = array( + 'name' => 'Archived', + 'created_at' => $date->modify('-10 day'), + 'updated_at' => $date->modify('-3 day'), + 'user_id' => 1, + 'deleted_at' => NULL, + 'deployable' => 0, + 'pending' => 0, + 'archived' => 1, + 'notes' => 'These assets are permanently undeployable' + ); + + $status[] = array( 'name' => 'Out for Diagnostics', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'deleted_at' => NULL, + 'deployable' => 0, + 'pending' => 0, + 'archived' => 0, + 'notes' => '' ); @@ -25,6 +66,10 @@ class StatuslabelsSeeder extends Seeder 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'deleted_at' => NULL, + 'deployable' => 0, + 'pending' => 0, + 'archived' => 0, + 'notes' => '' ); @@ -34,6 +79,10 @@ class StatuslabelsSeeder extends Seeder 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'deleted_at' => NULL, + 'deployable' => 0, + 'pending' => 0, + 'archived' => 1, + 'notes' => '' ); $status[] = array( @@ -42,6 +91,10 @@ class StatuslabelsSeeder extends Seeder 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'deleted_at' => NULL, + 'deployable' => 0, + 'pending' => 0, + 'archived' => 1, + 'notes' => '', ); diff --git a/app/lang/en/admin/hardware/form.php b/app/lang/en/admin/hardware/form.php index 6b6b6e512d..aef375bd0a 100755 --- a/app/lang/en/admin/hardware/form.php +++ b/app/lang/en/admin/hardware/form.php @@ -23,6 +23,7 @@ return array( 'order' => 'Order Number', 'qr' => 'QR Code', 'requestable' => 'Users may request this asset', + 'select_statustype' => 'Select Status Type', 'serial' => 'Serial', 'status' => 'Status', 'supplier' => 'Supplier', diff --git a/app/lang/en/admin/hardware/general.php b/app/lang/en/admin/hardware/general.php index 9e7915462f..a89940af34 100755 --- a/app/lang/en/admin/hardware/general.php +++ b/app/lang/en/admin/hardware/general.php @@ -1,11 +1,14 @@ 'Archived', 'asset' => 'Asset', 'checkin' => 'Checkin Asset', 'checkout' => 'Checkout Asset to User', 'clone' => 'Clone Asset', + 'deployable' => 'Deployable', 'edit' => 'Edit Asset', - 'pending' => 'Pending Asset', + 'pending' => 'Pending', + 'undeployable' => 'Undeployable', 'view' => 'View Asset', ); diff --git a/app/lang/en/admin/statuslabels/message.php b/app/lang/en/admin/statuslabels/message.php index 98280082ef..de5d901281 100755 --- a/app/lang/en/admin/statuslabels/message.php +++ b/app/lang/en/admin/statuslabels/message.php @@ -2,18 +2,18 @@ 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. ', + 'does_not_exist' => 'Status label does not exist.', + 'assoc_users' => 'This status label 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.' + 'error' => 'Status label was not created, please try again.', + 'success' => 'Status label created successfully.' ), 'update' => array( - 'error' => 'Location was not updated, please try again', - 'success' => 'Location updated successfully.' + 'error' => 'Status label was not updated, please try again', + 'success' => 'Status label updated successfully.' ), 'delete' => array( diff --git a/app/lang/en/admin/statuslabels/table.php b/app/lang/en/admin/statuslabels/table.php index 54094c5491..dd21781115 100755 --- a/app/lang/en/admin/statuslabels/table.php +++ b/app/lang/en/admin/statuslabels/table.php @@ -1,10 +1,15 @@ 'Status Name', - 'title' => 'Status Labels', - 'update' => 'Update Status Label', - 'create' => 'Create Status Label', 'about' => 'About Status Labels', - 'info' => 'Status labels are used to describe the various reasons why an asset cannot be deployed. It could be broken, out for diagnostics, out for repair, lost or stolen, etc. Status labels allow your team to show the progression.', + 'archived' => 'Archived', + 'create' => 'Create Status Label', + 'deployable' => 'Deployable', + 'info' => 'Status labels are used to describe the various states your assets could be in. They may be out for repair, lost/stolen, etc. You can create new status labels for deployable, pending and archived assets.', + 'name' => 'Status Name', + 'pending' => 'Pending', + 'status_type' => 'Status Type', + 'title' => 'Status Labels', + 'undeployable' => 'Undeployable', + 'update' => 'Update Status Label', ); diff --git a/app/lang/en/general.php b/app/lang/en/general.php index f25b694509..7c9cd05d2d 100755 --- a/app/lang/en/general.php +++ b/app/lang/en/general.php @@ -7,6 +7,7 @@ return array( 'admin' => 'Admin', 'all_assets' => 'All Assets', 'all' => 'All', + 'archived' => 'Archived', 'asset_models' => 'Asset Models', 'asset' => 'Asset', 'asset_report' => 'Asset Report', diff --git a/app/lang/pl/admin/hardware/general.php b/app/lang/pl/admin/hardware/general.php index 9e7915462f..7c5d5e3cce 100755 --- a/app/lang/pl/admin/hardware/general.php +++ b/app/lang/pl/admin/hardware/general.php @@ -1,11 +1,11 @@ 'Asset', - 'checkin' => 'Checkin Asset', - 'checkout' => 'Checkout Asset to User', - 'clone' => 'Clone Asset', - 'edit' => 'Edit Asset', - 'pending' => 'Pending Asset', - 'view' => 'View Asset', + 'asset' => 'Nabytek', + 'checkin' => 'Potwierdzanie zasobu/aktywa', + 'checkout' => 'Przypisanie aktywa do Użytkownika', + 'clone' => 'Klonuj zasób', + 'edit' => 'Edytuj zasób', + 'pending' => 'Oczekujący nabytek', + 'view' => 'Wyświetl nabytki', ); diff --git a/app/lang/zh-CN/admin/licenses/message.php b/app/lang/zh-CN/admin/licenses/message.php index 86c1178b11..95f774b577 100755 --- a/app/lang/zh-CN/admin/licenses/message.php +++ b/app/lang/zh-CN/admin/licenses/message.php @@ -15,15 +15,15 @@ return array( ), 'deletefile' => array( - 'error' => 'File not deleted. Please try again.', - 'success' => 'File successfully deleted.', + 'error' => '该文件无法删除,请重试。', + 'success' => '文件成功删除。', ), 'upload' => array( - 'error' => 'File(s) not uploaded. Please try again.', - 'success' => 'File(s) successfully uploaded.', - 'nofiles' => 'You did not select any files for upload', - 'invalidfiles' => 'One or more of your files is too large or is a filetype that is not allowed. Allowed filetypes are png, gif, jpg, doc, docx, pdf, and txt.', + 'error' => '文件上传失败,请重试。', + 'success' => '文件上传成功。', + 'nofiles' => '您没有选择要上传的文件', + 'invalidfiles' => '一个或多个文件过大或者属于不被允许的文件类型。允许上传的文件类型有PNG,GIF,JPG,DOC,DOCX,PDF和TXT。', ), 'update' => array( diff --git a/app/lang/zh-CN/button.php b/app/lang/zh-CN/button.php index e005964fcd..6796187b69 100755 --- a/app/lang/zh-CN/button.php +++ b/app/lang/zh-CN/button.php @@ -3,12 +3,12 @@ return array( 'actions' => '操作', - 'add' => 'Add New', - 'cancel' => 'Cancel', + 'add' => '新增', + 'cancel' => '取消', 'delete' => '刪除', 'edit' => '编辑', 'restore' => '恢复', 'submit' => '提交', - 'upload' => 'Upload', + 'upload' => '上传', ); diff --git a/app/lang/zh-CN/general.php b/app/lang/zh-CN/general.php index a278af912b..bfb991bf84 100755 --- a/app/lang/zh-CN/general.php +++ b/app/lang/zh-CN/general.php @@ -40,8 +40,8 @@ return array( 'editprofile' => '修改简介', 'eol' => '寿命', 'first_name' => '名字', - 'file_name' => 'File', - 'file_uploads' => 'File Uploads', + 'file_name' => '文件', + 'file_uploads' => '文件上传', 'generate' => '生成', 'groups' => '分组', 'gravatar_email' => 'Gravatar头像邮件地址', diff --git a/app/models/Actionlog.php b/app/models/Actionlog.php index 7741d65ae6..71179d7f65 100755 --- a/app/models/Actionlog.php +++ b/app/models/Actionlog.php @@ -6,7 +6,7 @@ class Actionlog extends Eloquent protected $dates = ['deleted_at']; protected $table = 'asset_logs'; - public $timestamps = false; + public $timestamps = true; public function assetlog() @@ -26,7 +26,7 @@ class Actionlog extends Eloquent public function adminlog() { - return $this->belongsTo('User','user_id'); + return $this->belongsTo('User','user_id')->withTrashed(); } public function userlog() diff --git a/app/models/Asset.php b/app/models/Asset.php index 2876667881..c6223dd73b 100755 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -90,7 +90,8 @@ class Asset extends Elegant */ public static function availassetcount() { - return Asset::orderBy('asset_tag', 'ASC')->where('status_id', '=', 0)->where('assigned_to','=','0')->where('physical', '=', 1)->count(); + return Asset::RTD()->whereNull('deleted_at')->count(); + } /** @@ -231,7 +232,10 @@ class Asset extends Elegant public function scopePending($query) { - return $query->whereNull('status_id','and')->where('assigned_to','=','0'); + return $query->whereHas('assetstatus',function($query) + { + $query->where('deployable','=',0)->where('pending','=',1)->where('archived','=',0); + }); } @@ -244,10 +248,15 @@ class Asset extends Elegant public function scopeRTD($query) { - return $query->where('status_id','=','0')->where('assigned_to','=','0'); + return $query->whereNULL('assigned_to')->whereHas('assetstatus',function($query) + { + $query->where('deployable','=',1)->where('pending','=',0)->where('archived','=',0); + }); } + + /** * Query builder scope for Undeployable assets * @@ -257,10 +266,30 @@ class Asset extends Elegant public function scopeUndeployable($query) { - return $query->where('status_id','>',1)->where('assigned_to','=','0'); + return $query->whereHas('assetstatus',function($query) + { + $query->where('deployable','=',0)->where('pending','=',0)->where('archived','=',0); + }); } + /** + * Query builder scope for Archived assets + * + * @param Illuminate\Database\Query\Builder $query Query builder instance + * @return Illuminate\Database\Query\Builder Modified query builder + */ + + public function scopeArchived($query) + { + return $query->whereHas('assetstatus',function($query) + { + $query->where('deployable','=',0)->where('pending','=',0)->where('archived','=',1); + }); + } + + + /** * Query builder scope for Deployed assets * diff --git a/app/models/Statuslabel.php b/app/models/Statuslabel.php index 38c31f6bf9..5cca696e1e 100755 --- a/app/models/Statuslabel.php +++ b/app/models/Statuslabel.php @@ -9,10 +9,49 @@ class Statuslabel extends Elegant protected $rules = array( 'name' => 'required|alpha_space|min:2|max:100|unique:status_labels,name,{id}', + 'statuslabel_types' => 'required|in:deployable,pending,archived,undeployable', ); public function has_assets() { return $this->hasMany('Asset', 'status_id')->count(); } + + public function getStatuslabelType() { + + if ($this->pending == 1) { + return 'pending'; + } elseif ($this->archived == 1) { + return 'archived'; + } elseif (($this->archived == 0) && ($this->deployable == 0) && ($this->deployable == 0)) { + return 'undeployable'; + } else { + return 'deployable'; + } + } + + public static function getStatuslabelTypesForDB($type) { + if ($type == 'pending') { + $statustype['pending'] = 1; + $statustype['deployable'] = 0; + $statustype['archived'] = 0; + + } elseif ($type == 'deployable') { + $statustype['pending'] = 0; + $statustype['deployable'] = 1; + $statustype['archived'] = 0; + + } elseif ($type == 'archived') { + $statustype['pending'] = 0; + $statustype['deployable'] = 0; + $statustype['archived'] = 1; + + } elseif ($type == 'undeployable') { + $statustype['pending'] = 0; + $statustype['deployable'] = 0; + $statustype['archived'] = 0; + } + + return $statustype; + } } diff --git a/app/views/backend/hardware/checkin.blade.php b/app/views/backend/hardware/checkin.blade.php index 71c3a612c4..28a3b0fe87 100755 --- a/app/views/backend/hardware/checkin.blade.php +++ b/app/views/backend/hardware/checkin.blade.php @@ -32,6 +32,7 @@ + @if ($asset->name)
@@ -39,11 +40,12 @@

{{{ $asset->name }}}

+ @endif +
- {{ $errors->first('note', ' :message') }}
diff --git a/app/views/backend/hardware/edit.blade.php b/app/views/backend/hardware/edit.blade.php index 2f605ec4e5..30a99586ab 100755 --- a/app/views/backend/hardware/edit.blade.php +++ b/app/views/backend/hardware/edit.blade.php @@ -82,6 +82,7 @@
@if (isset($selected_model)) {{ Form::select('model_id', $model_list , $selected_model->id, array('class'=>'select2', 'style'=>'min-width:400px')) }} + @else {{ Form::select('model_id', $model_list , Input::old('model_id', $asset->model_id), array('class'=>'select2', 'style'=>'min-width:400px')) }} @endif diff --git a/app/views/backend/hardware/index.blade.php b/app/views/backend/hardware/index.blade.php index 86698d762a..6361df81c1 100755 --- a/app/views/backend/hardware/index.blade.php +++ b/app/views/backend/hardware/index.blade.php @@ -1,7 +1,7 @@ @extends('backend/layouts/default') @section('title0') - @if (Input::get('Pending') || Input::get('Undeployable') || Input::get('RTD') || Input::get('Deployed')) + @if (Input::get('Pending') || Input::get('Undeployable') || Input::get('RTD') || Input::get('Deployed') || Input::get('Archived')) @if (Input::get('Pending')) @lang('general.pending') @elseif (Input::get('RTD')) @@ -10,6 +10,8 @@ @lang('general.undeployable') @elseif (Input::get('Deployed')) @lang('general.deployed') + @elseif (Input::get('Archived')) + @lang('general.archived') @endif @else @lang('general.all') @@ -38,8 +40,11 @@ @if ($assets->count() > 0) + +
+ @@ -125,12 +130,12 @@ @endif @endif + @@ -54,11 +55,19 @@ @endif - + @if (Setting::getSettings()->display_asset_name) @endif + + @@ -35,6 +36,17 @@ @foreach ($statuslabels as $statuslabel) +
@lang('admin/hardware/table.asset_tag') - @if ($asset->status_id < 1 ) - @if ($asset->assigned_to != 0) - @lang('general.checkin') - @else - @lang('general.checkout') - @endif + @if ($asset->assetstatus->deployable == 1 ) + @if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) + @lang('general.checkin') + @else + @lang('general.checkout') + @endif @endif diff --git a/app/views/backend/hardware/view.blade.php b/app/views/backend/hardware/view.blade.php index dfb82e3fac..e5737de527 100755 --- a/app/views/backend/hardware/view.blade.php +++ b/app/views/backend/hardware/view.blade.php @@ -252,7 +252,7 @@

@endif - @if ((isset($asset->assigned_to ) && ($asset->assigned_to > 0))) + @if ((isset($asset->assigneduser) && ($asset->assigned_to > 0)))

@lang('admin/hardware/form.checkedout_to')
- @elseif (($asset->status_id ) && ($asset->status_id > 1)) + @endif + + @if (($asset->status_id ) && ($asset->status_id > 0)) + @if ($asset->assetstatus)

{{{ $asset->assetstatus->name }}} @lang('admin/hardware/general.asset')
+ + + @if ($asset->assetstatus->notes)
-
- - @lang('admin/hardware/message.undeployable') +
+ + {{{ $asset->assetstatus->notes }}} +
-
- @endif + @endif - @elseif ($asset->status_id == NULL) -

@lang('admin/hardware/general.pending')
-
-
- - @lang('admin/hardware/message.undeployable') -
-
- - @else -

@lang('admin/hardware/general.checkout')
-
    -
  • This asset is not checked out to anyone yet. Use the button below to check it out now.
  • -


  • Checkout Asset
  • -
+ @endif @endif + diff --git a/app/views/backend/layouts/default.blade.php b/app/views/backend/layouts/default.blade.php index fb79abd560..0c24a47aa8 100644 --- a/app/views/backend/layouts/default.blade.php +++ b/app/views/backend/layouts/default.blade.php @@ -241,6 +241,7 @@
  • @lang('general.ready_to_deploy')
  • @lang('general.pending')
  • @lang('general.undeployable')
  • +
  • @lang('admin/hardware/general.archived')
  • @lang('general.list_all')
  •  
  • @lang('general.asset_models')
  • @@ -360,7 +361,7 @@ Documentation | Help Translate It! | Report a Bug -     (v1.2.3)

    +     (v1.2.4)

    diff --git a/app/views/backend/reports/asset.blade.php b/app/views/backend/reports/asset.blade.php index e1a5b8fbef..197d43e363 100644 --- a/app/views/backend/reports/asset.blade.php +++ b/app/views/backend/reports/asset.blade.php @@ -34,6 +34,7 @@
    @lang('general.name')@lang('admin/hardware/table.serial')@lang('admin/hardware/table.status') @lang('admin/hardware/table.purchase_date') @lang('admin/hardware/table.purchase_cost') @lang('admin/hardware/form.order') {{{ $asset->model->name }}}{{{ $asset->model->modelno }}}{{{ $asset->model->modelno }}}{{{ $asset->name }}}{{ $asset->serial }} + + @if ($asset->assetstatus) + {{{ $asset->assetstatus->name }}} + @elseif ($asset->assigneduser) + {{{ $asset->assigneduser->fullName() }}} + @endif + {{{ $asset->purchase_date }}} @lang('general.currency') {{{ number_format($asset->purchase_cost) }}} diff --git a/app/views/backend/statuslabels/edit.blade.php b/app/views/backend/statuslabels/edit.blade.php index 957c8d174f..14072b00e7 100755 --- a/app/views/backend/statuslabels/edit.blade.php +++ b/app/views/backend/statuslabels/edit.blade.php @@ -50,6 +50,32 @@ + + +
    + +
    + + {{ $errors->first('notes', ' :message') }} +
    +
    + + + +
    + + +
    + {{ Form::select('statuslabel_types', $statuslabel_types , $use_statuslabel_type, array('class'=>'select2', 'style'=>'min-width:400px')) }} + {{ $errors->first('notes', ' :message') }} + {{ $errors->first('status_type', ' :message') }} +
    +
    + + + +
    diff --git a/app/views/backend/statuslabels/index.blade.php b/app/views/backend/statuslabels/index.blade.php index e31cf43ef3..f211d25b3d 100755 --- a/app/views/backend/statuslabels/index.blade.php +++ b/app/views/backend/statuslabels/index.blade.php @@ -28,6 +28,7 @@
    @lang('admin/statuslabels/table.name')@lang('admin/statuslabels/table.status_type') @lang('table.actions')
    {{{ $statuslabel->name }}} + @if ($statuslabel->deployable == 1) + @lang('admin/statuslabels/table.deployable') + @elseif ($statuslabel->pending == 1) + @lang('admin/statuslabels/table.pending') + @elseif ($statuslabel->archived == 1) + @lang('admin/statuslabels/table.archived') + @else + @lang('admin/statuslabels/table.undeployable') + @endif +