Exemplo n.º 1
0
 /**
  * Returns a new grid instance of attachable work orders.
  *
  * @param int|string $assetId
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function gridAttachable($assetId)
 {
     $columns = ['work_orders.id', 'work_orders.created_at', 'work_orders.user_id', 'work_orders.subject', 'work_orders.priority_id', 'work_orders.status_id'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 10];
     $transformer = function (WorkOrder $workOrder) use($assetId) {
         return ['id' => $workOrder->id, 'created_at' => $workOrder->created_at, 'subject' => $workOrder->subject, 'created_by' => $workOrder->user->full_name, 'status' => $workOrder->viewer()->lblStatus(), 'priority' => $workOrder->viewer()->lblPriority(), 'view_url' => route('maintenance.work-orders.show', [$workOrder->id]), 'attach_url' => route('maintenance.assets.work-orders.attach.store', [$assetId, $workOrder->id])];
     };
     return $this->asset->gridAttachableWorkOrders($assetId, $columns, $settings, $transformer);
 }
Exemplo n.º 2
0
 /**
  * Returns a new grid instance of all assets.
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function grid()
 {
     $columns = ['id', 'tag', 'name', 'location_id', 'category_id', 'condition', 'created_at'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (Asset $asset) {
         return ['tag' => $asset->tag, 'name' => $asset->name, 'condition' => $asset->condition, 'location' => $asset->location ? $asset->location->trail : '<em>None</em>', 'category' => $asset->category ? $asset->category->trail : '<em>None</em>', 'created_at' => $asset->created_at, 'view_url' => route('maintenance.assets.show', [$asset->id])];
     };
     return $this->asset->grid($columns, $settings, $transformer);
 }
Exemplo n.º 3
0
 /**
  * Returns a new grid instance of all available asset images.
  *
  * @param int|string $id
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function grid($id)
 {
     $columns = ['attachments.id', 'attachments.user_id', 'attachments.name', 'attachments.file_name', 'attachments.file_path', 'attachments.created_at'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (Attachment $attachment) use($id) {
         return ['id' => $attachment->id, 'user' => $attachment->user ? $attachment->user->full_name : '<em>System</em>', 'name' => $attachment->name, 'icon' => $attachment->icon, 'file_name' => $attachment->file_name, 'created_at' => $attachment->created_at, 'view_url' => route('maintenance.assets.images.show', [$id, $attachment->id])];
     };
     return $this->asset->gridImages($id, $columns, $settings, $transformer);
 }
Exemplo n.º 4
0
 /**
  * Returns a new grid instance of the specified assets meter readings.
  *
  * @param int|string $id
  * @param int|string $meterId
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function gridReadings($id, $meterId)
 {
     $columns = ['meter_readings.reading', 'meter_readings.comment', 'meter_readings.user_id', 'meter_readings.created_at'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 10];
     $transformer = function (MeterReading $reading) use($id) {
         return ['id' => $reading->id, 'reading' => $reading->reading, 'comment' => $reading->comment, 'user' => $reading->user ? $reading->user->full_name : '<em>None</em>', 'created_at' => $reading->created_at];
     };
     return $this->asset->gridMeterReadings($id, $meterId, $columns, $settings, $transformer);
 }
Exemplo n.º 5
0
 /**
  * Removes the specified work order from the specified asset.
  *
  * @param int|string $assetId
  * @param int|string $workOrderId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function remove($assetId, $workOrderId)
 {
     if ($this->asset->detachWorkOrder($assetId, $workOrderId)) {
         $message = 'Successfully detached work order.';
         return redirect()->route('maintenance.assets.work-orders.index', [$assetId])->withSuccess($message);
     } else {
         $message = 'There was an issue detaching this work order. Please try again.';
         return redirect()->route('maintenance.assets.work-orders.index', [$assetId])->withErrors($message);
     }
 }
Exemplo n.º 6
0
 /**
  * Updates an asset meter.
  *
  * @param MeterRequest $request
  * @param int|string   $id
  * @param int|string   $meterId
  *
  * @return bool|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|null
  */
 public function update(MeterRequest $request, $id, $meterId)
 {
     $asset = $this->asset->model()->findOrFail($id);
     $meter = $asset->meters()->findOrFail($meterId);
     if ($meter) {
         $meter->metric_id = $request->input('metric');
         $meter->name = $request->input('name');
         if ($meter->save()) {
             $reading = ['user_id' => $this->sentry->getCurrentUserId(), 'reading' => $request->input('reading'), 'comment' => $request->input('comment')];
             $meter->readings()->create($reading);
             return $meter;
         }
     }
     return false;
 }
Exemplo n.º 7
0
 /**
  * Prompts the user to download the specified uploaded file.
  *
  * @param int|string $id
  * @param int|string $imageId
  *
  * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function download($id, $imageId)
 {
     $asset = $this->asset->find($id);
     $image = $asset->images()->find($imageId);
     if ($image) {
         return response()->download($image->download_path);
     }
     abort(404);
 }
Exemplo n.º 8
0
 /**
  * Prompts the user to download the specified uploaded file.
  *
  * @param int|string $id
  * @param int|string $manualId
  *
  * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function download($id, $manualId)
 {
     $asset = $this->asset->find($id);
     $manual = $asset->manuals()->find($manualId);
     if ($manual) {
         return response()->download($manual->download_path);
     }
     abort(404);
 }
Exemplo n.º 9
0
 /**
  * Deletes the specified asset.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id)
 {
     $asset = $this->asset->model()->findOrFail($id);
     if ($asset->delete()) {
         $message = 'Successfully deleted asset.';
         return redirect()->route('maintenance.assets.index')->withSuccess($message);
     } else {
         $message = 'There was an issue deleting this asset. Please try again.';
         return redirect()->route('maintenance.assets.index')->withErrors($message);
     }
 }
Exemplo n.º 10
0
 /**
  * Deletes the specified meter for the specified asset.
  *
  * @param int|string $id
  * @param int|string $meterId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id, $meterId)
 {
     $asset = $this->asset->model()->findOrFail($id);
     $meter = $asset->meters()->findOrFail($meterId);
     if ($meter->delete()) {
         $message = 'Successfully deleted meter.';
         return redirect()->route('maintenance.assets.meters.index', [$id])->withSuccess($message);
     } else {
         $message = 'There was an issue deleting this meter. Please try again.';
         return redirect()->route('maintenance.assets.meters.show', [$id, $meterId])->withErrors($message);
     }
 }
Exemplo n.º 11
0
 /**
  * @param View $view
  *
  * @return mixed
  */
 public function compose(View $view)
 {
     $allAssets = $this->asset->model()->orderBy('name', 'asc')->get()->lists('name', 'id')->toArray();
     return $view->with('allAssets', $allAssets);
 }
 /**
  * @param $view
  *
  * @return mixed
  */
 public function compose(View $view)
 {
     return $view->with('users', $this->user->all()->count())->with('assets', $this->asset->all()->count())->with('inventories', $this->inventory->all()->count())->with('workOrders', $this->workOrder->all()->count());
 }