From aa0a35f9d89b0f04b48b7e676ae1fc80e3be257d Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 29 Oct 2015 16:42:05 +0200 Subject: [PATCH] Added default quote terms --- app/Events/InvoiceInvitationWasEmailed.php | 6 +- app/Events/QuoteInvitationWasEmailed.php | 4 +- app/Http/Controllers/AccountController.php | 11 +- app/Http/Controllers/InvoiceController.php | 5 +- app/Http/Controllers/QuoteController.php | 5 +- app/Listeners/ActivityListener.php | 4 +- app/Listeners/InvoiceListener.php | 6 - app/Listeners/QuoteListener.php | 8 +- app/Models/Invitation.php | 8 + app/Models/Invoice.php | 27 +++- app/Ninja/Mailers/ContactMailer.php | 10 +- app/Ninja/Mailers/Mailer.php | 12 +- app/Ninja/Repositories/InvoiceRepository.php | 7 +- app/Providers/EventServiceProvider.php | 2 - app/Services/BaseService.php | 4 +- composer.lock | 143 ++++++++---------- ...5_10_29_133747_add_default_quote_terms.php | 44 ++++++ resources/lang/en/texts.php | 9 +- resources/views/accounts/details.blade.php | 4 +- .../views/accounts/invoice_settings.blade.php | 41 ++++- .../views/accounts/notifications.blade.php | 15 +- resources/views/invoices/edit.blade.php | 6 +- resources/views/invoices/knockout.blade.php | 4 +- resources/views/list.blade.php | 6 +- 24 files changed, 226 insertions(+), 165 deletions(-) create mode 100644 database/migrations/2015_10_29_133747_add_default_quote_terms.php diff --git a/app/Events/InvoiceInvitationWasEmailed.php b/app/Events/InvoiceInvitationWasEmailed.php index 1a602c867e..da00312492 100644 --- a/app/Events/InvoiceInvitationWasEmailed.php +++ b/app/Events/InvoiceInvitationWasEmailed.php @@ -8,17 +8,15 @@ class InvoiceInvitationWasEmailed extends Event { use SerializesModels; - public $invoice; public $invitation; - + /** * Create a new event instance. * * @return void */ - public function __construct($invoice, $invitation) + public function __construct($invitation) { - $this->invoice = $invoice; $this->invitation = $invitation; } diff --git a/app/Events/QuoteInvitationWasEmailed.php b/app/Events/QuoteInvitationWasEmailed.php index ce1b87d4a7..5ce1c68602 100644 --- a/app/Events/QuoteInvitationWasEmailed.php +++ b/app/Events/QuoteInvitationWasEmailed.php @@ -8,7 +8,6 @@ class QuoteInvitationWasEmailed extends Event { use SerializesModels; - public $quote; public $invitation; /** @@ -16,9 +15,8 @@ class QuoteInvitationWasEmailed extends Event { * * @return void */ - public function __construct($quote, $invitation) + public function __construct($invitation) { - $this->quote = $quote; $this->invitation = $invitation; } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 8431076731..f0f55f12c8 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -521,8 +521,10 @@ class AccountController extends BaseController $account->invoice_number_counter = Input::get('invoice_number_counter'); $account->quote_number_prefix = Input::get('quote_number_prefix'); $account->share_counter = Input::get('share_counter') ? true : false; - $account->pdf_email_attachment = Input::get('pdf_email_attachment') ? true : false; + $account->invoice_terms = Input::get('invoice_terms'); + $account->invoice_footer = Input::get('invoice_footer'); + $account->quote_terms = Input::get('quote_terms'); if (Input::has('recurring_hour')) { $account->recurring_hour = Input::get('recurring_hour'); @@ -801,12 +803,6 @@ class AccountController extends BaseController private function saveNotifications() { - $account = Auth::user()->account; - $account->invoice_terms = Input::get('invoice_terms'); - $account->invoice_footer = Input::get('invoice_footer'); - $account->email_footer = Input::get('email_footer'); - $account->save(); - $user = Auth::user(); $user->notify_sent = Input::get('notify_sent'); $user->notify_viewed = Input::get('notify_viewed'); @@ -847,6 +843,7 @@ class AccountController extends BaseController $account->country_id = Input::get('country_id') ? Input::get('country_id') : null; $account->size_id = Input::get('size_id') ? Input::get('size_id') : null; $account->industry_id = Input::get('industry_id') ? Input::get('industry_id') : null; + $account->email_footer = Input::get('email_footer'); $account->save(); /* Logo image file */ diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index a8fb60a778..40a89714eb 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -558,11 +558,10 @@ class InvoiceController extends BaseController { $action = Input::get('bulk_action') ?: Input::get('action');; $ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids')); - $statusId = Input::get('statusId', INVOICE_STATUS_SENT); - $count = $this->invoiceService->bulk($ids, $action, $statusId); + $count = $this->invoiceService->bulk($ids, $action); if ($count > 0) { - $key = $action == 'mark' ? "updated_{$entityType}" : "{$action}d_{$entityType}"; + $key = $action == 'markSent' ? "updated_{$entityType}" : "{$action}d_{$entityType}"; $message = Utils::pluralize($key, $count); Session::flash('message', $message); } diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index ccf1834a01..1c80981268 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -134,12 +134,11 @@ class QuoteController extends BaseController return Redirect::to('invoices/'.$clone->public_id); } - $statusId = Input::get('statusId'); $ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids')); - $count = $this->invoiceService->bulk($ids, $action, $statusId); + $count = $this->invoiceService->bulk($ids, $action); if ($count > 0) { - $key = $action == 'mark' ? "updated_quote" : "{$action}d_quote"; + $key = $action == 'markSent' ? "updated_quote" : "{$action}d_quote"; $message = Utils::pluralize($key, $count); Session::flash('message', $message); } diff --git a/app/Listeners/ActivityListener.php b/app/Listeners/ActivityListener.php index fe966d4745..afe25fe30f 100644 --- a/app/Listeners/ActivityListener.php +++ b/app/Listeners/ActivityListener.php @@ -146,7 +146,7 @@ class ActivityListener public function emailedInvoice(InvoiceInvitationWasEmailed $event) { $this->activityRepo->create( - $event->invoice, + $event->invitation->invoice, ACTIVITY_TYPE_EMAIL_INVOICE, false, false, @@ -224,7 +224,7 @@ class ActivityListener public function emailedQuote(QuoteInvitationWasEmailed $event) { $this->activityRepo->create( - $event->quote, + $event->invitation->invoice, ACTIVITY_TYPE_EMAIL_QUOTE, false, false, diff --git a/app/Listeners/InvoiceListener.php b/app/Listeners/InvoiceListener.php index 35762d8f86..49fee6578d 100644 --- a/app/Listeners/InvoiceListener.php +++ b/app/Listeners/InvoiceListener.php @@ -25,12 +25,6 @@ class InvoiceListener $invoice->updatePaidStatus(); } - public function emailedInvoice(InvoiceWasEmailed $event) - { - $invoice = $event->invoice; - $invoice->markSent(); - } - public function viewedInvoice(InvoiceInvitationWasViewed $event) { $invitation = $event->invitation; diff --git a/app/Listeners/QuoteListener.php b/app/Listeners/QuoteListener.php index a228dc1105..5dfa0e45ae 100644 --- a/app/Listeners/QuoteListener.php +++ b/app/Listeners/QuoteListener.php @@ -1,16 +1,12 @@ quote; - $quote->markSent(); - } - public function viewedQuote(QuoteInvitationWasViewed $event) { $invitation = $event->invitation; diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php index 821b8b8659..16d5043499 100644 --- a/app/Models/Invitation.php +++ b/app/Models/Invitation.php @@ -73,6 +73,14 @@ class Invitation extends EntityModel return $this->invitation_key; } + public function markSent($messageId = null) + { + $this->message_id = $messageId; + $this->email_error = null; + $this->sent_date = Carbon::now()->toDateTimeString(); + $this->save(); + } + public function markViewed() { $invoice = $this->invoice; diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 59ea9a60de..2af8deb347 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -9,6 +9,8 @@ use App\Events\QuoteWasCreated; use App\Events\QuoteWasUpdated; use App\Events\InvoiceWasCreated; use App\Events\InvoiceWasUpdated; +use App\Events\InvoiceInvitationWasEmailed; +use App\Events\QuoteInvitationWasEmailed; class Invoice extends EntityModel implements BalanceAffecting { @@ -145,12 +147,33 @@ class Invoice extends EntityModel implements BalanceAffecting return $this->hasMany('App\Models\Invitation')->orderBy('invitations.contact_id'); } - public function markSent() + public function markInvitationsSent($notify = false) + { + foreach ($this->invitations as $invitation) { + $this->markInvitationSent($invitation, false, $notify); + } + } + + public function markInvitationSent($invitation, $messageId = false, $notify = true) { if (!$this->isSent()) { $this->invoice_status_id = INVOICE_STATUS_SENT; $this->save(); } + + $invitation->markSent($messageId); + + // if the user marks it as sent rather than acually sending it + // then we won't track it in the activity log + if (!$notify) { + return; + } + + if ($this->is_quote) { + event(new QuoteInvitationWasEmailed($invitation)); + } else { + event(new InvoiceInvitationWasEmailed($invitation)); + } } public function markViewed() @@ -166,7 +189,7 @@ class Invoice extends EntityModel implements BalanceAffecting if ($this->isPaid() && $this->balance > 0) { $this->invoice_status_id = ($this->balance == $this->amount ? INVOICE_STATUS_SENT : INVOICE_STATUS_PARTIAL); $this->save(); - } elseif ($this->invoice_status_id && $this->amount && $this->balance == 0 && $this->invoice_status_id != INVOICE_STATUS_PAID) { + } elseif ($this->invoice_status_id && $this->amount > 0 && $this->balance == 0 && $this->invoice_status_id != INVOICE_STATUS_PAID) { $this->invoice_status_id = INVOICE_STATUS_PAID; $this->save(); } diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index d6d5e70a18..cce2b5fc16 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -11,10 +11,7 @@ use App\Models\Activity; use App\Models\Gateway; use App\Events\InvoiceWasEmailed; -use App\Events\InvoiceInvitationWasEmailed; - use App\Events\QuoteWasEmailed; -use App\Events\QuoteInvitationWasEmailed; class ContactMailer extends Mailer { @@ -103,15 +100,10 @@ class ContactMailer extends Mailer $subject = $this->processVariables($subject, $variables); $fromEmail = $user->email; + $response = $this->sendTo($invitation->contact->email, $fromEmail, $account->getDisplayName(), $subject, ENTITY_INVOICE, $data); if ($response === true) { - if ($invoice->is_quote) { - event(new QuoteInvitationWasEmailed($invoice, $invitation)); - } else { - event(new InvoiceInvitationWasEmailed($invoice, $invitation)); - } - return true; } else { return false; diff --git a/app/Ninja/Mailers/Mailer.php b/app/Ninja/Mailers/Mailer.php index f129eefb6b..34db634f88 100644 --- a/app/Ninja/Mailers/Mailer.php +++ b/app/Ninja/Mailers/Mailer.php @@ -50,16 +50,16 @@ class Mailer { if (isset($data['invitation'])) { $invitation = $data['invitation']; - + $invoice = $invitation->invoice; + $messageId = false; + // Track the Postmark message id if (isset($_ENV['POSTMARK_API_TOKEN']) && $response) { $json = $response->json(); - $invitation->message_id = $json['MessageID']; + $messageId = $json['MessageID']; } - - $invitation->email_error = null; - $invitation->sent_date = \Carbon::now()->toDateTimeString(); - $invitation->save(); + + $invoice->markInvitationSent($invitation, $messageId); } return true; diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 0e9f9dadf4..73439a8c54 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -243,7 +243,7 @@ class InvoiceRepository extends BaseRepository if ((isset($data['set_default_terms']) && $data['set_default_terms']) || (isset($data['set_default_footer']) && $data['set_default_footer'])) { if (isset($data['set_default_terms']) && $data['set_default_terms']) { - $account->invoice_terms = trim($data['terms']); + $account->{"{$entityType}_terms"} = trim($data['terms']); } if (isset($data['set_default_footer']) && $data['set_default_footer']) { $account->invoice_footer = trim($data['invoice_footer']); @@ -530,10 +530,9 @@ class InvoiceRepository extends BaseRepository return $clone; } - public function mark($invoice, $statusId) + public function markSent($invoice) { - $invoice->invoice_status_id = $statusId; - $invoice->save(); + $invoice->markInvitationsSent(); } public function findInvoiceByInvitation($invitationKey) diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 3b7e800773..02d3439e86 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -48,7 +48,6 @@ class EventServiceProvider extends ServiceProvider { ], 'App\Events\InvoiceWasEmailed' => [ 'App\Listeners\NotificationListener@emailedInvoice', - 'App\Listeners\InvoiceListener@emailedInvoice', ], 'App\Events\InvoiceInvitationWasEmailed' => [ 'App\Listeners\ActivityListener@emailedInvoice', @@ -77,7 +76,6 @@ class EventServiceProvider extends ServiceProvider { 'App\Listeners\ActivityListener@restoredQuote', ], 'App\Events\QuoteWasEmailed' => [ - 'App\Listeners\QuoteListener@emailedQuote', 'App\Listeners\NotificationListener@emailedQuote', ], 'App\Events\QuoteInvitationWasEmailed' => [ diff --git a/app/Services/BaseService.php b/app/Services/BaseService.php index affb8a235c..20553ad40b 100644 --- a/app/Services/BaseService.php +++ b/app/Services/BaseService.php @@ -11,7 +11,7 @@ class BaseService return null; } - public function bulk($ids, $action, $param = null) + public function bulk($ids, $action) { if ( ! $ids) { return 0; @@ -20,7 +20,7 @@ class BaseService $entities = $this->getRepo()->findByPublicIdsWithTrashed($ids); foreach ($entities as $entity) { - $this->getRepo()->$action($entity, $param); + $this->getRepo()->$action($entity); } return count($entities); diff --git a/composer.lock b/composer.lock index 55b826b5e8..f32fe59153 100644 --- a/composer.lock +++ b/composer.lock @@ -770,16 +770,16 @@ }, { "name": "doctrine/cache", - "version": "v1.4.2", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca" + "reference": "eb8a73619af4f1c8711e2ce482f5de3643258a1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/8c434000f420ade76a07c64cbe08ca47e5c101ca", - "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca", + "url": "https://api.github.com/repos/doctrine/cache/zipball/eb8a73619af4f1c8711e2ce482f5de3643258a1f", + "reference": "eb8a73619af4f1c8711e2ce482f5de3643258a1f", "shasum": "" }, "require": { @@ -800,8 +800,8 @@ } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Cache\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" } }, "notification-url": "https://packagist.org/downloads/", @@ -836,7 +836,7 @@ "cache", "caching" ], - "time": "2015-08-31 12:36:41" + "time": "2015-10-28 11:27:45" }, { "name": "doctrine/collections", @@ -2057,16 +2057,16 @@ }, { "name": "laravel/socialite", - "version": "v2.0.13", + "version": "v2.0.14", "source": { "type": "git", "url": "https://github.com/laravel/socialite.git", - "reference": "5995d2c9c60b47362412a84286e2a0707e0db386" + "reference": "b15f4be0ac739405120d74b837af423aa71502d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/socialite/zipball/5995d2c9c60b47362412a84286e2a0707e0db386", - "reference": "5995d2c9c60b47362412a84286e2a0707e0db386", + "url": "https://api.github.com/repos/laravel/socialite/zipball/b15f4be0ac739405120d74b837af423aa71502d9", + "reference": "b15f4be0ac739405120d74b837af423aa71502d9", "shasum": "" }, "require": { @@ -2107,7 +2107,7 @@ "laravel", "oauth" ], - "time": "2015-09-24 20:59:56" + "time": "2015-10-16 15:39:46" }, { "name": "laravelcollective/html", @@ -2245,16 +2245,16 @@ }, { "name": "league/oauth1-client", - "version": "1.6.0", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/thephpleague/oauth1-client.git", - "reference": "4d4edd9b6014f882e319231a9b3351e3a1dfdc81" + "reference": "cef3ceda13c78f89c323e4d5e6301c0eb7cea422" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth1-client/zipball/4d4edd9b6014f882e319231a9b3351e3a1dfdc81", - "reference": "4d4edd9b6014f882e319231a9b3351e3a1dfdc81", + "url": "https://api.github.com/repos/thephpleague/oauth1-client/zipball/cef3ceda13c78f89c323e4d5e6301c0eb7cea422", + "reference": "cef3ceda13c78f89c323e4d5e6301c0eb7cea422", "shasum": "" }, "require": { @@ -2304,7 +2304,7 @@ "tumblr", "twitter" ], - "time": "2015-08-22 09:49:14" + "time": "2015-10-23 04:02:07" }, { "name": "lokielse/omnipay-alipay", @@ -2357,16 +2357,16 @@ }, { "name": "maximebf/debugbar", - "version": "v1.10.4", + "version": "v1.10.5", "source": { "type": "git", "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "7b2006e6e095126b5a061ec33fca3d90ea8a8219" + "reference": "30e53e8a28284b69dd223c9f5ee8957befd72636" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/7b2006e6e095126b5a061ec33fca3d90ea8a8219", - "reference": "7b2006e6e095126b5a061ec33fca3d90ea8a8219", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/30e53e8a28284b69dd223c9f5ee8957befd72636", + "reference": "30e53e8a28284b69dd223c9f5ee8957befd72636", "shasum": "" }, "require": { @@ -2409,7 +2409,7 @@ "keywords": [ "debug" ], - "time": "2015-02-05 07:51:20" + "time": "2015-10-19 20:35:12" }, { "name": "mfauveau/omnipay-pacnet", @@ -4827,24 +4827,23 @@ }, { "name": "symfony/class-loader", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/class-loader.git", - "reference": "d957ea6295d7016e20d7eff33a6c1deef819c0d4" + "reference": "320f8d2a9cdbcbeb24be602c124aae9d998474a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/class-loader/zipball/d957ea6295d7016e20d7eff33a6c1deef819c0d4", - "reference": "d957ea6295d7016e20d7eff33a6c1deef819c0d4", + "url": "https://api.github.com/repos/symfony/class-loader/zipball/320f8d2a9cdbcbeb24be602c124aae9d998474a4", + "reference": "320f8d2a9cdbcbeb24be602c124aae9d998474a4", "shasum": "" }, "require": { "php": ">=5.3.9" }, "require-dev": { - "symfony/finder": "~2.0,>=2.0.5", - "symfony/phpunit-bridge": "~2.7" + "symfony/finder": "~2.0,>=2.0.5" }, "type": "library", "extra": { @@ -4873,7 +4872,7 @@ ], "description": "Symfony ClassLoader Component", "homepage": "https://symfony.com", - "time": "2015-08-26 17:56:37" + "time": "2015-10-23 14:47:27" }, { "name": "symfony/console", @@ -4996,16 +4995,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "ae4dcc2a8d3de98bd794167a3ccda1311597c5d9" + "reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ae4dcc2a8d3de98bd794167a3ccda1311597c5d9", - "reference": "ae4dcc2a8d3de98bd794167a3ccda1311597c5d9", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/87a5db5ea887763fa3a31a5471b512ff1596d9b8", + "reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8", "shasum": "" }, "require": { @@ -5016,7 +5015,6 @@ "symfony/config": "~2.0,>=2.0.5", "symfony/dependency-injection": "~2.6", "symfony/expression-language": "~2.6", - "symfony/phpunit-bridge": "~2.7", "symfony/stopwatch": "~2.3" }, "suggest": { @@ -5050,28 +5048,25 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2015-09-22 13:49:29" + "time": "2015-10-11 09:39:48" }, { "name": "symfony/filesystem", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "a17f8a17c20e8614c15b8e116e2f4bcde102cfab" + "reference": "56fd6df73be859323ff97418d97edc1d756df6df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/a17f8a17c20e8614c15b8e116e2f4bcde102cfab", - "reference": "a17f8a17c20e8614c15b8e116e2f4bcde102cfab", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/56fd6df73be859323ff97418d97edc1d756df6df", + "reference": "56fd6df73be859323ff97418d97edc1d756df6df", "shasum": "" }, "require": { "php": ">=5.3.9" }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, "type": "library", "extra": { "branch-alias": { @@ -5099,7 +5094,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2015-09-09 17:42:36" + "time": "2015-10-18 20:23:18" }, { "name": "symfony/finder", @@ -6494,16 +6489,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.8.13", + "version": "4.8.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "be067d6105286b74272facefc2697038f8807b77" + "reference": "625f8c345606ed0f3a141dfb88f4116f0e22978e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/be067d6105286b74272facefc2697038f8807b77", - "reference": "be067d6105286b74272facefc2697038f8807b77", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/625f8c345606ed0f3a141dfb88f4116f0e22978e", + "reference": "625f8c345606ed0f3a141dfb88f4116f0e22978e", "shasum": "" }, "require": { @@ -6562,7 +6557,7 @@ "testing", "xunit" ], - "time": "2015-10-14 13:49:40" + "time": "2015-10-23 06:48:33" }, { "name": "phpunit/phpunit-mock-objects", @@ -6993,16 +6988,16 @@ }, { "name": "symfony/browser-kit", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "277a2457776d4cc25706fbdd9d1e4ab2dac884e4" + "reference": "07d664a052572ccc28eb2ab7dbbe82155b1ad367" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/277a2457776d4cc25706fbdd9d1e4ab2dac884e4", - "reference": "277a2457776d4cc25706fbdd9d1e4ab2dac884e4", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/07d664a052572ccc28eb2ab7dbbe82155b1ad367", + "reference": "07d664a052572ccc28eb2ab7dbbe82155b1ad367", "shasum": "" }, "require": { @@ -7011,8 +7006,7 @@ }, "require-dev": { "symfony/css-selector": "~2.0,>=2.0.5", - "symfony/phpunit-bridge": "~2.7", - "symfony/process": "~2.0,>=2.0.5" + "symfony/process": "~2.3.34|~2.7,>=2.7.6" }, "suggest": { "symfony/process": "" @@ -7044,28 +7038,25 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2015-09-06 08:36:38" + "time": "2015-10-23 14:47:27" }, { "name": "symfony/css-selector", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "abe19cc0429a06be0c133056d1f9859854860970" + "reference": "e1b865b26be4a56d22a8dee398375044a80c865b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/abe19cc0429a06be0c133056d1f9859854860970", - "reference": "abe19cc0429a06be0c133056d1f9859854860970", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/e1b865b26be4a56d22a8dee398375044a80c865b", + "reference": "e1b865b26be4a56d22a8dee398375044a80c865b", "shasum": "" }, "require": { "php": ">=5.3.9" }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, "type": "library", "extra": { "branch-alias": { @@ -7097,28 +7088,27 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2015-09-22 13:49:29" + "time": "2015-10-11 09:39:48" }, { "name": "symfony/dom-crawler", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "2e185ca136399f902b948694987e62c80099c052" + "reference": "5fef7d8b80d8f9992df99d8ee283f420484c9612" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/2e185ca136399f902b948694987e62c80099c052", - "reference": "2e185ca136399f902b948694987e62c80099c052", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/5fef7d8b80d8f9992df99d8ee283f420484c9612", + "reference": "5fef7d8b80d8f9992df99d8ee283f420484c9612", "shasum": "" }, "require": { "php": ">=5.3.9" }, "require-dev": { - "symfony/css-selector": "~2.3", - "symfony/phpunit-bridge": "~2.7" + "symfony/css-selector": "~2.3" }, "suggest": { "symfony/css-selector": "" @@ -7150,28 +7140,25 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2015-09-20 21:13:58" + "time": "2015-10-11 09:39:48" }, { "name": "symfony/yaml", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770" + "reference": "eca9019c88fbe250164affd107bc8057771f3f4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/31cb2ad0155c95b88ee55fe12bc7ff92232c1770", - "reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770", + "url": "https://api.github.com/repos/symfony/yaml/zipball/eca9019c88fbe250164affd107bc8057771f3f4d", + "reference": "eca9019c88fbe250164affd107bc8057771f3f4d", "shasum": "" }, "require": { "php": ">=5.3.9" }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, "type": "library", "extra": { "branch-alias": { @@ -7199,7 +7186,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-09-14 14:14:09" + "time": "2015-10-11 09:39:48" } ], "aliases": [], diff --git a/database/migrations/2015_10_29_133747_add_default_quote_terms.php b/database/migrations/2015_10_29_133747_add_default_quote_terms.php new file mode 100644 index 0000000000..a156dc3a77 --- /dev/null +++ b/database/migrations/2015_10_29_133747_add_default_quote_terms.php @@ -0,0 +1,44 @@ +text('quote_terms')->nullable(); + }); + + $accounts = DB::table('accounts') + ->orderBy('id') + ->get(['id', 'invoice_terms']); + + foreach ($accounts as $account) { + DB::table('accounts') + ->where('id', $account->id) + ->update(['quote_terms' => $account->invoice_terms]); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function($table) + { + $table->dropColumn('quote_terms'); + }); + } + +} diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 1468594b8b..ea03815703 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -194,7 +194,6 @@ return array( 'email_paid' => 'Email me when an invoice is paid', 'site_updates' => 'Site Updates', 'custom_messages' => 'Custom Messages', - 'default_invoice_terms' => 'Set default invoice terms', 'default_email_footer' => 'Set default email signature', 'import_clients' => 'Import Client Data', 'csv_file' => 'Select CSV file', @@ -535,7 +534,6 @@ return array( 'match_address' => '*Address must match address associated with credit card.', 'click_once' => '*Please click "PAY NOW" only once - transaction may take up to 1 minute to process.', - 'default_invoice_footer' => 'Set default invoice footer', 'invoice_footer' => 'Invoice Footer', 'save_as_default_footer' => 'Save as default footer', @@ -884,6 +882,11 @@ return array( 'payment' => 'Payment', 'system' => 'System', - + 'signature' => 'Email Signature', + 'default_messages' => 'Default Messages', + 'quote_terms' => 'Quote Terms', + 'default_quote_terms' => 'Default Quote Terms', + 'default_invoice_terms' => 'Default Invoice Terms', + 'default_invoice_footer' => 'Default Invoice Footer', ); diff --git a/resources/views/accounts/details.blade.php b/resources/views/accounts/details.blade.php index a6dc72b4a8..0209242e36 100644 --- a/resources/views/accounts/details.blade.php +++ b/resources/views/accounts/details.blade.php @@ -33,7 +33,9 @@ {!! Former::text('vat_number') !!} {!! Former::text('work_email') !!} {!! Former::text('work_phone') !!} - {!! Former::file('logo')->max(2, 'MB')->accept('image')->inlineHelp(trans('texts.logo_help')) !!} + {!! Former::textarea('email_footer')->label(trans('texts.signature'))->rows(4) !!} + {!! Former::file('logo')->max(2, 'MB')->accept('image')->inlineHelp(trans('texts.logo_help')) !!} + @if ($account->hasLogo())
diff --git a/resources/views/accounts/invoice_settings.blade.php b/resources/views/accounts/invoice_settings.blade.php index f7f2ed1746..ab4ace8170 100644 --- a/resources/views/accounts/invoice_settings.blade.php +++ b/resources/views/accounts/invoice_settings.blade.php @@ -127,7 +127,6 @@ -

{!! trans('texts.custom_fields') !!}

@@ -190,6 +189,46 @@
+
+
+

{!! trans('texts.default_messages') !!}

+
+
+ +
+ +
+
+
+
+ {!! Former::textarea('invoice_terms') + ->label(trans('texts.default_invoice_terms')) + ->rows(4) !!} +
+
+
+
+ {!! Former::textarea('invoice_footer') + ->label(trans('texts.default_invoice_footer')) + ->rows(4) !!} +
+
+
+
+ {!! Former::textarea('quote_terms') + ->label(trans('texts.default_quote_terms')) + ->rows(4) !!} +
+
+
+
+
+ + @if (Auth::user()->isPro())
diff --git a/resources/views/accounts/notifications.blade.php b/resources/views/accounts/notifications.blade.php index c92bf3fc7b..2b1ebd4847 100644 --- a/resources/views/accounts/notifications.blade.php +++ b/resources/views/accounts/notifications.blade.php @@ -48,20 +48,7 @@ --> - -
-
-

{!! trans('texts.custom_messages') !!}

-
-
- {!! Former::textarea('invoice_terms')->label(trans('texts.default_invoice_terms'))->rows(4) - ->onchange("$('#invoice_terms').val(wordWrapText($('#invoice_terms').val(), 300))") !!} - {!! Former::textarea('invoice_footer')->label(trans('texts.default_invoice_footer'))->rows(4) - ->onchange("$('#invoice_footer').val(wordWrapText($('#invoice_footer').val(), 600))") !!} - {!! Former::textarea('email_footer')->label(trans('texts.default_email_footer'))->rows(4) !!} -
-
- + {!! Former::actions( Button::success(trans('texts.save')) ->submit()->large() diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 362194c81f..1ef8dba635 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -225,7 +225,7 @@ @@ -845,7 +845,7 @@ @if (!$invoice) if (!invoice.terms) { - invoice.terms = wordWrapText('{!! str_replace(["\r\n","\r","\n"], '\n', addslashes($account->invoice_terms)) !!}', 300); + invoice.terms = wordWrapText('{!! str_replace(["\r\n","\r","\n"], '\n', addslashes($account->{"{$entityType}e_terms"})) !!}', 300); } if (!invoice.invoice_footer) { invoice.invoice_footer = wordWrapText('{!! str_replace(["\r\n","\r","\n"], '\n', addslashes($account->invoice_footer)) !!}', 600); @@ -1011,7 +1011,7 @@ } function onMarkClick() { - submitBulkAction('mark'); + submitBulkAction('markSent'); } function onCloneClick() { diff --git a/resources/views/invoices/knockout.blade.php b/resources/views/invoices/knockout.blade.php index e125c43b11..2c605f3eed 100644 --- a/resources/views/invoices/knockout.blade.php +++ b/resources/views/invoices/knockout.blade.php @@ -202,8 +202,8 @@ function InvoiceModel(data) { self.is_amount_discount = ko.observable(0); self.frequency_id = ko.observable(4); // default to monthly self.terms = ko.observable(''); - self.default_terms = ko.observable(account.invoice_terms); - self.terms_placeholder = ko.observable({{ !$invoice->id && $account->invoice_terms ? 'account.invoice_terms' : false}}); + self.default_terms = ko.observable(account.{{ $entityType }}_terms); + self.terms_placeholder = ko.observable({{ !$invoice->id && $account->{"{$entityType}_terms"} ? "account.{$entityType}_terms" : false}}); self.set_default_terms = ko.observable(false); self.invoice_footer = ko.observable(''); self.default_footer = ko.observable(account.invoice_footer); diff --git a/resources/views/list.blade.php b/resources/views/list.blade.php index 2cf4863229..ed8c610e3a 100644 --- a/resources/views/list.blade.php +++ b/resources/views/list.blade.php @@ -5,7 +5,6 @@ {!! Former::open($entityType . 's/bulk')->addClass('listForm') !!}
{!! Former::text('action') !!} - {!! Former::text('statusId') !!} {!! Former::text('public_id') !!}
@@ -84,10 +83,9 @@ submitForm('convert'); } - function markEntity(id, statusId) { + function markEntity(id) { $('#public_id').val(id); - $('#statusId').val(statusId); - submitForm('mark'); + submitForm('markSent'); } function stopTask(id) {