/** * Generates the JSON used to display the manufacturer detail. * This JSON returns data on all of the assets with the specified * manufacturer ID number. * * @author [A. Gianotto] [<*****@*****.**>] * @see ManufacturersController::getView() * @param int $manufacturerId * @since [v1.0] * @return String JSON */ public function getDataView($manufacturerId) { $manufacturer = Manufacturer::with('assets.company')->find($manufacturerId); $manufacturer_assets = $manufacturer->assets; if (Input::has('search')) { $manufacturer_assets = $manufacturer_assets->TextSearch(e(Input::get('search'))); } if (Input::has('offset')) { $offset = e(Input::get('offset')); } else { $offset = 0; } if (Input::has('limit')) { $limit = e(Input::get('limit')); } else { $limit = 50; } $order = Input::get('order') === 'asc' ? 'asc' : 'desc'; $allowed_columns = ['id', 'name', 'serial', 'asset_tag']; $sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at'; $count = $manufacturer_assets->count(); $rows = array(); foreach ($manufacturer_assets as $asset) { $actions = ''; if ($asset->deleted_at == '') { $actions = '<div style=" white-space: nowrap;"><a href="' . route('clone/hardware', $asset->id) . '" class="btn btn-info btn-sm" title="Clone asset"><i class="fa fa-files-o"></i></a> <a href="' . route('update/hardware', $asset->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/hardware', $asset->id) . '" data-content="' . trans('admin/hardware/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($asset->asset_tag) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>'; } elseif ($asset->deleted_at != '') { $actions = '<a href="' . route('restore/hardware', $asset->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>'; } if ($asset->assetstatus) { if ($asset->assetstatus->deployable != 0) { if ($asset->assigned_to != '' && $asset->assigned_to > 0) { $inout = '<a href="' . route('checkin/hardware', $asset->id) . '" class="btn btn-primary btn-sm">' . trans('general.checkin') . '</a>'; } else { $inout = '<a href="' . route('checkout/hardware', $asset->id) . '" class="btn btn-info btn-sm">' . trans('general.checkout') . '</a>'; } } } $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))); if (isset($inout)) { $row['change'] = $inout; } $rows[] = $row; } $data = array('total' => $count, 'rows' => $rows); return $data; }
/** * Generates the JSON used to display the manufacturer detail. * This JSON returns data on all of the assets with the specified * manufacturer ID number. * * @author [A. Gianotto] [<*****@*****.**>] * @see ManufacturersController::getView() * @param int $manufacturerId * @since [v1.0] * @return String JSON */ 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"); }