From 2b56c8a2992a62f651deb8e397800530ebf6b590 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 7 Jan 2014 23:59:06 +0000 Subject: [PATCH] bug fixes --- README.md | 4 +- app/controllers/ActivityController.php | 4 +- app/controllers/ClientController.php | 16 +-- app/controllers/CreditController.php | 1 - app/controllers/InvoiceController.php | 4 +- app/controllers/PaymentController.php | 1 - app/database/seeds/ConstantsSeeder.php | 3 +- app/models/Activity.php | 115 +++++++++++---- app/models/Client.php | 10 ++ app/ninja/mailers/ContactMailer.php | 6 + app/ninja/mailers/Mailer.php | 11 +- app/ninja/mailers/UserMailer.php | 2 +- app/ninja/repositories/ClientRepository.php | 18 +++ app/routes.php | 38 ++--- app/views/invoices/edit.blade.php | 33 ++++- composer.lock | 148 ++++++++++---------- public/js/script.js | 15 +- 17 files changed, 267 insertions(+), 162 deletions(-) diff --git a/README.md b/README.md index b242e5f6ed..3e58e69292 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Invoice Ninja ## Simple, Intuitive Invoicing -### Live demo: [http://invoice-ninja.eu1.frbit.net](http://invoice-ninja.eu1.frbit.net) +### Live demo: [http://invoiceninja.eu1.frbit.net](http://invoiceninja.eu1.frbit.net) ### Introduction Most online invoicing sites are expensive. They shouldn't be. The aim of this project is to provide a free, open-source alternative. Additionally, the hope is this codebase will serve as a sample site for Laravel as well as other JavaScript technologies. @@ -9,11 +9,13 @@ Most online invoicing sites are expensive. They shouldn't be. The aim of this pr ### Features * Core application built using Laravel 4.1 * Invoice PDF generation directly in the browser +* Tax rates and payment terms * Integrates with many payment providers * Recurring invoices ### Remaining Work * Home dashboard +* Multiple language support * Reports ### Steps to setup diff --git a/app/controllers/ActivityController.php b/app/controllers/ActivityController.php index 712d929d80..cd341d273d 100755 --- a/app/controllers/ActivityController.php +++ b/app/controllers/ActivityController.php @@ -9,14 +9,12 @@ class ActivityController extends \BaseController { ->where('clients.public_id', '=', $clientPublicId) ->where('activities.account_id', '=', Auth::user()->account_id) ->select('activities.message', 'activities.created_at', 'activities.currency_id', 'activities.balance', 'activities.adjustment'); - return Datatable::query($query) - ->addColumn('date', function($model) { return Utils::timestampToDateTimeString(strtotime($model->created_at)); }) + ->addColumn('created_at', function($model) { return Utils::timestampToDateTimeString(strtotime($model->created_at)); }) ->addColumn('message', function($model) { return $model->message; }) ->addColumn('balance', function($model) { return Utils::formatMoney($model->balance, $model->currency_id); }) ->addColumn('adjustment', function($model) { return $model->adjustment != 0 ? Utils::formatMoney($model->adjustment, $model->currency_id) : ''; }) - ->orderColumns('date') ->make(); } diff --git a/app/controllers/ClientController.php b/app/controllers/ClientController.php index a97f8129b8..7fc7bf94c9 100755 --- a/app/controllers/ClientController.php +++ b/app/controllers/ClientController.php @@ -57,7 +57,6 @@ class ClientController extends \BaseController { '; }) - ->orderColumns('name','first_name','balance','last_login','created_at','email','phone') ->make(); } @@ -230,20 +229,9 @@ class ClientController extends \BaseController { { $action = Input::get('action'); $ids = Input::get('id') ? Input::get('id') : Input::get('ids'); - $clients = Client::scope($ids)->get(); + $count = $this->clientRepo->bulk($ids, $action); - foreach ($clients as $client) - { - if ($action == 'delete') - { - $client->is_deleted = true; - $client->save(); - } - - $client->delete(); - } - - $message = Utils::pluralize('Successfully '.$action.'d ? client', count($clients)); + $message = Utils::pluralize('Successfully '.$action.'d ? client', $count); Session::flash('message', $message); return Redirect::to('clients'); diff --git a/app/controllers/CreditController.php b/app/controllers/CreditController.php index 9f0e129edf..e769c51c34 100755 --- a/app/controllers/CreditController.php +++ b/app/controllers/CreditController.php @@ -53,7 +53,6 @@ class CreditController extends \BaseController { '; }) - ->orderColumns('number') ->make(); } diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index 380bec4139..bc40a8c872 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -73,7 +73,6 @@ class InvoiceController extends \BaseController { '; }) - ->orderColumns('invoice_number','client','total','balance','invoice_date','due_date','invoice_status_name') ->make(); } @@ -109,7 +108,6 @@ class InvoiceController extends \BaseController { '; }) - ->orderColumns('client','total','frequency','start_date','end_date') ->make(); } @@ -444,7 +442,7 @@ class InvoiceController extends \BaseController { } else if ($action == 'email') { - $this->mailer->sendInvoice($invoice); + $this->mailer->sendInvoice($invoice); Session::flash('message', 'Successfully emailed invoice'.$message); } else diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index 35f574f1fd..78d7c968af 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -52,7 +52,6 @@ class PaymentController extends \BaseController '; }) - ->orderColumns('transaction_reference', 'client_name', 'invoice_number', 'amount', 'payment_date') ->make(); } diff --git a/app/database/seeds/ConstantsSeeder.php b/app/database/seeds/ConstantsSeeder.php index 9b525cfd46..3b025ac561 100755 --- a/app/database/seeds/ConstantsSeeder.php +++ b/app/database/seeds/ConstantsSeeder.php @@ -88,7 +88,8 @@ class ConstantsSeeder extends Seeder Industry::create(array('name' => 'Transportation')); Industry::create(array('name' => 'Travel & Luxury')); - Size::create(array('name' => '1 - 10')); + Size::create(array('name' => '1 = 3')); + Size::create(array('name' => '4 - 10')); Size::create(array('name' => '11 - 50')); Size::create(array('name' => '51 - 100')); Size::create(array('name' => '101 - 500')); diff --git a/app/models/Activity.php b/app/models/Activity.php index 8a1f61dc71..28d895d9f9 100755 --- a/app/models/Activity.php +++ b/app/models/Activity.php @@ -57,14 +57,29 @@ class Activity extends Eloquent $activity->save(); } + public static function updateClient($client) + { + if ($client->is_deleted && !$client->getOriginal('is_deleted')) + { + $activity = Activity::getBlank(); + $activity->client_id = $client->id; + $activity->activity_type_id = ACTIVITY_TYPE_DELETE_CLIENT; + $activity->message = Auth::user()->getFullName() . ' deleted client ' . link_to('clients/'.$client->public_id, $client->name); + $activity->save(); + } + } + public static function archiveClient($client) { - $activity = Activity::getBlank(); - $activity->client_id = $client->id; - $activity->activity_type_id = ACTIVITY_TYPE_ARCHIVE_CLIENT; - $activity->message = Auth::user()->getFullName() . ' archived client ' . $client->name; - $activity->balance = $client->balance; - $activity->save(); + if (!$client->is_deleted) + { + $activity = Activity::getBlank(); + $activity->client_id = $client->id; + $activity->activity_type_id = ACTIVITY_TYPE_ARCHIVE_CLIENT; + $activity->message = Auth::user()->getFullName() . ' archived client ' . link_to('clients/'.$client->public_id, $client->name); + $activity->balance = $client->balance; + $activity->save(); + } } public static function createInvoice($invoice) @@ -92,13 +107,30 @@ class Activity extends Eloquent public static function archiveInvoice($invoice) { - $activity = Activity::getBlank(); - $activity->invoice_id = $invoice->id; - $activity->client_id = $invoice->client_id; - $activity->activity_type_id = ACTIVITY_TYPE_ARCHIVE_INVOICE; - $activity->message = Auth::user()->getFullName() . ' archived invoice ' . $invoice->invoice_number; - $activity->balance = $invoice->client->balance; - $activity->save(); + if ($invoice->invoice_status_id < INVOICE_STATUS_SENT) + { + return; + } + + if (!$invoice->is_deleted) + { + if ($invoice->balance > 0) + { + $client = $invoice->client; + $client->balance = $client->balance - $invoice->balance; + $client->save(); + } + + $activity = Activity::getBlank(); + $activity->invoice_id = $invoice->id; + $activity->client_id = $invoice->client_id; + $activity->activity_type_id = ACTIVITY_TYPE_ARCHIVE_INVOICE; + $activity->message = Auth::user()->getFullName() . ' archived invoice ' . $invoice->invoice_number; + $activity->balance = $client->balance; + $activity->adjustment = $invoice->balance; + + $activity->save(); + } } public static function emailInvoice($invitation) @@ -132,35 +164,56 @@ class Activity extends Eloquent return; } - $diff = floatval($invoice->amount) - floatval($invoice->getOriginal('amount')); - - if ($diff == 0) + if ($invoice->is_deleted && !$invoice->getOriginal('is_deleted')) { - return; + if ($invoice->balance > 0) + { + $client = $invoice->client; + $client->balance = $client->balance - $invoice->balance; + $client->save(); + } + + $activity = Activity::getBlank(); + $activity->client_id = $invoice->client_id; + $activity->invoice_id = $invoice->id; + $activity->activity_type_id = ACTIVITY_TYPE_DELETE_INVOICE; + $activity->message = Auth::user()->getFullName() . ' deleted invoice ' . link_to('invoices/'.$invoice->public_id, $invoice->invoice_number); + $activity->balance = $client->balance; + $activity->adjustment = $invoice->balance * -1; + $activity->save(); } + else + { + $diff = floatval($invoice->amount) - floatval($invoice->getOriginal('amount')); + + if ($diff == 0) + { + return; + } - $backupInvoice = Invoice::with('invoice_items', 'client.account', 'client.contacts')->find($invoice->id); - //dd($backupInvoice->hidePrivateFields()->toJSON()); + $backupInvoice = Invoice::with('invoice_items', 'client.account', 'client.contacts')->find($invoice->id); - $client = $invoice->client; - $client->balance = $client->balance + $diff; - $client->save(); + $client = $invoice->client; + $client->balance = $client->balance + $diff; + $client->save(); - $activity = Activity::getBlank($invoice); - $activity->client_id = $invoice->client_id; - $activity->invoice_id = $invoice->id; - $activity->activity_type_id = ACTIVITY_TYPE_UPDATE_INVOICE; - $activity->message = Auth::user()->getFullName() . ' updated invoice ' . link_to('invoices/'.$invoice->public_id, $invoice->invoice_number); - $activity->balance = $client->balance; - $activity->adjustment = $diff; - $activity->json_backup = $backupInvoice->hidePrivateFields()->toJSON(); - $activity->save(); + $activity = Activity::getBlank($invoice); + $activity->client_id = $invoice->client_id; + $activity->invoice_id = $invoice->id; + $activity->activity_type_id = ACTIVITY_TYPE_UPDATE_INVOICE; + $activity->message = Auth::user()->getFullName() . ' updated invoice ' . link_to('invoices/'.$invoice->public_id, $invoice->invoice_number); + $activity->balance = $client->balance; + $activity->adjustment = $diff; + $activity->json_backup = $backupInvoice->hidePrivateFields()->toJSON(); + $activity->save(); + } } public static function createPayment($payment) { $client = $payment->client; $client->balance = $client->balance - $payment->amount; + $client->paid_to_date = $client->paid_to_date + $payment->amount; $client->save(); if (Auth::check()) diff --git a/app/models/Client.php b/app/models/Client.php index 06a266e5b6..021768048a 100755 --- a/app/models/Client.php +++ b/app/models/Client.php @@ -167,4 +167,14 @@ class Client extends EntityModel Client::created(function($client) { Activity::createClient($client); +}); + +Client::updating(function($client) +{ + Activity::updateClient($client); +}); + +Client::deleting(function($client) +{ + Activity::archiveClient($client); }); \ No newline at end of file diff --git a/app/ninja/mailers/ContactMailer.php b/app/ninja/mailers/ContactMailer.php index 2c2f504a2f..82588a6d18 100755 --- a/app/ninja/mailers/ContactMailer.php +++ b/app/ninja/mailers/ContactMailer.php @@ -16,12 +16,18 @@ class ContactMailer extends Mailer { foreach ($invoice->invitations as $invitation) { + if (!$invitation->user->email) + { + return false; + } + $invitation->sent_date = \Carbon::now()->toDateTimeString(); $invitation->save(); $data = array('link' => URL::to('view') . '/' . $invitation->invitation_key); $this->sendTo($invitation->contact->email, $invitation->user->email, $subject, $view, $data); + //$this->sendTo($invitation->contact->email, $subject, $view, $data); Activity::emailInvoice($invitation); } diff --git a/app/ninja/mailers/Mailer.php b/app/ninja/mailers/Mailer.php index ca612beb96..69976a78a3 100755 --- a/app/ninja/mailers/Mailer.php +++ b/app/ninja/mailers/Mailer.php @@ -7,13 +7,14 @@ abstract class Mailer { public function sendTo($toEmail, $fromEmail, $subject, $view, $data = []) { $views = [ - 'html' => 'emails.'.$view.'_html', - 'text' => 'emails.'.$view.'_text' + 'emails.'.$view.'_html', + 'emails.'.$view.'_text' ]; - + \Log::info('data: ' . json_encode($data)); + Mail::queue($views, $data, function($message) use ($toEmail, $fromEmail, $subject) - { + { $message->to($toEmail)->replyTo($fromEmail)->subject($subject); - }); + }); } } \ No newline at end of file diff --git a/app/ninja/mailers/UserMailer.php b/app/ninja/mailers/UserMailer.php index f8905e250f..78d2f1fd53 100755 --- a/app/ninja/mailers/UserMailer.php +++ b/app/ninja/mailers/UserMailer.php @@ -15,7 +15,7 @@ class UserMailer extends Mailer { $view = 'invoice'; //$data = array('link' => URL::to('view') . '/' . $invoice->invoice_key); - $data = []; + $data = ['link' => '']; $subject = 'Notification - Invoice ' . $type; $this->sendTo($user->email, CONTACT_EMAIL, $subject, $view, $data); diff --git a/app/ninja/repositories/ClientRepository.php b/app/ninja/repositories/ClientRepository.php index ef9f23c0f8..12b86e1bc0 100755 --- a/app/ninja/repositories/ClientRepository.php +++ b/app/ninja/repositories/ClientRepository.php @@ -98,4 +98,22 @@ class ClientRepository return $client; } + + public function bulk($ids, $action) + { + $clients = Client::scope($ids)->get(); + + foreach ($clients as $client) + { + if ($action == 'delete') + { + $client->is_deleted = true; + $client->save(); + } + + $client->delete(); + } + + return count($clients); + } } \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index b7fab2b5f8..a1f2f1393a 100755 --- a/app/routes.php +++ b/app/routes.php @@ -133,29 +133,29 @@ HTML::macro('image_data', function($imagePath) { define('CONTACT_EMAIL', 'contact@invoiceninja.com'); -define("ENV_DEVELOPMENT", "local"); -define("ENV_STAGING", "staging"); -define("ENV_PRODUCTION", "production"); +define('ENV_DEVELOPMENT', 'local'); +define('ENV_STAGING', 'staging'); +define('ENV_PRODUCTION', 'production'); -define("RECENTLY_VIEWED", "RECENTLY_VIEWED"); -define("ENTITY_CLIENT", "client"); -define("ENTITY_INVOICE", "invoice"); -define("ENTITY_RECURRING_INVOICE", "recurring_invoice"); -define("ENTITY_PAYMENT", "payment"); -define("ENTITY_CREDIT", "credit"); +define('RECENTLY_VIEWED', 'RECENTLY_VIEWED'); +define('ENTITY_CLIENT', 'client'); +define('ENTITY_INVOICE', 'invoice'); +define('ENTITY_RECURRING_INVOICE', 'recurring_invoice'); +define('ENTITY_PAYMENT', 'payment'); +define('ENTITY_CREDIT', 'credit'); -define("PERSON_CONTACT", "contact"); -define("PERSON_USER", "user"); +define('PERSON_CONTACT', 'contact'); +define('PERSON_USER', 'user'); -define("ACCOUNT_DETAILS", "details"); -define("ACCOUNT_SETTINGS", "settings"); -define("ACCOUNT_IMPORT", "import"); -define("ACCOUNT_MAP", "import_map"); -define("ACCOUNT_EXPORT", "export"); +define('ACCOUNT_DETAILS', 'details'); +define('ACCOUNT_SETTINGS', 'settings'); +define('ACCOUNT_IMPORT', 'import'); +define('ACCOUNT_MAP', 'import_map'); +define('ACCOUNT_EXPORT', 'export'); -define("DEFAULT_INVOICE_NUMBER", "0001"); -define("RECENTLY_VIEWED_LIMIT", 8); -define("LOGGED_ERROR_LIMIT", 100); +define('DEFAULT_INVOICE_NUMBER', '0001'); +define('RECENTLY_VIEWED_LIMIT', 8); +define('LOGGED_ERROR_LIMIT', 100); define('INVOICE_STATUS_DRAFT', 1); define('INVOICE_STATUS_SENT', 2); diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index 467f761ef5..eae6cb1f27 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -170,7 +170,7 @@ Paid to Date - + @@ -634,6 +634,17 @@ self.loadClient = function(client) { ko.mapping.fromJS(client, model.invoice().client().mapping, model.invoice().client); + self.setDueDate(); + } + + self.setDueDate = function() { + var paymentTerms = parseInt(self.invoice().client().payment_terms()); + if (paymentTerms && !self.invoice().due_date()) + { + var dueDate = $('#invoice_date').datepicker('getDate'); + dueDate.setDate(dueDate.getDate() + paymentTerms); + self.invoice().due_date(dueDate); + } } self.invoice_taxes = ko.observable({{ Auth::user()->account->invoice_taxes ? 'true' : 'false' }}); @@ -773,6 +784,8 @@ self.invoice().client().public_id(-1); } + model.setDueDate(); + if (name) { // } else if (firstName || lastName) { @@ -857,7 +870,8 @@ self.is_recurring = ko.observable(false); self.invoice_status_id = ko.observable(0); self.invoice_items = ko.observableArray(); - + self.amount = ko.observable(0); + self.balance = ko.observable(0); self.mapping = { 'client': { @@ -982,6 +996,14 @@ } }); + this.totals.rawPaidToDate = ko.computed(function() { + return self.amount() - self.balance(); + }); + + this.totals.paidToDate = ko.computed(function() { + var total = self.totals.rawPaidToDate(); + return total > 0 ? formatMoney(total, self.currency_id()) : ''; + }); this.totals.total = ko.computed(function() { var total = self.totals.rawSubtotal(); @@ -996,7 +1018,12 @@ total = parseFloat(total) + (total * (taxRate/100)); } - return total > 0 ? formatMoney(total, self.currency_id()) : ''; + var paid = self.totals.rawPaidToDate(); + if (paid > 0) { + total -= paid; + } + + return total != 0 ? formatMoney(total, self.currency_id()) : ''; }); self.onDragged = function(item) { diff --git a/composer.lock b/composer.lock index d2f0478aae..ea0f5c13ac 100755 --- a/composer.lock +++ b/composer.lock @@ -211,12 +211,12 @@ "source": { "type": "git", "url": "https://github.com/barryvdh/laravel-debugbar.git", - "reference": "22f1751267e7a2714f0df74fe207623cc928c68b" + "reference": "d1ec609e371dc081562b106c36a77357641fefa3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/22f1751267e7a2714f0df74fe207623cc928c68b", - "reference": "22f1751267e7a2714f0df74fe207623cc928c68b", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/d1ec609e371dc081562b106c36a77357641fefa3", + "reference": "d1ec609e371dc081562b106c36a77357641fefa3", "shasum": "" }, "require": { @@ -248,7 +248,7 @@ "profiler", "webprofiler" ], - "time": "2014-01-05 20:29:11" + "time": "2014-01-07 10:13:21" }, { "name": "chumper/datatable", @@ -915,12 +915,12 @@ "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "c472ca9b043c373230ded1363dd05d1478effca4" + "reference": "a49d68a0c048718d442855f52c4c68b97d76fd89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/c472ca9b043c373230ded1363dd05d1478effca4", - "reference": "c472ca9b043c373230ded1363dd05d1478effca4", + "url": "https://api.github.com/repos/laravel/framework/zipball/a49d68a0c048718d442855f52c4c68b97d76fd89", + "reference": "a49d68a0c048718d442855f52c4c68b97d76fd89", "shasum": "" }, "require": { @@ -1024,7 +1024,7 @@ "framework", "laravel" ], - "time": "2014-01-06 02:22:05" + "time": "2014-01-07 02:54:25" }, { "name": "laravelbook/ardent", @@ -1087,16 +1087,16 @@ }, { "name": "maximebf/debugbar", - "version": "1.8", + "version": "1.9", "source": { "type": "git", "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "f1dd126ec13ad912a9c3a1b9b4d27e16da182d38" + "reference": "ec6a857a308373fb61449e74a5aaf06af5f2ce87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/f1dd126ec13ad912a9c3a1b9b4d27e16da182d38", - "reference": "f1dd126ec13ad912a9c3a1b9b4d27e16da182d38", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/ec6a857a308373fb61449e74a5aaf06af5f2ce87", + "reference": "ec6a857a308373fb61449e74a5aaf06af5f2ce87", "shasum": "" }, "require": { @@ -1133,7 +1133,7 @@ "keywords": [ "debug" ], - "time": "2013-12-19 22:23:19" + "time": "2014-01-07 20:49:48" }, { "name": "monolog/monolog", @@ -1204,16 +1204,16 @@ }, { "name": "nesbot/carbon", - "version": "1.7.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "03ede52a1f360441b5826cb8a798e0d0a919731f" + "reference": "21c4cb4301969c7d85aee8a62eefdfa881413af0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/03ede52a1f360441b5826cb8a798e0d0a919731f", - "reference": "03ede52a1f360441b5826cb8a798e0d0a919731f", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/21c4cb4301969c7d85aee8a62eefdfa881413af0", + "reference": "21c4cb4301969c7d85aee8a62eefdfa881413af0", "shasum": "" }, "require": { @@ -1246,7 +1246,7 @@ "datetime", "time" ], - "time": "2013-12-05 04:13:29" + "time": "2014-01-07 05:10:44" }, { "name": "nikic/php-parser", @@ -2943,12 +2943,12 @@ "source": { "type": "git", "url": "https://github.com/patricktalmadge/bootstrapper.git", - "reference": "d606a1c5b8b059ccc64b1c75fa45bad6b90008d5" + "reference": "85c8e3ec29d0f98554d85b73d1e454b6600c0432" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/patricktalmadge/bootstrapper/zipball/d606a1c5b8b059ccc64b1c75fa45bad6b90008d5", - "reference": "d606a1c5b8b059ccc64b1c75fa45bad6b90008d5", + "url": "https://api.github.com/repos/patricktalmadge/bootstrapper/zipball/85c8e3ec29d0f98554d85b73d1e454b6600c0432", + "reference": "85c8e3ec29d0f98554d85b73d1e454b6600c0432", "shasum": "" }, "require": { @@ -2990,7 +2990,7 @@ "bootstrap", "laravel" ], - "time": "2014-01-04 17:50:59" + "time": "2014-01-07 16:02:34" }, { "name": "phpseclib/phpseclib", @@ -3282,12 +3282,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/BrowserKit.git", - "reference": "0248b2dfc9cd6b259555d232eedfb1283eb496c3" + "reference": "c6b3cd51651f445908a11f3f81f965a157daef38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/0248b2dfc9cd6b259555d232eedfb1283eb496c3", - "reference": "0248b2dfc9cd6b259555d232eedfb1283eb496c3", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/c6b3cd51651f445908a11f3f81f965a157daef38", + "reference": "c6b3cd51651f445908a11f3f81f965a157daef38", "shasum": "" }, "require": { @@ -3328,7 +3328,7 @@ ], "description": "Symfony BrowserKit Component", "homepage": "http://symfony.com", - "time": "2013-12-28 21:39:51" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/console", @@ -3337,12 +3337,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "4c1ed2ff514bd85ee186eebb010ccbdeeab05af7" + "reference": "86e13d5b06146fbe81006570ad26cb7cbeafba15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/4c1ed2ff514bd85ee186eebb010ccbdeeab05af7", - "reference": "4c1ed2ff514bd85ee186eebb010ccbdeeab05af7", + "url": "https://api.github.com/repos/symfony/Console/zipball/86e13d5b06146fbe81006570ad26cb7cbeafba15", + "reference": "86e13d5b06146fbe81006570ad26cb7cbeafba15", "shasum": "" }, "require": { @@ -3381,7 +3381,7 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/css-selector", @@ -3390,12 +3390,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/CssSelector.git", - "reference": "352552da1f50a79f6a6fa427e4a85ee2ea1945f6" + "reference": "251273e7700b93a24012d4113ee5681a9000de5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/352552da1f50a79f6a6fa427e4a85ee2ea1945f6", - "reference": "352552da1f50a79f6a6fa427e4a85ee2ea1945f6", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/251273e7700b93a24012d4113ee5681a9000de5a", + "reference": "251273e7700b93a24012d4113ee5681a9000de5a", "shasum": "" }, "require": { @@ -3432,7 +3432,7 @@ ], "description": "Symfony CssSelector Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/debug", @@ -3441,12 +3441,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Debug.git", - "reference": "74110be5ec681a83fc5bd66dd5fd29fe85fe9c1f" + "reference": "7bd04476b53d676189196ba4c526ccde4302a8de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Debug/zipball/74110be5ec681a83fc5bd66dd5fd29fe85fe9c1f", - "reference": "74110be5ec681a83fc5bd66dd5fd29fe85fe9c1f", + "url": "https://api.github.com/repos/symfony/Debug/zipball/7bd04476b53d676189196ba4c526ccde4302a8de", + "reference": "7bd04476b53d676189196ba4c526ccde4302a8de", "shasum": "" }, "require": { @@ -3487,7 +3487,7 @@ ], "description": "Symfony Debug Component", "homepage": "http://symfony.com", - "time": "2014-01-01 09:02:49" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/dom-crawler", @@ -3496,12 +3496,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/DomCrawler.git", - "reference": "58e85928ad277c67102a41a046160de86df44d55" + "reference": "fa7d0ca404202d4330075ac90c6c22c546753d64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/58e85928ad277c67102a41a046160de86df44d55", - "reference": "58e85928ad277c67102a41a046160de86df44d55", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/fa7d0ca404202d4330075ac90c6c22c546753d64", + "reference": "fa7d0ca404202d4330075ac90c6c22c546753d64", "shasum": "" }, "require": { @@ -3540,7 +3540,7 @@ ], "description": "Symfony DomCrawler Component", "homepage": "http://symfony.com", - "time": "2013-12-29 20:33:52" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/event-dispatcher", @@ -3549,12 +3549,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "6a30cf4f7951794e2179c29b3ce30fb478019cd8" + "reference": "a37a9430e2eafb6a66de240ac13f91b45b4c3d37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/6a30cf4f7951794e2179c29b3ce30fb478019cd8", - "reference": "6a30cf4f7951794e2179c29b3ce30fb478019cd8", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/a37a9430e2eafb6a66de240ac13f91b45b4c3d37", + "reference": "a37a9430e2eafb6a66de240ac13f91b45b4c3d37", "shasum": "" }, "require": { @@ -3596,7 +3596,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2014-01-01 09:18:08" + "time": "2014-01-07 13:29:57" }, { "name": "symfony/filesystem", @@ -3605,12 +3605,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "548000429823d067206bdfe73d4eb850c585e810" + "reference": "e81f1b30eb9748c3f8e0de3a92ea210845cff0a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/548000429823d067206bdfe73d4eb850c585e810", - "reference": "548000429823d067206bdfe73d4eb850c585e810", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/e81f1b30eb9748c3f8e0de3a92ea210845cff0a9", + "reference": "e81f1b30eb9748c3f8e0de3a92ea210845cff0a9", "shasum": "" }, "require": { @@ -3643,7 +3643,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "http://symfony.com", - "time": "2013-12-31 13:43:37" + "time": "2014-01-07 13:29:57" }, { "name": "symfony/finder", @@ -3652,12 +3652,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "6904345cf2b3bbab1f6d6e4ce1724cb99df9f00a" + "reference": "b6735d1fc16da13c4c7dddfe78366a4a098cf011" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/6904345cf2b3bbab1f6d6e4ce1724cb99df9f00a", - "reference": "6904345cf2b3bbab1f6d6e4ce1724cb99df9f00a", + "url": "https://api.github.com/repos/symfony/Finder/zipball/b6735d1fc16da13c4c7dddfe78366a4a098cf011", + "reference": "b6735d1fc16da13c4c7dddfe78366a4a098cf011", "shasum": "" }, "require": { @@ -3690,7 +3690,7 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/http-foundation", @@ -3699,12 +3699,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844" + "reference": "25b49c494ea6aed2cfd8448ae3f8437d01e731eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", - "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/25b49c494ea6aed2cfd8448ae3f8437d01e731eb", + "reference": "25b49c494ea6aed2cfd8448ae3f8437d01e731eb", "shasum": "" }, "require": { @@ -3740,7 +3740,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2014-01-05 02:10:50" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/http-kernel", @@ -3749,12 +3749,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "2f5c4d0c7f273c0575f46823674ce2c1d0a5b310" + "reference": "eb1ed60a4a066238106721f67f664fd6382a99ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/2f5c4d0c7f273c0575f46823674ce2c1d0a5b310", - "reference": "2f5c4d0c7f273c0575f46823674ce2c1d0a5b310", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/eb1ed60a4a066238106721f67f664fd6382a99ea", + "reference": "eb1ed60a4a066238106721f67f664fd6382a99ea", "shasum": "" }, "require": { @@ -3811,7 +3811,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2014-01-05 10:33:23" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/process", @@ -3820,12 +3820,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "58fdccb311e44f28866f976c2d7b3227e9f713db" + "reference": "4f196b9d307d9e1a3d4372f1735c301c03d476c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/58fdccb311e44f28866f976c2d7b3227e9f713db", - "reference": "58fdccb311e44f28866f976c2d7b3227e9f713db", + "url": "https://api.github.com/repos/symfony/Process/zipball/4f196b9d307d9e1a3d4372f1735c301c03d476c5", + "reference": "4f196b9d307d9e1a3d4372f1735c301c03d476c5", "shasum": "" }, "require": { @@ -3858,7 +3858,7 @@ ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2014-01-05 02:10:50" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/routing", @@ -3867,12 +3867,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a" + "reference": "e4ef317134f5628b5f0d3b0ac96d30ba1c8146cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/4abfb500aab8be458c9e3a227ea56b190584f78a", - "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a", + "url": "https://api.github.com/repos/symfony/Routing/zipball/e4ef317134f5628b5f0d3b0ac96d30ba1c8146cc", + "reference": "e4ef317134f5628b5f0d3b0ac96d30ba1c8146cc", "shasum": "" }, "require": { @@ -3924,7 +3924,7 @@ "uri", "url" ], - "time": "2014-01-05 02:10:50" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/translation", @@ -3933,12 +3933,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "7f76dffd7eaf2c9a3a8f47649404c71440d18c8b" + "reference": "d08c27077115e4bd3030a812e4083daa49254ca9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/7f76dffd7eaf2c9a3a8f47649404c71440d18c8b", - "reference": "7f76dffd7eaf2c9a3a8f47649404c71440d18c8b", + "url": "https://api.github.com/repos/symfony/Translation/zipball/d08c27077115e4bd3030a812e4083daa49254ca9", + "reference": "d08c27077115e4bd3030a812e4083daa49254ca9", "shasum": "" }, "require": { @@ -3979,7 +3979,7 @@ ], "description": "Symfony Translation Component", "homepage": "http://symfony.com", - "time": "2013-12-31 13:43:26" + "time": "2014-01-07 13:28:54" }, { "name": "webpatser/laravel-countries", diff --git a/public/js/script.js b/public/js/script.js index 15646d09b2..bc36922fab 100755 --- a/public/js/script.js +++ b/public/js/script.js @@ -21,6 +21,7 @@ function generatePDF(invoice, checkMath) { var rowHeight = 15; var tableRowHeight = 20; var footerLeft = 420; + var tablePadding = 6; var tableTop = 240; var tableLeft = 60; @@ -60,7 +61,7 @@ function generatePDF(invoice, checkMath) { /* table header */ doc.setDrawColor(200,200,200); doc.setFillColor(230,230,230); - var x1 = headerLeft - 6; + var x1 = headerLeft - tablePadding; var y1 = headerTop + rowHeight + 4; var x2 = headerRight - headerLeft + 11; var y2 = rowHeight + 1; @@ -150,7 +151,7 @@ function generatePDF(invoice, checkMath) { doc.setDrawColor(200,200,200); doc.setFillColor(230,230,230); - doc.rect(tableLeft - 6, tableTop - 12, headerRight - tableLeft + 12, rowHeight + 2, 'FD'); + doc.rect(tableLeft - tablePadding, tableTop - 12, headerRight - tableLeft + 12, rowHeight + 2, 'FD'); var costX = unitCostRight - (doc.getStringUnitWidth('Unit Cost') * doc.internal.getFontSize()); var qtyX = qtyRight - (doc.getStringUnitWidth('Quantity') * doc.internal.getFontSize()); @@ -227,7 +228,9 @@ function generatePDF(invoice, checkMath) { line += doc.splitTextToSize(item.notes, 200).length; if (i < invoice.invoice_items.length - 2) { - doc.lines([[0,0],[headerRight-tableLeft+5,0]],tableLeft - 8, tableTop + (line * tableRowHeight) - 8); + doc.setLineWidth(0.5); + doc.line(tableLeft - tablePadding, tableTop + (line * tableRowHeight) - 8, + lineTotalRight+tablePadding, tableTop + (line * tableRowHeight) - 8); } } @@ -235,8 +238,10 @@ function generatePDF(invoice, checkMath) { /* table footer */ doc.setDrawColor(200,200,200); var x = tableTop + (line * tableRowHeight); - doc.lines([[0,0],[headerRight-tableLeft+5,0]],tableLeft - 8, x); + doc.setLineWidth(1); + doc.line(tableLeft - tablePadding, x, lineTotalRight+tablePadding, x); + 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); @@ -295,7 +300,7 @@ function generatePDF(invoice, checkMath) { return doc; } - var total = formatMoney(invoice.balance, currencyId); + var total = formatMoney(total - (invoice.amount - invoice.balance), currencyId); var totalX = headerRight - (doc.getStringUnitWidth(total) * doc.internal.getFontSize()); doc.text(totalX, x, total);