diff --git a/app/controllers/ActivityController.php b/app/controllers/ActivityController.php index d66607550d59..125e3bd72948 100755 --- a/app/controllers/ActivityController.php +++ b/app/controllers/ActivityController.php @@ -1,22 +1,21 @@ join('clients', 'clients.id', '=', 'activities.client_id') ->where('clients.public_id', '=', $clientPublicId) ->where('activities.account_id', '=', Auth::user()->account_id) ->select('activities.id', 'activities.message', 'activities.created_at', 'clients.currency_id', 'activities.balance', 'activities.adjustment'); - + return Datatable::query($query) //->addColumn('blank', function($model) { return ''; }) - ->addColumn('id', function($model) { return Utils::timestampToDateTimeString(strtotime($model->created_at)); }) - ->addColumn('message', function($model) { return Utils::decodeActivity($model->message); }) - ->addColumn('balance', function($model) { return Utils::formatMoney($model->balance, $model->currency_id); }) - ->addColumn('adjustment', function($model) { return $model->adjustment != 0 ? Utils::formatMoney($model->adjustment, $model->currency_id) : ''; }) - ->make(); - } - -} \ No newline at end of file + ->addColumn('id', function ($model) { return Utils::timestampToDateTimeString(strtotime($model->created_at)); }) + ->addColumn('message', function ($model) { return Utils::decodeActivity($model->message); }) + ->addColumn('balance', function ($model) { return Utils::formatMoney($model->balance, $model->currency_id); }) + ->addColumn('adjustment', function ($model) { return $model->adjustment != 0 ? Utils::formatMoney($model->adjustment, $model->currency_id) : ''; }) + ->make(); + } +} diff --git a/app/controllers/AppController.php b/app/controllers/AppController.php index ecaa5f6d8835..0d9405d846eb 100644 --- a/app/controllers/AppController.php +++ b/app/controllers/AppController.php @@ -43,7 +43,7 @@ class AppController extends BaseController { $database = Input::get('database'); $dbType = $database['default']; $database[$dbType] = $database['type']; - //unset($database['type']); + unset($database['type']); $mail = Input::get('mail'); $email = $mail['username']; @@ -58,7 +58,7 @@ class AppController extends BaseController { if ($test == 'db') { - return $valid ? 'Success' : 'Failed'; + return $valid === true ? 'Success' : $valid; } else if (!$valid) { @@ -115,7 +115,7 @@ class AppController extends BaseController { { Config::set("database.connections.{$dbType}.{$key}", $val); } - + try { $valid = DB::connection()->getDatabaseName() ? true : false; diff --git a/app/controllers/BaseController.php b/app/controllers/BaseController.php index 5c28d5fa1cca..11891536c641 100755 --- a/app/controllers/BaseController.php +++ b/app/controllers/BaseController.php @@ -1,22 +1,21 @@ layout)) { + $this->layout = View::make($this->layout); + } + } - /** - * Setup the layout used by the controller. - * - * @return void - */ - protected function setupLayout() - { - if ( ! is_null($this->layout)) - { - $this->layout = View::make($this->layout); - } - } - - public function __construct() - { - $this->beforeFilter('csrf', array('on' => array('post', 'delete', 'put'))); - } -} \ No newline at end of file + public function __construct() + { + $this->beforeFilter('csrf', array('on' => array('post', 'delete', 'put'))); + } +} diff --git a/app/controllers/ClientApiController.php b/app/controllers/ClientApiController.php index 3a1abc6fd135..2d76dfab108b 100644 --- a/app/controllers/ClientApiController.php +++ b/app/controllers/ClientApiController.php @@ -2,56 +2,56 @@ use ninja\repositories\ClientRepository; -class ClientApiController extends Controller { +class ClientApiController extends Controller +{ + protected $clientRepo; - protected $clientRepo; - - public function __construct(ClientRepository $clientRepo) - { - $this->clientRepo = $clientRepo; - } - - public function ping() - { - $headers = Utils::getApiHeaders(); - return Response::make('', 200, $headers); - } - - public function index() - { - if (!Utils::isPro()) { - return Redirect::to('/'); - } - - $clients = Client::scope()->with('contacts')->orderBy('created_at', 'desc')->get(); - $clients = Utils::remapPublicIds($clients->toArray()); - - $response = json_encode($clients, JSON_PRETTY_PRINT); - $headers = Utils::getApiHeaders(count($clients)); - return Response::make($response, 200, $headers); - } - - public function store() - { - if (!Utils::isPro()) { - return Redirect::to('/'); - } - - $data = Input::all(); - $error = $this->clientRepo->getErrors($data); - - if ($error) + public function __construct(ClientRepository $clientRepo) { - $headers = Utils::getApiHeaders(); - return Response::make($error, 500, $headers); - } - else - { - $client = $this->clientRepo->save(false, $data, false); - $response = json_encode($client, JSON_PRETTY_PRINT); - $headers = Utils::getApiHeaders(); - return Response::make($response, 200, $headers); + $this->clientRepo = $clientRepo; } - } + public function ping() + { + $headers = Utils::getApiHeaders(); + + return Response::make('', 200, $headers); + } + + public function index() + { + if (!Utils::isPro()) { + return Redirect::to('/'); + } + + $clients = Client::scope()->with('contacts')->orderBy('created_at', 'desc')->get(); + $clients = Utils::remapPublicIds($clients->toArray()); + + $response = json_encode($clients, JSON_PRETTY_PRINT); + $headers = Utils::getApiHeaders(count($clients)); + + return Response::make($response, 200, $headers); + } + + public function store() + { + if (!Utils::isPro()) { + return Redirect::to('/'); + } + + $data = Input::all(); + $error = $this->clientRepo->getErrors($data); + + if ($error) { + $headers = Utils::getApiHeaders(); + + return Response::make($error, 500, $headers); + } else { + $client = $this->clientRepo->save(false, $data, false); + $response = json_encode($client, JSON_PRETTY_PRINT); + $headers = Utils::getApiHeaders(); + + return Response::make($response, 200, $headers); + } + } } diff --git a/app/controllers/ClientController.php b/app/controllers/ClientController.php index c073ad87254b..ea697d185320 100755 --- a/app/controllers/ClientController.php +++ b/app/controllers/ClientController.php @@ -2,300 +2,276 @@ use ninja\repositories\ClientRepository; -class ClientController extends \BaseController { +class ClientController extends \BaseController +{ + protected $clientRepo; - protected $clientRepo; + public function __construct(ClientRepository $clientRepo) + { + parent::__construct(); - public function __construct(ClientRepository $clientRepo) - { - parent::__construct(); + $this->clientRepo = $clientRepo; + } - $this->clientRepo = $clientRepo; - } + /** + * Display a listing of the resource. + * + * @return Response + */ + public function index() + { + return View::make('list', array( + 'entityType' => ENTITY_CLIENT, + 'title' => trans('texts.clients'), + 'columns' => Utils::trans(['checkbox', 'client', 'contact', 'email', 'date_created', 'last_login', 'balance', 'action']), + )); + } - /** - * Display a listing of the resource. - * - * @return Response - */ - public function index() - { - return View::make('list', array( - 'entityType'=>ENTITY_CLIENT, - 'title' => trans('texts.clients'), - 'columns'=>Utils::trans(['checkbox', 'client', 'contact', 'email', 'date_created', 'last_login', 'balance', 'action']) - )); - } - - public function getDatatable() - { - $clients = $this->clientRepo->find(Input::get('sSearch')); + public function getDatatable() + { + $clients = $this->clientRepo->find(Input::get('sSearch')); return Datatable::query($clients) - ->addColumn('checkbox', function($model) { return ''; }) - ->addColumn('name', function($model) { return link_to('clients/' . $model->public_id, $model->name); }) - ->addColumn('first_name', function($model) { return link_to('clients/' . $model->public_id, $model->first_name . ' ' . $model->last_name); }) - ->addColumn('email', function($model) { return link_to('clients/' . $model->public_id, $model->email); }) - ->addColumn('created_at', function($model) { return Utils::timestampToDateString(strtotime($model->created_at)); }) - ->addColumn('last_login', function($model) { return Utils::timestampToDateString(strtotime($model->last_login)); }) - ->addColumn('balance', function($model) { return Utils::formatMoney($model->balance, $model->currency_id); }) - ->addColumn('dropdown', function($model) - { - if ($model->is_deleted) - { - return '
'; + ->addColumn('checkbox', function ($model) { return ''; }) + ->addColumn('name', function ($model) { return link_to('clients/'.$model->public_id, $model->name); }) + ->addColumn('first_name', function ($model) { return link_to('clients/'.$model->public_id, $model->first_name.' '.$model->last_name); }) + ->addColumn('email', function ($model) { return link_to('clients/'.$model->public_id, $model->email); }) + ->addColumn('created_at', function ($model) { return Utils::timestampToDateString(strtotime($model->created_at)); }) + ->addColumn('last_login', function ($model) { return Utils::timestampToDateString(strtotime($model->last_login)); }) + ->addColumn('balance', function ($model) { return Utils::formatMoney($model->balance, $model->currency_id); }) + ->addColumn('dropdown', function ($model) { + if ($model->is_deleted) { + return '
'; } - $str = '