From 6f9a04ca649fd3eb3b0a9c8e1a02704153acf0e0 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 22 Jan 2014 09:11:33 +0000 Subject: [PATCH] bug fixes --- app/controllers/AccountController.php | 46 ++++++++++++++++----------- app/routes.php | 6 ++-- app/views/invoices/edit.blade.php | 10 +++--- public/js/script.js | 24 ++++++++------ 4 files changed, 51 insertions(+), 35 deletions(-) diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index c19d66e3618e..e14db64eb26d 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -203,9 +203,11 @@ class AccountController extends \BaseController { $count = 0; $hasHeaders = Input::get('header_checkbox'); - $countries = Country::remember(DEFAULT_QUERY_CACHE)->all(); + $countries = Country::remember(DEFAULT_QUERY_CACHE)->get(); $countryMap = []; - foreach ($countries as $country) { + + foreach ($countries as $country) + { $countryMap[strtolower($country->name)] = $country->id; } @@ -219,6 +221,7 @@ class AccountController extends \BaseController { $client = Client::createNew(); $contact = Contact::createNew(); + $contact->is_primary = true; $count++; foreach ($row as $index => $value) @@ -226,56 +229,56 @@ class AccountController extends \BaseController { $field = $map[$index]; $value = trim($value); - if ($field == Client::$fieldName) + if ($field == Client::$fieldName && !$client->name) { $client->name = $value; } - else if ($field == Client::$fieldPhone) + else if ($field == Client::$fieldPhone && !$client->work_phone) { $client->work_phone = $value; } - else if ($field == Client::$fieldAddress1) + else if ($field == Client::$fieldAddress1 && !$client->address1) { $client->address1 = $value; } - else if ($field == Client::$fieldAddress2) + else if ($field == Client::$fieldAddress2 && !$client->address2) { $client->address2 = $value; } - else if ($field == Client::$fieldCity) + else if ($field == Client::$fieldCity && !$client->city) { $client->city = $value; } - else if ($field == Client::$fieldState) + else if ($field == Client::$fieldState && !$client->state) { $client->state = $value; } - else if ($field == Client::$fieldPostalCode) + else if ($field == Client::$fieldPostalCode && !$client->postal_code) { $client->postal_code = $value; } - else if ($field == Client::$fieldCountry) + else if ($field == Client::$fieldCountry && !$client->country_id) { $value = strtolower($value); $client->country_id = isset($countryMap[$value]) ? $countryMap[$value] : null; } - else if ($field == Client::$fieldNotes) + else if ($field == Client::$fieldNotes && !$client->private_notes) { - $client->notes = $value; + $client->private_notes = $value; } - else if ($field == Contact::$fieldFirstName) + else if ($field == Contact::$fieldFirstName && !$contact->first_name) { $contact->first_name = $value; } - else if ($field == Contact::$fieldLastName) + else if ($field == Contact::$fieldLastName && !$contact->last_name) { $contact->last_name = $value; } - else if ($field == Contact::$fieldPhone) + else if ($field == Contact::$fieldPhone && !$contact->phone) { $contact->phone = $value; } - else if ($field == Contact::$fieldEmail) + else if ($field == Contact::$fieldEmail && !$contact->email) { $contact->email = $value; } @@ -347,10 +350,10 @@ class AccountController extends \BaseController { 'mobile' => Contact::$fieldPhone, 'phone' => Client::$fieldPhone, 'name|organization' => Client::$fieldName, - 'address|address1' => Client::$fieldAddress1, - 'address2' => Client::$fieldAddress2, + 'street|address|address1' => Client::$fieldAddress1, + 'street2|address2' => Client::$fieldAddress2, 'city' => Client::$fieldCity, - 'state' => Client::$fieldState, + 'state|province' => Client::$fieldState, 'zip|postal|code' => Client::$fieldPostalCode, 'country' => Client::$fieldCountry, 'note' => Client::$fieldNotes, @@ -360,6 +363,11 @@ class AccountController extends \BaseController { { foreach(explode("|", $search) as $string) { + if (strpos($title, 'sec') === 0) + { + continue; + } + if (strpos($title, $string) !== false) { $mapped[$i] = $column; diff --git a/app/routes.php b/app/routes.php index ac2b1c24f339..44960731817f 100755 --- a/app/routes.php +++ b/app/routes.php @@ -55,8 +55,10 @@ Route::get('/send_emails', function() { }); */ -//Route::get('/', 'HomeController@showComingSoon'); -Route::get('/', 'HomeController@showWelcome'); +Route::get('/', function() { + return Redirect::to('http://signup.invoiceninja.com'); +}); + Route::get('/rocksteady', 'HomeController@showWelcome'); diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index 093ebb7edc3e..d9918069d51d 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -13,7 +13,7 @@ {{ Former::open($url)->method($method)->addClass('main_form')->rules(array( 'client' => 'required', 'email' => 'required', - 'product_key' => 'max:14', + 'product_key' => 'max:20', )); }}
@@ -47,7 +47,7 @@
@@ -80,7 +80,7 @@
{{ Former::text('invoice_number')->label('Invoice #')->data_bind("value: invoice_number, valueUpdate: 'afterkeydown'") }} {{ Former::text('po_number')->label('PO #')->data_bind("value: po_number, valueUpdate: 'afterkeydown'") }} - {{ Former::text('discount')->data_bind("value: discount, valueUpdate: 'afterkeydown'") }} + {{ Former::text('discount')->data_bind("value: discount, valueUpdate: 'afterkeydown'")->append('%') }} {{-- Former::select('currency_id')->label('Currency')->addOption('', '')->fromQuery($currencies, 'name', 'id')->data_bind("value: currency_id") --}}
@@ -115,7 +115,7 @@ - + {{ Former::text('product_key')->useDatalist(Product::getProductKeys($products), 'key')->onkeyup('onItemChange()') ->raw()->data_bind("value: product_key, valueUpdate: 'afterkeydown'")->addClass('datalist') }} @@ -1208,7 +1208,7 @@ self.email.display = ko.computed(function() { var str = ''; if (self.first_name() || self.last_name()) { - str += self.first_name() + ' ' + self.last_name() + ' - '; + str += self.first_name() + ' ' + self.last_name() + '
'; } return str + self.email(); }); diff --git a/public/js/script.js b/public/js/script.js index 5bb915f004cf..171a926ece8e 100755 --- a/public/js/script.js +++ b/public/js/script.js @@ -15,23 +15,23 @@ function generatePDF(invoice, checkMath) { var invoiceDate = invoice.invoice_date ? invoice.invoice_date : ''; var dueDate = invoice.due_date ? invoice.due_date : ''; - var marginLeft = 60; + var marginLeft = 50; var accountTop = 30; var headerTop = 140; var headerLeft = 360; - var headerRight = 540; + var headerRight = 550; var rowHeight = 15; var tableRowHeight = 20; var footerLeft = 420; var tablePadding = 6; var tableTop = 240; - var tableLeft = 60; - var descriptionLeft = 150; - var unitCostRight = 400; - var qtyRight = 470; - var taxRight = 470; - var lineTotalRight = 540; + var tableLeft = 50; + var descriptionLeft = 162; + var unitCostRight = 410; + var qtyRight = 480; + var taxRight = 480; + var lineTotalRight = 550; var hasTaxes = false; @@ -297,7 +297,13 @@ function generatePDF(invoice, checkMath) { console.log('%s %s %s', lineTotalRight, tableLeft, (lineTotalRight-tableLeft)); doc.text(tableLeft, x+16, invoice.public_notes); - doc.text(tableLeft, x+16 + (doc.splitTextToSize(invoice.public_notes, 340).length * rowHeight) + (rowHeight/2), invoice.terms); + if (invoice.terms) { + var termsX = x+16 + (doc.splitTextToSize(invoice.public_notes, 340).length * rowHeight) + (rowHeight/2); + doc.setFontType("bold"); + doc.text(tableLeft, termsX, "Terms"); + doc.setFontType("normal"); + doc.text(tableLeft, termsX + rowHeight, invoice.terms); + } x += 16; doc.text(footerLeft, x, 'Subtotal');