Skip to content

A free open source IT asset/license management system

Features/image uploads (#4320)

snipe75b527ab5993
diff --git a/.gitignore b/.gitignore
index d158248e1d..437be0ca0d 100755
--- a/.gitignore
+++ b/.gitignore
@@ -28,8 +28,15 @@ public/uploads/logo.svg
public/uploads/models/*
public/uploads/suppliers/*
public/uploads/accessories/*
+public/uploads/locations/*
+public/uploads/manufacturers/*
+public/uploads/components/*
+public/uploads/consumables/*
+public/uploads/companies/*
+public/uploads/categories/*
public/uploads/users/*
storage/app/private_uploads/users/*
+public/uploads/departments/*
storage/debugbar/
storage/dumps/*
storage/laravel-backups
diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.php
index 58f6dd0a14..1063ec05c0 100644
--- a/app/Http/Controllers/Api/CategoriesController.php
+++ b/app/Http/Controllers/Api/CategoriesController.php
@@ -20,9 +20,9 @@ class CategoriesController extends Controller
public function index(Request $request)
{
$this->authorize('view', Category::class);
- $allowed_columns = ['id', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email', 'assets_count', 'accessories_count', 'consumables_count', 'components_count'];
+ $allowed_columns = ['id', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email', 'assets_count', 'accessories_count', 'consumables_count', 'components_count', 'image'];
- $categories = Category::select(['id', 'created_at', 'updated_at', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email'])
+ $categories = Category::select(['id', 'created_at', 'updated_at', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email','image'])
->withCount('assets', 'accessories', 'consumables', 'components');
if ($request->has('search')) {
diff --git a/app/Http/Controllers/Api/ComponentsController.php b/app/Http/Controllers/Api/ComponentsController.php
index 48e4d05ca3..4e7a3c4ed7 100644
--- a/app/Http/Controllers/Api/ComponentsController.php
+++ b/app/Http/Controllers/Api/ComponentsController.php
@@ -34,7 +34,7 @@ class ComponentsController extends Controller
$offset = request('offset', 0);
$limit = request('limit', 50);
- $allowed_columns = ['id','name','min_amt','order_number','serial','purchase_date','purchase_cost','company','category','qty','location'];
+ $allowed_columns = ['id','name','min_amt','order_number','serial','purchase_date','purchase_cost','company','category','qty','location','image'];
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php
index 793de92140..e817c2b07f 100644
--- a/app/Http/Controllers/Api/ConsumablesController.php
+++ b/app/Http/Controllers/Api/ConsumablesController.php
@@ -43,7 +43,7 @@ class ConsumablesController extends Controller
$offset = request('offset', 0);
$limit = request('limit', 50);
- $allowed_columns = ['id','name','order_number','min_amt','purchase_date','purchase_cost','company','category','model_number', 'item_no', 'manufacturer','location','qty'];
+ $allowed_columns = ['id','name','order_number','min_amt','purchase_date','purchase_cost','company','category','model_number', 'item_no', 'manufacturer','location','qty','image'];
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
diff --git a/app/Http/Controllers/Api/DepartmentsController.php b/app/Http/Controllers/Api/DepartmentsController.php
index 8119c735ef..e7f0ac2996 100644
--- a/app/Http/Controllers/Api/DepartmentsController.php
+++ b/app/Http/Controllers/Api/DepartmentsController.php
@@ -21,7 +21,7 @@ class DepartmentsController extends Controller
public function index(Request $request)
{
$this->authorize('view', Department::class);
- $allowed_columns = ['id','name'];
+ $allowed_columns = ['id','name','image'];
$departments = Department::select([
'id',
@@ -30,7 +30,8 @@ class DepartmentsController extends Controller
'company_id',
'manager_id',
'created_at',
- 'updated_at'
+ 'updated_at',
+ 'image'
])->with('users')->with('location')->with('manager')->with('company')->withCount('users');
if ($request->has('search')) {
diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php
index 06d06d936b..ae4ad5eb7c 100644
--- a/app/Http/Controllers/Api/LocationsController.php
+++ b/app/Http/Controllers/Api/LocationsController.php
@@ -21,7 +21,7 @@ class LocationsController extends Controller
{
$this->authorize('view', Location::class);
$allowed_columns = ['id','name','address','address2','city','state','country','zip','created_at',
- 'updated_at','parent_id', 'manager_id'];
+ 'updated_at','parent_id', 'manager_id','image'];
$locations = Location::with('parent', 'manager', 'childLocations')->select([
'locations.id',
@@ -36,6 +36,7 @@ class LocationsController extends Controller
'locations.manager_id',
'locations.created_at',
'locations.updated_at',
+ 'locations.image',
'locations.currency'
])->withCount('locationAssets')
->withCount('assignedAssets')
diff --git a/app/Http/Controllers/Api/ManufacturersController.php b/app/Http/Controllers/Api/ManufacturersController.php
index 3840bc3634..6ecf848c25 100644
--- a/app/Http/Controllers/Api/ManufacturersController.php
+++ b/app/Http/Controllers/Api/ManufacturersController.php
@@ -21,10 +21,10 @@ class ManufacturersController extends Controller
public function index(Request $request)
{
$this->authorize('view', Manufacturer::class);
- $allowed_columns = ['id','name','url','support_url','support_email','support_phone','created_at','updated_at'];
+ $allowed_columns = ['id','name','url','support_url','support_email','support_phone','created_at','updated_at','image'];
$manufacturers = Manufacturer::select(
- array('id','name','url','support_url','support_email','support_phone','created_at','updated_at')
+ array('id','name','url','support_url','support_email','support_phone','created_at','updated_at','image')
)->withCount('assets')->withCount('licenses')->withCount('consumables')->withCount('accessories');
diff --git a/app/Http/Controllers/Api/SuppliersController.php b/app/Http/Controllers/Api/SuppliersController.php
index 063f82438b..fb3bc282ed 100644
--- a/app/Http/Controllers/Api/SuppliersController.php
+++ b/app/Http/Controllers/Api/SuppliersController.php
@@ -23,7 +23,7 @@ class SuppliersController extends Controller
$allowed_columns = ['id','name','address','phone','contact','fax','email','image','assets_count','licenses_count', 'accessories_count'];
$suppliers = Supplier::select(
- array('id','name','address','address2','city','state','country','fax', 'phone','email','contact','created_at','updated_at','deleted_at')
+ array('id','name','address','address2','city','state','country','fax', 'phone','email','contact','created_at','updated_at','deleted_at','image')
)->withCount('assets')->withCount('licenses')->withCount('accessories')->whereNull('deleted_at');
diff --git a/app/Http/Controllers/CategoriesController.php b/app/Http/Controllers/CategoriesController.php
index b502050e6a..f1ccb10668 100755
--- a/app/Http/Controllers/CategoriesController.php
+++ b/app/Http/Controllers/CategoriesController.php
@@ -15,6 +15,8 @@ use Lang;
use Redirect;
use Str;
use View;
+use Image;
+use App\Http\Requests\ImageUploadRequest;
/**
* This class controls all actions related to Categories for
@@ -67,7 +69,7 @@ class CategoriesController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
- public function store(Request $request)
+ public function store(ImageUploadRequest $request)
{
// create a new model instance
$category = new Category();
@@ -80,6 +82,18 @@ class CategoriesController extends Controller
$category->checkin_email = $request->input('checkin_email', '0');
$category->user_id = Auth::id();
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/categories/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $category->image = $file_name;
+ }
+
+
if ($category->save()) {
return redirect()->route('categories.index')->with('success', trans('admin/categories/message.create.success'));
}
@@ -118,7 +132,7 @@ class CategoriesController extends Controller
* @return \Illuminate\Http\RedirectResponse
* @since [v1.0]
*/
- public function update(Request $request, $categoryId = null)
+ public function update(ImageUploadRequest $request, $categoryId = null)
{
// Check if the blog post exists
if (is_null($category = Category::find($categoryId))) {
@@ -136,6 +150,20 @@ class CategoriesController extends Controller
$category->require_acceptance = $request->input('require_acceptance', '0');
$category->checkin_email = $request->input('checkin_email', '0');
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/categories/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $category->image = $file_name;
+ } elseif ($request->input('image_delete')=='1') {
+ $category->image = null;
+ }
+
+
if ($category->save()) {
// Redirect to the new category page
return redirect()->route('categories.index')->with('success', trans('admin/categories/message.update.success'));
diff --git a/app/Http/Controllers/CompaniesController.php b/app/Http/Controllers/CompaniesController.php
index 8ef76a9333..c6dbea0fad 100644
--- a/app/Http/Controllers/CompaniesController.php
+++ b/app/Http/Controllers/CompaniesController.php
@@ -7,6 +7,8 @@ use Lang;
use Redirect;
use View;
use Illuminate\Http\Request;
+use Image;
+use App\Http\Requests\ImageUploadRequest;
/**
* This controller handles all actions related to Companies for
@@ -50,11 +52,22 @@ final class CompaniesController extends Controller
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
- public function store(Request $request)
+ public function store(ImageUploadRequest $request)
{
$company = new Company;
$company->name = $request->input('name');
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/companies/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $company->image = $file_name;
+ }
+
if ($company->save()) {
return redirect()->route('companies.index')
->with('success', trans('admin/companies/message.create.success'));
@@ -89,7 +102,7 @@ final class CompaniesController extends Controller
* @param int $companyId
* @return \Illuminate\Http\RedirectResponse
*/
- public function update(Request $request, $companyId)
+ public function update(ImageUploadRequest $request, $companyId)
{
if (is_null($company = Company::find($companyId))) {
return redirect()->route('companies.index')->with('error', trans('admin/companies/message.does_not_exist'));
@@ -97,6 +110,20 @@ final class CompaniesController extends Controller
$company->name = $request->input('name');
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/companies/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $company->image = $file_name;
+ } elseif ($request->input('image_delete')=='1') {
+ $company->image = null;
+ }
+
+
if ($company->save()) {
return redirect()->route('companies.index')
->with('success', trans('admin/companies/message.update.success'));
diff --git a/app/Http/Controllers/ComponentsController.php b/app/Http/Controllers/ComponentsController.php
index c0636379d7..e06cb32246 100644
--- a/app/Http/Controllers/ComponentsController.php
+++ b/app/Http/Controllers/ComponentsController.php
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Helpers\Helper;
+use App\Http\Requests\ImageUploadRequest;
use App\Models\Company;
use App\Models\Component;
use App\Models\CustomField;
@@ -21,6 +22,7 @@ use View;
use Validator;
use Illuminate\Http\Request;
use Gate;
+use Image;
/**
* This class controls all actions related to Components for
@@ -74,7 +76,7 @@ class ComponentsController extends Controller
* @since [v3.0]
* @return \Illuminate\Http\RedirectResponse
*/
- public function store(Request $request)
+ public function store(ImageUploadRequest $request)
{
$this->authorize('create', Component::class);
$component = new Component();
@@ -90,6 +92,18 @@ class ComponentsController extends Controller
$component->qty = $request->input('qty');
$component->user_id = Auth::id();
+
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/components/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $component->image = $file_name;
+ }
+
if ($component->save()) {
return redirect()->route('components.index')->with('success', trans('admin/components/message.create.success'));
}
@@ -129,7 +143,7 @@ class ComponentsController extends Controller
* @since [v3.0]
* @return \Illuminate\Http\RedirectResponse
*/
- public function update($componentId = null)
+ public function update(ImageUploadRequest $request, $componentId = null)
{
if (is_null($component = Component::find($componentId))) {
return redirect()->route('components.index')->with('error', trans('admin/components/message.does_not_exist'));
@@ -150,6 +164,19 @@ class ComponentsController extends Controller
$component->purchase_cost = request('purchase_cost');
$component->qty = Input::get('qty');
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/components/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $component->image = $file_name;
+ } elseif ($request->input('image_delete')=='1') {
+ $component->image = null;
+ }
+
if ($component->save()) {
return redirect()->route('components.index')->with('success', trans('admin/components/message.update.success'));
}
diff --git a/app/Http/Controllers/ConsumablesController.php b/app/Http/Controllers/ConsumablesController.php
index eb61431258..dcaa164c05 100644
--- a/app/Http/Controllers/ConsumablesController.php
+++ b/app/Http/Controllers/ConsumablesController.php
@@ -19,6 +19,8 @@ use Slack;
use Str;
use View;
use Gate;
+use Image;
+use App\Http\Requests\ImageUploadRequest;
/**
* This controller handles all actions related to Consumables for
@@ -72,24 +74,36 @@ class ConsumablesController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
- public function store()
+ public function store(ImageUploadRequest $request)
{
$this->authorize('create', Consumable::class);
$consumable = new Consumable();
- $consumable->name = Input::get('name');
- $consumable->category_id = Input::get('category_id');
- $consumable->location_id = Input::get('location_id');
- $consumable->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
- $consumable->order_number = Input::get('order_number');
- $consumable->min_amt = Input::get('min_amt');
- $consumable->manufacturer_id = Input::get('manufacturer_id');
- $consumable->model_number = Input::get('model_number');
- $consumable->item_no = Input::get('item_no');
- $consumable->purchase_date = Input::get('purchase_date');
- $consumable->purchase_cost = Helper::ParseFloat(Input::get('purchase_cost'));
- $consumable->qty = Input::get('qty');
+ $consumable->name = $request->input('name');
+ $consumable->category_id = $request->input('category_id');
+ $consumable->location_id = $request->input('location_id');
+ $consumable->company_id = Company::getIdForCurrentUser($request->input('company_id'));
+ $consumable->order_number = $request->input('order_number');
+ $consumable->min_amt = $request->input('min_amt');
+ $consumable->manufacturer_id = $request->input('manufacturer_id');
+ $consumable->model_number = $request->input('model_number');
+ $consumable->item_no = $request->input('item_no');
+ $consumable->purchase_date = $request->input('purchase_date');
+ $consumable->purchase_cost = Helper::ParseFloat($request->input('purchase_cost'));
+ $consumable->qty = $request->input('qty');
$consumable->user_id = Auth::id();
+
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/consumables/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $consumable->image = $file_name;
+ }
+
if ($consumable->save()) {
return redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.create.success'));
}
@@ -132,7 +146,7 @@ class ConsumablesController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
- public function update($consumableId = null)
+ public function update(ImageUploadRequest $request, $consumableId = null)
{
if (is_null($consumable = Consumable::find($consumableId))) {
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.does_not_exist'));
@@ -140,19 +154,32 @@ class ConsumablesController extends Controller
$this->authorize($consumable);
- $consumable->name = Input::get('name');
- $consumable->category_id = Input::get('category_id');
- $consumable->location_id = Input::get('location_id');
- $consumable->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
- $consumable->order_number = Input::get('order_number');
- $consumable->min_amt = Input::get('min_amt');
- $consumable->manufacturer_id = Input::get('manufacturer_id');
- $consumable->model_number = Input::get('model_number');
- $consumable->item_no = Input::get('item_no');
- $consumable->purchase_date = Input::get('purchase_date');
- $consumable->purchase_cost = Helper::ParseFloat(Input::get('purchase_cost'));
+ $consumable->name = $request->input('name');
+ $consumable->category_id = $request->input('category_id');
+ $consumable->location_id = $request->input('location_id');
+ $consumable->company_id = Company::getIdForCurrentUser($request->input('company_id'));
+ $consumable->order_number = $request->input('order_number');
+ $consumable->min_amt = $request->input('min_amt');
+ $consumable->manufacturer_id = $request->input('manufacturer_id');
+ $consumable->model_number = $request->input('model_number');
+ $consumable->item_no = $request->input('item_no');
+ $consumable->purchase_date = $request->input('purchase_date');
+ $consumable->purchase_cost = Helper::ParseFloat(Input::get('purchase_cost'));
$consumable->qty = Helper::ParseFloat(Input::get('qty'));
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/consumables/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $consumable->image = $file_name;
+ } elseif ($request->input('image_delete')=='1') {
+ $consumable->image = null;
+ }
+
if ($consumable->save()) {
return redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.update.success'));
}
diff --git a/app/Http/Controllers/DepartmentsController.php b/app/Http/Controllers/DepartmentsController.php
index a78e2cecf0..51769614b4 100644
--- a/app/Http/Controllers/DepartmentsController.php
+++ b/app/Http/Controllers/DepartmentsController.php
@@ -6,6 +6,8 @@ use Illuminate\Http\Request;
use App\Models\Department;
use App\Helpers\Helper;
use Auth;
+use Image;
+use App\Http\Requests\ImageUploadRequest;
class DepartmentsController extends Controller
{
@@ -43,7 +45,7 @@ class DepartmentsController extends Controller
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
- public function store(Request $request)
+ public function store(ImageUploadRequest $request)
{
$this->authorize('create', Department::class);
$department = new Department;
@@ -51,6 +53,17 @@ class DepartmentsController extends Controller
$department->user_id = Auth::user()->id;
$department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null);
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/departments/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $department->image = $file_name;
+ }
+
if ($department->save()) {
return redirect()->route("departments.index")->with('success', trans('admin/departments/message.create.success'));
}
@@ -145,6 +158,20 @@ class DepartmentsController extends Controller
}
$department->fill($request->all());
+
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/departments/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $department->image = $file_name;
+ } elseif ($request->input('image_delete')=='1') {
+ $department->image = null;
+ }
+
$department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null);
if ($department->save()) {
diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php
index ffe480c63f..dc0cb1fe11 100755
--- a/app/Http/Controllers/LocationsController.php
+++ b/app/Http/Controllers/LocationsController.php
@@ -16,6 +16,8 @@ use Validator;
use View;
use Auth;
use Symfony\Component\HttpFoundation\JsonResponse;
+use Image;
+use App\Http\Requests\ImageUploadRequest;
/**
* This controller handles all actions related to Locations for
@@ -77,22 +79,33 @@ class LocationsController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
- public function store()
+ public function store(ImageUploadRequest $request)
{
$location = new Location();
- $location->name = Input::get('name');
- $location->parent_id = Input::get('parent_id', null);
- $location->currency = Input::get('currency', '$');
- $location->address = Input::get('address');
- $location->address2 = Input::get('address2');
- $location->city = Input::get('city');
- $location->state = Input::get('state');
- $location->country = Input::get('country');
- $location->zip = Input::get('zip');
- $location->ldap_ou = Input::get('ldap_ou');
- $location->manager_id = Input::get('manager_id');
+ $location->name = $request->input('name');
+ $location->parent_id = $request->input('parent_id', null);
+ $location->currency = $request->input('currency', '$');
+ $location->address = $request->input('address');
+ $location->address2 = $request->input('address2');
+ $location->city = $request->input('city');
+ $location->state = $request->input('state');
+ $location->country = $request->input('country');
+ $location->zip = $request->input('zip');
+ $location->ldap_ou = $request->input('ldap_ou');
+ $location->manager_id = $request->input('manager_id');
$location->user_id = Auth::id();
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/locations/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $location->image = $file_name;
+ }
+
if ($location->save()) {
return redirect()->route("locations.index")->with('success', trans('admin/locations/message.create.success'));
}
@@ -108,7 +121,7 @@ class LocationsController extends Controller
* @since [v1.0]
* @return String JSON
*/
- public function apiStore()
+ public function apiStore(Request $request)
{
$new['currency']=Setting::first()->default_currency;
@@ -116,13 +129,13 @@ class LocationsController extends Controller
$location = new Location();
// Save the location data
- $location->name = Input::get('name');
+ $location->name = $request->input('name');
$location->currency = Setting::first()->default_currency; //e(Input::get('currency'));
$location->address = ''; //e(Input::get('address'));
// $location->address2 = e(Input::get('address2'));
- $location->city = Input::get('city');
+ $location->city = $request->input('city');
$location->state = '';//e(Input::get('state'));
- $location->country = Input::get('country');
+ $location->country = $request->input('country');
// $location->zip = e(Input::get('zip'));
$location->user_id = Auth::id();
@@ -172,7 +185,7 @@ class LocationsController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
- public function update($locationId = null)
+ public function update(ImageUploadRequest $request, $locationId = null)
{
// Check if the location exists
if (is_null($location = Location::find($locationId))) {
@@ -180,24 +193,35 @@ class LocationsController extends Controller
}
// Update the location data
- $location->name = Input::get('name');
- $location->parent_id = Input::get('parent_id', null);
- $location->currency = Input::get('currency', '$');
- $location->address = Input::get('address');
- $location->address2 = Input::get('address2');
- $location->city = Input::get('city');
- $location->state = Input::get('state');
- $location->country = Input::get('country');
- $location->zip = Input::get('zip');
- $location->ldap_ou = Input::get('ldap_ou');
- $location->manager_id = Input::get('manager_id');
-
- // Was the location updated?
+ $location->name = $request->input('name');
+ $location->parent_id = $request->input('parent_id', null);
+ $location->currency = $request->input('currency', '$');
+ $location->address = $request->input('address');
+ $location->address2 = $request->input('address2');
+ $location->city = $request->input('city');
+ $location->state = $request->input('state');
+ $location->country = $request->input('country');
+ $location->zip = $request->input('zip');
+ $location->ldap_ou = $request->input('ldap_ou');
+ $location->manager_id = $request->input('manager_id');
+
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/locations/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $location->image = $file_name;
+ } elseif ($request->input('image_delete')=='1') {
+ $location->image = null;
+ }
+
+
if ($location->save()) {
- // Redirect to the saved location page
return redirect()->route("locations.index")->with('success', trans('admin/locations/message.update.success'));
}
- // Redirect to the location management page
return redirect()->back()->withInput()->withInput()->withErrors($location->getErrors());
}
@@ -211,20 +235,22 @@ class LocationsController extends Controller
*/
public function destroy($locationId)
{
- // Check if the location exists
if (is_null($location = Location::find($locationId))) {
- // Redirect to the blogs management page
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.not_found'));
}
if ($location->users->count() > 0) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_users'));
+
} elseif ($location->childLocations->count() > 0) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_child_loc'));
+
} elseif ($location->assets->count() > 0) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
+
} elseif ($location->assignedassets->count() > 0) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
+
} else {
$location->delete();
return redirect()->to(route('locations.index'))->with('success', trans('admin/locations/message.delete.success'));
@@ -248,11 +274,8 @@ class LocationsController extends Controller
if (isset($location->id)) {
return view('locations/view', compact('location'));
}
- // Prepare the error message
- $error = trans('admin/locations/message.does_not_exist', compact('id'));
- // Redirect to the user management page
- return redirect()->route('locations.index')->with('error', $error);
+ return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist', compact('id')));
}
}
diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php
index 1f20d5ccfc..18396ac452 100755
--- a/app/Http/Controllers/ManufacturersController.php
+++ b/app/Http/Controllers/ManufacturersController.php
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Helpers\Helper;
+use App\Http\Requests\ImageUploadRequest;
use App\Models\CustomField;
use App\Models\Manufacturer;
use Auth;
@@ -13,6 +14,7 @@ use Redirect;
use Str;
use View;
use Illuminate\Http\Request;
+use Image;
/**
* This controller handles all actions related to Manufacturers for
@@ -60,7 +62,7 @@ class ManufacturersController extends Controller
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
- public function store(Request $request)
+ public function store(ImageUploadRequest $request)
{
$manufacturer = new Manufacturer;
@@ -72,6 +74,18 @@ class ManufacturersController extends Controller
$manufacturer->support_email = $request->input('support_email');
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/manufacturers/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $manufacturer->image = $file_name;
+ }
+
+
if ($manufacturer->save()) {
return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.create.success'));
@@ -124,6 +138,20 @@ class ManufacturersController extends Controller
$manufacturer->support_phone = $request->input('support_phone');
$manufacturer->support_email = $request->input('support_email');
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
+ $path = public_path('uploads/manufacturers/'.$file_name);
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save($path);
+ $manufacturer->image = $file_name;
+ } elseif ($request->input('image_delete')=='1') {
+ $manufacturer->image = null;
+ }
+
+
if ($manufacturer->save()) {
return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.update.success'));
}
diff --git a/app/Http/Controllers/SuppliersController.php b/app/Http/Controllers/SuppliersController.php
index 6e579180c2..8d6c4926c2 100755
--- a/app/Http/Controllers/SuppliersController.php
+++ b/app/Http/Controllers/SuppliersController.php
@@ -77,19 +77,18 @@ class SuppliersController extends Controller
$supplier->url = $supplier->addhttp(request('url'));
$supplier->user_id = Auth::id();
- if (Input::file('image')) {
+ if ($request->file('image')) {
$image = $request->file('image');
$file_name = str_random(25).".".$image->getClientOriginalExtension();
$path = public_path('uploads/suppliers/'.$file_name);
- Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->save($path);
- $supplier->image = $file_name;
+ $supplier->image = $file_name;
}
if ($supplier->save()) {
- // Redirect to the nw supplier page
return redirect()->route('suppliers.index')->with('success', trans('admin/suppliers/message.create.success'));
}
return redirect()->back()->withInput()->withErrors($supplier->getErrors());
@@ -160,16 +159,16 @@ class SuppliersController extends Controller
$supplier->notes = request('notes');
- if (Input::file('image')) {
+ if ($request->file('image')) {
$image = $request->file('image');
- $file_name = 'suppliers-'.str_random(25).".".$image->getClientOriginalExtension();
+ $file_name = str_random(25).".".$image->getClientOriginalExtension();
$path = public_path('uploads/suppliers/'.$file_name);
- Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
+ Image::make($image->getRealPath())->resize(200, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->save($path);
$supplier->image = $file_name;
- } elseif (request('image_delete') == 1) {
+ } elseif ($request->input('image_delete')=='1') {
$supplier->image = null;
}
diff --git a/app/Http/Transformers/CategoriesTransformer.php b/app/Http/Transformers/CategoriesTransformer.php
index 213793c90a..121e73803e 100644
--- a/app/Http/Transformers/CategoriesTransformer.php
+++ b/app/Http/Transformers/CategoriesTransformer.php
@@ -25,6 +25,7 @@ class CategoriesTransformer
$array = [
'id' => (int) $category->id,
'name' => e($category->name),
+ 'image' => ($category->image) ? e(url('/').'/uploads/categories/'.e($category->image)) : null,
'type' => e($category->category_type),
'eula' => ($category->getEula()) ? true : false,
'checkin_email' => ($category->checkin_email =='1') ? true : false,
diff --git a/app/Http/Transformers/CompaniesTransformer.php b/app/Http/Transformers/CompaniesTransformer.php
index fb94535976..107ed59b17 100644
--- a/app/Http/Transformers/CompaniesTransformer.php
+++ b/app/Http/Transformers/CompaniesTransformer.php
@@ -25,6 +25,7 @@ class CompaniesTransformer
$array = [
'id' => (int) $company->id,
'name' => e($company->name),
+ 'image' => ($company->image) ? e(url('/').'/uploads/companies/'.e($company->image)) : null,
"created_at" => Helper::getFormattedDateObject($company->created_at, 'datetime'),
"updated_at" => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
"assets_count" => (int) $company->assets_count,
diff --git a/app/Http/Transformers/ComponentsTransformer.php b/app/Http/Transformers/ComponentsTransformer.php
index f80124e1db..bb24cafb0b 100644
--- a/app/Http/Transformers/ComponentsTransformer.php
+++ b/app/Http/Transformers/ComponentsTransformer.php
@@ -22,7 +22,8 @@ class ComponentsTransformer
$array = [
'id' => (int) $component->id,
'name' => e($component->name),
- 'serial_number' => e($component->serial),
+ 'image' => ($component->image) ? e(url('/').'/uploads/components/'.e($component->image)) : null,
+ 'serial_number' => ($component->serial) ? e($component->serial) : null,
'location' => ($component->location) ? [
'id' => (int) $component->location->id,
'name' => e($component->location->name)
diff --git a/app/Http/Transformers/ConsumablesTransformer.php b/app/Http/Transformers/ConsumablesTransformer.php
index 44bfe73818..426cfb9d41 100644
--- a/app/Http/Transformers/ConsumablesTransformer.php
+++ b/app/Http/Transformers/ConsumablesTransformer.php
@@ -22,6 +22,8 @@ class ConsumablesTransformer
{
$array = [
'id' => (int) $consumable->id,
+ 'name' => e($consumable->name),
+ 'image' => ($consumable->image) ? e(url('/').'/uploads/consumables/'.e($consumable->image)) : null,
'category' => ($consumable->category) ? ['id' => $consumable->category->id, 'name' => e($consumable->category->name)] : null,
'company' => ($consumable->company) ? ['id' => (int) $consumable->company->id, 'name' => e($consumable->company->name)] : null,
'item_no' => e($consumable->item_no),
@@ -29,7 +31,6 @@ class ConsumablesTransformer
'manufacturer' => ($consumable->manufacturer) ? ['id' => (int) $consumable->manufacturer->id, 'name' => e($consumable->manufacturer->name)] : null,
'min_amt' => (int) $consumable->min_amt,
'model_number' => e($consumable->model_number),
- 'name' => e($consumable->name),
'remaining' => $consumable->numRemaining(),
'order_number' => e($consumable->order_number),
'purchase_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost),
diff --git a/app/Http/Transformers/DepartmentsTranformer.php b/app/Http/Transformers/DepartmentsTranformer.php
index 8531a3b8ef..00a8746e8b 100644
--- a/app/Http/Transformers/DepartmentsTranformer.php
+++ b/app/Http/Transformers/DepartmentsTranformer.php
@@ -25,6 +25,7 @@ class DepartmentsTransformer
$array = [
'id' => (int) $department->id,
'name' => e($department->name),
+ 'image' => ($department->image) ? e(url('/').'/uploads/departments/'.e($department->image)) : null,
'company' => ($department->company) ? [
'id' => (int) $department->company->id,
'name'=> e($department->company->name)
diff --git a/app/Http/Transformers/LocationsTransformer.php b/app/Http/Transformers/LocationsTransformer.php
index 5dc8961dba..2822968623 100644
--- a/app/Http/Transformers/LocationsTransformer.php
+++ b/app/Http/Transformers/LocationsTransformer.php
@@ -33,6 +33,7 @@ class LocationsTransformer
$array = [
'id' => (int) $location->id,
'name' => e($location->name),
+ 'image' => ($location->image) ? e(url('/').'/uploads/locations/'.e($location->image)) : null,
'address' => e($location->address),
'city' => e($location->city),
'state' => e($location->state),
diff --git a/app/Http/Transformers/ManufacturersTransformer.php b/app/Http/Transformers/ManufacturersTransformer.php
index a1911a4468..93bcf36d24 100644
--- a/app/Http/Transformers/ManufacturersTransformer.php
+++ b/app/Http/Transformers/ManufacturersTransformer.php
@@ -26,6 +26,7 @@ class ManufacturersTransformer
'id' => (int) $manufacturer->id,
'name' => e($manufacturer->name),
'url' => e($manufacturer->url),
+ 'image' => ($manufacturer->image) ? e(url('/').'/uploads/manufacturers/'.e($manufacturer->image)) : null,
'support_url' => e($manufacturer->support_url),
'support_phone' => e($manufacturer->support_phone),
'support_email' => e($manufacturer->support_email),
diff --git a/app/Http/Transformers/SuppliersTransformer.php b/app/Http/Transformers/SuppliersTransformer.php
index 5802c87d86..bd3aac350b 100644
--- a/app/Http/Transformers/SuppliersTransformer.php
+++ b/app/Http/Transformers/SuppliersTransformer.php
@@ -25,6 +25,7 @@ class SuppliersTransformer
$array = [
'id' => (int) $supplier->id,
'name' => e($supplier->name),
+ 'image' => ($supplier->image) ? e(url('/').'/uploads/suppliers/'.e($supplier->image)) : null,
'address' => ($supplier->address) ? e($supplier->address) : null,
'address2' => ($supplier->address2) ? e($supplier->address2) : null,
'city' => ($supplier->city) ? e($supplier->city) : null,
@@ -38,7 +39,6 @@ class SuppliersTransformer
'assets_count' => (int) $supplier->assets_count,
'accessories_count' => (int) $supplier->accessories_count,
'licenses_count' => (int) $supplier->licenses_count,
- 'image' => ($supplier->image) ? url('/').'/uploads/suppliers/'.e($supplier->image) : null,
'notes' => ($supplier->notes) ? e($supplier->notes) : null,
'created_at' => Helper::getFormattedDateObject($supplier->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($supplier->updated_at, 'datetime'),
diff --git a/app/Models/Company.php b/app/Models/Company.php
index fe621ff4fe..e3b23e8645 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -192,4 +192,20 @@ final class Company extends SnipeModel
{
return $this->hasMany(Component::class);
}
+
+ /**
+ * Query builder scope to search on text
+ *
+ * @param Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $search Search term
+ *
+ * @return Illuminate\Database\Query\Builder Modified query builder
+ */
+ public function scopeTextSearch($query, $search)
+ {
+
+ return $query->where(function ($query) use ($search) {
+ $query->where('name', 'LIKE', '%'.$search.'%');
+ });
+ }
}
diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.php
index 42303f8e43..db864f43e7 100644
--- a/app/Presenters/CategoryPresenter.php
+++ b/app/Presenters/CategoryPresenter.php
@@ -32,6 +32,13 @@ class CategoryPresenter extends Presenter
"title" => trans('general.name'),
"visible" => true,
"formatter" => 'categoriesLinkFormatter',
+ ],[
+ "field" => "image",
+ "searchable" => false,
+ "sortable" => true,
+ "title" => trans('general.image'),
+ "visible" => true,
+ "formatter" => 'imageFormatter',
],[
"field" => "type",
"searchable" => true,
diff --git a/app/Presenters/CompanyPresenter.php b/app/Presenters/CompanyPresenter.php
index caf1690dd6..233245ff7d 100644
--- a/app/Presenters/CompanyPresenter.php
+++ b/app/Presenters/CompanyPresenter.php
@@ -30,6 +30,14 @@ class CompanyPresenter extends Presenter
"title" => trans('admin/companies/table.name'),
"visible" => true,
"formatter" => 'companiesLinkFormatter',
+ ],[
+ "field" => "image",
+ "searchable" => false,
+ "sortable" => true,
+ "switchable" => true,
+ "title" => trans('general.image'),
+ "visible" => true,
+ "formatter" => 'imageFormatter',
],[
"field" => "users_count",
"searchable" => false,
diff --git a/app/Presenters/ComponentPresenter.php b/app/Presenters/ComponentPresenter.php
index 1a62db667e..6983b73d11 100644
--- a/app/Presenters/ComponentPresenter.php
+++ b/app/Presenters/ComponentPresenter.php
@@ -42,6 +42,14 @@ class ComponentPresenter extends Presenter
"title" => trans('general.name'),
"visible" => true,
"formatter" => 'componentsLinkFormatter',
+ ], [
+ "field" => "image",
+ "searchable" => false,
+ "sortable" => true,
+ "switchable" => true,
+ "title" => trans('general.image'),
+ "visible" => false,
+ "formatter" => 'imageFormatter',
], [
"field" => "category",
"searchable" => true,
diff --git a/app/Presenters/ConsumablePresenter.php b/app/Presenters/ConsumablePresenter.php
index 2b542912af..2089771cc0 100644
--- a/app/Presenters/ConsumablePresenter.php
+++ b/app/Presenters/ConsumablePresenter.php
@@ -41,6 +41,15 @@ class ConsumablePresenter extends Presenter
"title" => trans('general.name'),
"visible" => true,
"formatter" => 'consumablesLinkFormatter',
+ ],
+ [
+ "field" => "image",
+ "searchable" => false,
+ "sortable" => true,
+ "switchable" => true,
+ "title" => trans('general.image'),
+ "visible" => false,
+ "formatter" => 'imageFormatter',
], [
"field" => "category",
"searchable" => true,
diff --git a/app/Presenters/ManufacturerPresenter.php b/app/Presenters/ManufacturerPresenter.php
index 60c94d005a..e07e9cff9c 100644
--- a/app/Presenters/ManufacturerPresenter.php
+++ b/app/Presenters/ManufacturerPresenter.php
@@ -35,6 +35,15 @@ class ManufacturerPresenter extends Presenter
"visible" => true,
"formatter" => "manufacturersLinkFormatter"
],
+ [
+ "field" => "image",
+ "searchable" => false,
+ "sortable" => true,
+ "switchable" => true,
+ "title" => trans('general.image'),
+ "visible" => true,
+ "formatter" => "imageFormatter"
+ ],
[
"field" => "url",
"searchable" => true,
@@ -44,7 +53,6 @@ class ManufacturerPresenter extends Presenter
"visible" => true,
"formatter" => "linkFormatter"
],
-
[
"field" => "support_url",
"searchable" => true,
diff --git a/database/migrations/2017_10_25_202930_add_images_uploads_to_locations_manufacturers_etc.php b/database/migrations/2017_10_25_202930_add_images_uploads_to_locations_manufacturers_etc.php
new file mode 100644
index 0000000000..f6775a564a
--- /dev/null
+++ b/database/migrations/2017_10_25_202930_add_images_uploads_to_locations_manufacturers_etc.php
@@ -0,0 +1,71 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddImagesUploadsToLocationsManufacturersEtc extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('categories', function (Blueprint $table) {
+ $table->string('image')->nullable()->default(null);
+ });
+ Schema::table('companies', function (Blueprint $table) {
+ $table->string('image')->nullable()->default(null);
+ });
+ Schema::table('components', function (Blueprint $table) {
+ $table->string('image')->nullable()->default(null);
+ });
+ Schema::table('consumables', function (Blueprint $table) {
+ $table->string('image')->nullable()->default(null);
+ });
+ Schema::table('departments', function (Blueprint $table) {
+ $table->string('image')->nullable()->default(null);
+ });
+ Schema::table('locations', function (Blueprint $table) {
+ $table->string('image')->nullable()->default(null);
+ });
+ Schema::table('manufacturers', function (Blueprint $table) {
+ $table->string('image')->nullable()->default(null);
+ });
+
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('categories', function (Blueprint $table) {
+ $table->dropColumn('image');
+ });
+ Schema::table('companies', function (Blueprint $table) {
+ $table->dropColumn('image');
+ });
+ Schema::table('components', function (Blueprint $table) {
+ $table->dropColumn('image');
+ });
+ Schema::table('consumables', function (Blueprint $table) {
+ $table->dropColumn('image');
+ });
+ Schema::table('departments', function (Blueprint $table) {
+ $table->dropColumn('image');
+ });
+ Schema::table('locations', function (Blueprint $table) {
+ $table->dropColumn('image');
+ });
+ Schema::table('manufacturers', function (Blueprint $table) {
+ $table->dropColumn('image');
+ });
+
+
+ }
+}
diff --git a/public/uploads/categories/.gitignore b/public/uploads/categories/.gitignore
new file mode 100755
index 0000000000..f935021a8f
--- /dev/null
+++ b/public/uploads/categories/.gitignore
@@ -0,0 +1 @@
+!.gitignore
diff --git a/public/uploads/companies/.gitignore b/public/uploads/companies/.gitignore
new file mode 100755
index 0000000000..f935021a8f
--- /dev/null
+++ b/public/uploads/companies/.gitignore
@@ -0,0 +1 @@
+!.gitignore
diff --git a/public/uploads/companies/LNwfCJ5P4WtaViO1XYbkWgX8D.jpg b/public/uploads/companies/LNwfCJ5P4WtaViO1XYbkWgX8D.jpg
new file mode 100644
index 0000000000..3aae4799f9
Binary files /dev/null and b/public/uploads/companies/LNwfCJ5P4WtaViO1XYbkWgX8D.jpg differ
diff --git a/public/uploads/companies/RZAs6WvRP9P5WMJIaPS0f1rDT.jpg b/public/uploads/companies/RZAs6WvRP9P5WMJIaPS0f1rDT.jpg
new file mode 100644
index 0000000000..57b28c264d
Binary files /dev/null and b/public/uploads/companies/RZAs6WvRP9P5WMJIaPS0f1rDT.jpg differ
diff --git a/public/uploads/components/.gitignore b/public/uploads/components/.gitignore
new file mode 100755
index 0000000000..f935021a8f
--- /dev/null
+++ b/public/uploads/components/.gitignore
@@ -0,0 +1 @@
+!.gitignore
diff --git a/public/uploads/consumables/.gitignore b/public/uploads/consumables/.gitignore
new file mode 100755
index 0000000000..f935021a8f
--- /dev/null
+++ b/public/uploads/consumables/.gitignore
@@ -0,0 +1 @@
+!.gitignore
diff --git a/public/uploads/departments/.gitignore b/public/uploads/departments/.gitignore
new file mode 100755
index 0000000000..f935021a8f
--- /dev/null
+++ b/public/uploads/departments/.gitignore
@@ -0,0 +1 @@
+!.gitignore
diff --git a/public/uploads/locations/.gitignore b/public/uploads/locations/.gitignore
new file mode 100755
index 0000000000..f935021a8f
--- /dev/null
+++ b/public/uploads/locations/.gitignore
@@ -0,0 +1 @@
+!.gitignore
diff --git a/public/uploads/manufacturers/.gitignore b/public/uploads/manufacturers/.gitignore
new file mode 100755
index 0000000000..f935021a8f
--- /dev/null
+++ b/public/uploads/manufacturers/.gitignore
@@ -0,0 +1 @@
+!.gitignore
diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php
index b7aa8cf442..854787ed91 100644
--- a/resources/lang/en/general.php
+++ b/resources/lang/en/general.php
@@ -2,14 +2,14 @@
return [
'accessories' => 'Accessories',
- 'activated' => 'Activated',
+ 'activated' => 'Activated',
'accessory' => 'Accessory',
- 'accessory_report' => 'Accessory Report',
+ 'accessory_report' => 'Accessory Report',
'action' => 'Action',
'activity_report' => 'Activity Report',
'address' => 'Address',
'admin' => 'Admin',
- 'add_seats' => 'Added seats',
+ 'add_seats' => 'Added seats',
'all_assets' => 'All Assets',
'all' => 'All',
'archived' => 'Archived',
@@ -40,9 +40,9 @@
'checkout' => 'Checkout',
'city' => 'City',
'click_here' => 'Click here',
- 'companies' => 'Companies',
+ 'companies' => 'Companies',
'company' => 'Company',
- 'component' => 'Component',
+ 'component' => 'Component',
'components' => 'Components',
'complete' => 'Complete',
'consumable' => 'Consumable',
@@ -58,10 +58,10 @@
'custom_report' => 'Custom Asset Report',
'dashboard' => 'Dashboard',
'days' => 'days',
- 'days_to_next_audit' => 'Days to Next Audit',
+ 'days_to_next_audit' => 'Days to Next Audit',
'date' => 'Date',
'debug_warning' => 'Warning!',
- 'debug_warning_text' => 'This application is running in production mode with debugging enabled. This can expose sensitive data if your application is accessible to the outside world. Disable debug mode by setting the <code>APP_DEBUG</code> value in your <code>.env</code> file to <code>false</code>.',
+ 'debug_warning_text' => 'This application is running in production mode with debugging enabled. This can expose sensitive data if your application is accessible to the outside world. Disable debug mode by setting the <code>APP_DEBUG</code> value in your <code>.env</code> file to <code>false</code>.',
'delete' => 'Delete',
'deleted' => 'Deleted',
'delete_seats' => 'Deleted Seats',
@@ -89,6 +89,7 @@
'history' => 'History',
'history_for' => 'History for',
'id' => 'ID',
+ 'image' => 'Image',
'image_delete' => 'Delete Image',
'image_upload' => 'Upload Image',
'import' => 'Import',
diff --git a/resources/views/categories/edit.blade.php b/resources/views/categories/edit.blade.php
index 6371db1950..ef995c9d0d 100755
--- a/resources/views/categories/edit.blade.php
+++ b/resources/views/categories/edit.blade.php
@@ -61,11 +61,33 @@
{{ trans('admin/categories/general.checkin_email') }}
</label>
</div>
+
+<!-- Image -->
+@if ($item->image)
+ <div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
+ <div class="col-md-5">
+ {{ Form::checkbox('image_delete') }}
+ <img src="{{ url('/') }}/uploads/categories/{{ $item->image }}" />
+ {!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+@endif
+
+<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
+ <div class="col-md-5">
+ {{ Form::file('image') }}
+ {!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
+ </div>
+</div>
+
@stop
@section('content')
@parent
+
@if ($snipeSettings->default_eula_text!='')
<!-- Modal -->
<div class="modal fade" id="eulaModal" tabindex="-1" role="dialog" aria-labelledby="eulaModalLabel" aria-hidden="true">
@@ -85,4 +107,7 @@
</div>
</div>
@endif
+
+
+
@stop
diff --git a/resources/views/companies/edit.blade.php b/resources/views/companies/edit.blade.php
index daa3eba9e8..46d55f6532 100644
--- a/resources/views/companies/edit.blade.php
+++ b/resources/views/companies/edit.blade.php
@@ -9,4 +9,25 @@
{{-- Page content --}}
@section('inputFields')
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/companies/table.name')])
+
+<!-- Image -->
+@if ($item->image)
+ <div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
+ <div class="col-md-5">
+ {{ Form::checkbox('image_delete') }}
+ <img src="{{ url('/') }}/uploads/companies/{{ $item->image }}" />
+ {!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+@endif
+
+<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
+ <div class="col-md-5">
+ {{ Form::file('image') }}
+ {!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
+ </div>
+</div>
+
@stop
diff --git a/resources/views/components/edit.blade.php b/resources/views/components/edit.blade.php
index 84b7bb3e2b..24f94e9b47 100644
--- a/resources/views/components/edit.blade.php
+++ b/resources/views/components/edit.blade.php
@@ -21,4 +21,24 @@
@include ('partials.forms.edit.purchase_date')
@include ('partials.forms.edit.purchase_cost')
+<!-- Image -->
+@if ($item->image)
+ <div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
+ <div class="col-md-5">
+ {{ Form::checkbox('image_delete') }}
+ <img src="{{ url('/') }}/uploads/components/{{ $item->image }}" />
+ {!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+@endif
+
+<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
+ <div class="col-md-5">
+ {{ Form::file('image') }}
+ {!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
+ </div>
+</div>
+
@stop
diff --git a/resources/views/components/view.blade.php b/resources/views/components/view.blade.php
index e47c6fe2cb..57f2eb7141 100644
--- a/resources/views/components/view.blade.php
+++ b/resources/views/components/view.blade.php
@@ -71,6 +71,12 @@
<!-- side address column -->
<div class="col-md-3">
+ @if ($component->image!='')
+ <div class="col-md-12" style="padding-bottom: 5px;">
+ <img src="{{ url('/') }}/uploads/components/{{ $component->image }}">
+ </div>
+ @endif
+
@if ($component->serial!='')
<div class="col-md-12" style="padding-bottom: 5px;"><strong>{{ trans('admin/hardware/form.serial') }}: </strong>
{{ $component->serial }} </div>
diff --git a/resources/views/consumables/edit.blade.php b/resources/views/consumables/edit.blade.php
index 54d5d5c27f..48f5d38c09 100644
--- a/resources/views/consumables/edit.blade.php
+++ b/resources/views/consumables/edit.blade.php
@@ -21,4 +21,23 @@
@include ('partials.forms.edit.quantity')
@include ('partials.forms.edit.minimum_quantity')
+<!-- Image -->
+@if ($item->image)
+ <div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
+ <div class="col-md-5">
+ {{ Form::checkbox('image_delete') }}
+ <img src="{{ url('/') }}/uploads/consumables/{{ $item->image }}" />
+ {!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+@endif
+
+<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
+ <div class="col-md-5">
+ {{ Form::file('image') }}
+ {!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
+ </div>
+</div>
@stop
diff --git a/resources/views/consumables/view.blade.php b/resources/views/consumables/view.blade.php
index 820f69dc51..f540d600d9 100644
--- a/resources/views/consumables/view.blade.php
+++ b/resources/views/consumables/view.blade.php
@@ -57,6 +57,12 @@
</div> <!-- /.col-md-9-->
<div class="col-md-3">
+ @if ($consumable->image!='')
+ <div class="col-md-12" style="padding-bottom: 5px;">
+ <img src="{{ url('/') }}/uploads/consumables/{{ $consumable->image }}">
+ </div>
+ @endif
+
<h4>{{ trans('admin/consumables/general.about_consumables_title') }}</h4>
<p>{{ trans('admin/consumables/general.about_consumables_text') }} </p>
diff --git a/resources/views/departments/edit.blade.php b/resources/views/departments/edit.blade.php
index 7412a8d126..7e3430044a 100644
--- a/resources/views/departments/edit.blade.php
+++ b/resources/views/departments/edit.blade.php
@@ -32,7 +32,25 @@
</div>
</div>
+ <!-- Image -->
+ @if ($item->image)
+ <div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
+ <div class="col-md-5">
+ {{ Form::checkbox('image_delete') }}
+ <img src="{{ url('/') }}/uploads/departments/{{ $item->image }}" />
+ {!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+ @endif
+ <div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
+ <div class="col-md-5">
+ {{ Form::file('image') }}
+ {!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
@stop
diff --git a/resources/views/departments/index.blade.php b/resources/views/departments/index.blade.php
index 4f9c884e49..bc5c0fb57c 100644
--- a/resources/views/departments/index.blade.php
+++ b/resources/views/departments/index.blade.php
@@ -29,8 +29,8 @@
<tr>
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
<th data-sortable="true" data-field="company" data-visible="false" data-formatter="companiesLinkObjFormatter">{{ trans('general.company') }}</th>
-
<th data-sortable="true" data-formatter="departmentsLinkFormatter" data-field="name" data-searchable="false">{{ trans('admin/departments/table.name') }}</th>
+ <th data-sortable="true" data-field="image" data-visible="false" data-formatter="imageFormatter">{{ trans('general.image') }}</th>
<th data-sortable="false" data-formatter="usersLinkObjFormatter" data-field="manager" data-searchable="false">{{ trans('admin/departments/table.manager') }}</th>
<th data-sortable="false" data-field="users_count" data-searchable="false">{{ trans('general.users') }}</th>
<th data-sortable="false" data-formatter="locationsLinkObjFormatter" data-field="location" data-searchable="false">{{ trans('admin/departments/table.location') }}</th>
diff --git a/resources/views/locations/edit.blade.php b/resources/views/locations/edit.blade.php
index ee65d69339..054a8d2ed5 100755
--- a/resources/views/locations/edit.blade.php
+++ b/resources/views/locations/edit.blade.php
@@ -58,6 +58,25 @@
</div>
@endif
+<!-- Image -->
+@if ($item->image)
+ <div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
+ <div class="col-md-5">
+ {{ Form::checkbox('image_delete') }}
+ <img src="{{ url('/') }}/uploads/locations/{{ $item->image }}" />
+ {!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+@endif
+
+<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
+ <div class="col-md-5">
+ {{ Form::file('image') }}
+ {!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
+ </div>
+</div>
@stop
@if (!$item->id)
diff --git a/resources/views/locations/index.blade.php b/resources/views/locations/index.blade.php
index 98adac48c6..d6b5212fae 100755
--- a/resources/views/locations/index.blade.php
+++ b/resources/views/locations/index.blade.php
@@ -29,10 +29,11 @@
<tr>
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
<th data-sortable="true" data-formatter="locationsLinkFormatter" data-field="name" data-searchable="true">{{ trans('admin/locations/table.name') }}</th>
+ <th data-sortable="true" data-field="image" data-visible="false" data-formatter="imageFormatter">{{ trans('general.image') }}</th>
<th data-sortable="true" data-field="parent" data-formatter="locationsLinkObjFormatter">{{ trans('admin/locations/table.parent') }}</th>
<th data-searchable="false" data-sortable="false" data-field="assets_default">{{ trans('admin/locations/table.assets_rtd') }}</th>
<th data-searchable="false" data-sortable="false" data-field="assets_checkedout">{{ trans('admin/locations/table.assets_checkedout') }}</th>
- <th data-searchable="true" data-sortable="true" data-field="currency">{{ App\Models\Setting::first()->default_currency }}</th>
+ <th data-searchable="true" data-sortable="true" data-field="currency">{{ trans('general.currency') }}</th>
<th data-searchable="true" data-sortable="true" data-field="address">{{ trans('admin/locations/table.address') }}</th>
<th data-searchable="true" data-sortable="true" data-field="city">{{ trans('admin/locations/table.city') }}
</th>
diff --git a/resources/views/manufacturers/edit.blade.php b/resources/views/manufacturers/edit.blade.php
index 895b45e554..69d0522256 100755
--- a/resources/views/manufacturers/edit.blade.php
+++ b/resources/views/manufacturers/edit.blade.php
@@ -50,4 +50,25 @@
</div>
</div>
+ <!-- Image -->
+ @if ($item->image)
+ <div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
+ <div class="col-md-5">
+ {{ Form::checkbox('image_delete') }}
+ <img src="{{ url('/') }}/uploads/manufacturers/{{ $item->image }}" />
+ {!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+ @endif
+
+ <div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
+ <label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
+ <div class="col-md-5">
+ {{ Form::file('image') }}
+ {!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+
+
@stop
diff --git a/resources/views/suppliers/index.blade.php b/resources/views/suppliers/index.blade.php
index 7a9b3f0e3c..276a91f023 100755
--- a/resources/views/suppliers/index.blade.php
+++ b/resources/views/suppliers/index.blade.php
@@ -30,7 +30,7 @@
<thead>
<tr>
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('admin/suppliers/table.id') }}</th>
- <th data-formatter="imageFormatter" data-sortable="true" data-field="image" data-visible="false" data-searchable="false">Image</th>
+ <th data-formatter="imageFormatter" data-sortable="true" data-field="image" data-visible="false" data-searchable="false">{{ trans('general.image') }}</th>
<th data-sortable="true" data-field="name" data-formatter="suppliersLinkFormatter">{{ trans('admin/suppliers/table.name') }}</th>
<th data-sortable="true" data-field="address">{{ trans('admin/suppliers/table.address') }}</th>
<th data-searchable="true" data-sortable="true" data-field="contact">{{ trans('admin/suppliers/table.contact') }}</th>