/** * @return \Illuminate\Http\RedirectResponse */ public function bulk() { $action = Input::get('action'); $ids = Input::get('public_id') ?: (Input::get('id') ?: Input::get('ids')); if ($action == 'stop') { $this->taskRepo->save($ids, ['action' => $action]); Session::flash('message', trans('texts.stopped_task')); return Redirect::to('tasks'); } else { if ($action == 'invoice' || $action == 'add_to_invoice') { $tasks = Task::scope($ids)->with('client')->get(); $clientPublicId = false; $data = []; foreach ($tasks as $task) { if ($task->client) { if (!$clientPublicId) { $clientPublicId = $task->client->public_id; } else { if ($clientPublicId != $task->client->public_id) { Session::flash('error', trans('texts.task_error_multiple_clients')); return Redirect::to('tasks'); } } } if ($task->is_running) { Session::flash('error', trans('texts.task_error_running')); return Redirect::to('tasks'); } else { if ($task->invoice_id) { Session::flash('error', trans('texts.task_error_invoiced')); return Redirect::to('tasks'); } } $account = Auth::user()->account; $data[] = ['publicId' => $task->public_id, 'description' => $task->description . "\n\n" . $task->present()->times($account), 'duration' => $task->getHours()]; } if ($action == 'invoice') { return Redirect::to("invoices/create/{$clientPublicId}")->with('tasks', $data); } else { $invoiceId = Input::get('invoice_id'); return Redirect::to("invoices/{$invoiceId}/edit")->with('tasks', $data); } } else { $count = $this->taskService->bulk($ids, $action); $message = Utils::pluralize($action . 'd_task', $count); Session::flash('message', $message); return $this->returnBulk($this->entityType, $action, $ids); } } }
/** * @param null $clientPublicId * @return \Illuminate\Http\JsonResponse */ public function getDatatable($clientPublicId = null) { return $this->taskService->getDatatable($clientPublicId, Input::get('sSearch')); }