1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Add checks for contact

This commit is contained in:
Hillel Coren 2017-04-24 10:35:30 +03:00
parent df3d2aeec3
commit a483ce487a
3 changed files with 6 additions and 2 deletions

View File

@ -259,7 +259,7 @@ class ContactMailer extends Mailer
$invitation = $payment->invitation;
} else {
$user = $payment->user;
$contact = $client->contacts[0];
$contact = count($client->contacts) ? $client->contacts[0] : '';
$invitation = $payment->invoice->invitations[0];
}

View File

@ -710,6 +710,10 @@ class InvoiceRepository extends BaseRepository
$client->load('contacts');
$sendInvoiceIds = [];
if (! count($client->contacts)) {
return $invoice;
}
foreach ($client->contacts as $contact) {
if ($contact->send_invoice) {
$sendInvoiceIds[] = $contact->id;

View File

@ -868,7 +868,7 @@ class ImportService
$this->maps['client'][$name] = $client->id;
$this->maps['client_ids'][$client->public_id] = $client->id;
}
if ($name = strtolower(trim($client->contacts[0]->email))) {
if (count($client->contacts) && $name = strtolower(trim($client->contacts[0]->email))) {
$this->maps['client'][$name] = $client->id;
$this->maps['client_ids'][$client->public_id] = $client->id;
}