From 9dcc4e0e52aa420f45e76fba33dd9b39e6395f26 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 12 Apr 2015 17:18:05 +0300 Subject: [PATCH 01/13] Working on L5 --- .env.example | 1 + app/Console/Commands/SendRecurringInvoices.php | 6 ++++++ app/Http/Controllers/AppController.php | 1 + app/Models/Invoice.php | 4 +--- config/app.php | 2 +- readme.md | 2 +- resources/views/auth/login.blade.php | 8 ++++++++ 7 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 651ccbbc5207..bd40885edb04 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,7 @@ APP_ENV=development APP_DEBUG=true APP_URL=http://ninja.dev +APP_CIPHER=rijndael-128 APP_KEY= DB_TYPE=mysql diff --git a/app/Console/Commands/SendRecurringInvoices.php b/app/Console/Commands/SendRecurringInvoices.php index ece16d94baa5..a5fe2cdaf9b9 100644 --- a/app/Console/Commands/SendRecurringInvoices.php +++ b/app/Console/Commands/SendRecurringInvoices.php @@ -1,9 +1,15 @@ users()->first(); //Auth::login($user, true); + $this->accountRepo->registerUser($user); return Redirect::to('/login'); } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 294a4eef1ba3..ead3f9fa38b7 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -236,8 +236,6 @@ Invoice::deleting(function ($invoice) { Activity::archiveInvoice($invoice); }); -// TODO: Fix for L5 -/*Invoice::restoring(function ($invoice) { +Invoice::restoring(function ($invoice) { Activity::restoreInvoice($invoice); }); -*/ \ No newline at end of file diff --git a/config/app.php b/config/app.php index 9a72079f9e25..4568f97c6fdd 100644 --- a/config/app.php +++ b/config/app.php @@ -80,7 +80,7 @@ return [ 'key' => env('APP_KEY', ''), - 'cipher' => MCRYPT_RIJNDAEL_128, + 'cipher' => env('APP_CIPHER', MCRYPT_RIJNDAEL_128), /* |-------------------------------------------------------------------------- diff --git a/readme.md b/readme.md index 1ccf35513890..19c0729c75de 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ ### [https://www.invoiceninja.com](https://www.invoiceninja.com) -#### Note: the application has recently been updated to Laravel 5. Please use the [1.7.x branch](https://github.com/hillelcoren/invoice-ninja/tree/1.7.x) for a more stable build. +#### Please [click here](https://bitnami.com/stack/invoice-ninja) to vote for us to be added to Bitnami's one-click install library If you'd like to use our code to sell your own invoicing app we have an affiliate program. Get in touch for more details. diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 9bebd1fb3b3a..c7a15dfe3a85 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -105,6 +105,7 @@ @if (!Utils::isNinja())

+ + +

 

+

 

+ + +
@endif From 564d00642824c966e4ce5bfceba1fa145273680c Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 13 Apr 2015 10:54:51 +0300 Subject: [PATCH 02/13] Working on L5 --- app/Exceptions/Handler.php | 8 +++++--- app/Http/Controllers/HomeController.php | 7 ++++--- app/Http/Controllers/InvoiceApiController.php | 13 +++++++++++-- app/Http/Controllers/TokenController.php | 5 ----- app/Http/routes.php | 2 +- app/Libraries/Utils.php | 1 + config/app.php | 2 +- readme.md | 2 +- resources/views/header.blade.php | 2 +- resources/views/invoices/edit.blade.php | 6 +++--- 10 files changed, 28 insertions(+), 20 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index c7a75d356dd5..1475cbb5cb09 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -1,5 +1,6 @@ where('invoices.is_quote', '=', false)->orderBy('created_at', 'desc')->get(); - $invoices = Utils::remapPublicIds($invoices->toArray()); + $invoices = Invoice::scope()->with('invitations')->where('invoices.is_quote', '=', false)->orderBy('created_at', 'desc')->get(); + // Add the first invitation link to the data + foreach ($invoices as $key => $invoice) { + foreach ($invoice->invitations as $subKey => $invitation) { + $invoices[$key]['link'] = $invitation->getLink(); + } + unset($invoice['invitations']); + } + + $invoices = Utils::remapPublicIds($invoices->toArray()); + $response = json_encode($invoices, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(count($invoices)); diff --git a/app/Http/Controllers/TokenController.php b/app/Http/Controllers/TokenController.php index f84411a60243..3b9d546849ab 100644 --- a/app/Http/Controllers/TokenController.php +++ b/app/Http/Controllers/TokenController.php @@ -93,11 +93,6 @@ class TokenController extends BaseController */ public function create() { - if (!Auth::user()->confirmed) { - Session::flash('error', trans('texts.register_to_add_user')); - return Redirect::to('company/advanced_settings/user_management'); - } - $data = [ 'showBreadcrumbs' => false, 'token' => null, diff --git a/app/Http/routes.php b/app/Http/routes.php index d090b43ec94a..eb5656b0880d 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -321,7 +321,7 @@ define('NINJA_GATEWAY_ID', GATEWAY_AUTHORIZE_NET); define('NINJA_GATEWAY_CONFIG', '{"apiLoginId":"626vWcD5","transactionKey":"4bn26TgL9r4Br4qJ","testMode":"","developerMode":""}'); define('NINJA_WEB_URL', 'https://www.invoiceninja.com'); define('NINJA_APP_URL', 'https://app.invoiceninja.com'); -define('NINJA_VERSION', '2.0'); +define('NINJA_VERSION', '1.7.2'); define('NINJA_DATE', '2000-01-01'); define('NINJA_FROM_EMAIL', 'maildelivery@invoiceninja.com'); define('RELEASES_URL', 'https://github.com/hillelcoren/invoice-ninja/releases/'); diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 33d799e4acb7..08a4e5d50a63 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -165,6 +165,7 @@ class Utils 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'ip' => Request::getClientIp(), 'count' => Session::get('error_count', 0), + 'input' => Input::all() ]; Log::error($error."\n", $data); diff --git a/config/app.php b/config/app.php index 4568f97c6fdd..a8dd21bff24c 100644 --- a/config/app.php +++ b/config/app.php @@ -13,7 +13,7 @@ return [ | */ - 'debug' => true, + 'debug' => env('APP_DEBUG', ''), /* |-------------------------------------------------------------------------- diff --git a/readme.md b/readme.md index 19c0729c75de..37236a85d6c3 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ ### [https://www.invoiceninja.com](https://www.invoiceninja.com) -#### Please [click here](https://bitnami.com/stack/invoice-ninja) to vote for us to be added to Bitnami's one-click install library +##### Please [click here](https://bitnami.com/stack/invoice-ninja) to vote for us to be added to Bitnami's one-click install library If you'd like to use our code to sell your own invoicing app we have an affiliate program. Get in touch for more details. diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index f8198e2504ae..abc37c633b15 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -164,7 +164,7 @@ @elseif (Session::has('news_feed_message'))
- {{ Session::get('news_feed_message') }} + {!! Session::get('news_feed_message') !!} {{ trans('texts.hide') }}
@endif diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index fc67dcce8b5e..2bf24232c4e8 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -672,11 +672,11 @@ invoice.is_quote = {{ $entityType == ENTITY_QUOTE ? 'true' : 'false' }}; invoice.contact = _.findWhere(invoice.client.contacts, {send_invoice: true}); - if (!invoice.terms) { - invoice.terms = "{{ str_replace(["\r\n","\r","\n"], '\n', addslashes($account->invoice_terms)) }}"; + if (!invoice.terms) { + invoice.terms = wordWrapText('{{ str_replace(["\r\n","\r","\n"], '\n', addslashes($account->invoice_terms)) }}', 300); } if (!invoice.invoice_footer) { - invoice.invoice_footer = "{{ str_replace(["\r\n","\r","\n"], '\n', addslashes($account->invoice_footer)) }}"; + invoice.invoice_footer = wordWrapText('{{ str_replace(["\r\n","\r","\n"], '\n', addslashes($account->invoice_footer)) }}', 600); } @if (file_exists($account->getLogoPath())) From 5a6197fbb4350d08398f6bbc9df2f884d86721c1 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 13 Apr 2015 15:00:31 +0300 Subject: [PATCH 03/13] Added notification email when quote is approved --- app/Events/QuoteApproved.php | 23 ++++++++++ app/Http/Controllers/AccountController.php | 1 + app/Http/Controllers/QuoteController.php | 10 ++++- app/Listeners/HandleQuoteApproved.php | 42 +++++++++++++++++++ app/Ninja/Mailers/UserMailer.php | 2 +- app/Ninja/Repositories/InvoiceRepository.php | 22 +++++----- app/Providers/EventServiceProvider.php | 3 ++ .../2015_04_13_100333_add_notify_approved.php | 34 +++++++++++++++ resources/lang/da/texts.php | 4 ++ resources/lang/de/texts.php | 4 ++ resources/lang/en/texts.php | 7 +++- resources/lang/es/texts.php | 6 ++- resources/lang/fr/texts.php | 6 ++- resources/lang/it/texts.php | 4 ++ resources/lang/lt/texts.php | 4 ++ resources/lang/nb_NO/texts.php | 4 ++ resources/lang/nl/texts.php | 4 ++ resources/lang/pt_BR/texts.php | 4 ++ resources/lang/sv/texts.php | 4 ++ .../views/accounts/notifications.blade.php | 4 +- .../emails/quote_approved_html.blade.php | 18 ++++++++ .../emails/quote_approved_text.blade.php | 8 ++++ resources/views/invoices/edit.blade.php | 16 +++---- resources/views/invoices/view.blade.php | 6 +-- 24 files changed, 210 insertions(+), 30 deletions(-) create mode 100644 app/Events/QuoteApproved.php create mode 100644 app/Listeners/HandleQuoteApproved.php create mode 100644 database/migrations/2015_04_13_100333_add_notify_approved.php create mode 100644 resources/views/emails/quote_approved_html.blade.php create mode 100644 resources/views/emails/quote_approved_text.blade.php diff --git a/app/Events/QuoteApproved.php b/app/Events/QuoteApproved.php new file mode 100644 index 000000000000..12b5384b35e3 --- /dev/null +++ b/app/Events/QuoteApproved.php @@ -0,0 +1,23 @@ +invoice = $invoice; + } + +} diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 44aa7a0c5e22..24025cc0f835 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -554,6 +554,7 @@ class AccountController extends BaseController $user->notify_sent = Input::get('notify_sent'); $user->notify_viewed = Input::get('notify_viewed'); $user->notify_paid = Input::get('notify_paid'); + $user->notify_approved = Input::get('notify_approved'); $user->save(); Session::flash('message', trans('texts.updated_settings')); diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 93181e628b83..378830c5bd43 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -6,7 +6,8 @@ use Redirect; use Utils; use View; use Cache; - +use Event; +use Session; use App\Models\Account; use App\Models\Client; use App\Models\Country; @@ -17,10 +18,13 @@ use App\Models\PaymentTerm; use App\Models\Product; use App\Models\Size; use App\Models\TaxRate; +use App\Models\Invitation; +use App\Models\Activity; use App\Ninja\Mailers\ContactMailer as Mailer; use App\Ninja\Repositories\InvoiceRepository; use App\Ninja\Repositories\ClientRepository; use App\Ninja\Repositories\TaxRateRepository; +use App\Events\QuoteApproved; class QuoteController extends BaseController { @@ -187,7 +191,9 @@ class QuoteController extends BaseController $invoice = $invitation->invoice; if ($invoice->is_quote && !$invoice->quote_invoice_id) { - Activity::approveQuote($invitation); + Event::fire(new QuoteApproved($invoice)); + Activity::approveQuote($invitation); + $invoice = $this->invoiceRepo->cloneInvoice($invoice, $invoice->id); Session::flash('message', trans('texts.converted_to_invoice')); diff --git a/app/Listeners/HandleQuoteApproved.php b/app/Listeners/HandleQuoteApproved.php new file mode 100644 index 000000000000..3a49aa9b5af5 --- /dev/null +++ b/app/Listeners/HandleQuoteApproved.php @@ -0,0 +1,42 @@ +userMailer = $userMailer; + } + + /** + * Handle the event. + * + * @param QuoteApproved $event + * @return void + */ + public function handle(QuoteApproved $event) + { + $invoice = $event->invoice; + + foreach ($invoice->account->users as $user) + { + if ($user->{'notify_approved'}) + { + $this->userMailer->sendNotification($user, $invoice, 'approved'); + } + } + } + +} diff --git a/app/Ninja/Mailers/UserMailer.php b/app/Ninja/Mailers/UserMailer.php index ad82923b7727..5831e66b5cdc 100644 --- a/app/Ninja/Mailers/UserMailer.php +++ b/app/Ninja/Mailers/UserMailer.php @@ -39,8 +39,8 @@ class UserMailer extends Mailer return; } - $view = 'invoice_'.$notificationType; $entityType = $invoice->getEntityType(); + $view = "{$entityType}_{$notificationType}"; $data = [ 'entityType' => $entityType, diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 5bfbcdd7c187..10631eb15112 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -223,6 +223,17 @@ class InvoiceRepository $account = \Auth::user()->account; + 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']); + } + if (isset($data['set_default_footer']) && $data['set_default_footer']) { + $account->invoice_footer = trim($data['invoice_footer']); + } + $account->save(); + } + $invoice->client_id = $data['client_id']; $invoice->discount = round(Utils::parseFloat($data['discount']), 2); $invoice->is_amount_discount = $data['is_amount_discount'] ? true : false; @@ -360,17 +371,6 @@ class InvoiceRepository $invoice->invoice_items()->save($invoiceItem); } - 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']); - } - if (isset($data['set_default_footer']) && $data['set_default_footer']) { - $account->invoice_footer = trim($data['invoice_footer']); - } - $account->save(); - } - return $invoice; } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index e5fd505a007a..3ce33b355412 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -26,6 +26,9 @@ class EventServiceProvider extends ServiceProvider { 'App\Events\InvoicePaid' => [ 'App\Listeners\HandleInvoicePaid', ], + 'App\Events\QuoteApproved' => [ + 'App\Listeners\HandleQuoteApproved', + ], ]; /** diff --git a/database/migrations/2015_04_13_100333_add_notify_approved.php b/database/migrations/2015_04_13_100333_add_notify_approved.php new file mode 100644 index 000000000000..8f0a4fd74060 --- /dev/null +++ b/database/migrations/2015_04_13_100333_add_notify_approved.php @@ -0,0 +1,34 @@ +boolean('notify_approved')->default(true); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function($table) + { + $table->dropColumn('notify_approved'); + }); + } + +} diff --git a/resources/lang/da/texts.php b/resources/lang/da/texts.php index 80cda729a834..20a2071c809c 100644 --- a/resources/lang/da/texts.php +++ b/resources/lang/da/texts.php @@ -580,5 +580,9 @@ return array( 'send_email' => 'Send email', 'set_password' => 'Set Password', 'converted' => 'Converted', + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', ); diff --git a/resources/lang/de/texts.php b/resources/lang/de/texts.php index cdb8b241bc4d..5b1da59faecd 100644 --- a/resources/lang/de/texts.php +++ b/resources/lang/de/texts.php @@ -571,6 +571,10 @@ return array( 'send_email' => 'Send email', 'set_password' => 'Set Password', 'converted' => 'Converted', + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', ); diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 8c3959020dc3..a8ad30ccc7a2 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -578,6 +578,9 @@ return array( 'send_email' => 'Send email', 'set_password' => 'Set Password', 'converted' => 'Converted', - - + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + ); diff --git a/resources/lang/es/texts.php b/resources/lang/es/texts.php index 2a06257d8c4b..5cedb7aa5154 100644 --- a/resources/lang/es/texts.php +++ b/resources/lang/es/texts.php @@ -550,7 +550,11 @@ return array( 'send_email' => 'Send email', 'set_password' => 'Set Password', 'converted' => 'Converted', - + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + ); \ No newline at end of file diff --git a/resources/lang/fr/texts.php b/resources/lang/fr/texts.php index 09a5a4339072..94836f2f68d0 100644 --- a/resources/lang/fr/texts.php +++ b/resources/lang/fr/texts.php @@ -571,6 +571,10 @@ return array( 'send_email' => 'Send email', 'set_password' => 'Set Password', 'converted' => 'Converted', - + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + ); \ No newline at end of file diff --git a/resources/lang/it/texts.php b/resources/lang/it/texts.php index 4bc0f7f0a59c..83af0c1028a8 100644 --- a/resources/lang/it/texts.php +++ b/resources/lang/it/texts.php @@ -573,6 +573,10 @@ return array( 'send_email' => 'Send email', 'set_password' => 'Set Password', 'converted' => 'Converted', + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', ); diff --git a/resources/lang/lt/texts.php b/resources/lang/lt/texts.php index f78284d8bb7f..96ab93f6d9ae 100644 --- a/resources/lang/lt/texts.php +++ b/resources/lang/lt/texts.php @@ -581,6 +581,10 @@ return array( 'send_email' => 'Send email', 'set_password' => 'Set Password', 'converted' => 'Converted', + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', diff --git a/resources/lang/nb_NO/texts.php b/resources/lang/nb_NO/texts.php index f87c1fa93129..ec63a0dbfc5a 100644 --- a/resources/lang/nb_NO/texts.php +++ b/resources/lang/nb_NO/texts.php @@ -580,5 +580,9 @@ return array( 'set_password' => 'Set Password', 'converted' => 'Converted', + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + ); \ No newline at end of file diff --git a/resources/lang/nl/texts.php b/resources/lang/nl/texts.php index 4c4b3e13c117..e4634a64f09b 100644 --- a/resources/lang/nl/texts.php +++ b/resources/lang/nl/texts.php @@ -574,6 +574,10 @@ return array( 'send_email' => 'Verstuur email', 'set_password' => 'Stel wachtwoord in', 'converted' => 'Omgezet', + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', diff --git a/resources/lang/pt_BR/texts.php b/resources/lang/pt_BR/texts.php index bac1303054a9..639eae4378ff 100644 --- a/resources/lang/pt_BR/texts.php +++ b/resources/lang/pt_BR/texts.php @@ -574,6 +574,10 @@ return array( 'send_email' => 'Send email', 'set_password' => 'Set Password', 'converted' => 'Converted', + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', ); diff --git a/resources/lang/sv/texts.php b/resources/lang/sv/texts.php index 755c5bd5a211..3185222c1eed 100644 --- a/resources/lang/sv/texts.php +++ b/resources/lang/sv/texts.php @@ -577,6 +577,10 @@ return array( 'send_email' => 'Skicka mail', 'set_password' => 'Ange lösenord', 'converted' => 'Konvertera', + + 'email_approved' => 'Email me when a quote is approved', + 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', + 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', ); diff --git a/resources/views/accounts/notifications.blade.php b/resources/views/accounts/notifications.blade.php index 15f9915d162f..0e4fe6f73b88 100644 --- a/resources/views/accounts/notifications.blade.php +++ b/resources/views/accounts/notifications.blade.php @@ -8,11 +8,13 @@ {{ Former::populateField('notify_sent', intval(Auth::user()->notify_sent)) }} {{ Former::populateField('notify_viewed', intval(Auth::user()->notify_viewed)) }} {{ Former::populateField('notify_paid', intval(Auth::user()->notify_paid)) }} + {{ Former::populateField('notify_approved', intval(Auth::user()->notify_approved)) }} {!! Former::legend(trans('texts.email_notifications')) !!} {!! Former::checkbox('notify_sent')->label(' ')->text(trans('texts.email_sent')) !!} {!! Former::checkbox('notify_viewed')->label(' ')->text(trans('texts.email_viewed')) !!} - {!! Former::checkbox('notify_paid')->label(' ')->text(trans('texts.email_paid')) !!} + {!! Former::checkbox('notify_paid')->label(' ')->text(trans('texts.email_paid')) !!} + {!! Former::checkbox('notify_approved')->label(' ')->text(trans('texts.email_approved')) !!} {!! Former::legend(trans('texts.site_updates')) !!} diff --git a/resources/views/emails/quote_approved_html.blade.php b/resources/views/emails/quote_approved_html.blade.php new file mode 100644 index 000000000000..0bcc50acfab4 --- /dev/null +++ b/resources/views/emails/quote_approved_html.blade.php @@ -0,0 +1,18 @@ + + + + + + + @include('emails.view_action', ['link' => $invoiceLink, 'entityType' => $entityType]) + {{ trans('texts.email_salutation', ['name' => $userName]) }}

+ + {{ trans("texts.notification_{$entityType}_approved", ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }}

+ + {{ trans('texts.email_signature') }}
+ {{ trans('texts.email_from') }}

+ + {{ trans('texts.user_email_footer') }}

+ + + \ No newline at end of file diff --git a/resources/views/emails/quote_approved_text.blade.php b/resources/views/emails/quote_approved_text.blade.php new file mode 100644 index 000000000000..826b18e7d58e --- /dev/null +++ b/resources/views/emails/quote_approved_text.blade.php @@ -0,0 +1,8 @@ +{{ trans('texts.email_salutation', ['name' => $userName]) }} + +{{ trans("texts.notification_{$entityType}_approved", ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} + +{{ trans('texts.email_signature') }} +{{ trans('texts.email_from') }} + +{{ trans('texts.user_email_footer') }} \ No newline at end of file diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 2bf24232c4e8..7be74e42d1c4 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -1181,8 +1181,8 @@ self.totals.rawSubtotal = ko.computed(function() { var total = 0; for(var p=0; p < self.invoice_items().length; ++p) { - var item = self.invoice_items()[p]; - total += item.totals.rawTotal(); + var item = self.invoice_items()[p]; + total += item.totals.rawTotal(); } return total; }); @@ -1526,12 +1526,12 @@ var cost = roundToTwo(NINJA.parseFloat(self.cost())); var qty = roundToTwo(NINJA.parseFloat(self.qty())); var taxRate = NINJA.parseFloat(self.tax_rate()); - var value = cost * qty; - if (taxRate > 0) { - value += value * (taxRate/100); - } - return value ? roundToTwo(value) : ''; - }); + var value = cost * qty; + if (taxRate > 0) { + value += value * (taxRate/100); + } + return value ? roundToTwo(value) : 0; + }); this.totals.total = ko.computed(function() { var total = self.totals.rawTotal(); diff --git a/resources/views/invoices/view.blade.php b/resources/views/invoices/view.blade.php index 0f6f768343bf..6caa93395dc6 100644 --- a/resources/views/invoices/view.blade.php +++ b/resources/views/invoices/view.blade.php @@ -24,7 +24,7 @@ @if ($invoice->is_quote) {!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}   @if (!$isConverted) - {!! Button::success(trans('texts.approve'))->asLinkTo('approve/' . $invitation->invitation_key)->large() !!} + {!! Button::success(trans('texts.approve'))->asLinkTo('/approve/' . $invitation->invitation_key)->large() !!} @endif @elseif ($invoice->client->account->isGatewayConfigured() && !$invoice->isPaid() && !$invoice->is_recurring) {!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}   @@ -39,10 +39,10 @@ ['url' => URL::to("payment/{$invitation->invitation_key}?use_paypal=false"), 'label' => trans('texts.pay_with_card')] ])->addClass('btn-lg') !!} @else - {!! Button::success(trans('texts.pay_now'))->asLinkTo(URL::to('payment/' . $invitation->invitation_key))->large() !!} + {!! Button::success(trans('texts.pay_now'))->asLinkTo('/payment/' . $invitation->invitation_key)->large() !!} @endif @else - {!! Button::success('Download PDF')->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!} + {!! Button::normal('Download PDF')->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!} @endif From 3641019d0418366bc8788dc007486f1b6c3e8315 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 13 Apr 2015 15:49:40 +0300 Subject: [PATCH 04/13] Enabled re-sending confirmation email --- app/Http/Controllers/AccountController.php | 8 ++++++++ app/Http/routes.php | 3 ++- resources/lang/en/texts.php | 3 +++ resources/views/accounts/details.blade.php | 2 ++ resources/views/accounts/notifications.blade.php | 6 ++++-- resources/views/header.blade.php | 2 +- resources/views/invoices/edit.blade.php | 2 +- 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 24025cc0f835..7beab2c92cb9 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -739,4 +739,12 @@ class AccountController extends BaseController return Redirect::to('/')->with('clearGuestKey', true); } + + public function resendConfirmation() + { + $user = Auth::user(); + $this->userMailer->sendConfirmation($user); + + return Redirect::to('/company/details')->with('message', trans('texts.confirmation_resent')); + } } diff --git a/app/Http/routes.php b/app/Http/routes.php index eb5656b0880d..bdca441d9bee 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -71,7 +71,7 @@ get('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getEma post('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postEmail')); get('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset')); post('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postReset')); -get('user/confirm/{code}', 'UserController@confirm'); +get('/user/confirm/{code}', 'UserController@confirm'); /* // Confide routes @@ -167,6 +167,7 @@ Route::group(['middleware' => 'auth'], function() { Route::get('api/credits/{client_id?}', array('as'=>'api.credits', 'uses'=>'CreditController@getDatatable')); Route::post('credits/bulk', 'CreditController@bulk'); + get('/resend_confirmation', 'AccountController@resendConfirmation'); //Route::resource('timesheets', 'TimesheetController'); }); diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index a8ad30ccc7a2..823e76d13883 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -582,5 +582,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', + ); diff --git a/resources/views/accounts/details.blade.php b/resources/views/accounts/details.blade.php index f1a944b3b05a..8cc1515e7a3d 100644 --- a/resources/views/accounts/details.blade.php +++ b/resources/views/accounts/details.blade.php @@ -66,6 +66,8 @@ {!! Former::text('phone') !!} @if (Auth::user()->confirmed) {!! Former::actions( Button::primary(trans('texts.change_password'))->small()->withAttributes(['onclick'=>'showChangePassword()'])) !!} + @elseif (Auth::user()->registered) + {!! Former::actions( Button::primary(trans('texts.resend_confirmation'))->asLinkTo('/resend_confirmation')->small() ) !!} @endif @endif diff --git a/resources/views/accounts/notifications.blade.php b/resources/views/accounts/notifications.blade.php index 0e4fe6f73b88..01eae5a70e3e 100644 --- a/resources/views/accounts/notifications.blade.php +++ b/resources/views/accounts/notifications.blade.php @@ -39,8 +39,10 @@ {!! Former::legend(trans('texts.custom_messages')) !!} - {!! Former::textarea('invoice_terms')->label(trans('texts.default_invoice_terms')) !!} - {!! Former::textarea('invoice_footer')->label(trans('texts.default_invoice_footer')) !!} + {!! Former::textarea('invoice_terms')->label(trans('texts.default_invoice_terms')) + ->onchange("$('#invoice_terms').val(wordWrapText($('#invoice_terms').val(), 300))") !!} + {!! Former::textarea('invoice_footer')->label(trans('texts.default_invoice_footer')) + ->onchange("$('#invoice_footer').val(wordWrapText($('#invoice_footer').val(), 600))") !!} {!! Former::textarea('email_footer')->label(trans('texts.default_email_footer')) !!} {!! Former::actions( diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index abc37c633b15..073700d45d68 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -363,7 +363,7 @@ var isFormValid = true; $(['first_name','last_name','email','password']).each(function(i, field) { var $input = $('form.signUpForm #new_'+field), - val = $.trim($input.val()); + val = $.trim($input.val()); var isValid = val && val.length >= (field == 'password' ? 6 : 1); if (isValid && field == 'email') { isValid = isValidEmailAddress(val); diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 7be74e42d1c4..067fd93cf3fa 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -685,7 +685,7 @@ invoice.imageHeight = {{ $account->getLogoHeight() }}; @endif - return invoice; + return invoice; } function getPDFString() { From 635c1b9df16e79f4319b508ea5a2ba27d790f5cc Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 13 Apr 2015 18:05:34 +0300 Subject: [PATCH 05/13] Working on L5 --- app/Http/Controllers/AccountController.php | 2 +- app/Http/Controllers/UserController.php | 2 +- app/Libraries/Utils.php | 2 +- resources/lang/da/texts.php | 2 ++ resources/lang/de/texts.php | 2 ++ resources/lang/es/texts.php | 2 ++ resources/lang/fr/texts.php | 2 ++ resources/lang/it/texts.php | 2 ++ resources/lang/lt/texts.php | 2 ++ resources/lang/nb_NO/texts.php | 2 ++ resources/lang/nl/texts.php | 2 ++ resources/lang/pt_BR/texts.php | 2 ++ resources/lang/sv/texts.php | 2 ++ resources/views/accounts/details.blade.php | 12 ++++++------ 14 files changed, 29 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 7beab2c92cb9..b80a59b86450 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -676,7 +676,7 @@ class AccountController extends BaseController $user->last_name = trim(Input::get('new_last_name')); $user->email = trim(strtolower(Input::get('new_email'))); $user->username = $user->email; - $user->password = trim(Input::get('new_password')); + $user->password = bcrypt(trim(Input::get('new_password'))); $user->registered = true; $user->save(); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index e4d3d512bfa1..19f3708fee64 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -336,7 +336,7 @@ class UserController extends BaseController // save the new password $user = Auth::user(); - $user->password = $password; + $user->password = bcrypt($password); $user->save(); return RESULT_SUCCESS; diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 08a4e5d50a63..d6789909c4c5 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -165,7 +165,7 @@ class Utils 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'ip' => Request::getClientIp(), 'count' => Session::get('error_count', 0), - 'input' => Input::all() + //'input' => Input::all() ]; Log::error($error."\n", $data); diff --git a/resources/lang/da/texts.php b/resources/lang/da/texts.php index 20a2071c809c..20c38f824130 100644 --- a/resources/lang/da/texts.php +++ b/resources/lang/da/texts.php @@ -584,5 +584,7 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', ); diff --git a/resources/lang/de/texts.php b/resources/lang/de/texts.php index 5b1da59faecd..3d655b318564 100644 --- a/resources/lang/de/texts.php +++ b/resources/lang/de/texts.php @@ -575,6 +575,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', ); diff --git a/resources/lang/es/texts.php b/resources/lang/es/texts.php index 5cedb7aa5154..eb26690bf8da 100644 --- a/resources/lang/es/texts.php +++ b/resources/lang/es/texts.php @@ -554,6 +554,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', diff --git a/resources/lang/fr/texts.php b/resources/lang/fr/texts.php index 94836f2f68d0..3de369f585cc 100644 --- a/resources/lang/fr/texts.php +++ b/resources/lang/fr/texts.php @@ -575,6 +575,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', ); \ No newline at end of file diff --git a/resources/lang/it/texts.php b/resources/lang/it/texts.php index 83af0c1028a8..271fbf6c931b 100644 --- a/resources/lang/it/texts.php +++ b/resources/lang/it/texts.php @@ -577,6 +577,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', ); diff --git a/resources/lang/lt/texts.php b/resources/lang/lt/texts.php index 96ab93f6d9ae..f146689e9a0f 100644 --- a/resources/lang/lt/texts.php +++ b/resources/lang/lt/texts.php @@ -585,6 +585,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', diff --git a/resources/lang/nb_NO/texts.php b/resources/lang/nb_NO/texts.php index ec63a0dbfc5a..36ea3d406659 100644 --- a/resources/lang/nb_NO/texts.php +++ b/resources/lang/nb_NO/texts.php @@ -583,6 +583,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', ); \ No newline at end of file diff --git a/resources/lang/nl/texts.php b/resources/lang/nl/texts.php index e4634a64f09b..433da85070b9 100644 --- a/resources/lang/nl/texts.php +++ b/resources/lang/nl/texts.php @@ -578,6 +578,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', diff --git a/resources/lang/pt_BR/texts.php b/resources/lang/pt_BR/texts.php index 639eae4378ff..328ee77f8aa5 100644 --- a/resources/lang/pt_BR/texts.php +++ b/resources/lang/pt_BR/texts.php @@ -578,6 +578,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', ); diff --git a/resources/lang/sv/texts.php b/resources/lang/sv/texts.php index 3185222c1eed..acea328b30a6 100644 --- a/resources/lang/sv/texts.php +++ b/resources/lang/sv/texts.php @@ -581,6 +581,8 @@ return array( 'email_approved' => 'Email me when a quote is approved', 'notification_quote_approved_subject' => 'Quote :invoice was approved by :client', 'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.', + 'resend_confirmation' => 'Resend confirmation email', + 'confirmation_resent' => 'The confirmation email was resent', ); diff --git a/resources/views/accounts/details.blade.php b/resources/views/accounts/details.blade.php index 8cc1515e7a3d..592a147042df 100644 --- a/resources/views/accounts/details.blade.php +++ b/resources/views/accounts/details.blade.php @@ -104,7 +104,7 @@   {!! Former::password('current_password')->style('width:300px') !!} - {!! Former::password('new_password')->style('width:300px') !!} + {!! Former::password('newer_password')->style('width:300px')->label(trans('texts.new_password')) !!} {!! Former::password('confirm_password')->style('width:300px') !!}   @@ -158,7 +158,7 @@ $('#country_id').combobox(); $('#passwordModal').on('hidden.bs.modal', function () { - $(['current_password', 'new_password', 'confirm_password']).each(function(i, field) { + $(['current_password', 'newer_password', 'confirm_password']).each(function(i, field) { var $input = $('form #'+field); $input.val(''); $input.closest('div.form-group').removeClass('has-success'); @@ -193,13 +193,13 @@ function validateChangePassword(showError) { var isFormValid = true; - $(['current_password', 'new_password', 'confirm_password']).each(function(i, field) { + $(['current_password', 'newer_password', 'confirm_password']).each(function(i, field) { var $input = $('form #'+field), val = $.trim($input.val()); var isValid = val && val.length >= 6; if (isValid && field == 'confirm_password') { - isValid = val == $.trim($('#new_password').val()); + isValid = val == $.trim($('#newer_password').val()); } if (isValid) { @@ -229,9 +229,9 @@ $.ajax({ type: 'POST', - url: '{{ URL::to('users/change_password') }}', + url: '{{ URL::to('/users/change_password') }}', data: 'current_password=' + encodeURIComponent($('form #current_password').val()) + - '&new_password=' + encodeURIComponent($('form #new_password').val()) + + '&new_password=' + encodeURIComponent($('form #newer_password').val()) + '&confirm_password=' + encodeURIComponent($('form #confirm_password').val()), success: function(result) { if (result == 'success') { From 686953aafddd555246d7d934e7671a756ef28c23 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 13 Apr 2015 22:43:51 +0300 Subject: [PATCH 06/13] Working on L5 --- app/Models/AccountGatewayToken.php | 1 + app/Models/Affiliate.php | 2 ++ app/Models/License.php | 1 + app/Models/Project.php | 1 + app/Models/ProjectCode.php | 2 +- app/Models/Timesheet.php | 1 + app/Models/TimesheetEvent.php | 2 +- app/Models/TimesheetEventSource.php | 2 +- resources/views/accounts/details.blade.php | 6 ++---- 9 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Models/AccountGatewayToken.php b/app/Models/AccountGatewayToken.php index 7726df1301f0..b706882af77d 100644 --- a/app/Models/AccountGatewayToken.php +++ b/app/Models/AccountGatewayToken.php @@ -1,5 +1,6 @@ submit()->large()->appendIcon(Icon::create('floppy-disk')) !!} + {!! Former::close() !!} +