diff --git a/app/Console/Commands/Purge.php b/app/Console/Commands/Purge.php index de7b518fb..8abe6048c 100644 --- a/app/Console/Commands/Purge.php +++ b/app/Console/Commands/Purge.php @@ -62,15 +62,19 @@ class Purge extends Command $assetcount = $assets->count(); $this->info($assets->count().' assets purged.'); $asset_assoc = 0; + $asset_maintenances = 0; foreach ($assets as $asset) { $this->info('- Asset "'.$asset->showAssetName().'" deleted.'); $asset_assoc += $asset->assetlog()->count(); $asset->assetlog()->forceDelete(); + $asset_maintenances += $asset->assetmaintenances()->count(); + $asset->assetmaintenances()->forceDelete(); $asset->forceDelete(); } $this->info($asset_assoc.' corresponding log records purged.'); + $this->info($asset_maintenances.' corresponding maintenance records purged.'); $locations = Location::whereNotNull('deleted_at')->withTrashed()->get(); $this->info($locations->count().' locations purged.'); diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index b6ce18c16..b0fc90551 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -43,6 +43,17 @@ class Helper return array_walk($emails_array, 'trim_value'); } + public static function formatCurrencyOutput($cost) + { + // The importer has formatted number strings since v3, so the value might be a string, or an integer. + // If it's a number, format it as a string + if (is_numeric($cost)) { + return number_format($cost, 2, '.', ''); + } + // It's already been parsed. + return $cost; + } + // This doesn't do anything yet public static function trim_value(&$value) { diff --git a/app/Http/Controllers/AccessoriesController.php b/app/Http/Controllers/AccessoriesController.php index 6c079345d..7f8c6debe 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')); } @@ -617,10 +614,12 @@ class AccessoriesController extends Controller '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), + 'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost), '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/AssetsController.php b/app/Http/Controllers/AssetsController.php index 0358040d6..99468dcb3 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -354,7 +354,7 @@ class AssetsController extends Controller } if ($request->has('purchase_cost')) { - $asset->purchase_cost = e(number_format($request->input('purchase_cost'), 2, '.', '')); + $asset->purchase_cost = e(Helper::formatCurrencyOutput($request->input('purchase_cost'))); } else { $asset->purchase_cost = null; } @@ -1709,24 +1709,26 @@ class AssetsController extends Controller $rows = array(); foreach ($assets as $asset) { $inout = ''; - $actions = ''; + $actions = '
'; if ($asset->deleted_at=='') { if (Gate::allows('assets.create')) { - $actions = '
'; + $actions .= ' '; } if (Gate::allows('assets.edit')) { - $actions .= ' id) . '" class="btn btn-warning btn-sm" title="Edit asset" data-toggle="tooltip"> '; } if (Gate::allows('assets.delete')) { $actions .= '
'; + $asset->id) . '" data-content="' . trans('admin/hardware/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($asset->asset_tag) . '?" onClick="return false;">'; } } elseif ($asset->model->deleted_at=='') { - $actions = ''; + $actions .= ''; } + $actions .= '
'; + if (($asset->availableForCheckout())) { if (Gate::allows('assets.checkout')) { @@ -1741,11 +1743,7 @@ class AssetsController extends Controller } } - // Lots going on here. Importer has parsed numbers before importing, so we need to check and see if it's a number before trying to parse. - $purchase_cost = $asset->purchase_cost ?: ''; - if (is_numeric($purchase_cost)) { - $purchase_cost = number_format($purchase_cost, 2); - } + $purchase_cost = Helper::formatCurrencyOutput($asset->purchase_cost); $row = array( 'checkbox' =>'
', @@ -1774,7 +1772,12 @@ class AssetsController extends Controller 'companyName' => is_null($asset->company) ? '' : e($asset->company->name) ); foreach ($all_custom_fields as $field) { - $row[$field->db_column_name()]=$asset->{$field->db_column_name()}; + if (($field->format=='URL') && ($asset->{$field->db_column_name()}!='')) { + $row[$field->db_column_name()] = ''.$asset->{$field->db_column_name()}.''; + } else { + $row[$field->db_column_name()] = e($asset->{$field->db_column_name()}); + } + } $rows[]=$row; } diff --git a/app/Http/Controllers/ComponentsController.php b/app/Http/Controllers/ComponentsController.php index 128b61709..b550944b8 100644 --- a/app/Http/Controllers/ComponentsController.php +++ b/app/Http/Controllers/ComponentsController.php @@ -375,7 +375,7 @@ class ComponentsController extends Controller 'fields' => [ [ 'title' => 'Checked Out:', - 'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/components/'.$component->id.'/view'.'|'.$component->name.'> checked out to <'.config('app.url').'/hardware/'.$asset->id.'/view|'.$asset->name.'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.' + 'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/components/'.$component->id.'/view'.'|'.$component->name.'> checked out to <'.config('app.url').'/hardware/'.$asset->id.'/view|'.$asset->showAssetName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.' ], [ 'title' => 'Note:', @@ -484,7 +484,7 @@ class ComponentsController extends Controller 'category' => ($component->category) ? e($component->category->name) : 'Missing category', 'order_number' => e($component->order_number), 'purchase_date' => e($component->purchase_date), - 'purchase_cost' => ($component->purchase_cost!='') ? number_format($component->purchase_cost, 2): '' , + 'purchase_cost' => Helper::formatCurrencyOutput($component->purchase_cost), 'numRemaining' => $component->numRemaining(), 'actions' => $actions, 'companyName' => is_null($company) ? '' : e($company->name), diff --git a/app/Http/Controllers/ConsumablesController.php b/app/Http/Controllers/ConsumablesController.php index 11f6a7812..821c388fd 100644 --- a/app/Http/Controllers/ConsumablesController.php +++ b/app/Http/Controllers/ConsumablesController.php @@ -470,13 +470,13 @@ class ConsumablesController extends Controller '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_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost), '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 bfd46a190..e03d17bce 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 : '', - 'purchase_cost' => ($license->purchase_cost) ? number_format($license->purchase_cost, 2) : '', + 'purchase_cost' => Helper::formatCurrencyOutput($license->purchase_cost), '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 312083bc5..666b8f8ea 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/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 624a4da75..f7dc09168 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -1,25 +1,26 @@ purchase_date; - $row[] = '"' . number_format($asset->purchase_cost, 2) . '"'; + $row[] = '"' . Helper::parsePurchasedCost($asset->purchase_cost) . '"'; if ($asset->order_number) { $row[] = e($asset->order_number); } else { @@ -308,9 +309,9 @@ class ReportsController extends Controller } $row[] = $asset->purchase_date; - $row[] = $currency . number_format($asset->purchase_cost, 2); - $row[] = $currency . number_format($asset->getDepreciatedValue(), 2); - $row[] = $currency . number_format(( $asset->purchase_cost - $asset->getDepreciatedValue() ), 2); + $row[] = $currency . Helper::formatCurrencyOutput($asset->purchase_cost); + $row[] = $currency . Helper::formatCurrencyOutput($asset->getDepreciatedValue()); + $row[] = $currency . Helper::formatCurrencyOutput(( $asset->purchase_cost - $asset->getDepreciatedValue() )); $csv->insertOne($row); } @@ -392,7 +393,7 @@ class ReportsController extends Controller $row[] = $license->remaincount(); $row[] = $license->expiration_date; $row[] = $license->purchase_date; - $row[] = '"' . number_format($license->purchase_cost, 2) . '"'; + $row[] = '"' . Helper::formatCurrencyOutput($license->purchase_cost) . '"'; $rows[] = implode($row, ','); } @@ -416,7 +417,7 @@ class ReportsController extends Controller public function getCustomReport() { $customfields = CustomField::get(); - return View::make('reports/custom')->with('customfields',$customfields); + return View::make('reports/custom')->with('customfields', $customfields); } /** @@ -528,7 +529,7 @@ class ReportsController extends Controller $row[] = e($asset->purchase_date); } if (e(Input::get('purchase_cost')) == '1' && ( e(Input::get('depreciation')) != '1' )) { - $row[] = '"' . number_format($asset->purchase_cost, 2) . '"'; + $row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"'; } if (e(Input::get('order')) == '1') { if ($asset->order_number) { @@ -605,9 +606,9 @@ class ReportsController extends Controller } if (e(Input::get('depreciation')) == '1') { $depreciation = $asset->getDepreciatedValue(); - $row[] = '"' . number_format($asset->purchase_cost, 2) . '"'; - $row[] = '"' . number_format($depreciation, 2) . '"'; - $row[] = '"' . number_format($asset->purchase_cost - $depreciation, 2) . '"'; + $row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"'; + $row[] = '"' . Helper::formatCurrencyOutput($depreciation) . '"'; + $row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"'; } foreach ($customfields as $customfield) { @@ -698,7 +699,7 @@ class ReportsController extends Controller $improvementTime = intval($assetMaintenance->asset_maintenance_time); } $row[] = $improvementTime; - $row[] = trans('general.currency') . number_format($assetMaintenance->cost, 2); + $row[] = trans('general.currency') . Helper::formatCurrencyOutput($assetMaintenance->cost); $rows[] = implode($row, ','); } diff --git a/app/Http/routes.php b/app/Http/routes.php index 8f7404d22..25feecf9c 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 1a37a6a59..8bd139b49 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/Ldap.php b/app/Models/Ldap.php index b05475f2b..9e4b01a9a 100644 --- a/app/Models/Ldap.php +++ b/app/Models/Ldap.php @@ -247,8 +247,12 @@ class Ldap extends Model // Perform the search do { + // Paginate (non-critical, if not supported by server) - ldap_control_paged_result($ldapconn, $page_size, false, $cookie); + if (!$ldap_paging = @ldap_control_paged_result($ldapconn, $page_size, false, $cookie)) { + throw new Exception('Problem with your LDAP connection. Try checking the Use TLS setting in Admin > Settings. '); + } + $search_results = ldap_search($ldapconn, $base_dn, '('.$filter.')'); diff --git a/app/Models/License.php b/app/Models/License.php index 843a74c4f..4444ac649 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 cc10833f8..c5d5b8e04 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/config/version.php b/config/version.php index e78256010..889214741 100644 --- a/config/version.php +++ b/config/version.php @@ -1,5 +1,5 @@ 'v3.3.0', - 'hash_version' => 'v3.3.0-3-g7ef4f23', + 'hash_version' => 'v3.3.0-16-ge52a0f6', ); 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 000000000..4b7dc0a09 --- /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 000000000..0415f1451 --- /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 99f2cd5ed..38a382444 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
') !!} +
+
+
@@ -132,7 +144,7 @@ {{ \App\Models\Setting::first()->default_currency }} - + {!! $errors->first('purchase_cost', ' :message') !!}
diff --git a/resources/views/accessories/index.blade.php b/resources/views/accessories/index.blade.php index 827719672..1ad97dfdd 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/asset_maintenances/edit.blade.php b/resources/views/asset_maintenances/edit.blade.php index 31d6caa70..ea7b5a1ac 100644 --- a/resources/views/asset_maintenances/edit.blade.php +++ b/resources/views/asset_maintenances/edit.blade.php @@ -122,7 +122,7 @@
{{ \App\Models\Setting::first()->default_currency }} - + {!! $errors->first('cost', ' :message') !!}
diff --git a/resources/views/components/edit.blade.php b/resources/views/components/edit.blade.php index c4e65ac48..9e20716f5 100644 --- a/resources/views/components/edit.blade.php +++ b/resources/views/components/edit.blade.php @@ -156,7 +156,7 @@ {{ \App\Models\Setting::first()->default_currency }} - + {!! $errors->first('purchase_cost', ' :message') !!} diff --git a/resources/views/components/view.blade.php b/resources/views/components/view.blade.php index 8c3454bd6..e84fb34f3 100644 --- a/resources/views/components/view.blade.php +++ b/resources/views/components/view.blade.php @@ -83,7 +83,7 @@
{{ trans('admin/components/general.cost') }}: {{ \App\Models\Setting::first()->default_currency }} - {{ number_format($component->purchase_cost,2) }}
+ {{ \App\Helpers\Helper::formatCurrencyOutput($component->purchase_cost) }} @endif @if ($component->order_number) diff --git a/resources/views/consumables/edit.blade.php b/resources/views/consumables/edit.blade.php index 9e00195c4..2cf1ec654 100644 --- a/resources/views/consumables/edit.blade.php +++ b/resources/views/consumables/edit.blade.php @@ -159,7 +159,7 @@ {{ \App\Models\Setting::first()->default_currency }} - + {!! $errors->first('purchase_cost', ' :message') !!} diff --git a/resources/views/consumables/view.blade.php b/resources/views/consumables/view.blade.php index 5e99b4fbb..afc2a3fea 100644 --- a/resources/views/consumables/view.blade.php +++ b/resources/views/consumables/view.blade.php @@ -72,7 +72,7 @@
{{ trans('admin/consumables/general.cost') }}: {{ \App\Models\Setting::first()->default_currency }} - {{ number_format($consumable->purchase_cost,2) }}
+ {{ \App\Helpers\Helper::formatCurrencyOutput($consumable->purchase_cost) }} @endif @if ($consumable->item_no) diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index 0b9190c18..53a469ece 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -215,7 +215,7 @@ - + {!! $errors->first('purchase_cost', ' :message') !!} diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index 025d83c10..314c40aba 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -97,8 +97,9 @@ @foreach(\App\Models\CustomField::all() AS $field) {{$field->name}} @endforeach - {{ trans('admin/hardware/table.change') }} {{ trans('general.created_at') }} + {{ trans('admin/hardware/table.change') }} + {{ trans('table.actions') }} diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 302e255e1..7cfdab993 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -43,8 +43,6 @@
- - +
-
- - +
+
+ @@ -478,157 +487,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')