From ac6364222478f4ad08a768efecf8085a7225508f Mon Sep 17 00:00:00 2001 From: Daniel Meltzer Date: Tue, 16 Aug 2016 20:49:54 -0500 Subject: [PATCH] Add manufacturer to licenses (#2436) * Add manufacturer to licenses. Shows in table and edit. Need to improve manufacturer view to show lists beyond assets still. * Remove extra closing tags, formatting * Work on making the manufacturer view show more options. Need to figure out how to change the table dynamically. * Cleanup formatting and fix a few weirdities in hardware/view.blade.php * Standardize on two-space tabs in this file, as it seems the most * common. * Fix a few places where we call number_format without guaranteeing the * item is a number and not a string. * Show a "No Results" message on components page if there are no * components. * Show table of licenses on manufacturer view page. This reworks the ManufacturersController::getDataView method to delegate the view to a sub method (currently assets or licenses, but plan to extend to consumables/accessories/components as well). We then put tabs at the top of the view to show multiple tables. This just duplicates the table layout from licenses/index.blade, but I wonder if theres a way to centralize that code, maybe through partials, over time.. The only known missing part of manufacturers for licenses would be adding it to the importer, but the license importer should probably migrate to object importer before doing too much more... * Add manufacturer to accessory. * Add consumables to the manufacturer view page. --- .../Controllers/AccessoriesController.php | 51 +- .../Controllers/ConsumablesController.php | 16 +- app/Http/Controllers/LicensesController.php | 68 +- .../Controllers/ManufacturersController.php | 233 +++++- app/Http/routes.php | 2 +- app/Models/Accessory.php | 5 + app/Models/License.php | 5 + app/Models/Manufacturer.php | 15 + ...09_002225_add_manufacturer_to_licenses.php | 32 + ..._add_manufacturer_to_accessories_table.php | 33 + resources/views/accessories/edit.blade.php | 12 + resources/views/accessories/index.blade.php | 1 + resources/views/hardware/view.blade.php | 723 +++++++++--------- resources/views/licenses/edit.blade.php | 9 + resources/views/licenses/index.blade.php | 1 + resources/views/licenses/view.blade.php | 7 + resources/views/manufacturers/view.blade.php | 167 +++- resources/views/models/edit.blade.php | 21 +- 18 files changed, 911 insertions(+), 490 deletions(-) create mode 100644 database/migrations/2016_08_09_002225_add_manufacturer_to_licenses.php create mode 100644 database/migrations/2016_08_12_121613_add_manufacturer_to_accessories_table.php diff --git a/app/Http/Controllers/AccessoriesController.php b/app/Http/Controllers/AccessoriesController.php index 6c079345d9..d5e8dd7e79 100755 --- a/app/Http/Controllers/AccessoriesController.php +++ b/app/Http/Controllers/AccessoriesController.php @@ -53,14 +53,12 @@ class AccessoriesController extends Controller public function getCreate(Request $request) { // Show the page - $category_list = Helper::categoryList('accessory'); - $company_list = Helper::companyList(); - $location_list = Helper::locationsList(); return View::make('accessories/edit') ->with('accessory', new Accessory) - ->with('category_list', $category_list) - ->with('company_list', $company_list) - ->with('location_list', $location_list); + ->with('category_list', Helper::categoryList('accessory')) + ->with('company_list', Helper::companyList()) + ->with('location_list', Helper::locationsList()) + ->with('manufacturer_list', Helper::manufacturerList()); } @@ -77,12 +75,13 @@ class AccessoriesController extends Controller $accessory = new Accessory(); // Update the accessory data - $accessory->name = e(Input::get('name')); - $accessory->category_id = e(Input::get('category_id')); - $accessory->location_id = e(Input::get('location_id')); - $accessory->min_amt = e(Input::get('min_amt')); + $accessory->name = e(Input::get('name')); + $accessory->category_id = e(Input::get('category_id')); + $accessory->location_id = e(Input::get('location_id')); + $accessory->min_amt = e(Input::get('min_amt')); $accessory->company_id = Company::getIdForCurrentUser(Input::get('company_id')); $accessory->order_number = e(Input::get('order_number')); + $accessory->manufacturer_id = e(Input::get('manufacturer_id')); if (e(Input::get('purchase_date')) == '') { $accessory->purchase_date = null; @@ -96,8 +95,8 @@ class AccessoriesController extends Controller $accessory->purchase_cost = e(Input::get('purchase_cost')); } - $accessory->qty = e(Input::get('qty')); - $accessory->user_id = Auth::user()->id; + $accessory->qty = e(Input::get('qty')); + $accessory->user_id = Auth::user()->id; // Was the accessory created? if ($accessory->save()) { @@ -126,14 +125,11 @@ class AccessoriesController extends Controller return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions')); } - $category_list = Helper::categoryList('accessory'); - $company_list = Helper::companyList(); - $location_list = Helper::locationsList(); - return View::make('accessories/edit', compact('accessory')) - ->with('category_list', $category_list) - ->with('company_list', $company_list) - ->with('location_list', $location_list); + ->with('category_list', Helper::categoryList('accessory')) + ->with('company_list', Helper::companyList()) + ->with('location_list', Helper::locationsList()) + ->with('manufacturer_list', Helper::manufacturerList()); } @@ -146,9 +142,9 @@ class AccessoriesController extends Controller */ public function postEdit(Request $request, $accessoryId = null) { - // Check if the blog post exists + // Check if the accessory exists if (is_null($accessory = Accessory::find($accessoryId))) { - // Redirect to the blogs management page + // Redirect to the accessory index page return redirect()->to('admin/accessories')->with('error', trans('admin/accessories/message.does_not_exist')); } elseif (!Company::isCurrentUserHasAccess($accessory)) { return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions')); @@ -160,11 +156,12 @@ class AccessoriesController extends Controller if (e(Input::get('location_id')) == '') { $accessory->location_id = null; } else { - $accessory->location_id = e(Input::get('location_id')); + $accessory->location_id = e(Input::get('location_id')); } - $accessory->min_amt = e(Input::get('min_amt')); + $accessory->min_amt = e(Input::get('min_amt')); $accessory->category_id = e(Input::get('category_id')); $accessory->company_id = Company::getIdForCurrentUser(Input::get('company_id')); + $accessory->manufacturer_id = e(Input::get('manufacturer_id')); $accessory->order_number = e(Input::get('order_number')); if (e(Input::get('purchase_date')) == '') { @@ -181,9 +178,9 @@ class AccessoriesController extends Controller $accessory->qty = e(Input::get('qty')); - // Was the accessory created? + // Was the accessory updated? if ($accessory->save()) { - // Redirect to the new accessory page + // Redirect to the updated accessory page return redirect()->to("admin/accessories")->with('success', trans('admin/accessories/message.update.success')); } @@ -620,7 +617,9 @@ class AccessoriesController extends Controller 'purchase_cost' => number_format($accessory->purchase_cost, 2), 'numRemaining' => $accessory->numRemaining(), 'actions' => $actions, - 'companyName' => is_null($company) ? '' : e($company->name) + 'companyName' => is_null($company) ? '' : e($company->name), + 'manufacturer' => $accessory->manufacturer ? (string) link_to('/admin/settings/manufacturers/'.$accessory->manufacturer_id.'/view', $accessory->manufacturer->name) : '' + ); } diff --git a/app/Http/Controllers/ConsumablesController.php b/app/Http/Controllers/ConsumablesController.php index 11f6a7812d..1c9609d196 100644 --- a/app/Http/Controllers/ConsumablesController.php +++ b/app/Http/Controllers/ConsumablesController.php @@ -467,16 +467,16 @@ class ConsumablesController extends Controller $rows[] = array( 'id' => $consumable->id, 'name' => (string)link_to('admin/consumables/'.$consumable->id.'/view', e($consumable->name)), - 'location' => ($consumable->location) ? e($consumable->location->name) : '', - 'min_amt' => e($consumable->min_amt), + 'location' => ($consumable->location) ? e($consumable->location->name) : '', + 'min_amt' => e($consumable->min_amt), 'qty' => e($consumable->qty), - 'manufacturer' => ($consumable->manufacturer) ? e($consumable->manufacturer->name) : '', - 'model_no' => e($consumable->model_no), - 'item_no' => e($consumable->item_no), - 'category' => ($consumable->category) ? e($consumable->category->name) : 'Missing category', + 'manufacturer' => ($consumable->manufacturer) ? (string) link_to('/admin/settings/manufacturers/'.$consumable->manufacturer_id.'/view', $consumable->manufacturer->name): '', + 'model_no' => e($consumable->model_no), + 'item_no' => e($consumable->item_no), + 'category' => ($consumable->category) ? (string) link_to('/admin/settings/categories/'.$consumable->category_id.'/view', $consumable->category->name) : 'Missing category', 'order_number' => e($consumable->order_number), - 'purchase_date' => e($consumable->purchase_date), - 'purchase_cost' => ($consumable->purchase_cost!='') ? number_format($consumable->purchase_cost, 2): '' , + 'purchase_date' => e($consumable->purchase_date), + 'purchase_cost' => ($consumable->purchase_cost!='') ? number_format($consumable->purchase_cost, 2): '' , 'numRemaining' => $consumable->numRemaining(), 'actions' => $actions, 'companyName' => is_null($company) ? '' : e($company->name), diff --git a/app/Http/Controllers/LicensesController.php b/app/Http/Controllers/LicensesController.php index bfd46a190d..671ac1e91f 100755 --- a/app/Http/Controllers/LicensesController.php +++ b/app/Http/Controllers/LicensesController.php @@ -61,18 +61,17 @@ class LicensesController extends Controller public function getCreate() { - $depreciation_list = Helper::depreciationList(); - $supplier_list = Helper::suppliersList(); $maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No'); - $company_list = Helper::companyList(); return View::make('licenses/edit') //->with('license_options',$license_options) - ->with('depreciation_list', $depreciation_list) - ->with('supplier_list', $supplier_list) + ->with('depreciation_list', Helper::depreciationList()) + ->with('supplier_list', Helper::suppliersList()) ->with('maintained_list', $maintained_list) - ->with('company_list', $company_list) + ->with('company_list', Helper::companyList()) + ->with('manufacturer_list', Helper::manufacturerList()) ->with('license', new License); + } @@ -125,6 +124,12 @@ class LicensesController extends Controller $license->purchase_order = e(Input::get('purchase_order')); } + if (empty(e(Input::get('manufacturer_id')))) { + $license->manufacturer_id = null; + } else { + $license->manufacturer_id = e(Input::get('manufacturer_id')); + } + // Save the license data $license->name = e(Input::get('name')); $license->serial = e(Input::get('serial')); @@ -206,17 +211,15 @@ class LicensesController extends Controller // Show the page $license_options = array('' => 'Top Level') + DB::table('assets')->where('id', '!=', $licenseId)->pluck('name', 'id'); - $depreciation_list = array('0' => trans('admin/licenses/form.no_depreciation')) + Depreciation::pluck('name', 'id')->toArray(); - $supplier_list = array('' => 'Select Supplier') + Supplier::orderBy('name', 'asc')->pluck('name', 'id')->toArray(); $maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No'); - $company_list = Helper::companyList(); return View::make('licenses/edit', compact('license')) ->with('license_options', $license_options) - ->with('depreciation_list', $depreciation_list) - ->with('supplier_list', $supplier_list) - ->with('company_list', $company_list) - ->with('maintained_list', $maintained_list); + ->with('depreciation_list', Helper::depreciationList()) + ->with('supplier_list', Helper::suppliersList()) + ->with('company_list', Helper::companyList()) + ->with('maintained_list', $maintained_list) + ->with('manufacturer_list', Helper::manufacturerList()); } @@ -253,6 +256,13 @@ class LicensesController extends Controller $license->maintained = e(Input::get('maintained')); $license->reassignable = e(Input::get('reassignable')); + if (empty(e(Input::get('manufacturer_id')))) { + $license->manufacturer_id = null; + } else { + $license->manufacturer_id = e(Input::get('manufacturer_id')); + } + + if (e(Input::get('supplier_id')) == '') { $license->supplier_id = null; } else { @@ -502,7 +512,7 @@ class LicensesController extends Controller } - if (($asset->assigned_to!='') && (($asset->assigned_to!=$assigned_to)) && ($assigned_to!='') ) { + if (($asset->assigned_to!='') && (($asset->assigned_to!=$assigned_to)) && ($assigned_to!='')) { return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.owner_doesnt_match_asset')); } @@ -987,21 +997,22 @@ class LicensesController extends Controller $actions = ''; if (Gate::allows('licenses.checkout')) { - $actions .= '' . trans('general.checkout') . ' '; + $actions .= '' . trans('general.checkout') . ' '; } if (Gate::allows('licenses.create')) { - $actions .= ''; + $actions .= ''; } if (Gate::allows('licenses.edit')) { - $actions .= ''; + $actions .= ''; } if (Gate::allows('licenses.delete')) { - $actions .= ''; + $actions .= ''; } $actions .=''; @@ -1012,15 +1023,16 @@ class LicensesController extends Controller 'totalSeats' => $license->totalSeatsByLicenseID(), 'remaining' => $license->remaincount(), 'license_name' => e($license->license_name), - 'license_email' => e($license->license_email), + 'license_email' => e($license->license_email), 'purchase_date' => ($license->purchase_date) ? $license->purchase_date : '', - 'expiration_date' => ($license->expiration_date) ? $license->expiration_date : '', + 'expiration_date' => ($license->expiration_date) ? $license->expiration_date : '', 'purchase_cost' => ($license->purchase_cost) ? number_format($license->purchase_cost, 2) : '', - 'purchase_order' => ($license->purchase_order) ? e($license->purchase_order) : '', - 'order_number' => ($license->order_number) ? e($license->order_number) : '', - 'notes' => ($license->notes) ? e($license->notes) : '', + 'purchase_order' => ($license->purchase_order) ? e($license->purchase_order) : '', + 'order_number' => ($license->order_number) ? e($license->order_number) : '', + 'notes' => ($license->notes) ? e($license->notes) : '', 'actions' => $actions, - 'companyName' => is_null($license->company) ? '' : e($license->company->name) + 'companyName' => is_null($license->company) ? '' : e($license->company->name), + 'manufacturer' => $license->manufacturer ? (string) link_to('/admin/settings/manufacturers/'.$license->manufacturer_id.'/view', $license->manufacturer->name) : '' ); } diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index 312083bc5a..666b8f8ea6 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -5,7 +5,7 @@ use App\Models\Company; use App\Models\Manufacturer; use App\Models\Setting; use Auth; -use Illuminate\Support\Facades\Gate; +use Gate; use Input; use Lang; use Redirect; @@ -255,10 +255,27 @@ class ManufacturersController extends Controller * @since [v1.0] * @return String JSON */ - public function getDataView($manufacturerId) + public function getDataView($manufacturerId, $itemtype = null) { - $manufacturer = Manufacturer::with('assets.company')->find($manufacturerId); + + switch ($itemtype) { + case "assets": + return $this->getDataAssetsView($manufacturer); + case "licenses": + return $this->getDataLicensesView($manufacturer); + case "accessories": + return $this->getDataAccessoriesView($manufacturer); + case "consumables": + return $this->getDataConsumablesView($manufacturer); + } + + throw new Exception("We shouldn't be here"); + + } + + protected function getDataAssetsView(Manufacturer $manufacturer) + { $manufacturer_assets = $manufacturer->assets; if (Input::has('search')) { @@ -304,25 +321,203 @@ class ManufacturersController extends Controller } } - $row = array( - 'id' => $asset->id, - 'name' => (string)link_to('/hardware/'.$asset->id.'/view', e($asset->showAssetName())), - 'model' => e($asset->model->name), - 'asset_tag' => e($asset->asset_tag), - 'serial' => e($asset->serial), - 'assigned_to' => ($asset->assigneduser) ? (string)link_to('/admin/users/'.$asset->assigneduser->id.'/view', e($asset->assigneduser->fullName())): '', - 'actions' => $actions, - 'companyName' => e(Company::getName($asset)), - ); + $rows[] = array( + 'id' => $asset->id, + 'name' => (string)link_to('/hardware/'.$asset->id.'/view', e($asset->showAssetName())), + 'model' => e($asset->model->name), + 'asset_tag' => e($asset->asset_tag), + 'serial' => e($asset->serial), + 'assigned_to' => ($asset->assigneduser) ? (string)link_to('/admin/users/'.$asset->assigneduser->id.'/view', e($asset->assigneduser->fullName())): '', + 'actions' => $actions, + 'companyName' => e(Company::getName($asset)), + ); - if (isset($inout)) { - $row['change'] = $inout; + if (isset($inout)) { + $row['change'] = $inout; + } } - - $rows[] = $row; - } - + $data = array('total' => $count, 'rows' => $rows); return $data; } + + protected function getDataLicensesView(Manufacturer $manufacturer) + { + $licenses = $manufacturer->licenses; + + if (Input::has('search')) { + $licenses = $licenses->TextSearch(Input::get('search')); + } + + $licenseCount = $licenses->count(); + + $rows = array(); + + foreach ($licenses as $license) { + $actions = ''; + + if (Gate::allows('licenses.checkout')) { + $actions .= '' . trans('general.checkout') . ' '; + } + + if (Gate::allows('licenses.create')) { + $actions .= ''; + } + if (Gate::allows('licenses.edit')) { + $actions .= ''; + } + if (Gate::allows('licenses.delete')) { + $actions .= ''; + } + $actions .=''; + + $rows[] = array( + 'id' => $license->id, + 'name' => (string) link_to('/admin/licenses/'.$license->id.'/view', $license->name), + 'serial' => (string) link_to('/admin/licenses/'.$license->id.'/view', mb_strimwidth($license->serial, 0, 50, "...")), + 'totalSeats' => $license->totalSeatsByLicenseID(), + 'remaining' => $license->remaincount(), + 'license_name' => e($license->license_name), + 'license_email' => e($license->license_email), + 'purchase_date' => ($license->purchase_date) ? $license->purchase_date : '', + 'expiration_date' => ($license->expiration_date) ? $license->expiration_date : '', + 'purchase_cost' => ($license->purchase_cost) ? number_format($license->purchase_cost, 2) : '', + 'purchase_order' => ($license->purchase_order) ? e($license->purchase_order) : '', + 'order_number' => ($license->order_number) ? e($license->order_number) : '', + 'notes' => ($license->notes) ? e($license->notes) : '', + 'actions' => $actions, + 'companyName' => is_null($license->company) ? '' : e($license->company->name), + 'manufacturer' => $license->manufacturer ? (string) link_to('/admin/settings/manufacturers/'.$license->manufacturer_id.'/view', $license->manufacturer->name) : '' + ); + } + + $data = array('total' => $licenseCount, 'rows' => $rows); + + return $data; + } + + public function getDataAccessoriesView(Manufacturer $manufacturer) + { + $accessories = $manufacturer->accessories; + + if (Input::has('search')) { + $accessories = $accessories->TextSearch(e(Input::get('search'))); + } + + if (Input::has('limit')) { + $limit = e(Input::get('limit')); + } else { + $limit = 50; + } + + $accessCount = $accessories->count(); + + $rows = array(); + + foreach ($accessories as $accessory) { + + $actions = ''; + if (Gate::allows('accessories.checkout')) { + $actions .= 'numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . ''; + } + if (Gate::allows('accessories.edit')) { + $actions .= ''; + } + if (Gate::allows('accessories.delete')) { + $actions .= ''; + } + $actions .= ''; + $company = $accessory->company; + + $rows[] = array( + 'name' => ''. $accessory->name.'', + 'category' => ($accessory->category) ? (string)link_to('admin/settings/categories/'.$accessory->category->id.'/view', $accessory->category->name) : '', + 'qty' => e($accessory->qty), + 'order_number' => e($accessory->order_number), + 'min_amt' => e($accessory->min_amt), + 'location' => ($accessory->location) ? e($accessory->location->name): '', + 'purchase_date' => e($accessory->purchase_date), + 'purchase_cost' => number_format($accessory->purchase_cost, 2), + 'numRemaining' => $accessory->numRemaining(), + 'actions' => $actions, + 'companyName' => is_null($company) ? '' : e($company->name), + 'manufacturer' => $accessory->manufacturer ? (string) link_to('/admin/settings/manufacturers/'.$accessory->manufacturer_id.'/view', $accessory->manufacturer->name) : '' + + ); + } + + $data = array('total'=>$accessCount, 'rows'=>$rows); + + return $data; + } + + public function getDataConsumablesView($manufacturer) + { + $consumables = $manufacturer->consumables; + + if (Input::has('search')) { + $consumables = $consumables->TextSearch(e(Input::get('search'))); + } + + if (Input::has('limit')) { + $limit = e(Input::get('limit')); + } else { + $limit = 50; + } + + $consumCount = $consumables->count(); + + $rows = array(); + + foreach ($consumables as $consumable) { + $actions = ''; + if (Gate::allows('consumables.checkout')) { + $actions .= 'numRemaining() > 0) ? '' : ' disabled') . '>' . trans('general.checkout') . ''; + } + + if (Gate::allows('consumables.edit')) { + $actions .= ''; + } + if (Gate::allows('consumables.delete')) { + $actions .= ''; + } + + $actions .=''; + + $company = $consumable->company; + + $rows[] = array( + 'id' => $consumable->id, + 'name' => (string)link_to('admin/consumables/'.$consumable->id.'/view', e($consumable->name)), + 'location' => ($consumable->location) ? e($consumable->location->name) : '', + 'min_amt' => e($consumable->min_amt), + 'qty' => e($consumable->qty), + 'manufacturer' => ($consumable->manufacturer) ? (string) link_to('/admin/settings/manufacturers/'.$consumable->manufacturer_id.'/view', $consumable->manufacturer->name): '', + 'model_no' => e($consumable->model_no), + 'item_no' => e($consumable->item_no), + 'category' => ($consumable->category) ? (string) link_to('/admin/settings/categories/'.$consumable->category_id.'/view', $consumable->category->name) : 'Missing category', + 'order_number' => e($consumable->order_number), + 'purchase_date' => e($consumable->purchase_date), + 'purchase_cost' => ($consumable->purchase_cost!='') ? number_format($consumable->purchase_cost, 2): '' , + 'numRemaining' => $consumable->numRemaining(), + 'actions' => $actions, + 'companyName' => is_null($company) ? '' : e($company->name), + ); + } + + $data = array('total' => $consumCount, 'rows' => $rows); + + return $data; + } } diff --git a/app/Http/routes.php b/app/Http/routes.php index 8f7404d22f..25feecf9cf 100755 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -78,7 +78,7 @@ Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () { /*---Manufacturers API---*/ Route::group(array('prefix'=>'manufacturers'), function () { Route::get('list', array('as'=>'api.manufacturers.list', 'uses'=>'ManufacturersController@getDatatable')); - Route::get('{manufacturerID}/view', array('as'=>'api.manufacturers.view', 'uses'=>'ManufacturersController@getDataView')); + Route::get('{manufacturerID}/view/{itemtype}', array('as'=>'api.manufacturers.view', 'uses'=>'ManufacturersController@getDataView')); }); /*---Suppliers API---*/ diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php index 1a37a6a595..8bd139b499 100755 --- a/app/Models/Accessory.php +++ b/app/Models/Accessory.php @@ -82,6 +82,11 @@ class Accessory extends Model return $this->belongsToMany('\App\Models\User', 'accessories_users', 'accessory_id', 'assigned_to')->count(); } + public function manufacturer() + { + return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id'); + } + public function checkin_email() { return $this->category->checkin_email; diff --git a/app/Models/License.php b/app/Models/License.php index 843a74c4f0..4444ac6497 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -36,6 +36,11 @@ class License extends Depreciable return $this->belongsTo('\App\Models\Company', 'company_id'); } + public function manufacturer() + { + return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id'); + } + /** * Get the assigned user */ diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index cc10833f88..c5d5b8e049 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -46,6 +46,21 @@ class Manufacturer extends Model return $this->hasManyThrough('\App\Models\Asset', '\App\Models\AssetModel', 'manufacturer_id', 'model_id'); } + public function licenses() + { + return $this->hasMany('\App\Models\License', 'manufacturer_id'); + } + + public function accessories() + { + return $this->hasMany('\App\Models\Accessory', 'manufacturer_id'); + } + + public function consumables() + { + return $this->hasMany('\App\Models\Consumable', 'manufacturer_id'); + } + /** * Query builder scope to search on text * diff --git a/database/migrations/2016_08_09_002225_add_manufacturer_to_licenses.php b/database/migrations/2016_08_09_002225_add_manufacturer_to_licenses.php new file mode 100644 index 0000000000..4b7dc0a09b --- /dev/null +++ b/database/migrations/2016_08_09_002225_add_manufacturer_to_licenses.php @@ -0,0 +1,32 @@ +integer('manufacturer_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('licenses', function (Blueprint $table) { + // + }); + } +} diff --git a/database/migrations/2016_08_12_121613_add_manufacturer_to_accessories_table.php b/database/migrations/2016_08_12_121613_add_manufacturer_to_accessories_table.php new file mode 100644 index 0000000000..0415f14519 --- /dev/null +++ b/database/migrations/2016_08_12_121613_add_manufacturer_to_accessories_table.php @@ -0,0 +1,33 @@ +integer('manufacturer_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accessories', function (Blueprint $table) { + // + $table->dropColumn('manufacturer_id'); + }); + } +} diff --git a/resources/views/accessories/edit.blade.php b/resources/views/accessories/edit.blade.php index 99f2cd5ede..a422d225e0 100755 --- a/resources/views/accessories/edit.blade.php +++ b/resources/views/accessories/edit.blade.php @@ -86,6 +86,18 @@ + +
+
+ {{ Form::label('manufacturer_id', trans('general.manufacturer')) }} +
+ +
+ {{ Form::select('manufacturer_id', $manufacturer_list , Input::old('manufacturer_id', $accessory->manufacturer_id), array('class'=>'select2', 'style'=>'width:350px')) }} + {!! $errors->first('manufacturer_id', '
:message
') !!} +
+
+
diff --git a/resources/views/accessories/index.blade.php b/resources/views/accessories/index.blade.php index 827719672d..1ad97dfdd4 100755 --- a/resources/views/accessories/index.blade.php +++ b/resources/views/accessories/index.blade.php @@ -35,6 +35,7 @@ {{ trans('admin/companies/table.title') }} {{ trans('admin/accessories/table.title') }} {{ trans('admin/accessories/general.accessory_category') }} + {{ trans('general.manufacturer') }} {{ trans('general.location') }} {{ trans('admin/accessories/general.total') }} {{ trans('admin/accessories/general.date') }} diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 302e255e1e..6321dd1e9b 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -43,8 +43,6 @@
- - +
-
- - +
+
+ @@ -478,157 +480,150 @@ - - - @if (count($asset->assetlog) > 0) - @foreach ($asset->assetlog as $log) - - - - - - + @if (count($asset->assetlog) > 0) + @foreach ($asset->assetlog as $log) + + + + + - + - + + - @endforeach + @endforeach @endif + - - - - - + + + + + - -
{{ trans('general.date') }} {{ trans('general.admin') }}{{ trans('general.user') }} {{ trans('general.notes') }}
{{ $log->created_at }} - @if (isset($log->adminlog)) - {{ $log->adminlog->fullName() }} - @else - Deleted Admin - @endif - {{ $log->action_type }} + +
{{ $log->created_at }} + @if (isset($log->adminlog)) + {{ $log->adminlog->fullName() }} + @else + Deleted Admin + @endif + {{ $log->action_type }} @if ((isset($log->checkedout_to)) && ($log->checkedout_to!=0) && ($log->checkedout_to!='')) - @if ($log->userlog) + @if ($log->userlog) - @if ($log->userlog->deleted_at=='') - - {{ $log->userlog->fullName() }} - - @else - {{ $log->userlog->fullName() }} - @endif - @else - Deleted User - @endif + @if ($log->userlog->deleted_at=='') + + {{ $log->userlog->fullName() }} + + + @else + {{ $log->userlog->fullName() }} + @endif + @else + Deleted User + @endif @endif - + @if ($log->note) {{ $log->note }} @endif -
{{ $asset->created_at }} - @if ($asset->adminuser) - {{ $asset->adminuser->fullName() }} - @else - {{ trans('general.unknown_admin') }} - @endif - - {{ trans('general.created_asset') }} - - {{ $asset->created_at }} + @if ($asset->adminuser) + {{ $asset->adminuser->fullName() }} + @else + {{ trans('general.unknown_admin') }} + @endif + {{ trans('general.created_asset') }}
-
-
-
+ + +
+
+
+
+ {{ Form::open([ + 'method' => 'POST', + 'route' => ['upload/asset', $asset->id], + 'files' => true, 'class' => 'form-horizontal' ]) }} - {{ Form::open([ - 'method' => 'POST', - 'route' => ['upload/asset', $asset->id], - 'files' => true, 'class' => 'form-horizontal' ]) }} +
+ Browse for file... + {{ Form::file('assetfile[]', ['multiple' => 'multiple']) }} + +
+
+ {{ Form::text('notes', Input::old('notes', Input::old('notes')), array('class' => 'form-control','placeholder' => 'Notes')) }} +
+
+ +
-
- Browse for file... - {{ Form::file('assetfile[]', ['multiple' => 'multiple']) }} - -
-
- {{ Form::text('notes', Input::old('notes', Input::old('notes')), array('class' => 'form-control','placeholder' => 'Notes')) }} -
-
- -
+
+

{{ trans('admin/hardware/general.filetype_info') }}

+
+
-
-

{{ trans('admin/hardware/general.filetype_info') }}

-
-
+ {{ Form::close() }} - {{ Form::close() }} +
-
- - - +
- - - - - - - + + + + + + + - @if (count($asset->uploads) > 0) - @foreach ($asset->uploads as $file) - - - - - - - - @endforeach - @else - - - + @if (count($asset->uploads) > 0) + @foreach ($asset->uploads as $file) + + + + + + + + @endforeach + @else + + + - @endif + @endif -
{{ trans('general.notes') }}{{ trans('general.file_name') }}
{{ trans('general.notes') }}{{ trans('general.file_name') }}
- @if ($file->note) - {{ $file->note }} - @endif - - @if ( \App\Helpers\Helper::checkUploadIsImage($file->get_src('assets'))) - - @endif - - {{ $file->filename }} - - @if ($file->filename) - {{ trans('general.download') }} - @endif - - -
- {{ trans('general.no_results') }} -
+ @if ($file->note) + {{ $file->note }} + @endif + + @if ( \App\Helpers\Helper::checkUploadIsImage($file->get_src('assets'))) + + @endif + + {{ $file->filename }} + + @if ($file->filename) + {{ trans('general.download') }} + @endif + + +
+ {{ trans('general.no_results') }} +
-
-
-
- -
- - - - + + + + + + + + @section('moar_scripts')