67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Created by Pensare Software.
|
|
* Customer: Theo Weijmer
|
|
* Date: 25/12/2017
|
|
* Time: 10:11
|
|
*/
|
|
|
|
class customersController 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] );
|
|
}
|
|
} |