当前位置: 首页>>代码示例>>PHP>>正文


PHP Task::scope方法代码示例

本文整理汇总了PHP中app\models\Task::scope方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::scope方法的具体用法?PHP Task::scope怎么用?PHP Task::scope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Task的用法示例。


在下文中一共展示了Task::scope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save($publicId, $data)
 {
     if ($publicId) {
         $task = Task::scope($publicId)->firstOrFail();
     } else {
         $task = Task::createNew();
     }
     if (isset($data['client']) && $data['client']) {
         $task->client_id = Client::getPrivateId($data['client']);
     }
     if (isset($data['description'])) {
         $task->description = trim($data['description']);
     }
     //$timeLog = $task->time_log ? json_decode($task->time_log, true) : [];
     $timeLog = isset($data['time_log']) ? json_decode($data['time_log']) : [];
     if ($data['action'] == 'start') {
         $task->is_running = true;
         $timeLog[] = [strtotime('now'), false];
     } else {
         if ($data['action'] == 'resume') {
             $task->is_running = true;
             $timeLog[] = [strtotime('now'), false];
         } else {
             if ($data['action'] == 'stop' && $task->is_running) {
                 $timeLog[count($timeLog) - 1][1] = time();
                 $task->is_running = false;
             }
         }
     }
     $task->time_log = json_encode($timeLog);
     $task->save();
     return $task;
 }
开发者ID:rogerapras,项目名称:invoice-ninja,代码行数:33,代码来源:TaskRepository.php

示例2: show

 /**
  * Display the specified resource.
  *
  * @param  int      $id
  * @return Response
  */
 public function show($publicId)
 {
     $client = Client::withTrashed()->scope($publicId)->with('contacts', 'size', 'industry')->firstOrFail();
     Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT);
     $actionLinks = [['label' => trans('texts.new_task'), 'url' => '/tasks/create/' . $client->public_id]];
     if (Utils::isPro()) {
         array_push($actionLinks, ['label' => trans('texts.new_quote'), 'url' => '/quotes/create/' . $client->public_id]);
     }
     array_push($actionLinks, ['label' => trans('texts.enter_payment'), 'url' => '/payments/create/' . $client->public_id], ['label' => trans('texts.enter_credit'), 'url' => '/credits/create/' . $client->public_id]);
     $data = array('actionLinks' => $actionLinks, 'showBreadcrumbs' => false, 'client' => $client, 'credit' => $client->getTotalCredit(), 'title' => trans('texts.view_client'), 'hasRecurringInvoices' => Invoice::scope()->where('is_recurring', '=', true)->whereClientId($client->id)->count() > 0, 'hasQuotes' => Invoice::scope()->where('is_quote', '=', true)->whereClientId($client->id)->count() > 0, 'hasTasks' => Task::scope()->whereClientId($client->id)->count() > 0, 'gatewayLink' => $client->getGatewayLink());
     return View::make('clients.show', $data);
 }
开发者ID:jargij,项目名称:invoiceninja,代码行数:18,代码来源:ClientController.php

示例3: store

 /**
  * @SWG\Post(
  *   path="/tasks",
  *   tags={"task"},
  *   summary="Create a task",
  *   @SWG\Parameter(
  *     in="body",
  *     name="body",
  *     @SWG\Schema(ref="#/definitions/Task")
  *   ),
  *   @SWG\Response(
  *     response=200,
  *     description="New task",
  *      @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Task"))
  *   ),
  *   @SWG\Response(
  *     response="default",
  *     description="an ""unexpected"" error"
  *   )
  * )
  */
 public function store()
 {
     $data = Input::all();
     $taskId = isset($data['id']) ? $data['id'] : false;
     if (isset($data['client_id']) && $data['client_id']) {
         $data['client'] = $data['client_id'];
     }
     $task = $this->taskRepo->save($taskId, $data);
     $task = Task::scope($task->public_id)->with('client')->first();
     $transformer = new TaskTransformer(Auth::user()->account, Input::get('serializer'));
     $data = $this->createItem($task, $transformer, 'task');
     return $this->response($data);
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:34,代码来源:TaskApiController.php

示例4: store

 public function store()
 {
     $data = Input::all();
     $taskId = isset($data['id']) ? $data['id'] : false;
     if (isset($data['client_id']) && $data['client_id']) {
         $data['client'] = $data['client_id'];
     }
     $task = $this->taskRepo->save($taskId, $data);
     $task = Task::scope($task->public_id)->with('client')->first();
     $task = Utils::remapPublicIds([$task]);
     $response = json_encode($task, JSON_PRETTY_PRINT);
     $headers = Utils::getApiHeaders();
     return Response::make($response, 200, $headers);
 }
开发者ID:nafrente,项目名称:invoice-ninja,代码行数:14,代码来源:TaskApiController.php

示例5: save

 public function save($publicId, $data)
 {
     if ($publicId) {
         $task = Task::scope($publicId)->firstOrFail();
     } else {
         $task = Task::createNew();
     }
     if (isset($data['client']) && $data['client']) {
         $task->client_id = Client::getPrivateId($data['client']);
     }
     if (isset($data['description'])) {
         $task->description = trim($data['description']);
     }
     $timeLog = $task->time_log ? json_decode($task->time_log, true) : [];
     if ($data['action'] == 'start') {
         $task->start_time = Carbon::now()->toDateTimeString();
         $task->is_running = true;
         $timeLog[] = [strtotime('now'), false];
     } else {
         if ($data['action'] == 'resume') {
             $task->break_duration = strtotime('now') - strtotime($task->start_time) + $task->duration;
             $task->resume_time = Carbon::now()->toDateTimeString();
             $task->is_running = true;
             $timeLog[] = [strtotime('now'), false];
         } else {
             if ($data['action'] == 'stop' && $task->is_running) {
                 if ($task->resume_time) {
                     $task->duration = $task->duration + strtotime('now') - strtotime($task->resume_time);
                     $task->resume_time = null;
                 } else {
                     $task->duration = strtotime('now') - strtotime($task->start_time);
                 }
                 $timeLog[count($timeLog) - 1][1] = strtotime('now');
                 $task->is_running = false;
             } else {
                 if ($data['action'] == 'save' && !$task->is_running) {
                     $task->start_time = $data['start_time'];
                     $task->duration = $data['duration'];
                     $task->break_duration = $data['break_duration'];
                 }
             }
         }
     }
     $task->duration = max($task->duration, 0);
     $task->break_duration = max($task->break_duration, 0);
     $task->time_log = json_encode($timeLog);
     $task->save();
     return $task;
 }
开发者ID:ricoa,项目名称:invoice-ninja,代码行数:49,代码来源:TaskRepository.php

示例6: save

 public function save($publicId, $data, $task = null)
 {
     if ($task) {
         // do nothing
     } elseif ($publicId) {
         $task = Task::scope($publicId)->withTrashed()->firstOrFail();
     } else {
         $task = Task::createNew();
     }
     if ($task->is_deleted) {
         return $task;
     }
     if (isset($data['client']) && $data['client']) {
         $task->client_id = Client::getPrivateId($data['client']);
     }
     if (isset($data['description'])) {
         $task->description = trim($data['description']);
     }
     if (isset($data['time_log'])) {
         $timeLog = json_decode($data['time_log']);
     } elseif ($task->time_log) {
         $timeLog = json_decode($task->time_log);
     } else {
         $timeLog = [];
     }
     array_multisort($timeLog);
     if (isset($data['action'])) {
         if ($data['action'] == 'start') {
             $task->is_running = true;
             $timeLog[] = [strtotime('now'), false];
         } else {
             if ($data['action'] == 'resume') {
                 $task->is_running = true;
                 $timeLog[] = [strtotime('now'), false];
             } else {
                 if ($data['action'] == 'stop' && $task->is_running) {
                     $timeLog[count($timeLog) - 1][1] = time();
                     $task->is_running = false;
                 }
             }
         }
     }
     $task->time_log = json_encode($timeLog);
     $task->save();
     return $task;
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:46,代码来源:TaskRepository.php

示例7: getData

 private function getData($request)
 {
     $account = Auth::user()->account;
     $data = ['account' => $account, 'title' => 'Invoice Ninja v' . NINJA_VERSION . ' - ' . $account->formatDateTime($account->getDateTime()), 'multiUser' => $account->users->count() > 1];
     if ($request->input(ENTITY_CLIENT)) {
         $data['clients'] = Client::scope()->with('user', 'contacts', 'country')->get();
         $data['contacts'] = Contact::scope()->with('user', 'client.contacts')->get();
         $data['credits'] = Credit::scope()->with('user', 'client.contacts')->get();
     }
     if ($request->input(ENTITY_TASK)) {
         $data['tasks'] = Task::scope()->with('user', 'client.contacts')->get();
     }
     if ($request->input(ENTITY_INVOICE)) {
         $data['invoices'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status')->where('is_quote', '=', false)->where('is_recurring', '=', false)->get();
         $data['quotes'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status')->where('is_quote', '=', true)->where('is_recurring', '=', false)->get();
     }
     if ($request->input(ENTITY_PAYMENT)) {
         $data['payments'] = Payment::scope()->with('user', 'client.contacts', 'payment_type', 'invoice', 'account_gateway.gateway')->get();
     }
     return $data;
 }
开发者ID:arooth,项目名称:invoiceninja,代码行数:21,代码来源:ImportExportController.php

示例8: save

 public function save($publicId, $data, $entityType)
 {
     if ($publicId) {
         $invoice = Invoice::scope($publicId)->firstOrFail();
     } else {
         $invoice = Invoice::createNew();
         if ($entityType == ENTITY_QUOTE) {
             $invoice->is_quote = true;
         }
     }
     $account = \Auth::user()->account;
     if (isset($data['set_default_terms']) && $data['set_default_terms'] || isset($data['set_default_footer']) && $data['set_default_footer']) {
         if (isset($data['set_default_terms']) && $data['set_default_terms']) {
             $account->invoice_terms = trim($data['terms']);
         }
         if (isset($data['set_default_footer']) && $data['set_default_footer']) {
             $account->invoice_footer = trim($data['invoice_footer']);
         }
         $account->save();
     }
     if (isset($data['invoice_number'])) {
         $invoice->invoice_number = trim($data['invoice_number']);
     }
     $invoice->discount = round(Utils::parseFloat($data['discount']), 2);
     $invoice->is_amount_discount = $data['is_amount_discount'] ? true : false;
     $invoice->partial = round(Utils::parseFloat($data['partial']), 2);
     $invoice->invoice_date = isset($data['invoice_date_sql']) ? $data['invoice_date_sql'] : Utils::toSqlDate($data['invoice_date']);
     $invoice->has_tasks = isset($data['has_tasks']) ? $data['has_tasks'] : false;
     if (!$publicId) {
         $invoice->client_id = $data['client_id'];
         $invoice->is_recurring = $data['is_recurring'] && !Utils::isDemo() ? true : false;
     }
     if ($invoice->is_recurring) {
         $invoice->frequency_id = $data['frequency_id'] ? $data['frequency_id'] : 0;
         $invoice->start_date = Utils::toSqlDate($data['start_date']);
         $invoice->end_date = Utils::toSqlDate($data['end_date']);
         $invoice->due_date = null;
     } else {
         $invoice->due_date = isset($data['due_date_sql']) ? $data['due_date_sql'] : Utils::toSqlDate($data['due_date']);
         $invoice->frequency_id = 0;
         $invoice->start_date = null;
         $invoice->end_date = null;
     }
     $invoice->terms = trim($data['terms']) ? trim($data['terms']) : (!$publicId && $account->invoice_terms ? $account->invoice_terms : '');
     $invoice->invoice_footer = trim($data['invoice_footer']) ? trim($data['invoice_footer']) : (!$publicId && $account->invoice_footer ? $account->invoice_footer : '');
     $invoice->public_notes = trim($data['public_notes']);
     // process date variables
     $invoice->terms = Utils::processVariables($invoice->terms);
     $invoice->invoice_footer = Utils::processVariables($invoice->invoice_footer);
     $invoice->public_notes = Utils::processVariables($invoice->public_notes);
     $invoice->po_number = trim($data['po_number']);
     $invoice->invoice_design_id = $data['invoice_design_id'];
     if (isset($data['tax_name']) && isset($data['tax_rate']) && $data['tax_name']) {
         $invoice->tax_rate = Utils::parseFloat($data['tax_rate']);
         $invoice->tax_name = trim($data['tax_name']);
     } else {
         $invoice->tax_rate = 0;
         $invoice->tax_name = '';
     }
     $total = 0;
     foreach ($data['invoice_items'] as $item) {
         $item = (array) $item;
         if (!$item['cost'] && !$item['product_key'] && !$item['notes']) {
             continue;
         }
         $invoiceItemCost = round(Utils::parseFloat($item['cost']), 2);
         $invoiceItemQty = round(Utils::parseFloat($item['qty']), 2);
         $invoiceItemTaxRate = 0;
         if (isset($item['tax_rate']) && Utils::parseFloat($item['tax_rate']) > 0) {
             $invoiceItemTaxRate = Utils::parseFloat($item['tax_rate']);
         }
         $lineTotal = $invoiceItemCost * $invoiceItemQty;
         $total += round($lineTotal + $lineTotal * $invoiceItemTaxRate / 100, 2);
     }
     if ($invoice->discount > 0) {
         if ($invoice->is_amount_discount) {
             $total -= $invoice->discount;
         } else {
             $total *= (100 - $invoice->discount) / 100;
         }
     }
     $invoice->custom_value1 = round($data['custom_value1'], 2);
     $invoice->custom_value2 = round($data['custom_value2'], 2);
     $invoice->custom_taxes1 = $data['custom_taxes1'] ? true : false;
     $invoice->custom_taxes2 = $data['custom_taxes2'] ? true : false;
     // custom fields charged taxes
     if ($invoice->custom_value1 && $invoice->custom_taxes1) {
         $total += $invoice->custom_value1;
     }
     if ($invoice->custom_value2 && $invoice->custom_taxes2) {
         $total += $invoice->custom_value2;
     }
     $total += $total * $invoice->tax_rate / 100;
     $total = round($total, 2);
     // custom fields not charged taxes
     if ($invoice->custom_value1 && !$invoice->custom_taxes1) {
         $total += $invoice->custom_value1;
     }
     if ($invoice->custom_value2 && !$invoice->custom_taxes2) {
         $total += $invoice->custom_value2;
//.........这里部分代码省略.........
开发者ID:hanspoelmans,项目名称:invoice-ninja,代码行数:101,代码来源:InvoiceRepository.php

示例9: bulk

 /**
  * @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);
         }
     }
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:53,代码来源:TaskController.php

示例10: save

 public function save($data)
 {
     $account = \Auth::user()->account;
     $publicId = isset($data['public_id']) ? $data['public_id'] : false;
     $isNew = !$publicId || $publicId == '-1';
     if ($isNew) {
         $entityType = ENTITY_INVOICE;
         if (isset($data['is_recurring']) && filter_var($data['is_recurring'], FILTER_VALIDATE_BOOLEAN)) {
             $entityType = ENTITY_RECURRING_INVOICE;
         } elseif (isset($data['is_quote']) && filter_var($data['is_quote'], FILTER_VALIDATE_BOOLEAN)) {
             $entityType = ENTITY_QUOTE;
         }
         $invoice = $account->createInvoice($entityType, $data['client_id']);
         if (isset($data['has_tasks']) && filter_var($data['has_tasks'], FILTER_VALIDATE_BOOLEAN)) {
             $invoice->has_tasks = true;
         }
     } else {
         $invoice = Invoice::scope($publicId)->firstOrFail();
     }
     if (isset($data['set_default_terms']) && $data['set_default_terms'] || isset($data['set_default_footer']) && $data['set_default_footer']) {
         if (isset($data['set_default_terms']) && $data['set_default_terms']) {
             $account->{"{$invoice->getEntityType()}_terms"} = trim($data['terms']);
         }
         if (isset($data['set_default_footer']) && $data['set_default_footer']) {
             $account->invoice_footer = trim($data['invoice_footer']);
         }
         $account->save();
     }
     if (isset($data['invoice_number']) && !$invoice->is_recurring) {
         $invoice->invoice_number = trim($data['invoice_number']);
     }
     if (isset($data['discount'])) {
         $invoice->discount = round(Utils::parseFloat($data['discount']), 2);
     }
     if (isset($data['is_amount_discount'])) {
         $invoice->is_amount_discount = $data['is_amount_discount'] ? true : false;
     }
     if (isset($data['partial'])) {
         $invoice->partial = round(Utils::parseFloat($data['partial']), 2);
     }
     $invoice->invoice_date = isset($data['invoice_date_sql']) ? $data['invoice_date_sql'] : Utils::toSqlDate($data['invoice_date']);
     if ($invoice->is_recurring) {
         if ($invoice->start_date && $invoice->start_date != Utils::toSqlDate($data['start_date'])) {
             $invoice->last_sent_date = null;
         }
         $invoice->frequency_id = $data['frequency_id'] ? $data['frequency_id'] : 0;
         $invoice->start_date = Utils::toSqlDate($data['start_date']);
         $invoice->end_date = Utils::toSqlDate($data['end_date']);
         $invoice->due_date = null;
         $invoice->auto_bill = isset($data['auto_bill']) && $data['auto_bill'] ? true : false;
     } else {
         if (isset($data['due_date']) || isset($data['due_date_sql'])) {
             $invoice->due_date = isset($data['due_date_sql']) ? $data['due_date_sql'] : Utils::toSqlDate($data['due_date']);
         }
         $invoice->frequency_id = 0;
         $invoice->start_date = null;
         $invoice->end_date = null;
     }
     $invoice->terms = trim($data['terms']) ? trim($data['terms']) : (!$publicId && $account->invoice_terms ? $account->invoice_terms : '');
     $invoice->invoice_footer = isset($data['invoice_footer']) && trim($data['invoice_footer']) ? trim($data['invoice_footer']) : (!$publicId && $account->invoice_footer ? $account->invoice_footer : '');
     $invoice->public_notes = trim($data['public_notes']);
     // process date variables
     $invoice->terms = Utils::processVariables($invoice->terms);
     $invoice->invoice_footer = Utils::processVariables($invoice->invoice_footer);
     $invoice->public_notes = Utils::processVariables($invoice->public_notes);
     $invoice->po_number = trim($data['po_number']);
     $invoice->invoice_design_id = isset($data['invoice_design_id']) ? $data['invoice_design_id'] : $account->invoice_design_id;
     if (isset($data['tax_name']) && isset($data['tax_rate']) && $data['tax_name']) {
         $invoice->tax_rate = Utils::parseFloat($data['tax_rate']);
         $invoice->tax_name = trim($data['tax_name']);
     } else {
         $invoice->tax_rate = 0;
         $invoice->tax_name = '';
     }
     $total = 0;
     $itemTax = 0;
     foreach ($data['invoice_items'] as $item) {
         $item = (array) $item;
         if (!$item['cost'] && !$item['product_key'] && !$item['notes']) {
             continue;
         }
         $invoiceItemCost = round(Utils::parseFloat($item['cost']), 2);
         $invoiceItemQty = round(Utils::parseFloat($item['qty']), 2);
         $lineTotal = $invoiceItemCost * $invoiceItemQty;
         $total += round($lineTotal, 2);
     }
     foreach ($data['invoice_items'] as $item) {
         $item = (array) $item;
         if (isset($item['tax_rate']) && Utils::parseFloat($item['tax_rate']) > 0) {
             $invoiceItemCost = round(Utils::parseFloat($item['cost']), 2);
             $invoiceItemQty = round(Utils::parseFloat($item['qty']), 2);
             $invoiceItemTaxRate = Utils::parseFloat($item['tax_rate']);
             $lineTotal = $invoiceItemCost * $invoiceItemQty;
             if ($invoice->discount > 0) {
                 if ($invoice->is_amount_discount) {
                     $lineTotal -= round($lineTotal / $total * $invoice->discount, 2);
                 } else {
                     $lineTotal -= round($lineTotal * ($invoice->discount / 100), 2);
                 }
             }
//.........这里部分代码省略.........
开发者ID:saratonite,项目名称:invoiceninja,代码行数:101,代码来源:InvoiceRepository.php

示例11: bulk

 public function bulk()
 {
     $action = Input::get('action');
     $ids = Input::get('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');
                     }
                 }
                 $data[] = ['publicId' => $task->public_id, 'description' => $task->description, 'startTime' => $task->getStartTime(), '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->taskRepo->bulk($ids, $action);
             $message = Utils::pluralize($action . 'd_task', $count);
             Session::flash('message', $message);
             if ($action == 'restore' && $count == 1) {
                 return Redirect::to('tasks/' . $ids[0] . '/edit');
             } else {
                 return Redirect::to('tasks');
             }
         }
     }
 }
开发者ID:GhDj,项目名称:erp-fac-fin,代码行数:53,代码来源:TaskController.php

示例12: getData

 /**
  * @param $request
  *
  * @return array
  */
 private function getData($request)
 {
     $account = Auth::user()->account;
     $data = ['account' => $account, 'title' => 'Invoice Ninja v' . NINJA_VERSION . ' - ' . $account->formatDateTime($account->getDateTime()), 'multiUser' => $account->users->count() > 1];
     if ($request->input('include') === 'all' || $request->input('clients')) {
         $data['clients'] = Client::scope()->with('user', 'contacts', 'country')->withArchived()->get();
     }
     if ($request->input('include') === 'all' || $request->input('contacts')) {
         $data['contacts'] = Contact::scope()->with('user', 'client.contacts')->withTrashed()->get();
     }
     if ($request->input('include') === 'all' || $request->input('credits')) {
         $data['credits'] = Credit::scope()->with('user', 'client.contacts')->get();
     }
     if ($request->input('include') === 'all' || $request->input('tasks')) {
         $data['tasks'] = Task::scope()->with('user', 'client.contacts')->withArchived()->get();
     }
     if ($request->input('include') === 'all' || $request->input('invoices')) {
         $data['invoices'] = Invoice::scope()->invoiceType(INVOICE_TYPE_STANDARD)->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_recurring', '=', false)->get();
     }
     if ($request->input('include') === 'all' || $request->input('quotes')) {
         $data['quotes'] = Invoice::scope()->invoiceType(INVOICE_TYPE_QUOTE)->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_recurring', '=', false)->get();
     }
     if ($request->input('include') === 'all' || $request->input('recurring')) {
         $data['recurringInvoices'] = Invoice::scope()->invoiceType(INVOICE_TYPE_STANDARD)->with('user', 'client.contacts', 'invoice_status', 'frequency')->withArchived()->where('is_recurring', '=', true)->get();
     }
     if ($request->input('include') === 'all' || $request->input('payments')) {
         $data['payments'] = Payment::scope()->withArchived()->with('user', 'client.contacts', 'payment_type', 'invoice', 'account_gateway.gateway')->get();
     }
     if ($request->input('include') === 'all' || $request->input('vendors')) {
         $data['vendors'] = Vendor::scope()->with('user', 'vendor_contacts', 'country')->withArchived()->get();
     }
     if ($request->input('include') === 'all' || $request->input('vendor_contacts')) {
         $data['vendor_contacts'] = VendorContact::scope()->with('user', 'vendor.vendor_contacts')->withTrashed()->get();
     }
     return $data;
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:41,代码来源:ExportController.php

示例13: show

 /**
  * Display the specified resource.
  *
  * @param  int      $id
  * @return Response
  */
 public function show(ClientRequest $request)
 {
     $client = $request->entity();
     $user = Auth::user();
     Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT);
     $actionLinks = [];
     if ($user->can('create', ENTITY_TASK)) {
         $actionLinks[] = ['label' => trans('texts.new_task'), 'url' => URL::to('/tasks/create/' . $client->public_id)];
     }
     if (Utils::hasFeature(FEATURE_QUOTES) && $user->can('create', ENTITY_INVOICE)) {
         $actionLinks[] = ['label' => trans('texts.new_quote'), 'url' => URL::to('/quotes/create/' . $client->public_id)];
     }
     if (!empty($actionLinks)) {
         $actionLinks[] = \DropdownButton::DIVIDER;
     }
     if ($user->can('create', ENTITY_PAYMENT)) {
         $actionLinks[] = ['label' => trans('texts.enter_payment'), 'url' => URL::to('/payments/create/' . $client->public_id)];
     }
     if ($user->can('create', ENTITY_CREDIT)) {
         $actionLinks[] = ['label' => trans('texts.enter_credit'), 'url' => URL::to('/credits/create/' . $client->public_id)];
     }
     if ($user->can('create', ENTITY_EXPENSE)) {
         $actionLinks[] = ['label' => trans('texts.enter_expense'), 'url' => URL::to('/expenses/create/0/' . $client->public_id)];
     }
     $data = array('actionLinks' => $actionLinks, 'showBreadcrumbs' => false, 'client' => $client, 'credit' => $client->getTotalCredit(), 'title' => trans('texts.view_client'), 'hasRecurringInvoices' => Invoice::scope()->where('is_recurring', '=', true)->whereClientId($client->id)->count() > 0, 'hasQuotes' => Invoice::scope()->where('is_quote', '=', true)->whereClientId($client->id)->count() > 0, 'hasTasks' => Task::scope()->whereClientId($client->id)->count() > 0, 'gatewayLink' => $client->getGatewayLink());
     return View::make('clients.show', $data);
 }
开发者ID:hannenijhuis,项目名称:invoiceninja,代码行数:33,代码来源:ClientController.php

示例14: tasks

 public function tasks($accountId, $userId, $viewAll)
 {
     return Task::scope()->withArchived()->whereIsRunning(true)->get();
 }
开发者ID:rafaelsisweb,项目名称:invoice-ninja,代码行数:4,代码来源:DashboardRepository.php

示例15: show

 /**
  * Display the specified resource.
  *
  * @param  int      $id
  * @return Response
  */
 public function show($publicId)
 {
     $client = Client::withTrashed()->scope($publicId)->with('contacts', 'size', 'industry')->firstOrFail();
     if (!$this->checkViewPermission($client, $response)) {
         return $response;
     }
     Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT);
     $actionLinks = [];
     if (Task::canCreate()) {
         $actionLinks[] = ['label' => trans('texts.new_task'), 'url' => '/tasks/create/' . $client->public_id];
     }
     if (Utils::isPro() && Invoice::canCreate()) {
         $actionLinks[] = ['label' => trans('texts.new_quote'), 'url' => '/quotes/create/' . $client->public_id];
     }
     if (!empty($actionLinks)) {
         $actionLinks[] = \DropdownButton::DIVIDER;
     }
     if (Payment::canCreate()) {
         $actionLinks[] = ['label' => trans('texts.enter_payment'), 'url' => '/payments/create/' . $client->public_id];
     }
     if (Credit::canCreate()) {
         $actionLinks[] = ['label' => trans('texts.enter_credit'), 'url' => '/credits/create/' . $client->public_id];
     }
     if (Expense::canCreate()) {
         $actionLinks[] = ['label' => trans('texts.enter_expense'), 'url' => '/expenses/create/0/' . $client->public_id];
     }
     $data = array('actionLinks' => $actionLinks, 'showBreadcrumbs' => false, 'client' => $client, 'credit' => $client->getTotalCredit(), 'title' => trans('texts.view_client'), 'hasRecurringInvoices' => Invoice::scope()->where('is_recurring', '=', true)->whereClientId($client->id)->count() > 0, 'hasQuotes' => Invoice::scope()->where('is_quote', '=', true)->whereClientId($client->id)->count() > 0, 'hasTasks' => Task::scope()->whereClientId($client->id)->count() > 0, 'gatewayLink' => $client->getGatewayLink());
     return View::make('clients.show', $data);
 }
开发者ID:sseshachala,项目名称:invoiceninja,代码行数:35,代码来源:ClientController.php


注:本文中的app\models\Task::scope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。