1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-19 16:01:34 +02:00

Support updating invoices through the API

This commit is contained in:
Hillel Coren 2015-07-30 17:44:47 +03:00
parent 914334511e
commit 4fa4f65005
33 changed files with 240 additions and 209 deletions

View File

@ -18,6 +18,4 @@ MAIL_HOST
MAIL_USERNAME MAIL_USERNAME
MAIL_FROM_ADDRESS MAIL_FROM_ADDRESS
MAIL_FROM_NAME MAIL_FROM_NAME
MAIL_PASSWORD MAIL_PASSWORD
ALLOW_NEW_ACCOUNTS

View File

@ -75,18 +75,18 @@ class AccountController extends BaseController
public function getStarted() public function getStarted()
{ {
if (Auth::check()) {
return Redirect::to('invoices/create');
}
if (!Utils::isNinja() && !Utils::allowNewAccounts() && Account::count() > 0) {
return Redirect::to('/login');
}
$user = false; $user = false;
$guestKey = Input::get('guest_key'); // local storage key to login until registered $guestKey = Input::get('guest_key'); // local storage key to login until registered
$prevUserId = Session::pull(PREV_USER_ID); // last user id used to link to new account $prevUserId = Session::pull(PREV_USER_ID); // last user id used to link to new account
if (Auth::check()) {
return Redirect::to('invoices/create');
}
if (!Utils::isNinja() && (Account::count() > 0 && !$prevUserId)) {
return Redirect::to('/login');
}
if ($guestKey && !$prevUserId) { if ($guestKey && !$prevUserId) {
$user = User::where('password', '=', $guestKey)->first(); $user = User::where('password', '=', $guestKey)->first();
@ -149,6 +149,7 @@ class AccountController extends BaseController
public function showSection($section = ACCOUNT_DETAILS, $subSection = false) public function showSection($section = ACCOUNT_DETAILS, $subSection = false)
{ {
if ($section == ACCOUNT_DETAILS) { if ($section == ACCOUNT_DETAILS) {
$primaryUser = Auth::user()->account->users()->orderBy('id')->first();
$data = [ $data = [
'account' => Account::with('users')->findOrFail(Auth::user()->account_id), 'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
'countries' => Cache::get('countries'), 'countries' => Cache::get('countries'),
@ -159,8 +160,9 @@ class AccountController extends BaseController
'datetimeFormats' => Cache::get('datetimeFormats'), 'datetimeFormats' => Cache::get('datetimeFormats'),
'currencies' => Cache::get('currencies'), 'currencies' => Cache::get('currencies'),
'languages' => Cache::get('languages'), 'languages' => Cache::get('languages'),
'showUser' => Auth::user()->id === Auth::user()->account->users()->first()->id, 'showUser' => Auth::user()->id === $primaryUser->id,
'title' => trans('texts.company_details'), 'title' => trans('texts.company_details'),
'primaryUser' => $primaryUser,
]; ];
return View::make('accounts.details', $data); return View::make('accounts.details', $data);
@ -639,7 +641,7 @@ class AccountController extends BaseController
'name' => 'required', 'name' => 'required',
); );
$user = Auth::user()->account->users()->first(); $user = Auth::user()->account->users()->orderBy('id')->first();
if (Auth::user()->id === $user->id) { if (Auth::user()->id === $user->id) {
$rules['email'] = 'email|required|unique:users,email,'.$user->id.',id'; $rules['email'] = 'email|required|unique:users,email,'.$user->id.',id';

View File

@ -88,9 +88,7 @@ class AppController extends BaseController
"MAIL_HOST={$mail['host']}\n". "MAIL_HOST={$mail['host']}\n".
"MAIL_USERNAME={$mail['username']}\n". "MAIL_USERNAME={$mail['username']}\n".
"MAIL_FROM_NAME={$mail['from']['name']}\n". "MAIL_FROM_NAME={$mail['from']['name']}\n".
"MAIL_PASSWORD={$mail['password']}\n\n". "MAIL_PASSWORD={$mail['password']}";
"ADMIN_USER_ID=1\n".
"ALLOW_NEW_ACCOUNTS\n";
// Write Config Settings // Write Config Settings
$fp = fopen(base_path()."/.env", 'w'); $fp = fopen(base_path()."/.env", 'w');
@ -178,7 +176,7 @@ class AppController extends BaseController
public function update() public function update()
{ {
if (!Utils::isNinja()) { if (!Utils::isNinja() && Auth::check()) {
try { try {
Artisan::call('migrate', array('--force' => true)); Artisan::call('migrate', array('--force' => true));
Artisan::call('db:seed', array('--force' => true, '--class' => 'PaymentLibrariesSeeder')); Artisan::call('db:seed', array('--force' => true, '--class' => 'PaymentLibrariesSeeder'));

View File

@ -110,7 +110,7 @@ class DashboardController extends BaseController
->where('contacts.deleted_at', '=', null) ->where('contacts.deleted_at', '=', null)
->where('contacts.is_primary', '=', true) ->where('contacts.is_primary', '=', true)
->select(['payments.payment_date', 'payments.amount', 'invoices.public_id', 'invoices.invoice_number', 'clients.name as client_name', 'contacts.email', 'contacts.first_name', 'contacts.last_name', 'clients.currency_id', 'clients.public_id as client_public_id']) ->select(['payments.payment_date', 'payments.amount', 'invoices.public_id', 'invoices.invoice_number', 'clients.name as client_name', 'contacts.email', 'contacts.first_name', 'contacts.last_name', 'clients.currency_id', 'clients.public_id as client_public_id'])
->orderBy('payments.payment_date', 'asc') ->orderBy('payments.id', 'desc')
->take(50) ->take(50)
->get(); ->get();

View File

@ -43,7 +43,7 @@ class HomeController extends BaseController
public function invoiceNow() public function invoiceNow()
{ {
if (Auth::check() && Input::get('new_account')) { if (Auth::check() && Input::get('new_company')) {
Session::put(PREV_USER_ID, Auth::user()->id); Session::put(PREV_USER_ID, Auth::user()->id);
Auth::user()->clearSession(); Auth::user()->clearSession();
Auth::logout(); Auth::logout();

View File

@ -50,12 +50,14 @@ class InvoiceApiController extends Controller
$error = null; $error = null;
// check if the invoice number is set and unique // check if the invoice number is set and unique
if (!isset($data['invoice_number'])) { if (!isset($data['invoice_number']) && !isset($data['id'])) {
$data['invoice_number'] = Auth::user()->account->getNextInvoiceNumber(); $data['invoice_number'] = Auth::user()->account->getNextInvoiceNumber();
} else { } else if (isset($data['invoice_number'])) {
$invoice = Invoice::scope()->where('invoice_number', '=', $data['invoice_number'])->first(); $invoice = Invoice::scope()->where('invoice_number', '=', $data['invoice_number'])->first();
if ($invoice) { if ($invoice) {
$error = trans('validation.unique', ['attribute' => 'texts.invoice_number']); $error = trans('validation.unique', ['attribute' => 'texts.invoice_number']);
} else {
$data['id'] = $invoice->public_id;
} }
} }
@ -98,13 +100,15 @@ class InvoiceApiController extends Controller
} else { } else {
$data = self::prepareData($data); $data = self::prepareData($data);
$data['client_id'] = $client->id; $data['client_id'] = $client->id;
$invoice = $this->invoiceRepo->save(false, $data, false); $invoice = $this->invoiceRepo->save(isset($data['id']) ? $data['id'] : false, $data, false);
$invitation = Invitation::createNew(); if (!isset($data['id'])) {
$invitation->invoice_id = $invoice->id; $invitation = Invitation::createNew();
$invitation->contact_id = $client->contacts[0]->id; $invitation->invoice_id = $invoice->id;
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH); $invitation->contact_id = $client->contacts[0]->id;
$invitation->save(); $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
$invitation->save();
}
if (isset($data['email_invoice']) && $data['email_invoice']) { if (isset($data['email_invoice']) && $data['email_invoice']) {
$this->mailer->sendInvoice($invoice); $this->mailer->sendInvoice($invoice);

View File

@ -86,11 +86,12 @@ class InvoiceController extends BaseController
} }
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first(); $invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
$color = $invitation->account->primary_color ? $invitation->account->primary_color : '#0b4d78'; $account = $invitation->account;
$color = $account->primary_color ? $account->primary_color : '#0b4d78';
$data = [ $data = [
'color' => $color, 'color' => $color,
'hideLogo' => Session::get('white_label'), 'hideLogo' => $account->isWhiteLabel(),
'title' => trans('texts.invoices'), 'title' => trans('texts.invoices'),
'entityType' => ENTITY_INVOICE, 'entityType' => ENTITY_INVOICE,
'columns' => Utils::trans(['invoice_number', 'invoice_date', 'invoice_total', 'balance_due', 'due_date']), 'columns' => Utils::trans(['invoice_number', 'invoice_date', 'invoice_total', 'balance_due', 'due_date']),
@ -205,7 +206,6 @@ class InvoiceController extends BaseController
Session::set($invitationKey, true); Session::set($invitationKey, true);
Session::set('invitation_key', $invitationKey); Session::set('invitation_key', $invitationKey);
Session::set('white_label', $account->isWhiteLabel());
$account->loadLocalizationSettings(); $account->loadLocalizationSettings();

View File

@ -61,11 +61,12 @@ class PaymentController extends BaseController
} }
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first(); $invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
$color = $invitation->account->primary_color ? $invitation->account->primary_color : '#0b4d78'; $account = $invitation->account;
$color = $account->primary_color ? $account->primary_color : '#0b4d78';
$data = [ $data = [
'color' => $color, 'color' => $color,
'hideLogo' => Session::get('white_label'), 'hideLogo' => $account->isWhiteLabel(),
'entityType' => ENTITY_PAYMENT, 'entityType' => ENTITY_PAYMENT,
'title' => trans('texts.payments'), 'title' => trans('texts.payments'),
'columns' => Utils::trans(['invoice', 'transaction_reference', 'method', 'payment_amount', 'payment_date']) 'columns' => Utils::trans(['invoice', 'transaction_reference', 'method', 'payment_amount', 'payment_date'])
@ -336,7 +337,7 @@ class PaymentController extends BaseController
'acceptedCreditCardTypes' => $acceptedCreditCardTypes, 'acceptedCreditCardTypes' => $acceptedCreditCardTypes,
'countries' => Cache::get('countries'), 'countries' => Cache::get('countries'),
'currencyId' => $client->getCurrencyId(), 'currencyId' => $client->getCurrencyId(),
'currencyCode' => $client->currency->code, 'currencyCode' => $client->currency ? $client->currency->code : ($account->currency ? $account->currency->code : 'USD'),
'account' => $client->account, 'account' => $client->account,
'hideLogo' => $account->isWhiteLabel(), 'hideLogo' => $account->isWhiteLabel(),
'showAddress' => $accountGateway->show_address, 'showAddress' => $accountGateway->show_address,

View File

@ -75,11 +75,12 @@ class QuoteController extends BaseController
} }
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first(); $invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
$color = $invitation->account->primary_color ? $invitation->account->primary_color : '#0b4d78'; $account = $invitation->account;
$color = $account->primary_color ? $account->primary_color : '#0b4d78';
$data = [ $data = [
'color' => $color, 'color' => $color,
'hideLogo' => Session::get('white_label'), 'hideLogo' => $account->isWhiteLabel(),
'title' => trans('texts.quotes'), 'title' => trans('texts.quotes'),
'entityType' => ENTITY_QUOTE, 'entityType' => ENTITY_QUOTE,
'columns' => Utils::trans(['quote_number', 'quote_date', 'quote_total', 'due_date']), 'columns' => Utils::trans(['quote_number', 'quote_date', 'quote_total', 'due_date']),

View File

@ -61,7 +61,7 @@ class Utils
public static function allowNewAccounts() public static function allowNewAccounts()
{ {
return Utils::isNinja() || (isset($_ENV['ALLOW_NEW_ACCOUNTS']) && $_ENV['ALLOW_NEW_ACCOUNTS'] == 'true'); return Utils::isNinja() || Auth::check();
} }
public static function isPro() public static function isPro()
@ -400,10 +400,12 @@ class Utils
} }
$object = new stdClass(); $object = new stdClass();
$object->accountId = Auth::user()->account_id;
$object->url = $url; $object->url = $url;
$object->name = ucwords($type).': '.$name; $object->name = ucwords($type).': '.$name;
$data = []; $data = [];
$counts = [];
for ($i = 0; $i<count($viewed); $i++) { for ($i = 0; $i<count($viewed); $i++) {
$item = $viewed[$i]; $item = $viewed[$i];
@ -412,12 +414,22 @@ class Utils
continue; continue;
} }
// temporary fix to check for new property in session
if (!property_exists($item, 'accountId')) {
continue;
}
array_unshift($data, $item); array_unshift($data, $item);
if (isset($counts[$item->accountId])) {
$counts[$item->accountId]++;
} else {
$counts[$item->accountId] = 1;
}
} }
array_unshift($data, $object); array_unshift($data, $object);
if (count($data) > RECENTLY_VIEWED_LIMIT) { if (isset($counts[Auth::user()->account_id]) && $counts[Auth::user()->account_id] > RECENTLY_VIEWED_LIMIT) {
array_pop($data); array_pop($data);
} }

View File

@ -176,37 +176,36 @@ class Account extends Eloquent
{ {
$counter = $isQuote && !$this->share_counter ? $this->quote_number_counter : $this->invoice_number_counter; $counter = $isQuote && !$this->share_counter ? $this->quote_number_counter : $this->invoice_number_counter;
$prefix .= $isQuote ? $this->quote_number_prefix : $this->invoice_number_prefix; $prefix .= $isQuote ? $this->quote_number_prefix : $this->invoice_number_prefix;
$counterOffset = 0;
// confirm the invoice number isn't already taken // confirm the invoice number isn't already taken
do { do {
$number = $prefix.str_pad($counter, 4, "0", STR_PAD_LEFT); $number = $prefix.str_pad($counter, 4, "0", STR_PAD_LEFT);
$check = Invoice::scope(false, $this->id)->whereInvoiceNumber($number)->withTrashed()->first(); $check = Invoice::scope(false, $this->id)->whereInvoiceNumber($number)->withTrashed()->first();
$counter++; $counter++;
$counterOffset++;
} while ($check); } while ($check);
// update the invoice counter to be caught up
if ($counterOffset > 1) {
if ($isQuote && !$this->share_counter) {
$this->quote_number_counter += $counterOffset - 1;
} else {
$this->invoice_number_counter += $counterOffset - 1;
}
$this->save();
}
return $number; return $number;
} }
public function incrementCounter($invoiceNumber, $isQuote = false, $isRecurring) public function incrementCounter($isQuote = false)
{ {
// check if the user modified the invoice number if ($isQuote && !$this->share_counter) {
if (!$isRecurring && $invoiceNumber != $this->getNextInvoiceNumber($isQuote)) { $this->quote_number_counter += 1;
// remove the prefix
$prefix = $isQuote ? $this->quote_number_prefix : $this->invoice_number_prefix;
$invoiceNumber = preg_replace('/^'.$prefix.'/', '', $invoiceNumber);
$invoiceNumber = intval(preg_replace('/[^0-9]/', '', $invoiceNumber));
if ($isQuote && !$this->share_counter) {
$this->quote_number_counter = $invoiceNumber + 1;
} else {
$this->invoice_number_counter = $invoiceNumber + 1;
}
// otherwise, just increment the counter
} else { } else {
if ($isQuote && !$this->share_counter) { $this->invoice_number_counter += 1;
$this->quote_number_counter += 1;
} else {
$this->invoice_number_counter += 1;
}
} }
$this->save(); $this->save();
@ -315,11 +314,11 @@ class Account extends Eloquent
public function isWhiteLabel() public function isWhiteLabel()
{ {
if (Utils::isNinjaProd()) { if (Utils::isNinja()) {
return false; return self::isPro();
} else {
return $this->pro_plan_paid == NINJA_DATE;
} }
return $this->pro_plan_paid == NINJA_DATE;
} }
public function getSubscription($eventId) public function getSubscription($eventId)

View File

@ -258,7 +258,7 @@ class Invoice extends EntityModel
} }
Invoice::creating(function ($invoice) { Invoice::creating(function ($invoice) {
$invoice->account->incrementCounter($invoice->invoice_number, $invoice->is_quote, $invoice->recurring_invoice_id); $invoice->account->incrementCounter($invoice->is_quote);
}); });
Invoice::created(function ($invoice) { Invoice::created(function ($invoice) {

View File

@ -47,7 +47,7 @@ class UserMailer extends Mailer
'clientName' => $invoice->client->getDisplayName(), 'clientName' => $invoice->client->getDisplayName(),
'accountName' => $invoice->account->getDisplayName(), 'accountName' => $invoice->account->getDisplayName(),
'userName' => $user->getDisplayName(), 'userName' => $user->getDisplayName(),
'invoiceAmount' => Utils::formatMoney($invoice->amount, $invoice->client->getCurrencyId()), 'invoiceAmount' => Utils::formatMoney($invoice->getRequestedAmount(), $invoice->client->getCurrencyId()),
'invoiceNumber' => $invoice->invoice_number, 'invoiceNumber' => $invoice->invoice_number,
'invoiceLink' => SITE_URL."/{$entityType}s/{$invoice->public_id}", 'invoiceLink' => SITE_URL."/{$entityType}s/{$invoice->public_id}",
]; ];

View File

@ -266,15 +266,18 @@ class InvoiceRepository
$account->save(); $account->save();
} }
$invoice->client_id = $data['client_id']; if (isset($data['invoice_number'])) {
$invoice->invoice_number = trim($data['invoice_number']);
}
$invoice->discount = round(Utils::parseFloat($data['discount']), 2); $invoice->discount = round(Utils::parseFloat($data['discount']), 2);
$invoice->is_amount_discount = $data['is_amount_discount'] ? true : false; $invoice->is_amount_discount = $data['is_amount_discount'] ? true : false;
$invoice->invoice_number = trim($data['invoice_number']);
$invoice->partial = round(Utils::parseFloat($data['partial']), 2); $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->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; $invoice->has_tasks = isset($data['has_tasks']) ? $data['has_tasks'] : false;
if (!$publicId) { if (!$publicId) {
$invoice->client_id = $data['client_id'];
$invoice->is_recurring = $data['is_recurring'] && !Utils::isDemo() ? true : false; $invoice->is_recurring = $data['is_recurring'] && !Utils::isDemo() ? true : false;
} }
@ -543,8 +546,9 @@ class InvoiceRepository
->whereClientId($clientId) ->whereClientId($clientId)
->whereIsQuote(false) ->whereIsQuote(false)
->whereIsRecurring(false) ->whereIsRecurring(false)
->whereDeletedAt(null)
->whereHasTasks(true) ->whereHasTasks(true)
->where('balance', '>', 0) ->where('invoice_status_id', '<', 5)
->select(['public_id', 'invoice_number']) ->select(['public_id', 'invoice_number'])
->get(); ->get();
} }

View File

@ -31599,7 +31599,10 @@ NINJA.decodeJavascript = function(invoice, javascript)
field = match.substring(2, match.indexOf('Label')); field = match.substring(2, match.indexOf('Label'));
field = toSnakeCase(field); field = toSnakeCase(field);
var value = getDescendantProp(invoice, field); var value = getDescendantProp(invoice, field);
if (match.indexOf('?') < 0) { if (match.indexOf('?') < 0 || value) {
if (invoice.partial && field == 'balance_due') {
field = 'amount_due';
}
var label = invoiceLabels[field]; var label = invoiceLabels[field];
if (match.indexOf('UC') >= 0) { if (match.indexOf('UC') >= 0) {
if (!label) console.log('match: ' + field); if (!label) console.log('match: ' + field);
@ -31663,14 +31666,14 @@ NINJA.invoiceColumns = function(invoice)
NINJA.invoiceLines = function(invoice) { NINJA.invoiceLines = function(invoice) {
var grid = [ var grid = [
[ [
{text: invoiceLabels.item, style: ['tableHeader', 'itemTableHeader']}, {text: invoiceLabels.item, style: ['tableHeader', 'itemTableHeader']},
{text: invoiceLabels.description, style: ['tableHeader', 'descriptionTableHeader']}, {text: invoiceLabels.description, style: ['tableHeader', 'descriptionTableHeader']},
{text: invoiceLabels.unit_cost, style: ['tableHeader', 'costTableHeader']}, {text: invoiceLabels.unit_cost, style: ['tableHeader', 'costTableHeader']},
{text: invoiceLabels.quantity, style: ['tableHeader', 'qtyTableHeader']}, {text: invoiceLabels.quantity, style: ['tableHeader', 'qtyTableHeader']},
{text: invoice.has_taxes ? invoiceLabels.tax : '', style: ['tableHeader', 'taxTableHeader']}, {text: invoice.has_taxes ? invoiceLabels.tax : '', style: ['tableHeader', 'taxTableHeader']},
{text: invoiceLabels.line_total, style: ['tableHeader', 'lineTotalTableHeader']} {text: invoiceLabels.line_total, style: ['tableHeader', 'lineTotalTableHeader']}
] ]
]; ];
var total = 0; var total = 0;
@ -31679,7 +31682,7 @@ NINJA.invoiceLines = function(invoice) {
var hideQuantity = invoice.account.hide_quantity == '1'; var hideQuantity = invoice.account.hide_quantity == '1';
for (var i = 0; i < invoice.invoice_items.length; i++) { for (var i = 0; i < invoice.invoice_items.length; i++) {
var row = []; var row = [];
var item = invoice.invoice_items[i]; var item = invoice.invoice_items[i];
var cost = formatMoney(item.cost, currencyId, true); var cost = formatMoney(item.cost, currencyId, true);
@ -31767,16 +31770,17 @@ NINJA.subtotals = function(invoice, removeBalance)
data.push([{text: account.custom_invoice_label2}, {text: formatMoney(invoice.custom_value2, invoice.client.currency_id)}]); data.push([{text: account.custom_invoice_label2}, {text: formatMoney(invoice.custom_value2, invoice.client.currency_id)}]);
} }
var paid = invoice.amount - invoice.balance; var paid = invoice.amount - invoice.balance;
if (invoice.account.hide_paid_to_date != '1' || paid) { if (invoice.account.hide_paid_to_date != '1' || paid) {
data.push([{text:invoiceLabels.paid_to_date}, {text:formatMoney(paid, invoice.client.currency_id)}]); data.push([{text:invoiceLabels.paid_to_date}, {text:formatMoney(paid, invoice.client.currency_id)}]);
} }
if (!removeBalance) { if (!removeBalance) {
var isPartial = NINJA.parseFloat(invoice.partial);
data.push([ data.push([
{text:invoice.is_quote ? invoiceLabels.balance_due : invoiceLabels.balance_due, style:['balanceDueLabel']}, {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style:['balanceDueLabel']},
{text:formatMoney(invoice.balance_amount, invoice.client.currency_id), style:['balanceDue']} {text: formatMoney(invoice.balance_amount, invoice.client.currency_id), style:['balanceDue']}
]); ]);
} }
return NINJA.prepareDataPairs(data, 'subtotals'); return NINJA.prepareDataPairs(data, 'subtotals');
@ -31785,11 +31789,11 @@ NINJA.subtotals = function(invoice, removeBalance)
NINJA.accountDetails = function(invoice) { NINJA.accountDetails = function(invoice) {
var account = invoice.account; var account = invoice.account;
var data = [ var data = [
{text:account.name, style: ['accountName']}, {text:account.name, style: ['accountName']},
{text:account.id_number}, {text:account.id_number},
{text:account.vat_number}, {text:account.vat_number},
{text:account.work_email}, {text:account.work_email},
{text:account.work_phone} {text:account.work_phone}
]; ];
return NINJA.prepareDataList(data, 'accountDetails'); return NINJA.prepareDataList(data, 'accountDetails');
} }
@ -31801,11 +31805,11 @@ NINJA.accountAddress = function(invoice) {
cityStatePostal = ((account.city ? account.city + ', ' : '') + account.state + ' ' + account.postal_code).trim(); cityStatePostal = ((account.city ? account.city + ', ' : '') + account.state + ' ' + account.postal_code).trim();
} }
var data = [ var data = [
{text: account.address1}, {text: account.address1},
{text: account.address2}, {text: account.address2},
{text: cityStatePostal}, {text: cityStatePostal},
{text: account.country ? account.country.name : ''} {text: account.country ? account.country.name : ''}
]; ];
return NINJA.prepareDataList(data, 'accountAddress'); return NINJA.prepareDataList(data, 'accountAddress');
@ -31814,42 +31818,43 @@ NINJA.accountAddress = function(invoice) {
NINJA.invoiceDetails = function(invoice) { NINJA.invoiceDetails = function(invoice) {
var data = [ var data = [
[ [
{text: (invoice.is_quote ? invoiceLabels.quote_number : invoiceLabels.invoice_number), style: ['invoiceNumberLabel']}, {text: (invoice.is_quote ? invoiceLabels.quote_number : invoiceLabels.invoice_number), style: ['invoiceNumberLabel']},
{text: invoice.invoice_number, style: ['invoiceNumber']} {text: invoice.invoice_number, style: ['invoiceNumber']}
], ],
[ [
{text: invoiceLabels.po_number}, {text: invoiceLabels.po_number},
{text: invoice.po_number} {text: invoice.po_number}
], ],
[ [
{text: invoiceLabels.invoice_date}, {text: (invoice.is_quote ? invoiceLabels.quote_date : invoiceLabels.invoice_date)},
{text: invoice.invoice_date} {text: invoice.invoice_date}
], ],
[ [
{text: invoiceLabels.due_date}, {text: invoiceLabels.due_date},
{text: invoice.due_date} {text: invoice.due_date}
] ]
]; ];
var isPartial = NINJA.parseFloat(invoice.partial);
if (NINJA.parseFloat(invoice.balance) < NINJA.parseFloat(invoice.amount)) { if (NINJA.parseFloat(invoice.balance) < NINJA.parseFloat(invoice.amount)) {
data.push([ data.push([
{text: invoiceLabels.total}, {text: invoiceLabels.total},
{text: formatMoney(invoice.amount, invoice.client.currency_id)} {text: formatMoney(invoice.amount, invoice.client.currency_id)}
]); ]);
} } else if (isPartial) {
if (NINJA.parseFloat(invoice.partial)) {
data.push([ data.push([
{text: invoiceLabels.balance}, {text: invoiceLabels.total},
{text: formatMoney(invoice.total_amount, invoice.client.currency_id)} {text: formatMoney(invoice.total_amount, invoice.client.currency_id)}
]); ]);
} }
data.push([ data.push([
{text: invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']}, {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']},
{text: formatMoney(invoice.balance_amount, invoice.client.currency_id), style: ['invoiceDetailBalanceDue']} {text: formatMoney(invoice.balance_amount, invoice.client.currency_id), style: ['invoiceDetailBalanceDue']}
]) ])
return NINJA.prepareDataPairs(data, 'invoiceDetails'); return NINJA.prepareDataPairs(data, 'invoiceDetails');
} }
@ -31865,11 +31870,11 @@ NINJA.clientDetails = function(invoice) {
var clientEmail = client.contacts[0].email == clientName ? '' : client.contacts[0].email; var clientEmail = client.contacts[0].email == clientName ? '' : client.contacts[0].email;
data = [ data = [
{text:clientName || ' ', style: ['clientName']}, {text:clientName || ' ', style: ['clientName']},
{text:client.address1}, {text:client.address1},
{text:concatStrings(client.city, client.state, client.postal_code)}, {text:concatStrings(client.city, client.state, client.postal_code)},
{text:client.country ? client.country.name : ''}, {text:client.country ? client.country.name : ''},
{text:clientEmail} {text:clientEmail}
]; ];
return NINJA.prepareDataList(data, 'clientDetails'); return NINJA.prepareDataList(data, 'clientDetails');

View File

@ -122,7 +122,10 @@ NINJA.decodeJavascript = function(invoice, javascript)
field = match.substring(2, match.indexOf('Label')); field = match.substring(2, match.indexOf('Label'));
field = toSnakeCase(field); field = toSnakeCase(field);
var value = getDescendantProp(invoice, field); var value = getDescendantProp(invoice, field);
if (match.indexOf('?') < 0) { if (match.indexOf('?') < 0 || value) {
if (invoice.partial && field == 'balance_due') {
field = 'amount_due';
}
var label = invoiceLabels[field]; var label = invoiceLabels[field];
if (match.indexOf('UC') >= 0) { if (match.indexOf('UC') >= 0) {
if (!label) console.log('match: ' + field); if (!label) console.log('match: ' + field);
@ -186,14 +189,14 @@ NINJA.invoiceColumns = function(invoice)
NINJA.invoiceLines = function(invoice) { NINJA.invoiceLines = function(invoice) {
var grid = [ var grid = [
[ [
{text: invoiceLabels.item, style: ['tableHeader', 'itemTableHeader']}, {text: invoiceLabels.item, style: ['tableHeader', 'itemTableHeader']},
{text: invoiceLabels.description, style: ['tableHeader', 'descriptionTableHeader']}, {text: invoiceLabels.description, style: ['tableHeader', 'descriptionTableHeader']},
{text: invoiceLabels.unit_cost, style: ['tableHeader', 'costTableHeader']}, {text: invoiceLabels.unit_cost, style: ['tableHeader', 'costTableHeader']},
{text: invoiceLabels.quantity, style: ['tableHeader', 'qtyTableHeader']}, {text: invoiceLabels.quantity, style: ['tableHeader', 'qtyTableHeader']},
{text: invoice.has_taxes ? invoiceLabels.tax : '', style: ['tableHeader', 'taxTableHeader']}, {text: invoice.has_taxes ? invoiceLabels.tax : '', style: ['tableHeader', 'taxTableHeader']},
{text: invoiceLabels.line_total, style: ['tableHeader', 'lineTotalTableHeader']} {text: invoiceLabels.line_total, style: ['tableHeader', 'lineTotalTableHeader']}
] ]
]; ];
var total = 0; var total = 0;
@ -202,7 +205,7 @@ NINJA.invoiceLines = function(invoice) {
var hideQuantity = invoice.account.hide_quantity == '1'; var hideQuantity = invoice.account.hide_quantity == '1';
for (var i = 0; i < invoice.invoice_items.length; i++) { for (var i = 0; i < invoice.invoice_items.length; i++) {
var row = []; var row = [];
var item = invoice.invoice_items[i]; var item = invoice.invoice_items[i];
var cost = formatMoney(item.cost, currencyId, true); var cost = formatMoney(item.cost, currencyId, true);
@ -290,16 +293,17 @@ NINJA.subtotals = function(invoice, removeBalance)
data.push([{text: account.custom_invoice_label2}, {text: formatMoney(invoice.custom_value2, invoice.client.currency_id)}]); data.push([{text: account.custom_invoice_label2}, {text: formatMoney(invoice.custom_value2, invoice.client.currency_id)}]);
} }
var paid = invoice.amount - invoice.balance; var paid = invoice.amount - invoice.balance;
if (invoice.account.hide_paid_to_date != '1' || paid) { if (invoice.account.hide_paid_to_date != '1' || paid) {
data.push([{text:invoiceLabels.paid_to_date}, {text:formatMoney(paid, invoice.client.currency_id)}]); data.push([{text:invoiceLabels.paid_to_date}, {text:formatMoney(paid, invoice.client.currency_id)}]);
} }
if (!removeBalance) { if (!removeBalance) {
var isPartial = NINJA.parseFloat(invoice.partial);
data.push([ data.push([
{text:invoice.is_quote ? invoiceLabels.balance_due : invoiceLabels.balance_due, style:['balanceDueLabel']}, {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style:['balanceDueLabel']},
{text:formatMoney(invoice.balance_amount, invoice.client.currency_id), style:['balanceDue']} {text: formatMoney(invoice.balance_amount, invoice.client.currency_id), style:['balanceDue']}
]); ]);
} }
return NINJA.prepareDataPairs(data, 'subtotals'); return NINJA.prepareDataPairs(data, 'subtotals');
@ -308,11 +312,11 @@ NINJA.subtotals = function(invoice, removeBalance)
NINJA.accountDetails = function(invoice) { NINJA.accountDetails = function(invoice) {
var account = invoice.account; var account = invoice.account;
var data = [ var data = [
{text:account.name, style: ['accountName']}, {text:account.name, style: ['accountName']},
{text:account.id_number}, {text:account.id_number},
{text:account.vat_number}, {text:account.vat_number},
{text:account.work_email}, {text:account.work_email},
{text:account.work_phone} {text:account.work_phone}
]; ];
return NINJA.prepareDataList(data, 'accountDetails'); return NINJA.prepareDataList(data, 'accountDetails');
} }
@ -324,11 +328,11 @@ NINJA.accountAddress = function(invoice) {
cityStatePostal = ((account.city ? account.city + ', ' : '') + account.state + ' ' + account.postal_code).trim(); cityStatePostal = ((account.city ? account.city + ', ' : '') + account.state + ' ' + account.postal_code).trim();
} }
var data = [ var data = [
{text: account.address1}, {text: account.address1},
{text: account.address2}, {text: account.address2},
{text: cityStatePostal}, {text: cityStatePostal},
{text: account.country ? account.country.name : ''} {text: account.country ? account.country.name : ''}
]; ];
return NINJA.prepareDataList(data, 'accountAddress'); return NINJA.prepareDataList(data, 'accountAddress');
@ -337,42 +341,43 @@ NINJA.accountAddress = function(invoice) {
NINJA.invoiceDetails = function(invoice) { NINJA.invoiceDetails = function(invoice) {
var data = [ var data = [
[ [
{text: (invoice.is_quote ? invoiceLabels.quote_number : invoiceLabels.invoice_number), style: ['invoiceNumberLabel']}, {text: (invoice.is_quote ? invoiceLabels.quote_number : invoiceLabels.invoice_number), style: ['invoiceNumberLabel']},
{text: invoice.invoice_number, style: ['invoiceNumber']} {text: invoice.invoice_number, style: ['invoiceNumber']}
], ],
[ [
{text: invoiceLabels.po_number}, {text: invoiceLabels.po_number},
{text: invoice.po_number} {text: invoice.po_number}
], ],
[ [
{text: invoiceLabels.invoice_date}, {text: (invoice.is_quote ? invoiceLabels.quote_date : invoiceLabels.invoice_date)},
{text: invoice.invoice_date} {text: invoice.invoice_date}
], ],
[ [
{text: invoiceLabels.due_date}, {text: invoiceLabels.due_date},
{text: invoice.due_date} {text: invoice.due_date}
] ]
]; ];
var isPartial = NINJA.parseFloat(invoice.partial);
if (NINJA.parseFloat(invoice.balance) < NINJA.parseFloat(invoice.amount)) { if (NINJA.parseFloat(invoice.balance) < NINJA.parseFloat(invoice.amount)) {
data.push([ data.push([
{text: invoiceLabels.total}, {text: invoiceLabels.total},
{text: formatMoney(invoice.amount, invoice.client.currency_id)} {text: formatMoney(invoice.amount, invoice.client.currency_id)}
]); ]);
} } else if (isPartial) {
if (NINJA.parseFloat(invoice.partial)) {
data.push([ data.push([
{text: invoiceLabels.balance}, {text: invoiceLabels.total},
{text: formatMoney(invoice.total_amount, invoice.client.currency_id)} {text: formatMoney(invoice.total_amount, invoice.client.currency_id)}
]); ]);
} }
data.push([ data.push([
{text: invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']}, {text: isPartial ? invoiceLabels.amount_due : invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']},
{text: formatMoney(invoice.balance_amount, invoice.client.currency_id), style: ['invoiceDetailBalanceDue']} {text: formatMoney(invoice.balance_amount, invoice.client.currency_id), style: ['invoiceDetailBalanceDue']}
]) ])
return NINJA.prepareDataPairs(data, 'invoiceDetails'); return NINJA.prepareDataPairs(data, 'invoiceDetails');
} }
@ -388,11 +393,11 @@ NINJA.clientDetails = function(invoice) {
var clientEmail = client.contacts[0].email == clientName ? '' : client.contacts[0].email; var clientEmail = client.contacts[0].email == clientName ? '' : client.contacts[0].email;
data = [ data = [
{text:clientName || ' ', style: ['clientName']}, {text:clientName || ' ', style: ['clientName']},
{text:client.address1}, {text:client.address1},
{text:concatStrings(client.city, client.state, client.postal_code)}, {text:concatStrings(client.city, client.state, client.postal_code)},
{text:client.country ? client.country.name : ''}, {text:client.country ? client.country.name : ''},
{text:clientEmail} {text:clientEmail}
]; ];
return NINJA.prepareDataList(data, 'clientDetails'); return NINJA.prepareDataList(data, 'clientDetails');

View File

@ -698,9 +698,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -688,9 +688,9 @@ return array(
'email_receipt' => 'Zahlungsbestätigung an Kunden per E-Mail senden', 'email_receipt' => 'Zahlungsbestätigung an Kunden per E-Mail senden',
'created_payment_emailed_client' => 'Zahlung erfolgreich erstellt und Kunde per E-Mail benachrichtigt', 'created_payment_emailed_client' => 'Zahlung erfolgreich erstellt und Kunde per E-Mail benachrichtigt',
'add_account' => 'Konto hinzufügen', 'add_company' => 'Konto hinzufügen',
'untitled' => 'Unbenannt', 'untitled' => 'Unbenannt',
'new_account' => 'Neues Konto', 'new_company' => 'Neues Konto',
'associated_accounts' => 'Konten erfolgreich verlinkt', 'associated_accounts' => 'Konten erfolgreich verlinkt',
'unlinked_account' => 'Konten erfolgreich getrennt', 'unlinked_account' => 'Konten erfolgreich getrennt',
'login' => 'Login', 'login' => 'Login',

View File

@ -696,9 +696,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -668,9 +668,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -697,9 +697,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -689,9 +689,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Paiement crée avec succès et envoyé au client', 'created_payment_emailed_client' => 'Paiement crée avec succès et envoyé au client',
'add_account' => 'Ajouter compte', 'add_company' => 'Ajouter compte',
'untitled' => 'Sans titre', 'untitled' => 'Sans titre',
'new_account' => 'Nouveau compte', 'new_company' => 'Nouveau compte',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Connexion', 'login' => 'Connexion',

View File

@ -690,9 +690,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -692,9 +692,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -699,9 +699,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -697,9 +697,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -692,9 +692,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -692,9 +692,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -695,9 +695,9 @@ return array(
'email_receipt' => 'Email payment receipt to the client', 'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client', 'created_payment_emailed_client' => 'Successfully created payment and emailed client',
'add_account' => 'Add Account', 'add_company' => 'Add Company',
'untitled' => 'Untitled', 'untitled' => 'Untitled',
'new_account' => 'New Account', 'new_company' => 'New Company',
'associated_accounts' => 'Successfully linked accounts', 'associated_accounts' => 'Successfully linked accounts',
'unlinked_account' => 'Successfully unlinked accounts', 'unlinked_account' => 'Successfully unlinked accounts',
'login' => 'Login', 'login' => 'Login',

View File

@ -18,12 +18,12 @@
{{ Former::populate($account) }} {{ Former::populate($account) }}
@if ($showUser) @if ($showUser)
{{ Former::populateField('first_name', $account->users()->first()->first_name) }} {{ Former::populateField('first_name', $primaryUser->first_name) }}
{{ Former::populateField('last_name', $account->users()->first()->last_name) }} {{ Former::populateField('last_name', $primaryUser->last_name) }}
{{ Former::populateField('email', $account->users()->first()->email) }} {{ Former::populateField('email', $primaryUser->email) }}
{{ Former::populateField('phone', $account->users()->first()->phone) }} {{ Former::populateField('phone', $primaryUser->phone) }}
@if (Utils::isNinja()) @if (Utils::isNinja())
{{ Former::populateField('dark_mode', intval($account->users()->first()->dark_mode)) }} {{ Former::populateField('dark_mode', intval($primaryUser->dark_mode)) }}
@endif @endif
@endif @endif

View File

@ -79,11 +79,11 @@
{!! Former::hidden('remember')->raw() !!} {!! Former::hidden('remember')->raw() !!}
</p> </p>
<p>{!! Button::success(trans(Input::get('new_account') && Utils::allowNewAccounts() ? 'texts.login' : 'texts.lets_go'))->large()->submit()->block() !!}</p> <p>{!! Button::success(trans(Input::get('new_company') ? 'texts.login' : 'texts.lets_go'))->large()->submit()->block() !!}</p>
@if (Input::get('new_account') && Utils::allowNewAccounts()) @if (Input::get('new_company') && Utils::allowNewAccounts())
<center><p>- {{ trans('texts.or') }} -</p></center> <center><p>- {{ trans('texts.or') }} -</p></center>
<p>{!! Button::primary(trans('texts.new_account'))->asLinkTo(URL::to('/invoice_now?new_account=true'))->large()->submit()->block() !!}</p> <p>{!! Button::primary(trans('texts.new_company'))->asLinkTo(URL::to('/invoice_now?new_company=true&sign_up=true'))->large()->submit()->block() !!}</p>
@endif @endif

View File

@ -427,7 +427,7 @@
@endif @endif
<li class="divider"></li> <li class="divider"></li>
@if (!session(SESSION_USER_ACCOUNTS) || count(session(SESSION_USER_ACCOUNTS)) < 5) @if (!session(SESSION_USER_ACCOUNTS) || count(session(SESSION_USER_ACCOUNTS)) < 5)
<li>{!! link_to('/login?new_account=true', trans('texts.add_account')) !!}</li> <li>{!! link_to('/login?new_company=true', trans('texts.add_company')) !!}</li>
@endif @endif
<li>{!! link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) !!}</li> <li>{!! link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) !!}</li>
</ul> </ul>
@ -462,7 +462,9 @@
<li><a href="#">{{ trans('texts.no_items') }}</a></li> <li><a href="#">{{ trans('texts.no_items') }}</a></li>
@else @else
@foreach (Session::get(RECENTLY_VIEWED) as $link) @foreach (Session::get(RECENTLY_VIEWED) as $link)
<li><a href="{{ $link->url }}">{{ $link->name }}</a></li> @if (property_exists($link, 'accountId') && $link->accountId == Auth::user()->account_id)
<li><a href="{{ $link->url }}">{{ $link->name }}</a></li>
@endif
@endforeach @endforeach
@endif @endif
</ul> </ul>

View File

@ -6,7 +6,7 @@
@endif @endif
@if (isset($show_remove) && $show_remove) @if (isset($show_remove) && $show_remove)
<div class="pull-right glyphicon glyphicon-remove remove" onclick="return showUnlink({{ $user_account_id }}, {{ $user_id }})"></div> <div class="pull-right glyphicon glyphicon-remove remove" onclick="return showUnlink({{ $user_account_id }}, {{ $user_id }})" title="{{ trans('texts.unlink') }}"></div>
@endif @endif
@if (file_exists('logo/'.$account_key.'.jpg')) @if (file_exists('logo/'.$account_key.'.jpg'))