externals

This commit is contained in:
2018-01-01 11:08:24 +01:00
parent cf345f6f43
commit 53ef539985
17 changed files with 726 additions and 29 deletions
@@ -1,12 +1,12 @@
<?php
/**
* Created by Pensare Software.
* Customer: Theo Weijmer
* External: Theo Weijmer
* Date: 25/12/2017
* Time: 10:11
*/
class externalsControllerController extends MY_Controller {
class externalsController extends MY_Controller {
public function __construct()
{
@@ -24,43 +24,43 @@ class externalsControllerController extends MY_Controller {
}
public function getAllCustomers( $archive = 'F' )
public function getAllExternals( $archive = 'F' )
{
$users = Customer::getAllCustomers( $archive );
$externals = External::getAllExternals( $archive );
$this->json( $users );
$this->json( $externals );
}
public function saveCustomer()
public function saveExternal()
{
$userValidation = new CustomerValidation();
$externalValidation = new ExternalValidation();
if ( ! $userValidation->getValidationResult() )
if ( ! $externalValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $userValidation->getErrorMessages()] );
'success' => FALSE, 'messages' => $externalValidation->getErrorMessages()] );
$user = $this->input->post();
$external = $this->input->post();
$userID = $user['id'];
unset( $user['id'] );
$externalID = $external['id'];
unset( $external['id'] );
$userID = Customer::saveCustomer( $userID, $user );
$externalID = External::saveExternal( $externalID, $external );
$this->json( ['success' => TRUE, 'userID' => $userID] );
$this->json( ['success' => TRUE, 'externalID' => $externalID] );
}
public function archiveCustomer( $userID, $status )
public function archiveExternal( $externalID, $status )
{
Customer::whereId( $userID )->update( ['archive' => $status] );
External::whereId( $externalID )->update( ['archive' => $status] );
}
public function removeCustomer( $userID )
public function removeExternal( $externalID )
{
$removeCustomer = new RemoveCustomer( $userID );
$removeExternal = new RemoveExternal( $externalID );
if ( $removeCustomer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
if ( $removeExternal->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Customer::removeCustomer( $userID );
External::removeExternal( $externalID );
$this->json( ['result' => TRUE] );
}