This commit is contained in:
2017-12-31 10:13:05 +01:00
parent 8ce71a444b
commit 57092eea2b
3 changed files with 71 additions and 100 deletions
@@ -0,0 +1,67 @@
<?php
/**
* Created by Pensare Software.
* Customer: Theo Weijmer
* Date: 25/12/2017
* Time: 10:11
*/
class externalsControllerController extends MY_Controller {
public function __construct()
{
parent::__construct();
$models = [];
$libraries = [];
$this->load->model( $models );
$this->load->library( $libraries );
}
public function index()
{
}
public function getAllCustomers( $archive = 'F' )
{
$users = Customer::getAllCustomers( $archive );
$this->json( $users );
}
public function saveCustomer()
{
$userValidation = new CustomerValidation();
if ( ! $userValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $userValidation->getErrorMessages()] );
$user = $this->input->post();
$userID = $user['id'];
unset( $user['id'] );
$userID = Customer::saveCustomer( $userID, $user );
$this->json( ['success' => TRUE, 'userID' => $userID] );
}
public function archiveCustomer( $userID, $status )
{
Customer::whereId( $userID )->update( ['archive' => $status] );
}
public function removeCustomer( $userID )
{
$removeCustomer = new RemoveCustomer( $userID );
if ( $removeCustomer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Customer::removeCustomer( $userID );
$this->json( ['result' => TRUE] );
}
}