diff --git a/application/controllers/beheer/CustomersController.php b/application/controllers/beheer/CustomersController.php index fe40206..0fd8500 100644 --- a/application/controllers/beheer/CustomersController.php +++ b/application/controllers/beheer/CustomersController.php @@ -12,6 +12,8 @@ class customersController extends MY_Controller { { parent::__construct(); + if( AUTHENTICATED == FALSE ) + $models = []; $libraries = []; diff --git a/application/controllers/beheer/ExternalsController.php b/application/controllers/beheer/ExternalsController.php index 949a8fd..28712cb 100644 --- a/application/controllers/beheer/ExternalsController.php +++ b/application/controllers/beheer/ExternalsController.php @@ -1,12 +1,12 @@ 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] ); } diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php index 87dd1eb..a2ae545 100644 --- a/application/core/MY_Controller.php +++ b/application/core/MY_Controller.php @@ -38,7 +38,14 @@ class MY_Controller extends CI_Controller { public function json( $data ) { - echo json_encode( $data ); + $this->output + ->set_content_type( 'application/json' ) + ->set_output( json_encode( $data ) ); + } + + public function unAuthorized() + { + } } \ No newline at end of file diff --git a/application/libraries/beheer/externals/RemoveExternal.php b/application/libraries/beheer/externals/RemoveExternal.php new file mode 100644 index 0000000..88dd9fd --- /dev/null +++ b/application/libraries/beheer/externals/RemoveExternal.php @@ -0,0 +1,36 @@ +setExternalID( $userID ); + + $this->handle(); + } + + public function getAllowDelete() + { + return $this->allowDelete; + } + + private function setExternalID( $externalID ) + { + $this->externalID = $externalID; + } + + private function handle() + { + + } + +} \ No newline at end of file diff --git a/application/libraries/validation/inputValidations/ExternalValidation.php b/application/libraries/validation/inputValidations/ExternalValidation.php new file mode 100644 index 0000000..9c29b90 --- /dev/null +++ b/application/libraries/validation/inputValidations/ExternalValidation.php @@ -0,0 +1,36 @@ + [ + 'validations' => 'required|alphaNumericSpaces', + 'fieldname' => 'contact' + ], + 'email' => [ + 'validations' => 'email', + 'fieldname' => 'email' + ], + 'rate' => [ + 'validations' => 'numeric', + 'fieldname' => 'tarief' + ] + ]; + + public function __construct() + { + parent::__construct(); + + $this->ci =& get_instance(); + } +} \ No newline at end of file diff --git a/application/models/beheer/External_model.php b/application/models/beheer/External_model.php new file mode 100644 index 0000000..c754af1 --- /dev/null +++ b/application/models/beheer/External_model.php @@ -0,0 +1,18 @@ +whereArchive( 'F' ); + + $externals = $externals->get(); + + return $externals; + } + + public static function saveExternal( $externalID, $external ) + { + $external = (array)$external; + + if( $externalID == 0) + { + $external = External::create($external); + } + else + { + $external = External::whereId($externalID)->update($external); + } + + return $external['id']; + } + + public static function removeExternal($externalID) + { + External::whereId($externalID)->delete(); + } + + +} \ No newline at end of file diff --git a/application/views/modals/customer_modal.php b/application/views/modals/customer_modal.php index 8f5fb26..106ec3f 100644 --- a/application/views/modals/customer_modal.php +++ b/application/views/modals/customer_modal.php @@ -21,7 +21,7 @@ diff --git a/application/views/modals/external_modal.php b/application/views/modals/external_modal.php new file mode 100644 index 0000000..91f2727 --- /dev/null +++ b/application/views/modals/external_modal.php @@ -0,0 +1,190 @@ +