Esempio n. 1
0
 /**
  * Check for permissions and display the file.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @param  int  $assetId
  * @param  int  $fileId
  * @since [v1.0]
  * @return View
  */
 public function displayFile($assetId = null, $fileId = null)
 {
     $asset = Asset::find($assetId);
     // the asset is valid
     if (isset($asset->id)) {
         if (!Company::isCurrentUserHasAccess($asset)) {
             return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
         }
         $log = Actionlog::find($fileId);
         $file = $log->get_src('assets');
         $filetype = Helper::checkUploadIsImage($file);
         if ($filetype) {
             $contents = file_get_contents($file);
             return Response::make($contents)->header('Content-Type', $filetype);
         } else {
             return Response::download($file);
         }
     } else {
         // Prepare the error message
         $error = trans('admin/hardware/message.does_not_exist', compact('id'));
         // Redirect to the hardware management page
         return redirect()->route('hardware')->with('error', $error);
     }
 }
 /**
  *  View an asset maintenance
  *
  * @author  Vincent Sposato <*****@*****.**>
  * @param int $assetMaintenanceId
  * @version v1.0
  * @since [v1.8]
  * @return View
  */
 public function getView($assetMaintenanceId)
 {
     // Check if the asset maintenance exists
     if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
         // Redirect to the asset maintenance management page
         return redirect()->to('admin/asset_maintenances')->with('error', trans('admin/asset_maintenances/message.not_found'));
     } elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
         return static::getInsufficientPermissionsRedirect();
     }
     return View::make('asset_maintenances/view')->with('assetMaintenance', $assetMaintenance);
 }
 /**
  * Returns a JSON response containing details on the users associated with this consumable.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @see ConsumablesController::getView() method that returns the form.
  * @since [v1.0]
  * @param int $consumableId
  * @return View
  */
 public function getDataView($consumableId)
 {
     //$consumable = Consumable::find($consumableID);
     $consumable = Consumable::with(array('consumableAssigments' => function ($query) {
         $query->orderBy('created_at', 'DESC');
     }, 'consumableAssigments.admin' => function ($query) {
     }, 'consumableAssigments.user' => function ($query) {
     }))->find($consumableId);
     //  $consumable->load('consumableAssigments.admin','consumableAssigments.user');
     if (!Company::isCurrentUserHasAccess($consumable)) {
         return ['total' => 0, 'rows' => []];
     }
     $rows = array();
     foreach ($consumable->consumableAssigments as $consumable_assignment) {
         $rows[] = array('name' => (string) link_to('/admin/users/' . $consumable_assignment->user->id . '/view', e($consumable_assignment->user->fullName())), 'created_at' => $consumable_assignment->created_at->format('Y-m-d H:i:s') == '-0001-11-30 00:00:00' ? '' : $consumable_assignment->created_at->format('Y-m-d H:i:s'), 'admin' => $consumable_assignment->admin ? e($consumable_assignment->admin->fullName()) : '');
     }
     $consumableCount = $consumable->users->count();
     $data = array('total' => $consumableCount, 'rows' => $rows);
     return $data;
 }
Esempio n. 4
0
 /**
  * Return JSON data to populate the components view,
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @see ComponentsController::getView() method that returns the view.
  * @since [v3.0]
  * @param int $componentId
  * @return string JSON
  */
 public function getDataView($componentId)
 {
     //$component = Component::find($componentID);
     $component = Component::with('assets')->find($componentId);
     if (!Company::isCurrentUserHasAccess($component)) {
         return ['total' => 0, 'rows' => []];
     }
     $rows = array();
     foreach ($component->assets as $component_assignment) {
         $rows[] = array('name' => (string) link_to('/hardware/' . $component_assignment->id . '/view', e($component_assignment->showAssetName())), 'qty' => e($component_assignment->pivot->assigned_qty), 'created_at' => $component_assignment->created_at->format('Y-m-d H:i:s') == '-0001-11-30 00:00:00' ? '' : $component_assignment->created_at->format('Y-m-d H:i:s'));
     }
     $componentCount = $component->assets->count();
     $data = array('total' => $componentCount, 'rows' => $rows);
     return $data;
 }
Esempio n. 5
0
 /**
  * Allows the selected file to be viewed.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @since [v1.4]
  * @param int $licenseId
  * @param int $fileId
  * @return Redirect
  */
 public function displayFile($licenseId = null, $fileId = null)
 {
     $license = License::find($licenseId);
     // the license is valid
     if (isset($license->id)) {
         if (!Company::isCurrentUserHasAccess($license)) {
             return redirect()->to('admin/licenses')->with('error', trans('general.insufficient_permissions'));
         }
         $log = Actionlog::find($fileId);
         $file = $log->get_src('licenses');
         return Response::download($file);
     } else {
         // Prepare the error message
         $error = trans('admin/licenses/message.does_not_exist', compact('id'));
         // Redirect to the licence management page
         return redirect()->route('licenses')->with('error', $error);
     }
 }
 /**
  * Generates the JSON response for accessory detail view.
  *
  * Example:
  * <code>
  * {
  * "rows": [
  * {
  * "actions": "(link to available actions)",
  * "name": "(link to user)"
  * }
  * ],
  * "total": 1
  * }
  * </code>
  *
  * The names of the fields in the returns JSON correspond directly to the the
  * names of the fields in the bootstrap-tables in the view.
  *
  * For debugging, see at /api/accessories/$accessoryID/view
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @param  int  $accessoryId
  * @return string JSON containing accessories and their associated atrributes.
  **/
 public function getDataView(Request $request, $accessoryID)
 {
     $accessory = Accessory::find($accessoryID);
     if (!Company::isCurrentUserHasAccess($accessory)) {
         return ['total' => 0, 'rows' => []];
     }
     $accessory_users = $accessory->users;
     $count = $accessory_users->count();
     $rows = array();
     foreach ($accessory_users as $user) {
         $actions = '<a href="' . route('checkin/accessory', $user->pivot->id) . '" class="btn btn-info btn-sm">Checkin</a>';
         $rows[] = array('name' => (string) link_to('/admin/users/' . $user->id . '/view', e($user->fullName())), 'actions' => $actions);
     }
     $data = array('total' => $count, 'rows' => $rows);
     return $data;
 }
Esempio n. 7
0
 public function getAcceptAsset($logID = null)
 {
     if (!($findlog = DB::table('asset_logs')->where('id', '=', $logID)->first())) {
         echo 'no record';
         //return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
     }
     $user = Auth::user();
     if ($user->id != $findlog->checkedout_to) {
         return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.incorrect_user_accepted'));
     }
     // Asset
     if ($findlog->asset_id != '' && $findlog->asset_type == 'hardware') {
         $item = Asset::find($findlog->asset_id);
         // software
     } elseif ($findlog->asset_id != '' && $findlog->asset_type == 'software') {
         $item = License::find($findlog->asset_id);
         // accessories
     } elseif ($findlog->accessory_id != '') {
         $item = Accessory::find($findlog->accessory_id);
         // consumable
     } elseif ($findlog->consumable_id != '') {
         $item = Consumable::find($findlog->consumable_id);
         // components
     } elseif ($findlog->component_id != '') {
         $item = Component::find($findlog->component_id);
     }
     // Check if the asset exists
     if (is_null($item)) {
         // Redirect to the asset management page
         return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($item)) {
         return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions'));
     } else {
         return View::make('account/accept-asset', compact('item'))->with('findlog', $findlog);
     }
 }