Files
dbois/application/controllers/beheer/CustomersController.php
T
2018-01-10 14:09:34 +01:00

70 lines
1.7 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by Pensare Software.
* Customer: Theo Weijmer
* Date: 25/12/2017
* Time: 10:11
*/
class customersController extends MY_Controller {
public function __construct()
{
parent::__construct();
if( AUTHENTICATED == FALSE ) die('NO ACCES');
$models = [];
$libraries = [];
$this->load->model( $models );
$this->load->library( $libraries );
}
public function index()
{
}
public function getAllCustomers( $archive = 'F' )
{
$customers = Customer::getAllCustomers( $archive );
$this->json( $customers );
}
public function saveCustomer()
{
$customerValidation = new CustomerValidation();
if ( ! $customerValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $customerValidation->getErrorMessages()] );
$customer = $this->input->post();
$customerID = $customer['id'];
unset( $customer['id'] );
$customerID = Customer::saveCustomer( $customerID, $customer );
$this->json( ['success' => TRUE, 'customerID' => $customerID] );
}
public function archiveCustomer( $customerID, $status )
{
Customer::whereId( $customerID )->update( ['archive' => $status] );
}
public function removeCustomer( $customerID )
{
$removeCustomer = new RemoveCustomer( $customerID );
if ( $removeCustomer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Customer::removeCustomer( $customerID );
$this->json( ['result' => TRUE] );
}
}