diff --git a/app/Http/Controllers/StatuslabelsController.php b/app/Http/Controllers/StatuslabelsController.php index 88fb6c0398..fb4cab69ef 100755 --- a/app/Http/Controllers/StatuslabelsController.php +++ b/app/Http/Controllers/StatuslabelsController.php @@ -47,23 +47,32 @@ class StatuslabelsController extends Controller { $colors = []; - $statuslabels = Statuslabel::get(); + $statuslabels = Statuslabel::with('assets')->get(); $labels=[]; $points=[]; - + $colors=[]; foreach ($statuslabels as $statuslabel) { - $labels[]=$statuslabel->name; - $points[]=$statuslabel->assets()->whereNull('assigned_to')->count(); + if ($statuslabel->assets->count() > 0) { + $labels[]=$statuslabel->name; + $points[]=$statuslabel->assets()->whereNull('assigned_to')->count(); + if ($statuslabel->color!='') { + $colors[]=$statuslabel->color; + } + } + + } $labels[]='Deployed'; $points[]=Asset::whereNotNull('assigned_to')->count(); + $colors_array = array_merge($colors, Helper::chartColors()); + $result= [ "labels" => $labels, "datasets" => [ [ "data" => $points, - "backgroundColor" => Helper::chartColors(), - "hoverBackgroundColor" => Helper::chartColors() + "backgroundColor" => $colors_array, + "hoverBackgroundColor" => $colors_array ]] ]; return $result; @@ -110,6 +119,7 @@ class StatuslabelsController extends Controller $statuslabel->deployable = $statustype['deployable']; $statuslabel->pending = $statustype['pending']; $statuslabel->archived = $statustype['archived']; + $statuslabel->color = e(Input::get('color')); // Was the asset created? @@ -197,6 +207,7 @@ class StatuslabelsController extends Controller $statuslabel->deployable = $statustype['deployable']; $statuslabel->pending = $statustype['pending']; $statuslabel->archived = $statustype['archived']; + $statuslabel->color = e(Input::get('color')); // Was the asset created? @@ -247,7 +258,7 @@ class StatuslabelsController extends Controller public function getDatatable() { - $statuslabels = Statuslabel::select(array('id','name','deployable','pending','archived')) + $statuslabels = Statuslabel::select(array('id','name','deployable','pending','archived','color')) ->whereNull('deleted_at'); if (Input::has('search')) { @@ -291,10 +302,18 @@ class StatuslabelsController extends Controller $actions = ''; + if ($statuslabel->color!='') { + $color = '
'.e($statuslabel->color); + } else { + $color = ''; + } + + $rows[] = array( 'id' => e($statuslabel->id), 'type' => e($label_type), 'name' => e($statuslabel->name), + 'color' => $color, 'actions' => $actions ); } diff --git a/database/migrations/2016_08_02_124944_add_color_to_statuslabel.php b/database/migrations/2016_08_02_124944_add_color_to_statuslabel.php new file mode 100644 index 0000000000..9c58c2ec65 --- /dev/null +++ b/database/migrations/2016_08_02_124944_add_color_to_statuslabel.php @@ -0,0 +1,31 @@ +string('color', 10)->nullable()->default(NULL); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('status_labels', function ($table) { + $table->dropColumn('color'); + }); + } +} diff --git a/resources/lang/en/admin/statuslabels/table.php b/resources/lang/en/admin/statuslabels/table.php index dd21781115..bd5d544fa5 100644 --- a/resources/lang/en/admin/statuslabels/table.php +++ b/resources/lang/en/admin/statuslabels/table.php @@ -4,6 +4,7 @@ return array( 'about' => 'About Status Labels', 'archived' => 'Archived', 'create' => 'Create Status Label', + 'color' => 'Chart Color', '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', diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index e8d78fc37d..f59ad3d516 100755 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -188,7 +188,7 @@