From 0e15c122986c1669da96a6296b1280319d95da64 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 11 Aug 2015 17:38:36 +0300 Subject: [PATCH] Bug fixes --- app/Console/Commands/SendRecurringInvoices.php | 8 ++++++-- app/Http/Controllers/InvoiceController.php | 4 +++- app/Http/Controllers/ReportController.php | 4 +++- app/Http/routes.php | 1 + app/Models/Account.php | 13 +++++++++++-- app/Ninja/Repositories/TaskRepository.php | 12 +++++++++--- resources/views/accounts/email_templates.blade.php | 2 +- resources/views/header.blade.php | 6 +++--- resources/views/invoices/edit.blade.php | 14 ++++++++++---- resources/views/invoices/pdf.blade.php | 1 + resources/views/reports/d3.blade.php | 2 +- resources/views/tasks/edit.blade.php | 12 ++++-------- 12 files changed, 53 insertions(+), 26 deletions(-) diff --git a/app/Console/Commands/SendRecurringInvoices.php b/app/Console/Commands/SendRecurringInvoices.php index 8f31473c9eca..6acd87aa0c6e 100644 --- a/app/Console/Commands/SendRecurringInvoices.php +++ b/app/Console/Commands/SendRecurringInvoices.php @@ -39,8 +39,12 @@ class SendRecurringInvoices extends Command foreach ($invoices as $recurInvoice) { $this->info('Processing Invoice '.$recurInvoice->id.' - Should send '.($recurInvoice->shouldSendToday() ? 'YES' : 'NO')); - $this->invoiceRepo->createRecurringInvoice($recurInvoice); - $this->mailer->sendInvoice($invoice); + $invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice); + + if ($invoice) { + $recurInvoice->account->loadLocalizationSettings(); + $this->mailer->sendInvoice($invoice); + } } $this->info('Done'); diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index efed3effd150..6426333f1d5b 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -214,6 +214,8 @@ class InvoiceController extends BaseController if ($invoice->invoice_design_id == CUSTOM_DESIGN) { $invoice->invoice_design->javascript = $account->custom_design; + } elseif ($account->utf8_invoices) { + $invoice->invoice_design->javascript = $invoice->invoice_design->pdfmake; } $contact = $invitation->contact; @@ -253,7 +255,7 @@ class InvoiceController extends BaseController 'invoiceLabels' => $account->getInvoiceLabels(), 'contact' => $contact, 'paymentTypes' => $paymentTypes, - 'paymentURL' => $paymentURL + 'paymentURL' => $paymentURL, ); return View::make('invoices.view', $data); diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index da37c9eb9bec..dfd7a96470b3 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -20,7 +20,9 @@ class ReportController extends BaseController $fileName = storage_path() . '/dataviz_sample.txt'; if (Auth::user()->account->isPro()) { - $account = Account::where('id', '=', Auth::user()->account->id)->with(['clients.invoices.invoice_items', 'clients.contacts'])->first(); + $account = Account::where('id', '=', Auth::user()->account->id) + ->with(['clients.invoices.invoice_items', 'clients.contacts']) + ->first(); $account = $account->hideFieldsForViz(); $clients = $account->clients->toJson(); } elseif (file_exists($fileName)) { diff --git a/app/Http/routes.php b/app/Http/routes.php index 7c158a314490..f7c829070f3a 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -326,6 +326,7 @@ define('SESSION_LAST_REQUEST_TIME', 'SESSION_LAST_REQUEST_TIME'); define('DEFAULT_TIMEZONE', 'US/Eastern'); define('DEFAULT_CURRENCY', 1); // US Dollar +define('DEFAULT_LANGUAGE', 1); // English define('DEFAULT_DATE_FORMAT', 'M j, Y'); define('DEFAULT_DATE_PICKER_FORMAT', 'M d, yyyy'); define('DEFAULT_DATETIME_FORMAT', 'F j, Y, g:i a'); diff --git a/app/Models/Account.php b/app/Models/Account.php index ee88e2fd1fcb..243715ceaadd 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -4,7 +4,7 @@ use Eloquent; use Utils; use Session; use DateTime; - +use App; use Illuminate\Database\Eloquent\SoftDeletes; class Account extends Eloquent @@ -92,6 +92,11 @@ class Account extends Eloquent } } + public function isEnglish() + { + return !$this->language_id || $this->language_id == DEFAULT_LANGUAGE; + } + public function getDisplayName() { if ($this->name) { @@ -229,6 +234,8 @@ class Account extends Eloquent Session::put(SESSION_DATETIME_FORMAT, $this->datetime_format ? $this->datetime_format->format : DEFAULT_DATETIME_FORMAT); Session::put(SESSION_CURRENCY, $this->currency_id ? $this->currency_id : DEFAULT_CURRENCY); Session::put(SESSION_LOCALE, $this->language_id ? $this->language->locale : DEFAULT_LOCALE); + + App::setLocale(session(SESSION_LOCALE)); } public function getInvoiceLabels() @@ -277,7 +284,7 @@ class Account extends Eloquent if (isset($custom[$field]) && $custom[$field]) { $data[$field] = $custom[$field]; } else { - $data[$field] = uctrans("texts.$field"); + $data[$field] = $this->isEnglish() ? uctrans("texts.$field") : trans("texts.$field"); } } @@ -348,6 +355,8 @@ class Account extends Eloquent 'invoice_status_id', 'invoice_items', 'created_at', + 'is_recurring', + 'is_quote', ]); foreach ($invoice->invoice_items as $invoiceItem) { diff --git a/app/Ninja/Repositories/TaskRepository.php b/app/Ninja/Repositories/TaskRepository.php index 4504e78fb7fa..47761900e1e6 100644 --- a/app/Ninja/Repositories/TaskRepository.php +++ b/app/Ninja/Repositories/TaskRepository.php @@ -46,7 +46,7 @@ class TaskRepository } public function save($publicId, $data) - { + { if ($publicId) { $task = Task::scope($publicId)->firstOrFail(); } else { @@ -60,8 +60,14 @@ class TaskRepository $task->description = trim($data['description']); } - //$timeLog = $task->time_log ? json_decode($task->time_log, true) : []; - $timeLog = isset($data['time_log']) ? json_decode($data['time_log']) : []; + if (isset($data['time_log'])) { + $timeLog = json_decode($data['time_log']); + } elseif ($task->time_log) { + $timeLog = json_decode($task->time_log); + } else { + $timeLog = []; + } + if ($data['action'] == 'start') { $task->is_running = true; $timeLog[] = [strtotime('now'), false]; diff --git a/resources/views/accounts/email_templates.blade.php b/resources/views/accounts/email_templates.blade.php index ab30b19016db..4e29172b6dc7 100644 --- a/resources/views/accounts/email_templates.blade.php +++ b/resources/views/accounts/email_templates.blade.php @@ -108,7 +108,7 @@ } keys = ['footer', 'account', 'client', 'amount', 'link', 'contact']; - vals = [{!! json_encode($emailFooter) !!}, '{!! Auth::user()->account->getDisplayName() !!}', 'Client Name', formatMoney(100), '{!! NINJA_WEB_URL !!}', 'Contact Name']; + vals = [{!! json_encode($emailFooter) !!}, '{!! Auth::user()->account->getDisplayName() !!}', 'Client Name', formatMoney(100), '{!! SITE_URL . '/view/...' !!}', 'Contact Name']; // Add any available payment method links @foreach (\App\Models\Gateway::getPaymentTypeLinks() as $type) diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 6925992c315f..14ba1419e094 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -253,12 +253,12 @@ }, 2000); $('#search').blur(function(){ - $('#search').css('width', '{{ Utils::isEnglish() ? 150 : 100 }}px'); + $('#search').css('width', '{{ Utils::isEnglish() ? 150 : 110 }}px'); $('ul.navbar-right').show(); }); $('#search').focus(function(){ - $('#search').css('width', '{{ Utils::isEnglish() ? 256 : 206 }}px'); + $('#search').css('width', '{{ Utils::isEnglish() ? 256 : 216 }}px'); $('ul.navbar-right').hide(); if (!window.hasOwnProperty('searchData')) { $.get('{{ URL::route('getSearchData') }}', function(data) { @@ -460,7 +460,7 @@ diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 109085992d2a..35c889e7eddf 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -57,7 +57,7 @@
- + | {{ trans('texts.view_client') }} @@ -673,9 +673,15 @@ var product = products[i]; if (product.product_key == key) { var model = ko.dataFor(this); - model.notes(product.notes); - model.cost(accounting.toFixed(product.cost,2)); - model.qty(1); + if (!model.notes()) { + model.notes(product.notes); + } + if (!model.cost()) { + model.cost(accounting.toFixed(product.cost,2)); + } + if (!model.qty()) { + model.qty(1); + } break; } } diff --git a/resources/views/invoices/pdf.blade.php b/resources/views/invoices/pdf.blade.php index 2af394e8ec9d..f60e7ac096d2 100644 --- a/resources/views/invoices/pdf.blade.php +++ b/resources/views/invoices/pdf.blade.php @@ -74,6 +74,7 @@ var NINJA = NINJA || {}; NINJA.primaryColor = "{{ $account->primary_color }}"; NINJA.secondaryColor = "{{ $account->secondary_color }}"; + NINJA.fontSize = {{ $account->font_size }}; var invoiceLabels = {!! json_encode($account->getInvoiceLabels()) !!}; diff --git a/resources/views/reports/d3.blade.php b/resources/views/reports/d3.blade.php index 4ca78569c71f..0b75bef85cb9 100644 --- a/resources/views/reports/d3.blade.php +++ b/resources/views/reports/d3.blade.php @@ -75,7 +75,7 @@ // remove quotes and recurring invoices invoices = _.filter(invoices, function(invoice) { - return !parseInt(invoice.is_quote) && !parseInt(invoice.is_recurring); + return !parseInt(invoice.is_quote) && !invoice.is_recurring; }); var products = _.flatten(_.pluck(invoices, 'invoice_items')); diff --git a/resources/views/tasks/edit.blade.php b/resources/views/tasks/edit.blade.php index 294b85af80a5..cb89585622c1 100644 --- a/resources/views/tasks/edit.blade.php +++ b/resources/views/tasks/edit.blade.php @@ -4,10 +4,9 @@ @@ -79,13 +78,13 @@
+ class="form-control time-input" placeholder="{{ trans('texts.start_time') }}"/>
+ class="form-control time-input" placeholder="{{ trans('texts.end_time') }}"/>
@@ -202,9 +201,6 @@ } function TimeModel(data) { - console.log('== TimeModel =='); - console.log(data); - var self = this; self.startTime = ko.observable(0); self.endTime = ko.observable(0);