diff --git a/app/controllers/ActivityController.php b/app/controllers/ActivityController.php
new file mode 100755
index 000000000000..cf1bc4fe97cb
--- /dev/null
+++ b/app/controllers/ActivityController.php
@@ -0,0 +1,21 @@
+account_id)
+ ->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;
+ })
+ ->orderColumns('date')
+ ->make();
+ }
+
+}
\ No newline at end of file
diff --git a/app/controllers/ClientController.php b/app/controllers/ClientController.php
index 655b9223cef7..e9ad390df2f9 100755
--- a/app/controllers/ClientController.php
+++ b/app/controllers/ClientController.php
@@ -79,7 +79,10 @@ class ClientController extends \BaseController {
*/
public function show($id)
{
- $client = Client::find($id);
+ $client = Client::with('contacts')->find($id);
+ trackViewed(Request::url(), $client->name);
+
+
return View::make('clients.show')->with('client', $client);
}
@@ -128,6 +131,7 @@ class ClientController extends \BaseController {
$client = Client::find($id);
} else {
$client = new Client;
+ $client->account_id = Auth::user()->account_id;
}
$client->name = Input::get('name');
diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php
index f0edded2ee80..c22efbd09d0e 100755
--- a/app/controllers/InvoiceController.php
+++ b/app/controllers/InvoiceController.php
@@ -13,18 +13,28 @@ class InvoiceController extends \BaseController {
return View::make('invoices.index');
}
- public function getDatatable()
+ public function getDatatable($clientId = null)
{
- return Datatable::collection(Invoice::with('client','invoice_items')->where('account_id','=',Auth::user()->account_id)->get())
- ->addColumn('number', function($model)
- {
- return link_to('invoices/' . $model->id . '/edit', $model->invoice_number);
- })
- ->addColumn('client', function($model)
- {
- return link_to('clients/' . $model->client->id, $model->client->name);
- })
- ->addColumn('amount', function($model)
+ $collection = Invoice::with('client','invoice_items')->where('account_id','=',Auth::user()->account_id);
+
+ if ($clientId) {
+ $collection->where('client_id','=',$clientId);
+ }
+
+ $table = Datatable::collection($collection->get())->addColumn('number', function($model)
+ {
+ return link_to('invoices/' . $model->id . '/edit', $model->invoice_number);
+ });
+
+ if (!$clientId)
+ {
+ $table->addColumn('client', function($model) {
+ return link_to('clients/' . $model->client->id, $model->client->name);
+ });
+
+ }
+
+ return $table->addColumn('amount', function($model)
{
return '$' . money_format('%i', $model->getTotal());
})
@@ -33,7 +43,7 @@ class InvoiceController extends \BaseController {
return $model->created_at->format('m/d/y h:i a');
})
->orderColumns('number')
- ->make();
+ ->make();
}
@@ -176,7 +186,8 @@ class InvoiceController extends \BaseController {
public function edit($id)
{
$invoice = Invoice::with('client', 'invoice_items')->find($id);
-
+ trackViewed(Request::url(), $invoice->invoice_number . ' - ' . $invoice->client->name);
+
$data = array(
'invoice' => $invoice,
'method' => 'PUT',
diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php
index 8188731dc8d0..bff7f8a0c151 100755
--- a/app/controllers/PaymentController.php
+++ b/app/controllers/PaymentController.php
@@ -7,14 +7,24 @@ class PaymentController extends \BaseController
return View::make('payments.index');
}
- public function getDatatable()
+ public function getDatatable($clientId = null)
{
- return Datatable::collection(Payment::with('invoice.client')->where('account_id', '=', Auth::user()->account_id)->get())
- ->addColumn('client', function($model)
+ $collection = Payment::with('invoice.client')->where('account_id', '=', Auth::user()->account_id);
+
+ if ($clientId) {
+ $collection->where('client_id','=',$clientId);
+ }
+
+ $table = Datatable::collection($collection->get());
+
+ if (!$clientId) {
+ $table->addColumn('client', function($model)
{
return link_to('clients/' . $model->invoice->client->id, $model->invoice->client->name);
- })
- ->addColumn('invoice', function($model)
+ });
+ }
+
+ return $table->addColumn('invoice', function($model)
{
return link_to('invoices/' . $model->invoice->id . '/edit', $model->invoice->number);
})
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 2151a838eaec..2604ee9500de 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
@@ -195,6 +195,7 @@ class ConfideSetupUsersTable extends Migration {
$t->increments('id');
$t->integer('invoice_id');
$t->integer('account_id');
+ $t->integer('client_id');
$t->integer('contact_id');
$t->integer('user_id');
$t->timestamps();
diff --git a/app/libraries/entity.php b/app/libraries/entity.php
new file mode 100644
index 000000000000..57e447e2e271
--- /dev/null
+++ b/app/libraries/entity.php
@@ -0,0 +1,8 @@
+
+
+class Entity
+{
+ public $id;
+ public $type;
+}
+
diff --git a/app/models/Client.php b/app/models/Client.php
index 3e410df89f86..0db799cd0cae 100755
--- a/app/models/Client.php
+++ b/app/models/Client.php
@@ -27,6 +27,58 @@ class Client extends Eloquent
{
return $this->hasMany('Contact');
}
+
+ public function getAddress()
+ {
+ $str = '';
+
+ if ($this->address1) {
+ $str .= $this->address1 . '
';
+ }
+ if ($this->address2) {
+ $str .= $this->address2 . '
';
+ }
+ if ($this->city) {
+ $str .= $this->city . ', ';
+ }
+ if ($this->state) {
+ $str .= $this->state . ' ';
+ }
+ if ($this->postal_code) {
+ $str .= $this->postal_code;
+ }
+
+ if ($str)
+ {
+ $str = '
' . $str . '
'; + } + + return $str; + } + + public function getPhone() + { + $str = ''; + + if ($this->work_phone) + { + $str .= '' . $this->work_phone; + } + + return $str; + } + + public function getNotes() + { + $str = ''; + + if ($this->notes) + { + $str .= '' . $this->notes . ''; + } + + return $str; + } } Client::created(function($client) diff --git a/app/models/Contact.php b/app/models/Contact.php index a3424d23a53b..4d37619afb38 100755 --- a/app/models/Contact.php +++ b/app/models/Contact.php @@ -32,11 +32,38 @@ class Contact extends Eloquent if ($fullName == ' ') { - return "Unknown"; + return 'Guest'; } else { return $fullName; } } + + public function getDetails() + { + $str = ''; + + if ($this->first_name || $this->last_name) + { + $str .= '' . $this->first_name . ' ' . $this->last_name . '' . $str . '
'; + } + + return $str; + } } \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index 54f9ef9efbf3..e256e699d091 100755 --- a/app/routes.php +++ b/app/routes.php @@ -39,15 +39,17 @@ Route::group(array('before' => array('auth', 'csrf')), function() Route::get('api/clients', array('as'=>'api.clients', 'uses'=>'ClientController@getDatatable')); Route::resource('invoices', 'InvoiceController'); - Route::get('api/invoices', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable')); + Route::get('api/invoices/{client_id?}', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable')); Route::get('invoices/create/{client_id}', 'InvoiceController@create'); Route::get('payments', 'PaymentController@index'); - Route::get('api/payments', array('as'=>'api.payments', 'uses'=>'PaymentController@getDatatable')); + Route::get('api/payments/{client_id?}', array('as'=>'api.payments', 'uses'=>'PaymentController@getDatatable')); Route::get('home', function() { return View::make('header'); }); Route::get('reports', function() { return View::make('header'); }); Route::get('payments/create', function() { return View::make('header'); }); + + Route::get('api/activities/{client_id?}', array('as'=>'api.activities', 'uses'=>'ActivityController@getDatatable')); }); // Confide routes @@ -65,9 +67,14 @@ Route::get('logout', 'UserController@logout'); -HTML::macro('nav_link', function($url, $text, $url2 = '') { +HTML::macro('nav_link', function($url, $text, $url2 = '', $extra = '') { $class = ( Request::is($url) || Request::is($url.'/*') || Request::is($url2) ) ? ' class="active"' : ''; - return '{{ $client->getAddress() }}
+{{ $client->getPhone() }}
+{{ $client->getNotes() }}
++ + + +
This is a sample site, the data is erased
@@ -261,11 +267,25 @@ {{ HTML::menu_link('payment') }} {{-- HTML::nav_link('reports', 'Reports') --}} - +