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


PHP Invoice::getEntityType方法代码示例

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


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

示例1: sendInvoice

 public function sendInvoice(Invoice $invoice, $reminder = false)
 {
     $invoice->load('invitations', 'client.language', 'account');
     $entityType = $invoice->getEntityType();
     $client = $invoice->client;
     $account = $invoice->account;
     if ($invoice->trashed() || $client->trashed()) {
         return false;
     }
     $account->loadLocalizationSettings($client);
     if ($account->pdf_email_attachment) {
         $invoice->updateCachedPDF();
     }
     $view = 'invoice';
     $accountName = $invoice->account->getDisplayName();
     $emailTemplate = $invoice->account->getEmailTemplate($reminder ?: $entityType);
     $emailSubject = $invoice->account->getEmailSubject($reminder ?: $entityType);
     $this->initClosure($invoice);
     $response = false;
     $sent = false;
     foreach ($invoice->invitations as $invitation) {
         if (Auth::check()) {
             $user = Auth::user();
         } else {
             $user = $invitation->user;
             if ($invitation->user->trashed()) {
                 $user = $account->users()->orderBy('id')->first();
             }
         }
         if (!$user->email || !$user->confirmed) {
             continue;
         }
         if (!$invitation->contact->email || $invitation->contact->trashed()) {
             continue;
         }
         $invitation->sent_date = \Carbon::now()->toDateTimeString();
         $invitation->save();
         $variables = ['account' => $account, 'client' => $client, 'invitation' => $invitation, 'amount' => $invoice->getRequestedAmount()];
         $data['body'] = $this->processVariables($emailTemplate, $variables);
         $data['link'] = $invitation->getLink();
         $data['entityType'] = $entityType;
         $data['invoice_id'] = $invoice->id;
         $subject = $this->processVariables($emailSubject, $variables);
         $fromEmail = $user->email;
         $response = $this->sendTo($invitation->contact->email, $fromEmail, $accountName, $subject, $view, $data);
         if ($response === true) {
             $sent = true;
             Activity::emailInvoice($invitation);
         }
     }
     if ($sent === true) {
         if (!$invoice->isSent()) {
             $invoice->invoice_status_id = INVOICE_STATUS_SENT;
             $invoice->save();
         }
         $account->loadLocalizationSettings();
         Event::fire(new InvoiceSent($invoice));
     }
     return $response ?: trans('texts.email_error');
 }
开发者ID:juanmanavarro,项目名称:invoice-ninja,代码行数:60,代码来源:ContactMailer.php

示例2: sendInvoice

 public function sendInvoice(Invoice $invoice, $reminder = false, $pdfString = false)
 {
     $invoice->load('invitations', 'client.language', 'account');
     $entityType = $invoice->getEntityType();
     $client = $invoice->client;
     $account = $invoice->account;
     if ($client->trashed()) {
         return trans('texts.email_errors.inactive_client');
     } elseif ($invoice->trashed()) {
         return trans('texts.email_errors.inactive_invoice');
     }
     $account->loadLocalizationSettings($client);
     $emailTemplate = $account->getEmailTemplate($reminder ?: $entityType);
     $emailSubject = $account->getEmailSubject($reminder ?: $entityType);
     $sent = false;
     if ($account->attatchPDF() && !$pdfString) {
         $pdfString = $invoice->getPDFString();
     }
     foreach ($invoice->invitations as $invitation) {
         $response = $this->sendInvitation($invitation, $invoice, $emailTemplate, $emailSubject, $pdfString);
         if ($response === true) {
             $sent = true;
         }
     }
     $account->loadLocalizationSettings();
     if ($sent === true) {
         if ($invoice->is_quote) {
             event(new QuoteWasEmailed($invoice));
         } else {
             event(new InvoiceWasEmailed($invoice));
         }
     }
     return $response;
 }
开发者ID:jargij,项目名称:invoiceninja,代码行数:34,代码来源:ContactMailer.php

示例3: sendInvoice

 public function sendInvoice(Invoice $invoice, $reminder = false, $pdfString = false)
 {
     $invoice->load('invitations', 'client.language', 'account');
     $entityType = $invoice->getEntityType();
     $client = $invoice->client;
     $account = $invoice->account;
     if ($invoice->trashed() || $client->trashed()) {
         return false;
     }
     $account->loadLocalizationSettings($client);
     $emailTemplate = $account->getEmailTemplate($reminder ?: $entityType);
     $emailSubject = $account->getEmailSubject($reminder ?: $entityType);
     $sent = false;
     if ($account->attatchPDF() && !$pdfString) {
         $pdfString = $invoice->getPDFString();
     }
     foreach ($invoice->invitations as $invitation) {
         if ($this->sendInvitation($invitation, $invoice, $emailTemplate, $emailSubject, $pdfString)) {
             $sent = true;
         }
     }
     $account->loadLocalizationSettings();
     if ($sent === true) {
         Event::fire(new InvoiceSent($invoice));
     }
     return $sent ?: trans('texts.email_error');
 }
开发者ID:nafrente,项目名称:invoice-ninja,代码行数:27,代码来源:ContactMailer.php

示例4: sendInvoice

 public function sendInvoice(Invoice $invoice)
 {
     $invoice->load('invitations', 'client', 'account');
     $entityType = $invoice->getEntityType();
     $view = 'invoice';
     $subject = trans("texts.{$entityType}_subject", ['invoice' => $invoice->invoice_number, 'account' => $invoice->account->getDisplayName()]);
     $accountName = $invoice->account->getDisplayName();
     $emailTemplate = $invoice->account->getEmailTemplate($entityType);
     $invoiceAmount = Utils::formatMoney($invoice->getRequestedAmount(), $invoice->client->currency_id);
     foreach ($invoice->invitations as $invitation) {
         if (!$invitation->user || !$invitation->user->email) {
             return false;
         }
         if (!$invitation->contact || !$invitation->contact->email) {
             return false;
         }
         $invitation->sent_date = \Carbon::now()->toDateTimeString();
         $invitation->save();
         $variables = ['$footer' => $invoice->account->getEmailFooter(), '$link' => $invitation->getLink(), '$client' => $invoice->client->getDisplayName(), '$account' => $accountName, '$contact' => $invitation->contact->getDisplayName(), '$amount' => $invoiceAmount];
         $data['body'] = str_replace(array_keys($variables), array_values($variables), $emailTemplate);
         $data['link'] = $invitation->getLink();
         $data['entityType'] = $entityType;
         $data['invoice_id'] = $invoice->id;
         $fromEmail = $invitation->user->email;
         $this->sendTo($invitation->contact->email, $fromEmail, $accountName, $subject, $view, $data);
         Activity::emailInvoice($invitation);
     }
     if (!$invoice->isSent()) {
         $invoice->invoice_status_id = INVOICE_STATUS_SENT;
         $invoice->save();
     }
     Event::fire(new InvoiceSent($invoice));
 }
开发者ID:biggtfish,项目名称:invoiceNinja-1,代码行数:33,代码来源:ContactMailer.php

示例5: sendInvoice

 public function sendInvoice(Invoice $invoice, $reminder = false, $pdfString = false)
 {
     $invoice->load('invitations', 'client.language', 'account');
     $entityType = $invoice->getEntityType();
     $client = $invoice->client;
     $account = $invoice->account;
     $response = null;
     if ($client->trashed()) {
         return trans('texts.email_errors.inactive_client');
     } elseif ($invoice->trashed()) {
         return trans('texts.email_errors.inactive_invoice');
     }
     $account->loadLocalizationSettings($client);
     $emailTemplate = $account->getEmailTemplate($reminder ?: $entityType);
     $emailSubject = $account->getEmailSubject($reminder ?: $entityType);
     $sent = false;
     if ($account->attatchPDF() && !$pdfString) {
         $pdfString = $invoice->getPDFString();
     }
     $documentStrings = array();
     if ($account->document_email_attachment && $invoice->hasDocuments()) {
         $documents = $invoice->documents;
         foreach ($invoice->expenses as $expense) {
             $documents = $documents->merge($expense->documents);
         }
         $documents = $documents->sortBy('size');
         $size = 0;
         $maxSize = MAX_EMAIL_DOCUMENTS_SIZE * 1000;
         foreach ($documents as $document) {
             $size += $document->size;
             if ($size > $maxSize) {
                 break;
             }
             $documentStrings[] = array('name' => $document->name, 'data' => $document->getRaw());
         }
     }
     foreach ($invoice->invitations as $invitation) {
         $response = $this->sendInvitation($invitation, $invoice, $emailTemplate, $emailSubject, $pdfString, $documentStrings);
         if ($response === true) {
             $sent = true;
         }
     }
     $account->loadLocalizationSettings();
     if ($sent === true) {
         if ($invoice->is_quote) {
             event(new QuoteWasEmailed($invoice));
         } else {
             event(new InvoiceWasEmailed($invoice));
         }
     }
     return $response;
 }
开发者ID:hannenijhuis,项目名称:invoiceninja,代码行数:52,代码来源:ContactMailer.php

示例6: sendNotification

 public function sendNotification(User $user, Invoice $invoice, $notificationType, Payment $payment = null)
 {
     if (!$user->email) {
         return;
     }
     $entityType = $invoice->getEntityType();
     $view = ($notificationType == 'approved' ? ENTITY_QUOTE : ENTITY_INVOICE) . "_{$notificationType}";
     $account = $user->account;
     $client = $invoice->client;
     $data = ['entityType' => $entityType, 'clientName' => $client->getDisplayName(), 'accountName' => $account->getDisplayName(), 'userName' => $user->getDisplayName(), 'invoiceAmount' => $account->formatMoney($invoice->getRequestedAmount(), $client), 'invoiceNumber' => $invoice->invoice_number, 'invoiceLink' => SITE_URL . "/{$entityType}s/{$invoice->public_id}", 'account' => $account];
     if ($payment) {
         $data['paymentAmount'] = $account->formatMoney($payment->amount, $client);
     }
     $subject = trans("texts.notification_{$entityType}_{$notificationType}_subject", ['invoice' => $invoice->invoice_number, 'client' => $client->getDisplayName()]);
     $this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
 }
开发者ID:joshuadwire,项目名称:invoiceninja,代码行数:16,代码来源:UserMailer.php

示例7: sendInvoice

 public function sendInvoice(Invoice $invoice)
 {
     $invoice->load('invitations', 'client.language', 'account');
     $entityType = $invoice->getEntityType();
     $client = $invoice->client;
     $account = $invoice->account;
     $account->loadLocalizationSettings($client);
     $view = 'invoice';
     $subject = trans("texts.{$entityType}_subject", ['invoice' => $invoice->invoice_number, 'account' => $invoice->account->getDisplayName()]);
     $accountName = $invoice->account->getDisplayName();
     $emailTemplate = $invoice->account->getEmailTemplate($entityType);
     $invoiceAmount = Utils::formatMoney($invoice->getRequestedAmount(), $client->getCurrencyId());
     $this->initClosure($invoice);
     foreach ($invoice->invitations as $invitation) {
         if (!$invitation->user || !$invitation->user->email || $invitation->user->trashed()) {
             return false;
         }
         if (!$invitation->contact || !$invitation->contact->email || $invitation->contact->trashed()) {
             return false;
         }
         $invitation->sent_date = \Carbon::now()->toDateTimeString();
         $invitation->save();
         $variables = ['$footer' => $invoice->account->getEmailFooter(), '$link' => $invitation->getLink(), '$client' => $client->getDisplayName(), '$account' => $accountName, '$contact' => $invitation->contact->getDisplayName(), '$amount' => $invoiceAmount, '$advancedRawInvoice->' => '$'];
         // Add variables for available payment types
         foreach (Gateway::getPaymentTypeLinks() as $type) {
             $variables["\${$type}_link"] = URL::to("/payment/{$invitation->invitation_key}/{$type}");
         }
         $data['body'] = str_replace(array_keys($variables), array_values($variables), $emailTemplate);
         $data['body'] = preg_replace_callback('/\\{\\{\\$?(.*)\\}\\}/', $this->advancedTemplateHandler, $data['body']);
         $data['link'] = $invitation->getLink();
         $data['entityType'] = $entityType;
         $data['invoice_id'] = $invoice->id;
         $fromEmail = $invitation->user->email;
         $response = $this->sendTo($invitation->contact->email, $fromEmail, $accountName, $subject, $view, $data);
         if ($response !== true) {
             return $response;
         }
         Activity::emailInvoice($invitation);
     }
     if (!$invoice->isSent()) {
         $invoice->invoice_status_id = INVOICE_STATUS_SENT;
         $invoice->save();
     }
     $account->loadLocalizationSettings();
     Event::fire(new InvoiceSent($invoice));
     return $response;
 }
开发者ID:jorisvandesande,项目名称:invoice-ninja,代码行数:47,代码来源:ContactMailer.php

示例8: save

 /**
  * @param array $data
  * @param Invoice|null $invoice
  * @return Invoice|mixed
  */
 public function save(array $data, Invoice $invoice = null)
 {
     /** @var Account $account */
     $account = \Auth::user()->account;
     $publicId = isset($data['public_id']) ? $data['public_id'] : false;
     $isNew = !$publicId || $publicId == '-1';
     if ($invoice) {
         // do nothing
         $entityType = $invoice->getEntityType();
     } elseif ($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']);
         $invoice->invoice_date = date_create()->format('Y-m-d');
         if (isset($data['has_tasks']) && filter_var($data['has_tasks'], FILTER_VALIDATE_BOOLEAN)) {
             $invoice->has_tasks = true;
         }
         if (isset($data['has_expenses']) && filter_var($data['has_expenses'], FILTER_VALIDATE_BOOLEAN)) {
             $invoice->has_expenses = true;
         }
     } else {
         $invoice = Invoice::scope($publicId)->firstOrFail();
         \Log::warning('Entity not set in invoice repo save');
     }
     $invoice->fill($data);
     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);
     }
     if (isset($data['invoice_date_sql'])) {
         $invoice->invoice_date = $data['invoice_date_sql'];
     } elseif (isset($data['invoice_date'])) {
         $invoice->invoice_date = Utils::toSqlDate($data['invoice_date']);
     }
     if (isset($data['invoice_status_id'])) {
         if ($data['invoice_status_id'] == 0) {
             $data['invoice_status_id'] = INVOICE_STATUS_DRAFT;
         }
         $invoice->invoice_status_id = $data['invoice_status_id'];
     }
     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->client_enable_auto_bill = isset($data['client_enable_auto_bill']) && $data['client_enable_auto_bill'] ? true : false;
         $invoice->auto_bill = isset($data['auto_bill']) ? intval($data['auto_bill']) : AUTO_BILL_OFF;
         if ($invoice->auto_bill < AUTO_BILL_OFF || $invoice->auto_bill > AUTO_BILL_ALWAYS) {
             $invoice->auto_bill = AUTO_BILL_OFF;
         }
         if (isset($data['recurring_due_date'])) {
             $invoice->due_date = $data['recurring_due_date'];
         } elseif (isset($data['due_date'])) {
             $invoice->due_date = $data['due_date'];
         }
     } 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;
     }
     if (isset($data['terms']) && trim($data['terms'])) {
         $invoice->terms = trim($data['terms']);
     } elseif ($isNew && $account->{"{$entityType}_terms"}) {
         $invoice->terms = $account->{"{$entityType}_terms"};
     } else {
         $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 = isset($data['public_notes']) ? trim($data['public_notes']) : null;
//.........这里部分代码省略.........
开发者ID:rafaelsisweb,项目名称:invoice-ninja,代码行数:101,代码来源:InvoiceRepository.php

示例9: sendInvitation

 /**
  * @param Invitation $invitation
  * @param Invoice $invoice
  * @param $body
  * @param $subject
  * @param $pdfString
  * @param $documentStrings
  * @return bool|string
  * @throws \Laracasts\Presenter\Exceptions\PresenterException
  */
 private function sendInvitation(Invitation $invitation, Invoice $invoice, $body, $subject, $pdfString, $documentStrings)
 {
     $client = $invoice->client;
     $account = $invoice->account;
     if (Auth::check()) {
         $user = Auth::user();
     } else {
         $user = $invitation->user;
         if ($invitation->user->trashed()) {
             $user = $account->users()->orderBy('id')->first();
         }
     }
     if (!$user->email || !$user->registered) {
         return trans('texts.email_error_user_unregistered');
     } elseif (!$user->confirmed) {
         return trans('texts.email_error_user_unconfirmed');
     } elseif (!$invitation->contact->email) {
         return trans('texts.email_error_invalid_contact_email');
     } elseif ($invitation->contact->trashed()) {
         return trans('texts.email_error_inactive_contact');
     }
     $variables = ['account' => $account, 'client' => $client, 'invitation' => $invitation, 'amount' => $invoice->getRequestedAmount()];
     // Let the client know they'll be billed later
     if ($client->autoBillLater()) {
         $variables['autobill'] = $invoice->present()->autoBillEmailMessage();
     }
     if (empty($invitation->contact->password) && $account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $account->enable_portal_password && $account->send_portal_password) {
         // The contact needs a password
         $variables['password'] = $password = $this->generatePassword();
         $invitation->contact->password = bcrypt($password);
         $invitation->contact->save();
     }
     $data = ['body' => $this->templateService->processVariables($body, $variables), 'link' => $invitation->getLink(), 'entityType' => $invoice->getEntityType(), 'invoiceId' => $invoice->id, 'invitation' => $invitation, 'account' => $account, 'client' => $client, 'invoice' => $invoice, 'documents' => $documentStrings];
     if ($account->attachPDF()) {
         $data['pdfString'] = $pdfString;
         $data['pdfFileName'] = $invoice->getFileName();
     }
     $subject = $this->templateService->processVariables($subject, $variables);
     $fromEmail = $user->email;
     $view = $account->getTemplateView(ENTITY_INVOICE);
     $response = $this->sendTo($invitation->contact->email, $fromEmail, $account->getDisplayName(), $subject, $view, $data);
     if ($response === true) {
         return true;
     } else {
         return $response;
     }
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:57,代码来源:ContactMailer.php


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