diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.php index 89edf122ca..01f2845eb5 100644 --- a/app/Http/Controllers/Api/CategoriesController.php +++ b/app/Http/Controllers/Api/CategoriesController.php @@ -43,6 +43,7 @@ class CategoriesController extends Controller 'created_at', 'updated_at', 'image', + 'tag_color', 'notes', ]; @@ -57,6 +58,7 @@ class CategoriesController extends Controller 'require_acceptance', 'checkin_email', 'image', + 'tag_color', 'notes', ]) ->with('adminuser') diff --git a/app/Http/Controllers/Api/DepartmentsController.php b/app/Http/Controllers/Api/DepartmentsController.php index 076b5a4c4b..b03a755616 100644 --- a/app/Http/Controllers/Api/DepartmentsController.php +++ b/app/Http/Controllers/Api/DepartmentsController.php @@ -24,7 +24,7 @@ class DepartmentsController extends Controller public function index(Request $request) : JsonResponse | array { $this->authorize('view', Department::class); - $allowed_columns = ['id', 'name', 'image', 'users_count', 'notes']; + $allowed_columns = ['id', 'name', 'image', 'users_count', 'notes', 'tag_color']; $departments = Department::select( [ @@ -38,6 +38,7 @@ class DepartmentsController extends Controller 'departments.created_at', 'departments.updated_at', 'departments.image', + 'departments.tag_color', 'departments.notes' ])->with('users')->with('location')->with('manager')->with('company')->withCount('users as users_count'); @@ -61,6 +62,10 @@ class DepartmentsController extends Controller $departments->where('location_id', '=', $request->input('location_id')); } + if ($request->filled('tag_color')) { + $departments->where('tag_color', '=', $request->input('departments.tag_color')); + } + // Make sure the offset and limit are actually integers and do not exceed system limits $offset = ($request->input('offset') > $departments->count()) ? $departments->count() : app('api_offset_value'); $limit = app('api_limit_value'); diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php index 3038cfcf0b..7d175ba32e 100644 --- a/app/Http/Controllers/Api/LocationsController.php +++ b/app/Http/Controllers/Api/LocationsController.php @@ -59,6 +59,7 @@ class LocationsController extends Controller 'state', 'updated_at', 'zip', + 'tag_color', 'notes', ]; @@ -81,6 +82,8 @@ class LocationsController extends Controller 'locations.ldap_ou', 'locations.currency', 'locations.company_id', + 'locations.tag_color', + 'locations.tag_color', 'locations.notes', 'locations.created_by', 'locations.deleted_at', @@ -145,6 +148,10 @@ class LocationsController extends Controller $locations->onlyTrashed(); } + if ($request->filled('tag_color')) { + $locations->where('tag_color', '=', $request->input('locations.tag_color')); + } + // Make sure the offset and limit are actually integers and do not exceed system limits $offset = ($request->input('offset') > $locations->count()) ? $locations->count() : app('api_offset_value'); $limit = app('api_limit_value'); diff --git a/app/Http/Controllers/Api/ManufacturersController.php b/app/Http/Controllers/Api/ManufacturersController.php index b714675b75..749ebf70d2 100644 --- a/app/Http/Controllers/Api/ManufacturersController.php +++ b/app/Http/Controllers/Api/ManufacturersController.php @@ -47,6 +47,7 @@ class ManufacturersController extends Controller 'consumables_count', 'components_count', 'licenses_count', + 'tag_color', 'notes', ]; @@ -63,6 +64,7 @@ class ManufacturersController extends Controller 'updated_at', 'image', 'deleted_at', + 'tag_color', 'notes', ]) ->with('adminuser') @@ -104,6 +106,10 @@ class ManufacturersController extends Controller $manufacturers->where('support_email', '=', $request->input('support_email')); } + if ($request->filled('tag_color')) { + $manufacturers->where('tag_color', '=', $request->input('manufacturers.tag_color')); + } + // Make sure the offset and limit are actually integers and do not exceed system limits $offset = ($request->input('offset') > $manufacturers->count()) ? $manufacturers->count() : app('api_offset_value'); $limit = app('api_limit_value'); diff --git a/app/Http/Controllers/Api/SuppliersController.php b/app/Http/Controllers/Api/SuppliersController.php index b985be6587..d098b5944a 100644 --- a/app/Http/Controllers/Api/SuppliersController.php +++ b/app/Http/Controllers/Api/SuppliersController.php @@ -50,12 +50,13 @@ class SuppliersController extends Controller 'accessories_count', 'components_count', 'consumables_count', + 'tag_color', 'url', 'notes', ]; $suppliers = Supplier::select( - ['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'created_by', 'updated_at', 'deleted_at', 'image', 'notes', 'url', 'zip']) + ['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'created_by', 'updated_at', 'deleted_at', 'image', 'notes', 'url', 'zip', 'tag_color']) ->withCount('assets as assets_count') ->withCount('licenses as licenses_count') ->withCount('accessories as accessories_count') diff --git a/app/Http/Controllers/CategoriesController.php b/app/Http/Controllers/CategoriesController.php index 600d99d6b6..f74e2fcb44 100755 --- a/app/Http/Controllers/CategoriesController.php +++ b/app/Http/Controllers/CategoriesController.php @@ -78,6 +78,7 @@ class CategoriesController extends Controller $category->require_acceptance = $request->input('require_acceptance', '0'); $category->alert_on_response = $request->input('alert_on_response', '0'); $category->checkin_email = $request->input('checkin_email', '0'); + $category->tag_color = $request->input('tag_color'); $category->notes = $request->input('notes'); $category->created_by = auth()->id(); @@ -132,6 +133,7 @@ class CategoriesController extends Controller $category->require_acceptance = $request->input('require_acceptance', '0'); $category->alert_on_response = $request->input('alert_on_response', '0'); $category->checkin_email = $request->input('checkin_email', '0'); + $category->tag_color = $request->input('tag_color'); $category->notes = $request->input('notes'); $category = $request->handleImages($category); diff --git a/app/Http/Controllers/DepartmentsController.php b/app/Http/Controllers/DepartmentsController.php index f49242127e..618567d699 100644 --- a/app/Http/Controllers/DepartmentsController.php +++ b/app/Http/Controllers/DepartmentsController.php @@ -55,6 +55,7 @@ class DepartmentsController extends Controller $department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null); $department->location_id = ($request->filled('location_id') ? $request->input('location_id') : null); $department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null); + $department->tag_color = $request->input('tag_color'); $department->notes = $request->input('notes'); $department = $request->handleImages($department); @@ -157,6 +158,7 @@ class DepartmentsController extends Controller $department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null); $department->phone = $request->input('phone'); $department->fax = $request->input('fax'); + $department->tag_color = $request->input('tag_color'); $department->notes = $request->input('notes'); $department = $request->handleImages($department); diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 3457e115f9..ddc4454e33 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -82,6 +82,7 @@ class LocationsController extends Controller $location->created_by = auth()->id(); $location->phone = request('phone'); $location->fax = request('fax'); + $location->tag_color = $request->input('tag_color'); $location->notes = $request->input('notes'); $location->company_id = Company::getIdForCurrentUser($request->input('company_id')); @@ -156,6 +157,7 @@ class LocationsController extends Controller $location->fax = request('fax'); $location->ldap_ou = $request->input('ldap_ou'); $location->manager_id = $request->input('manager_id'); + $location->tag_color = $request->input('tag_color'); $location->notes = $request->input('notes'); // Only scope the location if the setting is enabled diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index d996855a5e..b5e33a1cff 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -101,6 +101,7 @@ class ManufacturersController extends Controller $manufacturer->support_email = $request->input('support_email'); $manufacturer->notes = $request->input('notes'); $manufacturer = $request->handleImages($manufacturer); + $manufacturer->tag_color = $request->input('tag_color'); if ($manufacturer->save()) { return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.create.success')); @@ -142,6 +143,7 @@ class ManufacturersController extends Controller $manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url'); $manufacturer->support_phone = $request->input('support_phone'); $manufacturer->support_email = $request->input('support_email'); + $manufacturer->tag_color = $request->input('tag_color'); $manufacturer->notes = $request->input('notes'); // Set the model's image property to null if the image is being deleted diff --git a/app/Http/Controllers/SuppliersController.php b/app/Http/Controllers/SuppliersController.php index e699c5ced8..78e0cbfed2 100755 --- a/app/Http/Controllers/SuppliersController.php +++ b/app/Http/Controllers/SuppliersController.php @@ -67,6 +67,7 @@ class SuppliersController extends Controller $supplier->phone = request('phone'); $supplier->fax = request('fax'); $supplier->email = request('email'); + $supplier->tag_color = $request->input('tag_color'); $supplier->notes = request('notes'); $supplier->url = $supplier->addhttp(request('url')); $supplier->created_by = auth()->id(); @@ -111,6 +112,7 @@ class SuppliersController extends Controller $supplier->fax = request('fax'); $supplier->email = request('email'); $supplier->url = $supplier->addhttp(request('url')); + $supplier->tag_color = $request->input('tag_color'); $supplier->notes = request('notes'); $supplier = $request->handleImages($supplier); diff --git a/app/Http/Transformers/AccessoriesTransformer.php b/app/Http/Transformers/AccessoriesTransformer.php index c7af414d08..b256917c0e 100644 --- a/app/Http/Transformers/AccessoriesTransformer.php +++ b/app/Http/Transformers/AccessoriesTransformer.php @@ -26,12 +26,32 @@ class AccessoriesTransformer 'id' => $accessory->id, 'name' => e($accessory->name), 'image' => ($accessory->image) ? Storage::disk('public')->url('accessories/'.e($accessory->image)) : null, - 'company' => ($accessory->company) ? ['id' => $accessory->company->id, 'name'=> e($accessory->company->name)] : null, - 'manufacturer' => ($accessory->manufacturer) ? ['id' => $accessory->manufacturer->id, 'name'=> e($accessory->manufacturer->name)] : null, - 'supplier' => ($accessory->supplier) ? ['id' => $accessory->supplier->id, 'name'=> e($accessory->supplier->name)] : null, + 'company' => ($accessory->company) ? [ + 'id' => $accessory->company->id, + 'name'=> e($accessory->company->name), + 'tag_color'=> ($accessory->company->tag_color) ? e($accessory->company->tag_color) : null, + ] : null, + 'manufacturer' => ($accessory->manufacturer) ? [ + 'id' => $accessory->manufacturer->id, + 'name'=> e($accessory->manufacturer->name), + 'tag_color'=> ($accessory->manufacturer->tag_color) ? e($accessory->manufacturer->tag_color) : null, + ] : null, + 'supplier' => ($accessory->supplier) ? [ + 'id' => $accessory->supplier->id, + 'name'=> e($accessory->supplier->name), + 'tag_color'=> ($accessory->supplier->tag_color) ? e($accessory->supplier->tag_color) : null, + ] : null, 'model_number' => ($accessory->model_number) ? e($accessory->model_number) : null, - 'category' => ($accessory->category) ? ['id' => $accessory->category->id, 'name'=> e($accessory->category->name)] : null, - 'location' => ($accessory->location) ? ['id' => $accessory->location->id, 'name'=> e($accessory->location->name)] : null, + 'category' => ($accessory->category) ? [ + 'id' => $accessory->category->id, + 'name'=> e($accessory->category->name), + 'tag_color'=> ($accessory->category->tag_color) ? e($accessory->category->tag_color) : null, + ] : null, + 'location' => ($accessory->location) ? [ + 'id' => $accessory->location->id, + 'name'=> e($accessory->location->name), + 'tag_color'=> ($accessory->location->tag_color) ? e($accessory->location->tag_color) : null, + ] : null, 'notes' => ($accessory->notes) ? Helper::parseEscapedMarkedownInline($accessory->notes) : null, 'qty' => ($accessory->qty) ? (int) $accessory->qty : null, 'purchase_date' => ($accessory->purchase_date) ? Helper::getFormattedDateObject($accessory->purchase_date, 'date') : null, diff --git a/app/Http/Transformers/ActionlogsTransformer.php b/app/Http/Transformers/ActionlogsTransformer.php index 2cf16d0640..027997197b 100644 --- a/app/Http/Transformers/ActionlogsTransformer.php +++ b/app/Http/Transformers/ActionlogsTransformer.php @@ -161,6 +161,7 @@ class ActionlogsTransformer 'location' => ($actionlog->location) ? [ 'id' => (int) $actionlog->location->id, 'name' => e($actionlog->location->name), + 'tag_color'=> ($actionlog->location->tag_color) ? e($actionlog->location->tag_color) : null, ] : null, 'created_at' => Helper::getFormattedDateObject($actionlog->created_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($actionlog->updated_at, 'datetime'), diff --git a/app/Http/Transformers/AssetModelsTransformer.php b/app/Http/Transformers/AssetModelsTransformer.php index 8ba1fb9d15..134cebab63 100644 --- a/app/Http/Transformers/AssetModelsTransformer.php +++ b/app/Http/Transformers/AssetModelsTransformer.php @@ -44,6 +44,7 @@ class AssetModelsTransformer 'manufacturer' => ($assetmodel->manufacturer) ? [ 'id' => (int) $assetmodel->manufacturer->id, 'name'=> e($assetmodel->manufacturer->name), + 'tag_color'=> ($assetmodel->manufacturer->tag_color) ? e($assetmodel->manufacturer->tag_color) : null, ] : null, 'image' => ($assetmodel->image != '') ? Storage::disk('public')->url('models/'.e($assetmodel->image)) : null, 'model_number' => ($assetmodel->model_number ? e($assetmodel->model_number): null), @@ -60,6 +61,7 @@ class AssetModelsTransformer 'category' => ($assetmodel->category) ? [ 'id' => (int) $assetmodel->category->id, 'name'=> e($assetmodel->category->name), + 'tag_color'=> ($assetmodel->category->tag_color) ? e($assetmodel->category->tag_color) : null, ] : null, 'fieldset' => ($assetmodel->fieldset) ? [ 'id' => (int) $assetmodel->fieldset->id, diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index e971f1e7ae..2d2d5f5f81 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -40,7 +40,6 @@ class AssetsTransformer ] : null, 'byod' => ($asset->byod ? true : false), 'requestable' => ($asset->requestable ? true : false), - 'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null, 'eol' => (($asset->asset_eol_date != '') && ($asset->purchase_date != '')) ? (int) Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date, true) . ' months' : null, 'asset_eol_date' => ($asset->asset_eol_date != '') ? Helper::getFormattedDateObject($asset->asset_eol_date, 'date') : null, @@ -53,10 +52,12 @@ class AssetsTransformer 'category' => (($asset->model) && ($asset->model->category)) ? [ 'id' => (int) $asset->model->category->id, 'name'=> e($asset->model->category->name), + 'tag_color'=> ($asset->model->category->tag_color) ? e($asset->model->category->tag_color) : null, ] : null, 'manufacturer' => (($asset->model) && ($asset->model->manufacturer)) ? [ 'id' => (int) $asset->model->manufacturer->id, 'name'=> e($asset->model->manufacturer->name), + 'tag_color'=> ($asset->model->manufacturer->tag_color) ? e($asset->model->manufacturer->tag_color) : null, ] : null, 'depreciation' => (($asset->model) && ($asset->model->depreciation)) ? [ 'id' => (int) $asset->model->depreciation->id, @@ -68,20 +69,24 @@ class AssetsTransformer 'supplier' => ($asset->supplier) ? [ 'id' => (int) $asset->supplier->id, 'name'=> e($asset->supplier->name), + 'tag_color'=> ($asset->supplier->tag_color) ? e($asset->supplier->tag_color) : null, ] : null, 'notes' => ($asset->notes) ? Helper::parseEscapedMarkedownInline($asset->notes) : null, 'order_number' => ($asset->order_number) ? e($asset->order_number) : null, 'company' => ($asset->company) ? [ 'id' => (int) $asset->company->id, 'name'=> e($asset->company->name), + 'tag_color'=> ($asset->company->tag_color) ? e($asset->company->tag_color) : null, ] : null, 'location' => ($asset->location) ? [ 'id' => (int) $asset->location->id, 'name'=> e($asset->location->name), + 'tag_color'=> ($asset->location->tag_color) ? e($asset->location->tag_color) : null, ] : null, 'rtd_location' => ($asset->defaultLoc) ? [ 'id' => (int) $asset->defaultLoc->id, 'name'=> e($asset->defaultLoc->name), + 'tag_color'=> ($asset->defaultLoc->tag_color) ? e($asset->defaultLoc->tag_color) : null, ] : null, 'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null, 'qr' => ($setting->qr_code=='1') ? config('app.url').'/uploads/barcodes/qr-'.str_slug($asset->asset_tag).'-'.str_slug($asset->id).'.png' : null, diff --git a/app/Http/Transformers/CategoriesTransformer.php b/app/Http/Transformers/CategoriesTransformer.php index 348c5d4552..b2e5c4cae9 100644 --- a/app/Http/Transformers/CategoriesTransformer.php +++ b/app/Http/Transformers/CategoriesTransformer.php @@ -66,6 +66,7 @@ class CategoriesTransformer 'id' => (int) $category->adminuser->id, 'name'=> e($category->adminuser->display_name), ] : null, + 'tag_color' => $category->tag_color ? e($category->tag_color) : null, 'notes' => Helper::parseEscapedMarkedownInline($category->notes), 'created_at' => Helper::getFormattedDateObject($category->created_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($category->updated_at, 'datetime'), diff --git a/app/Http/Transformers/DepartmentsTransformer.php b/app/Http/Transformers/DepartmentsTransformer.php index 267413e104..b999089159 100644 --- a/app/Http/Transformers/DepartmentsTransformer.php +++ b/app/Http/Transformers/DepartmentsTransformer.php @@ -44,6 +44,7 @@ class DepartmentsTransformer 'name' => e($department->location->name), ] : null, 'users_count' => (int) ($department->users_count), + 'tag_color' => $department->tag_color ? e($department->tag_color) : null, 'notes' => Helper::parseEscapedMarkedownInline($department->notes), 'created_at' => Helper::getFormattedDateObject($department->created_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($department->updated_at, 'datetime'), diff --git a/app/Http/Transformers/LicensesTransformer.php b/app/Http/Transformers/LicensesTransformer.php index c360834c1c..5c71390929 100644 --- a/app/Http/Transformers/LicensesTransformer.php +++ b/app/Http/Transformers/LicensesTransformer.php @@ -25,7 +25,11 @@ class LicensesTransformer 'id' => (int) $license->id, 'name' => e($license->name), 'company' => ($license->company) ? ['id' => (int) $license->company->id, 'name'=> e($license->company->name)] : null, - 'manufacturer' => ($license->manufacturer) ? ['id' => (int) $license->manufacturer->id, 'name'=> e($license->manufacturer->name)] : null, + 'manufacturer' => ($license->manufacturer) ? [ + 'id' => (int) $license->manufacturer->id, + 'name'=> e($license->manufacturer->name), + 'tag_color'=> ($license->manufacturer->tag_color) ? e($license->manufacturer->tag_color) : null, + ] : null, 'product_key' => (Gate::allows('viewKeys', License::class)) ? e($license->serial) : '------------', 'order_number' => ($license->order_number) ? e($license->order_number) : null, 'purchase_order' => ($license->purchase_order) ? e($license->purchase_order) : null, @@ -44,8 +48,16 @@ class LicensesTransformer 'license_email' => ($license->license_email) ? e($license->license_email) : null, 'reassignable' => ($license->reassignable == 1) ? true : false, 'maintained' => ($license->maintained == 1) ? true : false, - 'supplier' => ($license->supplier) ? ['id' => (int) $license->supplier->id, 'name'=> e($license->supplier->name)] : null, - 'category' => ($license->category) ? ['id' => (int) $license->category->id, 'name'=> e($license->category->name)] : null, + 'supplier' => ($license->supplier) ? [ + 'id' => (int) $license->supplier->id, + 'name'=> e($license->supplier->name), + 'tag_color'=> ($license->supplier->tag_color) ? e($license->supplier->tag_color) : null, + ] : null, + 'category' => ($license->category) ? [ + 'id' => (int) $license->category->id, + 'name'=> e($license->category->name), + 'tag_color'=> ($license->category->tag_color) ? e($license->category->tag_color) : null, + ] : null, 'created_by' => ($license->adminuser) ? [ 'id' => (int) $license->adminuser->id, 'name'=> e($license->adminuser->display_name), diff --git a/app/Http/Transformers/LocationsTransformer.php b/app/Http/Transformers/LocationsTransformer.php index 538f7e54c3..8844cd3f7b 100644 --- a/app/Http/Transformers/LocationsTransformer.php +++ b/app/Http/Transformers/LocationsTransformer.php @@ -58,6 +58,7 @@ class LocationsTransformer 'children_count' => (int) $location->children_count, 'currency' => ($location->currency) ? e($location->currency) : null, 'ldap_ou' => ($location->ldap_ou) ? e($location->ldap_ou) : null, + 'tag_color' => $location->tag_color ? e($location->tag_color) : null, 'notes' => Helper::parseEscapedMarkedownInline($location->notes), 'created_at' => Helper::getFormattedDateObject($location->created_at, 'datetime'), 'created_by' => $location->adminuser ? [ @@ -68,11 +69,13 @@ class LocationsTransformer 'parent' => ($location->parent) ? [ 'id' => (int) $location->parent->id, 'name'=> e($location->parent->name), + 'tag_color' => $location->parent->tag_color ? e($location->parent->tag_color) : null, ] : null, 'manager' => ($location->manager) ? (new UsersTransformer)->transformUser($location->manager) : null, 'company' => ($location->company) ? [ 'id' => (int) $location->company->id, - 'name'=> e($location->company->name) + 'name'=> e($location->company->name), + 'tag_color' => $location->company->tag_color ? e($location->company->tag_color) : null, ] : null, 'children' => $children_arr, diff --git a/app/Http/Transformers/ManufacturersTransformer.php b/app/Http/Transformers/ManufacturersTransformer.php index 0d1373414c..5f05c62e05 100644 --- a/app/Http/Transformers/ManufacturersTransformer.php +++ b/app/Http/Transformers/ManufacturersTransformer.php @@ -37,6 +37,7 @@ class ManufacturersTransformer 'consumables_count' => (int) $manufacturer->consumables_count, 'accessories_count' => (int) $manufacturer->accessories_count, 'components_count' => (int) $manufacturer->components_count, + 'tag_color' => $manufacturer->tag_color ? e($manufacturer->tag_color) : null, 'notes' => Helper::parseEscapedMarkedownInline($manufacturer->notes), 'created_by' => ($manufacturer->adminuser) ? [ 'id' => (int) $manufacturer->adminuser->id, diff --git a/app/Http/Transformers/SuppliersTransformer.php b/app/Http/Transformers/SuppliersTransformer.php index 750c969c63..1f60f680c6 100644 --- a/app/Http/Transformers/SuppliersTransformer.php +++ b/app/Http/Transformers/SuppliersTransformer.php @@ -43,6 +43,7 @@ class SuppliersTransformer 'licenses_count' => (int) $supplier->licenses_count, 'consumables_count' => (int) $supplier->consumables_count, 'components_count' => (int) $supplier->components_count, + 'tag_color' => $supplier->tag_color ? e($supplier->tag_color) : null, 'notes' => ($supplier->notes) ? Helper::parseEscapedMarkedownInline($supplier->notes) : null, 'created_at' => Helper::getFormattedDateObject($supplier->created_at, 'datetime'), 'created_by' => $supplier->adminuser ? [ diff --git a/app/Http/Transformers/UsersTransformer.php b/app/Http/Transformers/UsersTransformer.php index 1de71615cf..6058bd8d7a 100644 --- a/app/Http/Transformers/UsersTransformer.php +++ b/app/Http/Transformers/UsersTransformer.php @@ -65,6 +65,7 @@ class UsersTransformer 'location' => ($user->userloc) ? [ 'id' => (int) $user->userloc->id, 'name'=> e($user->userloc->name), + 'tag_color'=> ($user->userloc->tag_color) ? e($user->userloc->tag_color) : null, ] : null, 'notes'=> Helper::parseEscapedMarkedownInline($user->notes), 'role' => $role, @@ -80,7 +81,11 @@ class UsersTransformer 'consumables_count' => (int) $user->consumables_count, 'manages_users_count' => (int) $user->manages_users_count, 'manages_locations_count' => (int) $user->manages_locations_count, - 'company' => ($user->company) ? ['id' => (int) $user->company->id, 'name'=> e($user->company->name)] : null, + 'company' => ($user->company) ? [ + 'id' => (int) $user->company->id, + 'name'=> e($user->company->name), + 'tag_color'=> ($user->company->tag_color) ? e($user->company->tag_color) : null, + ] : null, 'created_by' => ($user->createdBy) ? [ 'id' => (int) $user->createdBy->id, 'name'=> e($user->createdBy->display_name), diff --git a/app/Models/Category.php b/app/Models/Category.php index c3b6080c1e..25101edf3d 100755 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -73,6 +73,7 @@ class Category extends SnipeModel 'alert_on_response', 'use_default_eula', 'created_by', + 'tag_color', 'notes', ]; diff --git a/app/Models/Department.php b/app/Models/Department.php index fda461bdad..d908aef571 100644 --- a/app/Models/Department.php +++ b/app/Models/Department.php @@ -53,6 +53,7 @@ class Department extends SnipeModel 'location_id', 'company_id', 'manager_id', + 'tag_color', 'notes', ]; diff --git a/app/Models/Location.php b/app/Models/Location.php index b8729a8e94..ab2536bd0b 100755 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -77,6 +77,7 @@ class Location extends SnipeModel 'manager_id', 'image', 'company_id', + 'tag_color', 'notes', ]; protected $hidden = ['user_id']; diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index 6d7b010677..cc1d2c1753 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -53,6 +53,7 @@ class Manufacturer extends SnipeModel 'support_url', 'url', 'warranty_lookup_url', + 'tag_color', 'notes', ]; diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index 25e763c957..1437275bbb 100755 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -66,7 +66,7 @@ class Supplier extends SnipeModel * * @var array */ - protected $fillable = ['name', 'address', 'address2', 'city', 'state', 'country', 'zip', 'phone', 'fax', 'email', 'contact', 'url', 'notes']; + protected $fillable = ['name', 'address', 'address2', 'city', 'state', 'country', 'zip', 'phone', 'fax', 'email', 'contact', 'url', 'tag_color', 'notes']; /** * Eager load counts diff --git a/app/Presenters/AccessoryPresenter.php b/app/Presenters/AccessoryPresenter.php index d4aaa768c3..8257f9babc 100644 --- a/app/Presenters/AccessoryPresenter.php +++ b/app/Presenters/AccessoryPresenter.php @@ -49,7 +49,7 @@ class AccessoryPresenter extends Presenter 'field' => 'category', 'searchable' => true, 'sortable' => true, - 'title' => trans('admin/accessories/general.accessory_category'), + 'title' => trans('general.category'), 'formatter' => 'categoriesLinkObjFormatter', ], [ 'field' => 'model_number', diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.php index 9299d15c33..6ab7f03087 100644 --- a/app/Presenters/CategoryPresenter.php +++ b/app/Presenters/CategoryPresenter.php @@ -82,6 +82,14 @@ class CategoryPresenter extends Presenter "title" => trans('admin/categories/general.use_default_eula_column'), 'visible' => true, "formatter" => 'trueFalseFormatter', + ], [ + 'field' => 'tag_color', + 'searchable' => true, + 'sortable' => true, + 'switchable' => true, + 'title' => trans('general.tag_color'), + 'visible' => false, + 'formatter' => 'colorTagFormatter', ], [ 'field' => 'notes', 'searchable' => true, @@ -142,4 +150,13 @@ class CategoryPresenter extends Presenter { return route('categories.show', $this->id); } + + public function formattedNameLink() { + + if (auth()->user()->can('category.view', $this)) { + return ($this->tag_color ? " " : '').' '.e($this->name).''; + } + + return ($this->tag_color ? " " : '').$this->name; + } } diff --git a/app/Presenters/LocationPresenter.php b/app/Presenters/LocationPresenter.php index 30225460dc..1e2f000417 100644 --- a/app/Presenters/LocationPresenter.php +++ b/app/Presenters/LocationPresenter.php @@ -227,7 +227,15 @@ class LocationPresenter extends Presenter 'title' => trans('admin/users/table.manager'), 'visible' => false, 'formatter' => 'usersLinkObjFormatter', - ], [ + ], [ + 'field' => 'tag_color', + 'searchable' => true, + 'sortable' => true, + 'switchable' => true, + 'title' => trans('general.tag_color'), + 'visible' => false, + 'formatter' => 'colorTagFormatter', + ], [ 'field' => 'notes', 'searchable' => true, 'sortable' => true, diff --git a/app/Presenters/SupplierPresenter.php b/app/Presenters/SupplierPresenter.php index 6dd594dc6b..cb28d1af0e 100644 --- a/app/Presenters/SupplierPresenter.php +++ b/app/Presenters/SupplierPresenter.php @@ -156,6 +156,14 @@ class SupplierPresenter extends Presenter 'visible' => false, 'formatter' => 'phoneFormatter', ], [ + 'field' => 'tag_color', + 'searchable' => true, + 'sortable' => true, + 'switchable' => true, + 'title' => trans('general.tag_color'), + 'visible' => false, + 'formatter' => 'colorTagFormatter', + ],[ 'field' => 'notes', 'searchable' => true, 'sortable' => true, diff --git a/database/migrations/2025_11_14_150613_add_color_to_companies.php b/database/migrations/2025_11_14_150613_add_color_to_companies.php index fe1630364f..4c730c6853 100644 --- a/database/migrations/2025_11_14_150613_add_color_to_companies.php +++ b/database/migrations/2025_11_14_150613_add_color_to_companies.php @@ -14,6 +14,26 @@ return new class extends Migration Schema::table('companies', function (Blueprint $table) { $table->string('tag_color', )->after('name')->nullable()->default(null); }); + + Schema::table('categories', function (Blueprint $table) { + $table->string('tag_color', )->after('name')->nullable()->default(null); + }); + + Schema::table('manufacturers', function (Blueprint $table) { + $table->string('tag_color', )->after('name')->nullable()->default(null); + }); + + Schema::table('suppliers', function (Blueprint $table) { + $table->string('tag_color', )->after('name')->nullable()->default(null); + }); + + Schema::table('locations', function (Blueprint $table) { + $table->string('tag_color', )->after('name')->nullable()->default(null); + }); + + Schema::table('departments', function (Blueprint $table) { + $table->string('tag_color', )->after('name')->nullable()->default(null); + }); } /** @@ -24,5 +44,25 @@ return new class extends Migration Schema::table('companies', function ($table) { $table->dropColumn('tag_color'); }); + + Schema::table('categories', function ($table) { + $table->dropColumn('tag_color'); + }); + + Schema::table('manufacturers', function ($table) { + $table->dropColumn('tag_color'); + }); + + Schema::table('suppliers', function ($table) { + $table->dropColumn('tag_color'); + }); + + Schema::table('locations', function ($table) { + $table->dropColumn('tag_color'); + }); + + Schema::table('departments', function ($table) { + $table->dropColumn('tag_color'); + }); } }; diff --git a/resources/views/accessories/view.blade.php b/resources/views/accessories/view.blade.php index 9851d46140..3c2b119149 100644 --- a/resources/views/accessories/view.blade.php +++ b/resources/views/accessories/view.blade.php @@ -188,7 +188,7 @@ {{ trans('general.category')}}
- {{ $accessory->category->name }} + {!! $accessory->category->present()->formattedNameLink !!}
@endif diff --git a/resources/views/blade/input/colorpicker.blade.php b/resources/views/blade/input/colorpicker.blade.php new file mode 100644 index 0000000000..10f2865a35 --- /dev/null +++ b/resources/views/blade/input/colorpicker.blade.php @@ -0,0 +1,13 @@ +@props([ + 'item' => null, + 'name' => 'color', + 'id' => 'color', +]) + + +
+ + +
+ + diff --git a/resources/views/categories/edit.blade.php b/resources/views/categories/edit.blade.php index d3a8891613..598796227d 100755 --- a/resources/views/categories/edit.blade.php +++ b/resources/views/categories/edit.blade.php @@ -63,11 +63,6 @@ -@stop - -@section('content') -@parent - @if ($snipeSettings->default_eula_text!='') @@ -89,6 +84,21 @@ @endif +
+ + {{ trans('general.tag_color') }} + + +
+ +
+ + {!! $errors->first('tag_color', '') !!} +
+
+
@stop diff --git a/resources/views/companies/edit.blade.php b/resources/views/companies/edit.blade.php index d6b9cf9afd..4bd123d7c9 100644 --- a/resources/views/companies/edit.blade.php +++ b/resources/views/companies/edit.blade.php @@ -30,4 +30,21 @@ +
+ + {{ trans('general.tag_color') }} + + +
+ +
+ + {!! $errors->first('tag_color', '') !!} +
+
+
+ + @stop diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index d495e067ee..bdadd0ee1a 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -1086,6 +1086,10 @@ dir="{{ Helper::determineLanguageDirection() }}"> - -@stop diff --git a/resources/views/statuslabels/index.blade.php b/resources/views/statuslabels/index.blade.php index 84fcfcf283..a06bdb9577 100755 --- a/resources/views/statuslabels/index.blade.php +++ b/resources/views/statuslabels/index.blade.php @@ -79,7 +79,7 @@