2020-05-29 13:41:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
use App\Controller\AppController;
|
|
|
|
use Cake\Utility\Hash;
|
|
|
|
use Cake\Utility\Text;
|
|
|
|
use Cake\Database\Expression\QueryExpression;
|
|
|
|
use Cake\Http\Exception\NotFoundException;
|
|
|
|
use Cake\Http\Exception\MethodNotAllowedException;
|
|
|
|
use Cake\Http\Exception\ForbiddenException;
|
|
|
|
|
|
|
|
class IndividualsController extends AppController
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
2020-06-19 00:37:56 +02:00
|
|
|
$this->CRUD->index([
|
|
|
|
'filters' => ['uuid', 'email', 'first_name', 'last_name', 'position', 'Organisations.id'],
|
|
|
|
'quickFilters' => ['uuid', 'email', 'first_name', 'last_name', 'position'],
|
|
|
|
'contain' => ['Alignments' => 'Organisations']
|
|
|
|
]);
|
|
|
|
if ($this->ParamHandler->isRest()) {
|
|
|
|
return $this->restResponsePayload;
|
2020-05-29 13:41:58 +02:00
|
|
|
}
|
2020-06-19 00:37:56 +02:00
|
|
|
$this->set('alignmentScope', 'individuals');
|
|
|
|
$this->set('metaGroup', 'ContactDB');
|
2020-05-29 13:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function add()
|
|
|
|
{
|
2020-06-19 00:37:56 +02:00
|
|
|
$this->CRUD->add();
|
|
|
|
if ($this->ParamHandler->isRest()) {
|
|
|
|
return $this->restResponsePayload;
|
2020-05-29 13:41:58 +02:00
|
|
|
}
|
|
|
|
$this->set('metaGroup', 'ContactDB');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function view($id)
|
|
|
|
{
|
2020-06-19 00:37:56 +02:00
|
|
|
$this->CRUD->view($id, ['contain' => ['Alignments' => 'Organisations']]);
|
|
|
|
if ($this->ParamHandler->isRest()) {
|
|
|
|
return $this->restResponsePayload;
|
2020-05-29 13:41:58 +02:00
|
|
|
}
|
|
|
|
$this->set('metaGroup', 'ContactDB');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function edit($id)
|
|
|
|
{
|
2020-06-19 00:37:56 +02:00
|
|
|
$this->CRUD->edit($id);
|
|
|
|
if ($this->ParamHandler->isRest()) {
|
|
|
|
return $this->restResponsePayload;
|
2020-12-10 15:18:02 +01:00
|
|
|
} else if($this->ParamHandler->isAjax() && $this->request->is(['post', 'put'])) {
|
|
|
|
return $this->ajaxResponsePayload;
|
2020-05-29 13:41:58 +02:00
|
|
|
}
|
|
|
|
$this->set('metaGroup', 'ContactDB');
|
|
|
|
$this->render('add');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete($id)
|
|
|
|
{
|
2020-06-19 00:37:56 +02:00
|
|
|
$this->CRUD->delete($id);
|
|
|
|
if ($this->ParamHandler->isRest()) {
|
|
|
|
return $this->restResponsePayload;
|
2020-05-29 13:41:58 +02:00
|
|
|
}
|
|
|
|
$this->set('metaGroup', 'ContactDB');
|
|
|
|
}
|
|
|
|
}
|