Bug fixes

This commit is contained in:
Hillel Coren 2015-09-29 13:21:57 +03:00
parent 8a071f43df
commit bf85aa7ddd
7 changed files with 22 additions and 16 deletions

View File

@ -42,9 +42,6 @@ class SendRecurringInvoices extends Command
if ($invoice && !$invoice->isPaid()) { if ($invoice && !$invoice->isPaid()) {
$recurInvoice->account->loadLocalizationSettings($invoice->client); $recurInvoice->account->loadLocalizationSettings($invoice->client);
if ($invoice->account->pdf_email_attachment) {
$invoice->updateCachedPDF();
}
$this->mailer->sendInvoice($invoice); $this->mailer->sendInvoice($invoice);
} }
} }

View File

@ -49,7 +49,8 @@ class Handler extends ExceptionHandler {
} }
// In production, except for maintenance mode, we'll show a custom error screen // In production, except for maintenance mode, we'll show a custom error screen
if (Utils::isNinjaProd() && $e->getStatusCode() != 503) { //if (Utils::isNinjaProd() && $e->getStatusCode() != 503) {
if (Utils::isNinjaProd()) {
$data = [ $data = [
'error' => get_class($e), 'error' => get_class($e),
'hideHeader' => true, 'hideHeader' => true,

View File

@ -527,10 +527,10 @@ class InvoiceController extends BaseController
Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url); Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url);
} }
if ($invoice->account->pdf_email_attachment) { if ($invoice->account->pdf_email_attachment && !$invoice->is_recurring) {
$pdfUpload = Input::get('pdfupload'); $pdfUpload = Input::get('pdfupload');
if (!empty($pdfUpload) && strpos($pdfUpload, 'data:application/pdf;base64,') === 0) { if (!empty($pdfUpload) && strpos($pdfUpload, 'data:application/pdf;base64,') === 0) {
$invoice->updateCachedPDF(Input::get('pdfupload')); $invoice->updateCachedPDF($pdfUpload);
} }
} }

View File

@ -1,5 +1,6 @@
<?php namespace App\Models; <?php namespace App\Models;
use Utils;
use DateTime; use DateTime;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
@ -284,12 +285,13 @@ class Invoice extends EntityModel
{ {
if (!$encodedString) { if (!$encodedString) {
$invitation = $this->invitations[0]; $invitation = $this->invitations[0];
$key = $invitation->getLink(); $link = $invitation->getLink();
$curl = curl_init(); $curl = curl_init();
$jsonEncodedData = json_encode([ $jsonEncodedData = json_encode([
'targetUrl' => SITE_URL . "/view/{$key}/?phantomjs=true", 'targetUrl' => "{$link}?phantomjs=true",
'requestType' => 'raw', 'requestType' => 'raw',
'delayTime' => 3000,
]); ]);
$opts = [ $opts = [
@ -304,14 +306,12 @@ class Invoice extends EntityModel
curl_setopt_array($curl, $opts); curl_setopt_array($curl, $opts);
$encodedString = strip_tags(curl_exec($curl)); $encodedString = strip_tags(curl_exec($curl));
curl_close($curl); curl_close($curl);
if (!$encodedString) {
return false;
}
} }
$encodedString = str_replace('data:application/pdf;base64,', '', $encodedString); $encodedString = str_replace('data:application/pdf;base64,', '', $encodedString);
file_put_contents($this->getPDFPath(), base64_decode($encodedString)); if ($encodedString = base64_decode($encodedString)) {
file_put_contents($this->getPDFPath(), $encodedString);
}
} }
} }

View File

@ -21,6 +21,10 @@ class ContactMailer extends Mailer
$client = $invoice->client; $client = $invoice->client;
$account = $invoice->account; $account = $invoice->account;
if ($invoice->trashed() || $client->trashed()) {
return false;
}
$account->loadLocalizationSettings($client); $account->loadLocalizationSettings($client);
$view = 'invoice'; $view = 'invoice';

View File

@ -655,6 +655,10 @@ class InvoiceRepository
} }
} }
if ($recurInvoice->account->pdf_email_attachment) {
$invoice->updateCachedPDF();
}
return $invoice; return $invoice;
} }

View File

@ -128,14 +128,14 @@ class PaymentService {
'billingCity' => $client->city, 'billingCity' => $client->city,
'billingPostcode' => $client->postal_code, 'billingPostcode' => $client->postal_code,
'billingState' => $client->state, 'billingState' => $client->state,
'billingCountry' => $client->country->iso_3166_2, 'billingCountry' => $client->country ? $client->country->iso_3166_2 : '',
'billingPhone' => $contact->phone, 'billingPhone' => $contact->phone,
'shippingAddress1' => $client->address1, 'shippingAddress1' => $client->address1,
'shippingAddress2' => $client->address2, 'shippingAddress2' => $client->address2,
'shippingCity' => $client->city, 'shippingCity' => $client->city,
'shippingPostcode' => $client->postal_code, 'shippingPostcode' => $client->postal_code,
'shippingState' => $client->state, 'shippingState' => $client->state,
'shippingCountry' => $client->country->iso_3166_2, 'shippingCountry' => $client->country ? $client->country->iso_3166_2 : '',
'shippingPhone' => $contact->phone, 'shippingPhone' => $contact->phone,
]; ];
} }