diff --git a/app/commands/SendRecurringInvoices.php b/app/commands/SendRecurringInvoices.php index d634c1c1187b..b0e452d646b9 100755 --- a/app/commands/SendRecurringInvoices.php +++ b/app/commands/SendRecurringInvoices.php @@ -69,7 +69,7 @@ class SendRecurringInvoices extends Command { { $invitation = Invitation::createNew($recurInvitation); $invitation->contact_id = $recurInvitation->contact_id; - $invitation->invitation_key = str_random(20); + $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH); $invoice->invitations()->save($invitation); } diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index af642671c917..44d4a49c8f43 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -38,13 +38,14 @@ class AccountController extends \BaseController { { $account = new Account; $account->ip = Request::getClientIp(); - $account->account_key = str_random(20); + $account->account_key = str_random(RANDOM_KEY_LENGTH); $account->save(); - $random = str_random(20); + $random = str_random(RANDOM_KEY_LENGTH); $user = new User; $user->password = $random; + $user->password_confirmation = $random; $account->users()->save($user); Session::forget(RECENTLY_VIEWED); @@ -537,6 +538,7 @@ class AccountController extends \BaseController { $user->last_name = trim(Input::get('new_last_name')); $user->email = trim(Input::get('new_email')); $user->password = trim(Input::get('new_password')); + $user->password_confirmation = trim(Input::get('new_password')); $user->registered = true; $user->save(); diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index 355b1cd162f1..1a02a7a23e6a 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -431,7 +431,7 @@ class InvoiceController extends \BaseController { $invitation = Invitation::createNew(); $invitation->invoice_id = $invoice->id; $invitation->contact_id = $contact->id; - $invitation->invitation_key = str_random(20); + $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH); $invitation->save(); } else if (!in_array($contact->id, $sendInvoiceIds) && $invitation) diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index 1dcf603aecf8..ce98574d1f90 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -68,6 +68,7 @@ class PaymentController extends \BaseController 'url' => 'payments', 'title' => '- New Payment', 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), + 'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('payments.edit', $data); @@ -87,6 +88,7 @@ class PaymentController extends \BaseController 'url' => 'payments/' . $publicId, 'title' => '- Edit Payment', 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), + 'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('payments.edit', $data); } diff --git a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php index 48e4863ff009..acc0068d518a 100755 --- a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php +++ b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php @@ -36,7 +36,8 @@ class ConfideSetupUsersTable extends Migration { Schema::dropIfExists('sizes'); Schema::dropIfExists('industries'); Schema::dropIfExists('gateways'); - + Schema::dropIfExists('payment_types'); + Schema::create('countries', function($table) { $table->increments('id'); @@ -61,6 +62,12 @@ class ConfideSetupUsersTable extends Migration { $t->string('name'); }); + Schema::create('payment_types', function($t) + { + $t->increments('id'); + $t->string('name'); + }); + Schema::create('payment_terms', function($t) { $t->increments('id'); @@ -433,6 +440,7 @@ class ConfideSetupUsersTable extends Migration { $t->unsignedInteger('invitation_id')->nullable(); $t->unsignedInteger('user_id')->nullable(); $t->unsignedInteger('account_gateway_id')->nullable(); + $t->unsignedInteger('payment_type_id')->nullable(); $t->unsignedInteger('currency_id')->default(1); $t->timestamps(); $t->softDeletes(); @@ -450,6 +458,7 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('account_gateway_id')->references('id')->on('account_gateways'); $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');; $t->foreign('currency_id')->references('id')->on('currencies'); + $t->foreign('payment_type_id')->references('id')->on('payment_types'); $t->unsignedInteger('public_id')->index(); $t->unique( array('account_id','public_id') ); @@ -543,5 +552,6 @@ class ConfideSetupUsersTable extends Migration { Schema::dropIfExists('sizes'); Schema::dropIfExists('industries'); Schema::dropIfExists('gateways'); + Schema::dropIfExists('payment_types'); } } diff --git a/app/database/seeds/ConstantsSeeder.php b/app/database/seeds/ConstantsSeeder.php index 3b025ac561c2..29ecf642d910 100755 --- a/app/database/seeds/ConstantsSeeder.php +++ b/app/database/seeds/ConstantsSeeder.php @@ -31,6 +31,11 @@ class ConstantsSeeder extends Seeder $client->invoices()->save($invoice); */ + PaymentType::create(array('name' => 'Visa')); + PaymentType::create(array('name' => 'MasterCard')); + PaymentType::create(array('name' => 'American Express')); + PaymentType::create(array('name' => 'Cash')); + Theme::create(array('name' => 'amelia')); Theme::create(array('name' => 'cerulean')); Theme::create(array('name' => 'cosmo')); diff --git a/app/models/Activity.php b/app/models/Activity.php index 303f9e5ec0f4..e342dd82f0b9 100755 --- a/app/models/Activity.php +++ b/app/models/Activity.php @@ -286,6 +286,12 @@ class Activity extends Eloquent public static function viewInvoice($invitation) { + if (Session::get($invitation->invitation_key)) + { + return; + } + Session::put($invitation->invitation_key, true); + $invoice = $invitation->invoice; if (!$invoice->isViewed()) diff --git a/app/models/PaymentType.php b/app/models/PaymentType.php new file mode 100755 index 000000000000..ee2153021ec6 --- /dev/null +++ b/app/models/PaymentType.php @@ -0,0 +1,7 @@ + 'required|email|unique:users', 'email' => 'required|email|unique:users', - 'password' => 'required|between:4,20|confirmed', - 'password_confirmation' => 'between:4,20', */ + 'password' => 'required|between:6,20|confirmed', + 'password_confirmation' => 'between:6,20', ); /** diff --git a/app/ninja/repositories/PaymentRepository.php b/app/ninja/repositories/PaymentRepository.php index f5b019b6ce00..13df777024fe 100755 --- a/app/ninja/repositories/PaymentRepository.php +++ b/app/ninja/repositories/PaymentRepository.php @@ -11,7 +11,7 @@ class PaymentRepository { $query = \DB::table('payments') ->join('clients', 'clients.id', '=','payments.client_id') - ->leftJoin('invoices', 'invoices.id', '=','payments.invoice_id') + ->join('invoices', 'invoices.id', '=','payments.invoice_id') ->join('contacts', 'contacts.client_id', '=', 'clients.id') ->where('payments.account_id', '=', \Auth::user()->account_id) ->where('payments.deleted_at', '=', null) @@ -49,6 +49,7 @@ class PaymentRepository $payment->client_id = Client::getPrivateId($input['client']); $payment->invoice_id = isset($input['invoice']) && $input['invoice'] != "-1" ? Invoice::getPrivateId($input['invoice']) : null; $payment->currency_id = $input['currency_id'] ? $input['currency_id'] : null; + $payment->payment_type_id = $input['payment_type_id'] ? $input['payment_type_id'] : null; $payment->payment_date = Utils::toSqlDate($input['payment_date']); $payment->amount = floatval($input['amount']); $payment->save(); diff --git a/app/routes.php b/app/routes.php index d35655527256..45846c571ed3 100755 --- a/app/routes.php +++ b/app/routes.php @@ -22,6 +22,7 @@ //Log::error('test'); +/* Event::listen('illuminate.query', function($query, $bindings, $time, $name) { $data = compact('bindings', 'time', 'name'); @@ -45,17 +46,9 @@ Event::listen('illuminate.query', function($query, $bindings, $time, $name) Log::info($query, $data); }); - - -/* -Route::get('/test', function() { - foreach (Invoice::all() as $invoice) { - echo $invoice->id . ' ' . $invoice->shouldSendToday() . '
'; - } - dd(true); -}); */ + /* // TODO_FIX replace with cron Route::get('/send_emails', function() { @@ -190,6 +183,7 @@ define('ACCOUNT_EXPORT', 'export'); define('DEFAULT_INVOICE_NUMBER', '0001'); define('RECENTLY_VIEWED_LIMIT', 8); define('LOGGED_ERROR_LIMIT', 100); +define('RANDOM_KEY_LENGTH', 32); define('INVOICE_STATUS_DRAFT', 1); define('INVOICE_STATUS_SENT', 2); diff --git a/app/views/header.blade.php b/app/views/header.blade.php index 85c896519d21..879860352821 100755 --- a/app/views/header.blade.php +++ b/app/views/header.blade.php @@ -189,7 +189,8 @@ -
+
+
{{ Former::open('signup/submit')->addClass('signUpForm') }} @@ -205,6 +206,7 @@ {{ Former::password('new_password')->label('Password') }} {{ Former::close() }}
+
-
+
@if (Auth::user()->registered) -

Please confirm your account to email an invoice.

+ Please confirm your account to email an invoice. @else -

Please sign up to email an invoice.

+ Please sign up to email an invoice. @endif +