mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 06:34:29 -04:00
Bug fixes
This commit is contained in:
parent
b11ab39a9f
commit
55a8ef4951
@ -156,7 +156,7 @@ class InvoiceController extends \BaseController {
|
||||
|
||||
public function edit($publicId)
|
||||
{
|
||||
$invoice = Invoice::scope($publicId)->withTrashed()->with('account.country', 'client.contacts', 'client.country', 'invoice_items')->firstOrFail();
|
||||
$invoice = Invoice::scope($publicId)->withTrashed()->with('invitations', 'account.country', 'client.contacts', 'client.country', 'invoice_items')->firstOrFail();
|
||||
Utils::trackViewed($invoice->invoice_number . ' - ' . $invoice->client->getDisplayName(), ENTITY_INVOICE);
|
||||
|
||||
$invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
|
||||
@ -165,13 +165,13 @@ class InvoiceController extends \BaseController {
|
||||
$invoice->end_date = Utils::fromSqlDate($invoice->end_date);
|
||||
$invoice->is_pro = Auth::user()->isPro();
|
||||
|
||||
$contactIds = DB::table('invitations')
|
||||
->join('contacts', 'contacts.id', '=','invitations.contact_id')
|
||||
->where('invitations.invoice_id', '=', $invoice->id)
|
||||
->where('invitations.account_id', '=', Auth::user()->account_id)
|
||||
->where('invitations.deleted_at', '=', null)
|
||||
->select('contacts.public_id')->lists('public_id');
|
||||
|
||||
$contactIds = DB::table('invitations')
|
||||
->join('contacts', 'contacts.id', '=','invitations.contact_id')
|
||||
->where('invitations.invoice_id', '=', $invoice->id)
|
||||
->where('invitations.account_id', '=', Auth::user()->account_id)
|
||||
->where('invitations.deleted_at', '=', null)
|
||||
->select('contacts.public_id')->lists('public_id');
|
||||
|
||||
$data = array(
|
||||
'showBreadcrumbs' => false,
|
||||
'account' => $invoice->account,
|
||||
@ -183,6 +183,27 @@ class InvoiceController extends \BaseController {
|
||||
'title' => '- ' . $invoice->invoice_number,
|
||||
'client' => $invoice->client);
|
||||
$data = array_merge($data, self::getViewModel());
|
||||
|
||||
// Set the invitation link on the client's contacts
|
||||
$clients = $data['clients'];
|
||||
foreach ($clients as $client)
|
||||
{
|
||||
if ($client->id == $invoice->client->id)
|
||||
{
|
||||
foreach ($invoice->invitations as $invitation)
|
||||
{
|
||||
foreach ($client->contacts as $contact)
|
||||
{
|
||||
if ($invitation->contact_id == $contact->id)
|
||||
{
|
||||
$contact->invitation_link = $invitation->getLink();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return View::make('invoices.edit', $data);
|
||||
}
|
||||
|
||||
@ -311,6 +332,10 @@ class InvoiceController extends \BaseController {
|
||||
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
|
||||
$invitation->save();
|
||||
}
|
||||
else if (!in_array($contact->id, $sendInvoiceIds) && $invitation)
|
||||
{
|
||||
$invitation->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$message = trans($publicId ? 'texts.updated_invoice' : 'texts.created_invoice');
|
||||
|
@ -317,6 +317,6 @@ return array(
|
||||
'field_label' => 'Field Label',
|
||||
'field_value' => 'Field Value',
|
||||
'edit' => 'Edit',
|
||||
|
||||
'view_invoice' => 'View invoice',
|
||||
|
||||
);
|
||||
|
@ -324,7 +324,7 @@ return array(
|
||||
'field_value' => 'Field Value',
|
||||
'edit' => 'Edit',
|
||||
'set_name' => 'Set your company name',
|
||||
|
||||
'view_invoice' => 'View invoice',
|
||||
|
||||
|
||||
|
||||
|
@ -316,6 +316,6 @@ return array(
|
||||
'field_label' => 'Field Label',
|
||||
'field_value' => 'Field Value',
|
||||
'edit' => 'Edit',
|
||||
|
||||
'view_invoice' => 'View invoice',
|
||||
|
||||
);
|
||||
|
@ -317,6 +317,6 @@ return array(
|
||||
'field_label' => 'Field Label',
|
||||
'field_value' => 'Field Value',
|
||||
'edit' => 'Edit',
|
||||
|
||||
'view_invoice' => 'View invoice',
|
||||
|
||||
);
|
||||
|
@ -317,6 +317,6 @@ return array(
|
||||
'field_label' => 'Field Label',
|
||||
'field_value' => 'Field Value',
|
||||
'edit' => 'Edit',
|
||||
|
||||
'view_invoice' => 'View invoice',
|
||||
|
||||
);
|
||||
|
@ -317,6 +317,6 @@ return array(
|
||||
'field_label' => 'Field Label',
|
||||
'field_value' => 'Field Value',
|
||||
'edit' => 'Edit',
|
||||
|
||||
'view_invoice' => 'View invoice',
|
||||
|
||||
);
|
||||
|
@ -305,6 +305,6 @@ return array(
|
||||
'field_label' => 'Field Label',
|
||||
'field_value' => 'Field Value',
|
||||
'edit' => 'Edit',
|
||||
|
||||
'view_invoice' => 'View invoice',
|
||||
|
||||
);
|
||||
|
@ -16,4 +16,9 @@ class Invitation extends EntityModel
|
||||
{
|
||||
return $this->belongsTo('User');
|
||||
}
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
return URL::to('view') . '/' . $this->invitation_key;
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ class ContactMailer extends Mailer {
|
||||
$invitation->save();
|
||||
|
||||
$data = [
|
||||
'link' => URL::to('view') . '/' . $invitation->invitation_key,
|
||||
'link' => $invitation->getLink(),
|
||||
'clientName' => $invoice->client->getDisplayName(),
|
||||
'accountName' => $invoice->account->getDisplayName(),
|
||||
'contactName' => $invitation->contact->getDisplayName(),
|
||||
|
@ -174,8 +174,8 @@ class AccountRepository
|
||||
$user->username = $random;
|
||||
$user->first_name = 'Invoice';
|
||||
$user->last_name = 'Ninja';
|
||||
$user->notify_sent = false;
|
||||
$user->notify_paid = false;
|
||||
$user->notify_sent = true;
|
||||
$user->notify_paid = true;
|
||||
$account->users()->save($user);
|
||||
|
||||
$accountGateway = new AccountGateway();
|
||||
|
@ -1245,16 +1245,22 @@
|
||||
self.email = ko.observable('');
|
||||
self.phone = ko.observable('');
|
||||
self.send_invoice = ko.observable(false);
|
||||
self.invitation_link = ko.observable('');
|
||||
|
||||
self.email.display = ko.computed(function() {
|
||||
var str = '';
|
||||
if (self.first_name() || self.last_name()) {
|
||||
str += self.first_name() + ' ' + self.last_name() + '<br/>';
|
||||
}
|
||||
return str + self.email();
|
||||
str += self.email();
|
||||
|
||||
if (self.invitation_link()) {
|
||||
str += '<br/><a href="' + self.invitation_link() + '" target="_blank">{{ trans('texts.view_invoice') }}</a>';
|
||||
}
|
||||
|
||||
return str;
|
||||
});
|
||||
|
||||
|
||||
if (data) {
|
||||
ko.mapping.fromJS(data, {}, this);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user