예제 #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int      $id
  * @return Response
  */
 public function edit(TaskRequest $request)
 {
     $this->checkTimezone();
     $task = $request->entity();
     $actions = [];
     if ($task->invoice) {
         $actions[] = ['url' => URL::to("invoices/{$task->invoice->public_id}/edit"), 'label' => trans("texts.view_invoice")];
     } else {
         $actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans("texts.invoice_task")];
         // check for any open invoices
         $invoices = $task->client_id ? $this->invoiceRepo->findOpenInvoices($task->client_id) : [];
         foreach ($invoices as $invoice) {
             $actions[] = ['url' => 'javascript:submitAction("add_to_invoice", ' . $invoice->public_id . ')', 'label' => trans("texts.add_to_invoice", ["invoice" => $invoice->invoice_number])];
         }
     }
     $actions[] = DropdownButton::DIVIDER;
     if (!$task->trashed()) {
         $actions[] = ['url' => 'javascript:submitAction("archive")', 'label' => trans('texts.archive_task')];
         $actions[] = ['url' => 'javascript:onDeleteClick()', 'label' => trans('texts.delete_task')];
     } else {
         $actions[] = ['url' => 'javascript:submitAction("restore")', 'label' => trans('texts.restore_task')];
     }
     $data = ['task' => $task, 'clientPublicId' => $task->client ? $task->client->public_id : 0, 'method' => 'PUT', 'url' => 'tasks/' . $task->public_id, 'title' => trans('texts.edit_task'), 'duration' => $task->is_running ? $task->getCurrentDuration() : $task->getDuration(), 'actions' => $actions, 'timezone' => Auth::user()->account->timezone ? Auth::user()->account->timezone->name : DEFAULT_TIMEZONE, 'datetimeFormat' => Auth::user()->account->getMomentDateTimeFormat()];
     $data = array_merge($data, self::getViewModel());
     return View::make('tasks.edit', $data);
 }