Пример #1
0
 /**
  * Returns a new work order grid.
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function grid()
 {
     $columns = ['id', 'priority_id', 'status_id', 'created_at', 'user_id', 'subject'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (WorkOrder $workOrder) {
         return ['id' => $workOrder->id, 'created_at' => $workOrder->created_at, 'subject' => str_limit($workOrder->subject), 'view_url' => route('maintenance.work-orders.show', [$workOrder->id]), 'created_by' => $workOrder->user->full_name, 'status' => $workOrder->viewer()->lblStatus(), 'priority' => $workOrder->viewer()->lblPriority()];
     };
     return $this->workOrder->grid($columns, $settings, $transformer);
 }
 /**
  * Returns a new grid instance of all available work order attachments.
  *
  * @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' => 10];
     $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.work-orders.attachments.show', [$id, $attachment->id])];
     };
     return $this->workOrder->gridAttachments($id, $columns, $settings, $transformer);
 }
Пример #3
0
 /**
  * Returns a new grid instance of the specified work order sessions.
  *
  * @param int|string $workOrderId
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function grid($workOrderId)
 {
     $columns = ['user_id', 'in', 'out'];
     $settings = ['sort' => 'in', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function ($session) {
         return ['user' => $session->user->full_name, 'in' => $session->in, 'out' => $session->viewer()->lblOut()];
     };
     return $this->workOrder->gridSessions($workOrderId, $columns, $settings, $transformer);
 }
Пример #4
0
 /**
  * Returns a new grid instance of
  * parts added to the specified work order.
  *
  * @param int|string $workOrderId
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function grid($workOrderId)
 {
     $columns = ['inventory_stocks.id', 'inventory_id', 'location_id', 'work_order_parts.created_at'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (InventoryStock $stock) use($workOrderId) {
         return ['item_id' => $stock->inventory_id, 'item_sku' => $stock->item->sku_code ? $stock->item->sku_code : '<em>None</em>', 'item_name' => $stock->item->name, 'item_view_url' => route('maintenance.inventory.show', [$stock->inventory_id]), 'location' => $stock->location ? $stock->location->trail : '<em>None</em>', 'quantity_taken' => $stock->pivot->quantity, 'date_taken' => $stock->pivot->created_at->format('Y-m-d h:i a'), 'put_back_url' => route('maintenance.work-orders.parts.stocks.put', [$workOrderId, $stock->inventory_id, $stock->id])];
     };
     return $this->workOrder->gridParts($workOrderId, $columns, $settings, $transformer);
 }
Пример #5
0
 /**
  * Allows all users to start work order sessions
  * if they don't already have an open session.
  *
  * @param Repository $repository
  *
  * @return bool
  */
 public function authorize(Repository $repository)
 {
     $workOrderId = $this->route('work_orders');
     $session = $repository->findLastUserSession($workOrderId);
     if ($session && $session->out !== null) {
         return false;
     } else {
         return true;
     }
 }
Пример #6
0
 /**
  * Returns a new grid instance of all available
  * inventory variants for selection.
  *
  * @param int|string $workOrderId
  * @param int|string $inventoryId
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function gridVariants($workOrderId, $inventoryId)
 {
     $workOrder = $this->workOrder->model()->findOrFail($workOrderId);
     $columns = ['id', 'name', 'category_id', 'created_at'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (Inventory $item) use($workOrder) {
         return ['id' => $item->id, 'sku' => $item->sku_code ? $item->sku_code : '<em>None</em>', 'name' => $item->name, 'category' => $item->category ? $item->category->trail : null, 'current_stock' => $item->viewer()->lblCurrentStock(), 'created_at' => $item->created_at, 'view_url' => route('maintenance.inventory.show', [$item->id]), 'select_url' => route('maintenance.work-orders.parts.stocks.index', [$workOrder->id, $item->id])];
     };
     return $this->inventory->gridVariants($inventoryId, $columns, $settings, $transformer);
 }
Пример #7
0
 /**
  * Restores the specified work order.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function restore($id)
 {
     if ($this->workOrder->restore($id)) {
         $message = 'Successfully restored work order.';
         return redirect()->route('maintenance.admin.archive.work-orders.index')->withSuccess($message);
     } else {
         $this->message = 'There was an error trying to restore this work order, please try again';
         $this->messageType = 'success';
         $this->redirect = route('maintenance.admin.archive.work-orders.index');
     }
     return $this->response();
 }
 /**
  * Creates a user work request.
  *
  * @param WorkRequest $request
  *
  * @return bool|\Stevebauman\Maintenance\Models\WorkRequest
  */
 public function create(WorkRequest $request)
 {
     $attributes = ['subject' => $request->input('subject'), 'description' => $request->clean($request->input('description')), 'best_time' => $request->input('best_time')];
     $workRequest = $this->model()->create($attributes);
     if ($workRequest) {
         $autoGenerate = $this->config->setPrefix('maintenance')->get('rules.work-orders.auto_generate_from_request', true);
         if ($autoGenerate) {
             $this->workOrder->createFromWorkRequest($workRequest);
         }
         return $workRequest;
     }
     return false;
 }
Пример #9
0
 /**
  * Creates a new report for the specified work order.
  *
  * @param ReportRequest $request
  * @param int|string    $workOrderId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(ReportRequest $request, $workOrderId)
 {
     $workOrder = $this->workOrder->find($workOrderId);
     $report = $this->report->create($request, $workOrder->id);
     if ($report) {
         // Complete the work order.
         $workOrder->complete($request);
         $message = 'Successfully created work order report.';
         return redirect()->route('maintenance.work-orders.show', [$workOrder->id])->withSuccess($message);
     } else {
         $message = 'There was an issue creating a work order report. Please try again';
         return redirect()->route('maintenance.work-orders.report.create', [$workOrder->id])->withErrors($message);
     }
 }
Пример #10
0
 /**
  * Creates a new work request.
  *
  * @param Request $request
  *
  * @return bool|WorkRequest
  */
 public function create(Request $request)
 {
     $workRequest = $this->model();
     $workRequest->user_id = $this->sentry->getCurrentUserId();
     $workRequest->subject = $request->input('subject');
     $workRequest->best_time = $request->input('best_time');
     $workRequest->description = $request->clean($request->input('description'));
     if ($workRequest->save()) {
         $autoGenerate = $this->config->setPrefix('maintenance')->get('rules.work-orders.auto_generate_from_request', true);
         if ($autoGenerate) {
             $this->workOrder->createFromWorkRequest($workRequest);
         }
         return $workRequest;
     }
     return false;
 }
Пример #11
0
 /**
  * Prompts the user to download the specified uploaded file.
  *
  * @param int|string $id
  * @param int|string $attachmentId
  *
  * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function download($id, $attachmentId)
 {
     $workOrder = $this->workOrder->find($id);
     $attachment = $workOrder->attachments()->find($attachmentId);
     if ($attachment) {
         return response()->download($attachment->download_path);
     }
     abort(404);
 }
Пример #12
0
 /**
  * Processes returning parts back into the inventory.
  *
  * @param ReturnRequest $request
  * @param int|string $workOrderId
  * @param int|string $inventoryId
  * @param int|string $stockId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postPut(ReturnRequest $request, $workOrderId, $inventoryId, $stockId)
 {
     if ($this->workOrder->returnPart($request, $workOrderId, $stockId)) {
         $message = "Successfully returned parts to the inventory.";
         return redirect()->route('maintenance.work-orders.parts.index', [$workOrderId])->withSuccess($message);
     } else {
         $message = "There was an issue returning parts into the inventory. Please try again.";
         return redirect()->route('maintenance.work-orders.parts.stocks.put', [$workOrderId])->withErrors($message);
     }
 }
Пример #13
0
 /**
  * Deletes a work order.
  *
  * @param string|int $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id)
 {
     if ($this->workOrder->delete($id)) {
         $message = "Successfully deleted work order.";
         return redirect()->route('maintenance.work-orders.index')->withSuccess($message);
     } else {
         $message = "There was an issue deleting this work order. Please try again";
         return redirect()->route('maintenance.work-orders.index')->withErrors($message);
     }
 }
Пример #14
0
 /**
  * Updates a work order session.
  *
  * @param int|string $workOrderId
  *
  * @return bool|WorkOrderSession
  */
 public function update($workOrderId)
 {
     $session = $this->workOrder->findLastUserSession($workOrderId);
     if ($session && $session->user_id === $this->sentry->getCurrentUserId()) {
         $now = Carbon::now()->toDateTimeString();
         $session->out = $now;
         if ($session->save()) {
             return $session;
         }
     }
     return false;
 }
Пример #15
0
 /**
  * Displays all the sessions for the specified work order.
  *
  * @param int|string $workOrderId
  *
  * @return \Illuminate\View\View
  */
 public function index($workOrderId)
 {
     $workOrder = $this->workOrder->find($workOrderId);
     return view('maintenance::work-orders.sessions.index', compact('workOrder'));
 }
 /**
  * @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());
 }