From 2142538e159d9c2b322f6994194cf0cca9ddcf9f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 3 Dec 2013 19:32:33 +0200 Subject: [PATCH] Improving data model --- README.md | 3 +- app/controllers/AccountController.php | 72 ++++++++++-- app/controllers/ActivityController.php | 3 +- app/controllers/BaseController.php | 4 + app/controllers/ClientController.php | 26 ++--- app/controllers/CreditController.php | 6 +- app/controllers/InvoiceController.php | 69 +++++++---- app/controllers/PaymentController.php | 6 +- ...11_05_180133_confide_setup_users_table.php | 6 +- app/filters.php | 21 +--- app/models/Activity.php | 5 + app/models/Client.php | 7 +- app/models/Credit.php | 5 + app/models/Invitation.php | 5 + app/models/Invoice.php | 5 + app/models/Payment.php | 5 + app/models/Product.php | 8 +- app/routes.php | 18 ++- app/views/clients/index.blade.php | 14 --- app/views/clients/show.blade.php | 40 ++++++- app/views/emails/welcome_html.blade.php | 10 ++ app/views/emails/welcome_text.blade.php | 1 + app/views/header.blade.php | 110 +++++++++++++----- app/views/invoices/edit.blade.php | 87 ++++++++++---- app/views/invoices/index.blade.php | 71 ----------- app/views/list.blade.php | 4 +- app/views/payments/index.blade.php | 12 -- public/js/script.js | 30 ++++- 28 files changed, 415 insertions(+), 238 deletions(-) delete mode 100755 app/views/clients/index.blade.php create mode 100755 app/views/emails/welcome_html.blade.php create mode 100755 app/views/emails/welcome_text.blade.php delete mode 100755 app/views/invoices/index.blade.php delete mode 100755 app/views/payments/index.blade.php diff --git a/README.md b/README.md index bc77877bfe2c..2152b77ee2df 100644 --- a/README.md +++ b/README.md @@ -54,4 +54,5 @@ Configure config/database.php and then initialize the database * [Chumper/Datatable](https://github.com/Chumper/Datatable) - This is a laravel 4 package for the server and client side of datatables * [omnipay/omnipay](https://github.com/omnipay/omnipay) - A framework agnostic, multi-gateway payment processing library for PHP 5.3+ * [Intervention/image](https://github.com/Intervention/image) - PHP Image Manipulation -* [webpatser/laravel-countries](https://github.com/webpatser/laravel-countries) - Almost ISO 3166_2, 3166_3, currency, Capital and more for all countries \ No newline at end of file +* [webpatser/laravel-countries](https://github.com/webpatser/laravel-countries) - Almost ISO 3166_2, 3166_3, currency, Capital and more for all countries +* [briannesbitt/Carbon](https://github.com/briannesbitt/Carbon) - A simple API extension for DateTime with PHP 5.3+ \ No newline at end of file diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 855c54f64f80..fc2f620a4a19 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -10,7 +10,7 @@ class AccountController extends \BaseController { if ($guestKey) { - //$user = User::where('key','=',$guestKey)->firstOrFail(); + //$user = User::where('password', '=', $guestKey)->firstOrFail(); $user = User::where('password', '=', $guestKey)->first(); if ($user && !$user->is_guest) @@ -29,10 +29,7 @@ class AccountController extends \BaseController { $random = str_random(20); $user = new User; - //$user->username = $random.'@gmail.com'; - //$user->password = $random; - //$user->email = $random.'@gmail.com'; - //$user->password_confirmation = $random; + $user->password = $random; $account->users()->save($user); } @@ -46,7 +43,7 @@ class AccountController extends \BaseController { { if ($section == ACCOUNT_DETAILS) { - $account = Account::with('users')->find(Auth::user()->account_id); + $account = Account::with('users')->findOrFail(Auth::user()->account_id); $countries = Country::orderBy('name')->get(); $timezones = Timezone::orderBy('location')->get(); @@ -54,7 +51,7 @@ class AccountController extends \BaseController { } else if ($section == ACCOUNT_SETTINGS) { - $account = Account::with('account_gateways')->find(Auth::user()->account_id); + $account = Account::with('account_gateways')->findOrFail(Auth::user()->account_id); $accountGateway = null; $config = null; @@ -355,7 +352,7 @@ class AccountController extends \BaseController { if ($gatewayId = Input::get('gateway_id')) { - $gateway = Gateway::find($gatewayId); + $gateway = Gateway::findOrFail($gatewayId); $fields = Omnipay::create($gateway->provider)->getDefaultParameters(); foreach ($fields as $field => $details) @@ -377,7 +374,7 @@ class AccountController extends \BaseController { } else { - $account = Account::find(Auth::user()->account_id); + $account = Account::findOrFail(Auth::user()->account_id); $account->account_gateways()->forceDelete(); if ($gatewayId) @@ -417,7 +414,7 @@ class AccountController extends \BaseController { } else { - $account = Account::find(Auth::user()->account_id); + $account = Account::findOrFail(Auth::user()->account_id); $account->name = Input::get('name'); $account->address1 = Input::get('address1'); $account->address2 = Input::get('address2'); @@ -436,7 +433,7 @@ class AccountController extends \BaseController { $user->save(); if (Input::get('timezone_id')) { - $timezone = Timezone::find(Input::get('timezone_id')); + $timezone = Timezone::findOrFail(Input::get('timezone_id')); Session::put('tz', $timezone->name); } @@ -452,4 +449,57 @@ class AccountController extends \BaseController { return Redirect::to('account/details'); } } + + public function checkEmail() + { + $email = User::where('email', '=', Input::get('email'))->first(); + + if ($email) { + return "taken"; + } else { + return "available"; + } + } + + public function submitSignup() + { + $rules = array( + 'first_name' => 'required', + 'last_name' => 'required', + 'password' => 'required|min:6', + 'email' => 'email|required' + ); + + $validator = Validator::make(Input::all(), $rules); + + if ($validator->fails()) + { + return Redirect::to(Input::get('path')); + } + + $user = Auth::user(); + $user->first_name = Input::get('first_name'); + $user->last_name = Input::get('last_name'); + $user->email = Input::get('email'); + $user->password = Input::get('password'); + $user->registered = true; + $user->save(); + + $activities = Activity::scope()->get(); + foreach ($activities as $activity) { + $activity->message = str_replace('Guest', $user->getFullName(), $activity->message); + $activity->save(); + } + + /* + Mail::send(array('html'=>'emails.welcome_html','text'=>'emails.welcome_text'), $data, function($message) use ($user) + { + $message->from('hillelcoren@gmail.com', 'Hillel Coren'); + $message->to($user->email); + }); + */ + + Session::flash('message', 'Successfully registered'); + return Redirect::to(Input::get('path')); + } } \ No newline at end of file diff --git a/app/controllers/ActivityController.php b/app/controllers/ActivityController.php index 2a551f66b3bc..3ecf5756c132 100755 --- a/app/controllers/ActivityController.php +++ b/app/controllers/ActivityController.php @@ -4,8 +4,7 @@ class ActivityController extends \BaseController { public function getDatatable($clientId) { - return Datatable::collection(Activity::where('account_id','=',Auth::user()->account_id) - ->where('client_id','=',$clientId)->get()) + 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('message', function($model) { return $model->message; }) ->addColumn('balance', function($model) { return '$' . $model->balance; }) diff --git a/app/controllers/BaseController.php b/app/controllers/BaseController.php index 097e161a3761..625790ae0076 100755 --- a/app/controllers/BaseController.php +++ b/app/controllers/BaseController.php @@ -15,4 +15,8 @@ class BaseController extends Controller { } } + public function __construct() + { + $this->beforeFilter('csrf', array('on' => array('post', 'delete', 'put'))); + } } \ No newline at end of file diff --git a/app/controllers/ClientController.php b/app/controllers/ClientController.php index 98439f805973..e03cb54ab3a7 100755 --- a/app/controllers/ClientController.php +++ b/app/controllers/ClientController.php @@ -20,7 +20,7 @@ class ClientController extends \BaseController { public function getDatatable() { - $clients = Client::with('contacts')->where('account_id','=',Auth::user()->account_id)->get(); + $clients = Client::scope()->with('contacts')->get(); return Datatable::collection($clients) ->addColumn('checkbox', function($model) { return ''; }) @@ -38,10 +38,11 @@ class ClientController extends \BaseController { Select '; }) @@ -84,9 +85,8 @@ class ClientController extends \BaseController { */ public function show($id) { - $client = Client::with('contacts')->find($id); + $client = Client::scope()->with('contacts')->findOrFail($id); trackViewed($client->name); - return View::make('clients.show')->with('client', $client); } @@ -99,7 +99,7 @@ class ClientController extends \BaseController { */ public function edit($id) { - $client = Client::with('contacts')->find($id); + $client = Client::scope()->with('contacts')->findOrFail($id); $data = array( 'client' => $client, 'method' => 'PUT', @@ -133,7 +133,7 @@ class ClientController extends \BaseController { ->withInput(Input::except('password')); } else { if ($id) { - $client = Client::find($id); + $client = Client::scope()->findOrFail($id); } else { $client = new Client; $client->account_id = Auth::user()->account_id; @@ -159,7 +159,7 @@ class ClientController extends \BaseController { { if (isset($contact->id) && $contact->id) { - $record = Contact::find($contact->id); + $record = Contact::findOrFail($contact->id); } else { @@ -192,8 +192,8 @@ class ClientController extends \BaseController { public function bulk() { $action = Input::get('action'); - $ids = Input::get('ids'); - $clients = Client::find($ids); + $ids = Input::get('ids') ? Input::get('ids') : [Input::get('id')]; + $clients = Client::scope()->findOrFail($ids); foreach ($clients as $client) { if ($action == 'archive') { @@ -211,7 +211,7 @@ class ClientController extends \BaseController { public function archive($id) { - $client = Client::find($id); + $client = Client::scope()->findOrFail($id); $client->delete(); foreach ($client->invoices as $invoice) @@ -225,7 +225,7 @@ class ClientController extends \BaseController { public function delete($id) { - $client = Client::find($id); + $client = Client::scope()->findOrFail($id); $client->forceDelete(); Session::flash('message', 'Successfully deleted ' . $client->name); diff --git a/app/controllers/CreditController.php b/app/controllers/CreditController.php index d6355d9a2e65..979b3e184958 100755 --- a/app/controllers/CreditController.php +++ b/app/controllers/CreditController.php @@ -17,7 +17,7 @@ class CreditController extends \BaseController { public function getDatatable($clientId = null) { - $collection = Credit::with('client')->where('account_id','=',Auth::user()->account_id); + $collection = Credit::scope()->with('client'); if ($clientId) { $collection->where('client_id','=',$clientId); @@ -43,7 +43,7 @@ class CreditController extends \BaseController { public function archive($id) { - $credit = Credit::find($id); + $credit = Credit::scope()->findOrFail($id); $creidt->delete(); Session::flash('message', 'Successfully archived credit ' . $credit->credit_number); @@ -52,7 +52,7 @@ class CreditController extends \BaseController { public function delete($id) { - $credit = Credit::find($id); + $credit = Credit::scope()->findOrFail($id); $credit->forceDelete(); Session::flash('message', 'Successfully deleted credit ' . $credit->credit_number); diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index ec3b8c2d4f32..39cec380e3de 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -17,7 +17,7 @@ class InvoiceController extends \BaseController { public function getDatatable($clientId = null) { - $collection = Invoice::with('client','invoice_items','invoice_status')->where('account_id','=',Auth::user()->account_id); + $collection = Invoice::scope()->with('client','invoice_items','invoice_status'); if ($clientId) { $collection->where('client_id','=',$clientId); @@ -47,10 +47,10 @@ class InvoiceController extends \BaseController { Select '; }) @@ -64,13 +64,20 @@ class InvoiceController extends \BaseController { $invitation = Invitation::with('user', 'invoice.account', 'invoice.invoice_items', 'invoice.client.account.account_gateways')->where('key', '=', $key)->firstOrFail(); $user = $invitation->user; + $invoice = $invitation->invoice; + + $now = Carbon::now()->toDateTimeString(); - $invitation->viewed_date = Carbon::now()->toDateTimeString(); + $invitation->viewed_date = $now; $invitation->save(); + $client = $invoice->client; + $client->last_login = $now; + $client->save(); + Activity::viewInvoice($invitation); - return View::make('invoices.view')->with('invoice', $invitation->invoice); + return View::make('invoices.view')->with('invoice', $invoice); } private function createGateway($accountGateway) @@ -201,7 +208,7 @@ class InvoiceController extends \BaseController { public function edit($id) { - $invoice = Invoice::with('account.country', 'client', 'invoice_items')->find($id); + $invoice = Invoice::scope()->with('account.country', 'client', 'invoice_items')->findOrFail($id); trackViewed($invoice->invoice_number . ' - ' . $invoice->client->name); $data = array( @@ -211,9 +218,9 @@ class InvoiceController extends \BaseController { 'url' => 'invoices/' . $id, 'title' => 'Edit', 'account' => Auth::user()->account, - 'products' => Product::getProducts()->get(), + 'products' => Product::scope()->get(), 'client' => $invoice->client, - 'clients' => Client::where('account_id','=',Auth::user()->account_id)->orderBy('name')->get()); + 'clients' => Client::scope()->orderBy('name')->get()); return View::make('invoices.edit', $data); } @@ -221,7 +228,11 @@ class InvoiceController extends \BaseController { { $client = null; $invoiceNumber = Auth::user()->account->getNextInvoiceNumber(); - $account = Account::with('country')->find(Auth::user()->account_id); + $account = Account::with('country')->findOrFail(Auth::user()->account_id); + + if ($clientId) { + $client = Client::scope()->findOrFail($clientId); + } $data = array( 'account' => $account, @@ -233,8 +244,8 @@ class InvoiceController extends \BaseController { 'client' => $client, 'items' => json_decode(Input::old('items')), 'account' => Auth::user()->account, - 'products' => Product::getProducts()->get(), - 'clients' => Client::where('account_id','=',Auth::user()->account_id)->orderBy('name')->get()); + 'products' => Product::scope()->get(), + 'clients' => Client::scope()->orderBy('name')->get()); return View::make('invoices.edit', $data); } @@ -250,6 +261,17 @@ class InvoiceController extends \BaseController { private function save($id = null) { + $action = Input::get('action'); + + if ($action == 'archive') + { + return InvoiceController::archive($id); + } + else if ($action == 'delete') + { + return InvoiceController::delete($id); + } + $rules = array( 'client' => 'required', 'invoice_number' => 'required', @@ -279,12 +301,12 @@ class InvoiceController extends \BaseController { } else { - $client = Client::with('contacts')->find($clientId); + $client = Client::scope()->with('contacts')->findOrFail($clientId); $contact = $client->contacts()->first(); } if ($id) { - $invoice = Invoice::find($id); + $invoice = Invoice::scope()->findOrFail($id); $invoice->invoice_items()->forceDelete(); } else { $invoice = new Invoice; @@ -308,11 +330,16 @@ class InvoiceController extends \BaseController { if (!isset($item->qty)) { $item->qty = 0; - } + } + + if (!$item->cost && !$item->qty && !$item->product_key && !$item->notes) + { + continue; + } if ($item->product_key) { - $product = Product::findProduct($item->product_key); + $product = Product::findProductByKey($item->product_key); if (!$product) { @@ -340,7 +367,7 @@ class InvoiceController extends \BaseController { $invoice->invoice_items()->save($invoiceItem); } - if (Input::get('send_email_checkBox')) + if ($action == 'email') { $data = array('link' => URL::to('view') . '/' . $invoice->invoice_key); /* @@ -404,7 +431,7 @@ class InvoiceController extends \BaseController { { $action = Input::get('action'); $ids = Input::get('ids'); - $invoices = Invoice::find($ids); + $invoices = Invoice::scope()->findOrFail($ids); foreach ($invoices as $invoice) { if ($action == 'archive') { @@ -422,16 +449,16 @@ class InvoiceController extends \BaseController { public function archive($id) { - $invoice = Invoice::find($id); + $invoice = Invoice::scope()->findOrFail($id); $invoice->delete(); - + Session::flash('message', 'Successfully archived invoice ' . $invoice->invoice_number); return Redirect::to('invoices'); } public function delete($id) { - $invoice = Invoice::find($id); + $invoice = Invoice::scope()->findOrFail($id); $invoice->forceDelete(); Session::flash('message', 'Successfully deleted invoice ' . $invoice->invoice_number); diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index f120e65d161d..633ded29de38 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -9,7 +9,7 @@ class PaymentController extends \BaseController public function getDatatable($clientId = null) { - $collection = Payment::with('invoice.client')->where('account_id', '=', Auth::user()->account_id); + $collection = Payment::scope()->with('invoice.client'); if ($clientId) { $collection->where('client_id','=',$clientId); @@ -42,7 +42,7 @@ class PaymentController extends \BaseController public function archive($id) { - $payment = Payment::find($id); + $payment = Payment::scope()->findOrFail($id); $payment->delete(); Session::flash('message', 'Successfully archived payment'); @@ -51,7 +51,7 @@ class PaymentController extends \BaseController public function delete($id) { - $payment = Payment::find($id); + $payment = Payment::scope()->findOrFail($id); $payment->forceDelete(); Session::flash('message', 'Successfully deleted payment'); 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 6a5fe34b9884..3b3d26a18f8a 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 @@ -66,7 +66,8 @@ class ConfideSetupUsersTable extends Migration { $t->string('ip'); $t->string('logo_path'); $t->string('key')->unique(); - + $t->timestamp('last_login'); + $t->string('address1'); $t->string('address2'); $t->string('city'); @@ -115,7 +116,7 @@ class ConfideSetupUsersTable extends Migration { $t->string('last_name'); $t->string('phone'); $t->string('username'); - $t->string('email')->unique(); + $t->string('email'); $t->string('password'); $t->string('confirmation_code'); $t->boolean('registered')->default(false); @@ -149,6 +150,7 @@ class ConfideSetupUsersTable extends Migration { $t->string('work_phone'); $t->text('notes'); $t->decimal('balance', 10, 2); + $t->timestamp('last_login'); $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $t->foreign('country_id')->references('id')->on('countries'); diff --git a/app/filters.php b/app/filters.php index e6e99d3d6b7e..740b37e4365b 100755 --- a/app/filters.php +++ b/app/filters.php @@ -73,23 +73,8 @@ Route::filter('guest', function() Route::filter('csrf', function() { - if (!Input::get('_token')) - { - return; - } - - $tokenInput = Input::get('_token'); - $tokenSession = Session::token(); - - /* - if ($url = Session::get($tokenInput)) - { - return Redirect::to($url); - } - */ - - if ($tokenSession != $tokenInput) - { + $token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token'); + if (Session::token() != $token) { throw new Illuminate\Session\TokenMismatchException; - } + } }); \ No newline at end of file diff --git a/app/models/Activity.php b/app/models/Activity.php index d17fe01068bf..4ee87ff9705f 100755 --- a/app/models/Activity.php +++ b/app/models/Activity.php @@ -18,6 +18,11 @@ define("ACTIVITY_TYPE_DELETE_CREDIT", 14); class Activity extends Eloquent { + public function scopeScope($query) + { + return $query->whereAccountId(Auth::user()->account_id); + } + private static function getBlank() { $user = Auth::user(); diff --git a/app/models/Client.php b/app/models/Client.php index 179b2d67e9bf..8a4b67a47e4f 100755 --- a/app/models/Client.php +++ b/app/models/Client.php @@ -3,7 +3,7 @@ class Client extends Eloquent implements iEntity { protected $softDelete = true; - + public static $fieldName = 'Client - Name'; public static $fieldPhone = 'Client - Phone'; public static $fieldAddress1 = 'Client - Street'; @@ -14,6 +14,11 @@ class Client extends Eloquent implements iEntity public static $fieldNotes = 'Client - Notes'; public static $fieldCountry = 'Client - Country'; + public function scopeScope($query) + { + return $query->whereAccountId(Auth::user()->account_id); + } + public function account() { return $this->belongsTo('Account'); diff --git a/app/models/Credit.php b/app/models/Credit.php index 843e798b85f1..cd8178135ba3 100755 --- a/app/models/Credit.php +++ b/app/models/Credit.php @@ -4,6 +4,11 @@ class Credit extends Eloquent implements iEntity { protected $softDelete = true; + public function scopeScope($query) + { + return $query->whereAccountId(Auth::user()->account_id); + } + public function invoice() { return $this->belongsTo('Invoice'); diff --git a/app/models/Invitation.php b/app/models/Invitation.php index c66ea1cd1e97..1337a8785424 100644 --- a/app/models/Invitation.php +++ b/app/models/Invitation.php @@ -4,6 +4,11 @@ class Invitation extends Eloquent { protected $softDelete = true; + public function scopeScope($query) + { + return $query->whereAccountId(Auth::user()->account_id); + } + public function invoice() { return $this->belongsTo('Invoice'); diff --git a/app/models/Invoice.php b/app/models/Invoice.php index 9b45e713871a..e8d6bfaafb4c 100755 --- a/app/models/Invoice.php +++ b/app/models/Invoice.php @@ -4,6 +4,11 @@ class Invoice extends Eloquent implements iEntity { protected $softDelete = true; + public function scopeScope($query) + { + return $query->whereAccountId(Auth::user()->account_id); + } + public function account() { return $this->belongsTo('Account'); diff --git a/app/models/Payment.php b/app/models/Payment.php index c52bdaea7c9c..a96dd15c176c 100755 --- a/app/models/Payment.php +++ b/app/models/Payment.php @@ -4,6 +4,11 @@ class Payment extends Eloquent implements iEntity { protected $softDelete = true; + public function scopeScope($query) + { + return $query->whereAccountId(Auth::user()->account_id); + } + public function invoice() { return $this->belongsTo('Invoice'); diff --git a/app/models/Product.php b/app/models/Product.php index 85c1d9b92580..6aa5b45e3737 100755 --- a/app/models/Product.php +++ b/app/models/Product.php @@ -4,14 +4,14 @@ class Product extends Eloquent { protected $softDelete = true; - public static function getProducts() + public function scopeScope($query) { - return Product::where('account_id','=',Auth::user()->account_id); + return $query->whereAccountId(Auth::user()->account_id); } - public static function findProduct($key) + public static function findProductByKey($key) { - return Product::getProducts()->where('key','=',$key)->first(); + return Product::scope()->where('key','=',$key)->first(); } public static function getProductKeys($products) diff --git a/app/routes.php b/app/routes.php index 54e52414f071..5ae083fe5d6e 100755 --- a/app/routes.php +++ b/app/routes.php @@ -30,12 +30,13 @@ Route::filter('auth', function() } }); -Route::group(array('before' => array('auth', 'csrf')), function() +Route::group(array('before' => 'auth'), function() { Route::get('home', function() { return View::make('header'); }); Route::get('account/{section?}', 'AccountController@showSection'); Route::post('account/{section?}', 'AccountController@doSection'); - + Route::post('signup/validate', 'AccountController@checkEmail'); + Route::post('signup/submit', 'AccountController@submitSignup'); Route::resource('clients', 'ClientController'); Route::get('api/clients', array('as'=>'api.clients', 'uses'=>'ClientController@getDatatable')); @@ -127,7 +128,16 @@ function toSpaceCase($camelStr) return preg_replace('/([a-z])([A-Z])/s','$1 $2', $camelStr); } -/* +function timestampToDateTimeString($timestamp) { + $tz = Session::get('tz'); + if (!$tz) { + $tz = 'US/Eastern'; + } + $date = new Carbon($timestamp); + $date->tz = $tz; + return $date->toDayDateTimeString(); +} + function toDateString($date) { if ($date->year < 1900) { @@ -140,7 +150,7 @@ function toDateString($date) $date->tz = $tz; return $date->toFormattedDateString(); } -*/ + function toDateTimeString($date) { diff --git a/app/views/clients/index.blade.php b/app/views/clients/index.blade.php deleted file mode 100755 index 899fde962209..000000000000 --- a/app/views/clients/index.blade.php +++ /dev/null @@ -1,14 +0,0 @@ -@extends('header') - -@section('content') - - {{ Button::primary_link(URL::to('clients/create'), 'New Client', array('class' => 'pull-right')) }} - - {{ Datatable::table() - ->addColumn('Client', 'Contact', 'Balance', 'Last Login', 'Date Created', 'Email', 'Phone') - ->setUrl(route('api.clients')) - ->setOptions('sPaginationType', 'bootstrap') - ->setOptions('bFilter', false) - ->render() }} - -@stop \ No newline at end of file diff --git a/app/views/clients/show.blade.php b/app/views/clients/show.blade.php index 6045380b4df9..5570c5b00630 100755 --- a/app/views/clients/show.blade.php +++ b/app/views/clients/show.blade.php @@ -4,11 +4,33 @@
- {{ Button::link(URL::to('clients/' . $client->id . '/edit'), 'Edit Client') }} + {{ Former::open('clients/bulk')->addClass('mainForm') }} +
+ {{ Former::text('action') }} + {{ Former::text('id')->value($client->id) }} +
+ + {{ DropdownButton::normal('Edit Client', + Navigation::links( + array( + array('Edit Client', URL::to('clients/' . $client->id . '/edit')), + array(Navigation::DIVIDER), + array('Archive Client', "javascript:onArchiveClick()"), + array('Delete Client', "javascript:onDeleteClick()"), + ) + ) + , array('id'=>'actionDropDown'))->split(); }} {{ Button::primary_link(URL::to('invoices/create/' . $client->id), 'Create Invoice') }} + {{ Former::close() }} +

{{ $client->name }}

+ @if ($client->last_login > 0) +

+ Last logged in {{ timestampToDateTimeString($client->last_login); }} +

+ @endif
@@ -90,9 +112,23 @@ @stop \ No newline at end of file diff --git a/app/views/emails/welcome_html.blade.php b/app/views/emails/welcome_html.blade.php new file mode 100755 index 000000000000..cbd24d06043d --- /dev/null +++ b/app/views/emails/welcome_html.blade.php @@ -0,0 +1,10 @@ + + + + + + +

Welcome

+ + + \ No newline at end of file diff --git a/app/views/emails/welcome_text.blade.php b/app/views/emails/welcome_text.blade.php new file mode 100755 index 000000000000..01f3f00c6337 --- /dev/null +++ b/app/views/emails/welcome_text.blade.php @@ -0,0 +1 @@ +Welcome \ No newline at end of file diff --git a/app/views/header.blade.php b/app/views/header.blade.php index 7c9726f9e888..8b3048e6b019 100755 --- a/app/views/header.blade.php +++ b/app/views/header.blade.php @@ -6,7 +6,8 @@ - + + Invoice Ninja @@ -54,7 +55,7 @@ body > div.container { - /*max-width: 850px;*/ + min-height: 600px; } label.control-label { @@ -62,6 +63,7 @@ } + div.panel { padding-left: 0px !important; padding-right: 0px !important; @@ -228,18 +230,29 @@ @endif
-

Invoice Ninja -
+
@if (Auth::user()->registered) - + {{ Auth::user()->email }}   @else - {{ Button::sm_primary('Sign up', array('data-toggle'=>'modal', 'data-target'=>'#signUpModal')); }}   - {{ link_to('account/details', 'My Account'); }} + {{ Button::sm_primary('Sign up', array('data-toggle'=>'modal', 'data-target'=>'#signUpModal')); }} @endif -

This is a sample site, the data is erased.

+ +
+ + +
@@ -293,6 +306,13 @@ @yield('content') + +
+
+
@@ -303,20 +323,29 @@