Пример #1
0
 /**
  * Creates a new work order session.
  *
  * @param int|string          $workOrderId
  *
  * @return bool|WorkOrderSession
  */
 public function create($workOrderId)
 {
     $workOrder = $this->workOrder->find($workOrderId);
     if ($workOrder) {
         // Create a new date time string set to now
         $now = Carbon::now()->toDateTimeString();
         // Create a new session
         $session = $this->model();
         // Assign its attributes
         $session->work_order_id = $workOrder->id;
         $session->user_id = $this->sentry->getCurrentUserId();
         $session->in = $now;
         /*
          * If this is the first session that is being created on
          * the work order, set the started at property to now
          */
         if ($workOrder->sessions->count() === 0) {
             $workOrder->update(['started_at' => $now]);
         }
         if ($session->save()) {
             return $session;
         }
     }
     return false;
 }
Пример #2
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);
     }
 }
 /**
  * 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);
 }
Пример #4
0
 /**
  * Displays the form for returning parts to the inventory.
  *
  * @param int|string $workOrderId
  * @param int|string $inventoryId
  * @param int|string $stockId
  *
  * @return \Illuminate\View\View
  */
 public function getPut($workOrderId, $inventoryId, $stockId)
 {
     $workOrder = $this->workOrder->find($workOrderId);
     $stock = $workOrder->parts()->find($stockId);
     if ($stock instanceof InventoryStock) {
         $item = $stock->item;
         return view('maintenance::work-orders.parts.inventory.stocks.put', compact('workOrder', 'item', 'stock'));
     }
     abort(404);
 }
Пример #5
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'));
 }