diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index fc2f620a4a19..0077a72c1950 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -13,7 +13,7 @@ class AccountController extends \BaseController { //$user = User::where('password', '=', $guestKey)->firstOrFail(); $user = User::where('password', '=', $guestKey)->first(); - if ($user && !$user->is_guest) + if ($user && $user->registered) { exit; } @@ -33,7 +33,7 @@ class AccountController extends \BaseController { $account->users()->save($user); } - Auth::login($user); + Auth::login($user, true); Session::put('tz', 'US/Eastern'); return Redirect::to('invoices/create'); @@ -452,7 +452,7 @@ class AccountController extends \BaseController { public function checkEmail() { - $email = User::where('email', '=', Input::get('email'))->first(); + $email = User::where('email', '=', Input::get('email'))->where('id', '<>', Auth::user()->id)->first(); if ($email) { return "taken"; @@ -500,6 +500,6 @@ class AccountController extends \BaseController { */ Session::flash('message', 'Successfully registered'); - return Redirect::to(Input::get('path')); + return Redirect::to(Input::get('path'))->with('clearGuestKey', true); } } \ No newline at end of file diff --git a/app/controllers/ActivityController.php b/app/controllers/ActivityController.php index 3ecf5756c132..79b706685318 100755 --- a/app/controllers/ActivityController.php +++ b/app/controllers/ActivityController.php @@ -5,7 +5,7 @@ class ActivityController extends \BaseController { public function getDatatable($clientId) { return Datatable::collection(Activity::scope()->where('client_id','=',$clientId)->get()) - ->addColumn('date', function($model) { return $model->created_at->format('m/d/y h:i a'); }) + ->addColumn('date', function($model) { return timestampToDateTimeString($model->created_at); }) ->addColumn('message', function($model) { return $model->message; }) ->addColumn('balance', function($model) { return '$' . $model->balance; }) ->orderColumns('date') diff --git a/app/controllers/ClientController.php b/app/controllers/ClientController.php index e03cb54ab3a7..171683155fba 100755 --- a/app/controllers/ClientController.php +++ b/app/controllers/ClientController.php @@ -14,6 +14,7 @@ class ClientController extends \BaseController { return View::make('list', array( 'entityType'=>ENTITY_CLIENT, + 'title' => '- Clients', 'columns'=>['checkbox', 'Client', 'Contact', 'Balance', 'Last Login', 'Date Created', 'Email', 'Phone', 'Action'] )); } @@ -61,7 +62,7 @@ class ClientController extends \BaseController { 'client' => null, 'method' => 'POST', 'url' => 'clients', - 'title' => 'New', + 'title' => '- New Client', 'countries' => Country::orderBy('name')->get()); return View::make('clients.edit', $data); @@ -88,7 +89,11 @@ class ClientController extends \BaseController { $client = Client::scope()->with('contacts')->findOrFail($id); trackViewed($client->name); - return View::make('clients.show')->with('client', $client); + $data = array( + 'client' => $client, + 'title' => '- ' . $client->name); + + return View::make('clients.show', $data); } /** @@ -104,7 +109,7 @@ class ClientController extends \BaseController { 'client' => $client, 'method' => 'PUT', 'url' => 'clients/' . $id, - 'title' => 'Edit', + 'title' => '- ' . $client->name, 'countries' => Country::orderBy('name')->get()); return View::make('clients.edit', $data); } diff --git a/app/controllers/CreditController.php b/app/controllers/CreditController.php index 979b3e184958..f53af7cbbb16 100755 --- a/app/controllers/CreditController.php +++ b/app/controllers/CreditController.php @@ -11,6 +11,7 @@ class CreditController extends \BaseController { { return View::make('list', array( 'entityType'=>ENTITY_CREDIT, + 'title' => '- Credits', 'columns'=>['checkbox', 'Credit Number', 'Client', 'Amount', 'Credit Date'] )); } diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index 39cec380e3de..16ed1316550d 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -11,6 +11,7 @@ class InvoiceController extends \BaseController { { return View::make('list', array( 'entityType'=>ENTITY_INVOICE, + 'title' => '- Invoices', 'columns'=>['checkbox', 'Invoice Number', 'Client', 'Total', 'Amount Due', 'Invoice Date', 'Due Date', 'Status', 'Action'] )); } @@ -61,7 +62,8 @@ class InvoiceController extends \BaseController { public function view($key) { - $invitation = Invitation::with('user', 'invoice.account', 'invoice.invoice_items', 'invoice.client.account.account_gateways')->where('key', '=', $key)->firstOrFail(); + $invitation = Invitation::with('user', 'invoice.account', 'invoice.invoice_items', 'invoice.client.account.account_gateways') + ->where('key', '=', $key)->firstOrFail(); $user = $invitation->user; $invoice = $invitation->invoice; @@ -216,9 +218,9 @@ class InvoiceController extends \BaseController { 'invoice' => $invoice, 'method' => 'PUT', 'url' => 'invoices/' . $id, - 'title' => 'Edit', + 'title' => '- ' . $invoice->invoice_number, 'account' => Auth::user()->account, - 'products' => Product::scope()->get(), + 'products' => Product::scope()->get(array('key','notes','cost','qty')), 'client' => $invoice->client, 'clients' => Client::scope()->orderBy('name')->get()); return View::make('invoices.edit', $data); @@ -240,11 +242,11 @@ class InvoiceController extends \BaseController { 'invoiceNumber' => $invoiceNumber, 'method' => 'POST', 'url' => 'invoices', - 'title' => 'New', + 'title' => '- New Invoice', 'client' => $client, 'items' => json_decode(Input::old('items')), 'account' => Auth::user()->account, - 'products' => Product::scope()->get(), + 'products' => Product::scope()->get(array('key','notes','cost','qty')), 'clients' => Client::scope()->orderBy('name')->get()); return View::make('invoices.edit', $data); } diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index 633ded29de38..8f2a838eab54 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -4,7 +4,11 @@ class PaymentController extends \BaseController { public function index() { - return View::make('payments.index'); + return View::make('list', array( + 'entityType'=>ENTITY_PAYMENT, + 'title' => '- Payments', + 'columns'=>['checkbox', 'Transaction Reference', 'Client', 'Amount', 'Payment Date'] + )); } public function getDatatable($clientId = null) @@ -18,24 +22,17 @@ class PaymentController extends \BaseController $table = Datatable::collection($collection->get()); if (!$clientId) { - $table->addColumn('client', function($model) - { - return link_to('clients/' . $model->invoice->client->id, $model->invoice->client->name); - }); + $table->addColumn('checkbox', function($model) { return ''; }); } - return $table->addColumn('invoice', function($model) - { - return link_to('invoices/' . $model->invoice->id . '/edit', $model->invoice->number); - }) - ->addColumn('amount', function($model) - { - return '$' . $model->amount; - }) - ->addColumn('date', function($model) - { - return $model->created_at->format('m/d/y h:i a'); - }) + $table->addColumn('transaction_reference', function($model) { return $model->transaction_reference; }); + + if (!$clientId) { + $table->addColumn('client', function($model) { return link_to('clients/' . $model->client->id, $model->client->name); }); + } + + return $table->addColumn('amount', function($model) { return '$' . $model->amount; }) + ->addColumn('date', function($model) { return timestampToDateTimeString($model->created_at); }) ->orderColumns('client') ->make(); } diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 622abde5994d..52b45aabbcc6 100755 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -219,9 +219,14 @@ class UserController extends BaseController { */ public function logout() { - Confide::logout(); - - return Redirect::to('/'); - } + if (!Auth::user()->registered) + { + $account = Auth::user()->account; + $account->forceDelete(); + } + Confide::logout(); + + return Redirect::to('/')->with('clearGuestKey', true); + } } 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 3b3d26a18f8a..0d404bbc7bd2 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 @@ -212,7 +212,7 @@ class ConfideSetupUsersTable extends Migration { $t->timestamp('viewed_date'); $t->foreign('user_id')->references('id')->on('users'); - $t->foreign('contact_id')->references('id')->on('contacts'); + $t->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade'); $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); }); diff --git a/app/models/Account.php b/app/models/Account.php index a5b312031416..03ff81764e24 100755 --- a/app/models/Account.php +++ b/app/models/Account.php @@ -3,6 +3,7 @@ class Account extends Eloquent { protected $softDelete = true; + protected $hidden = array('ip', 'timezone_id', 'created_at', 'updated_at', 'deleted_at', 'key', 'last_login'); public function users() { diff --git a/app/models/AccountGateway.php b/app/models/AccountGateway.php index a49d922f3e6a..a9fb45a209c1 100755 --- a/app/models/AccountGateway.php +++ b/app/models/AccountGateway.php @@ -2,6 +2,8 @@ class AccountGateway extends Eloquent { + protected $hidden = array('config'); + public function gateway() { return $this->belongsTo('Gateway'); diff --git a/app/models/Client.php b/app/models/Client.php index 8a4b67a47e4f..fad31c3434a2 100755 --- a/app/models/Client.php +++ b/app/models/Client.php @@ -3,7 +3,8 @@ class Client extends Eloquent implements iEntity { protected $softDelete = true; - + protected $hidden = array('created_at', 'updated_at', 'deleted_at', 'notes', 'last_login'); + public static $fieldName = 'Client - Name'; public static $fieldPhone = 'Client - Phone'; public static $fieldAddress1 = 'Client - Street'; diff --git a/app/models/Invitation.php b/app/models/Invitation.php index 1337a8785424..c7bafa32e38d 100644 --- a/app/models/Invitation.php +++ b/app/models/Invitation.php @@ -3,6 +3,7 @@ class Invitation extends Eloquent { protected $softDelete = true; + protected $hidden = array('created_at', 'updated_at', 'deleted_at'); public function scopeScope($query) { diff --git a/app/models/Invoice.php b/app/models/Invoice.php index e8d6bfaafb4c..188c31eb6e6e 100755 --- a/app/models/Invoice.php +++ b/app/models/Invoice.php @@ -3,6 +3,7 @@ class Invoice extends Eloquent implements iEntity { protected $softDelete = true; + protected $hidden = array('created_at', 'updated_at', 'deleted_at', 'viewed_date', 'key'); public function scopeScope($query) { diff --git a/app/models/InvoiceItem.php b/app/models/InvoiceItem.php index d6d9dd9411e5..8ce490c8232c 100755 --- a/app/models/InvoiceItem.php +++ b/app/models/InvoiceItem.php @@ -3,6 +3,7 @@ class InvoiceItem extends Eloquent { protected $softDelete = true; + protected $hidden = array('created_at', 'updated_at', 'deleted_at'); public function invoice() { diff --git a/app/models/User.php b/app/models/User.php index c9fa06b68015..31523960d777 100755 --- a/app/models/User.php +++ b/app/models/User.php @@ -8,6 +8,7 @@ class User extends ConfideUser implements UserInterface, RemindableInterface, iP { protected $softDelete = true; + protected $hidden = array('created_at', 'updated_at', 'deleted_at', 'password', 'confirmation_code', 'registered', 'confirmed'); public static $rules = array( /* @@ -25,13 +26,6 @@ class User extends ConfideUser implements UserInterface, RemindableInterface, iP */ protected $table = 'users'; - /** - * The attributes excluded from the model's JSON form. - * - * @var array - */ - protected $hidden = array('password'); - public function account() { return $this->belongsTo('Account'); diff --git a/app/views/accounts/details.blade.php b/app/views/accounts/details.blade.php index dbfd5e0184bb..2f789773c461 100755 --- a/app/views/accounts/details.blade.php +++ b/app/views/accounts/details.blade.php @@ -11,7 +11,7 @@ - {{ Former::open_for_files()->addClass('col-md-9 col-md-offset-1')->rules(array( + {{ Former::open_for_files()->addClass('col-md-10 col-md-offset-1')->rules(array( 'name' => 'required', 'email' => 'email|required' )); }} @@ -58,7 +58,10 @@ - {{ Former::actions( Button::lg_primary_submit('Save') ) }} +