67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Created by Pensare Software.
|
|
* External: Theo Weijmer
|
|
* Date: 25/12/2017
|
|
* Time: 10:11
|
|
*/
|
|
|
|
class externalsController extends MY_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
$models = [];
|
|
$libraries = [];
|
|
|
|
$this->load->model( $models );
|
|
$this->load->library( $libraries );
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
|
|
}
|
|
|
|
public function getAllExternals( $archive = 'F' )
|
|
{
|
|
$externals = External::getAllExternals( $archive );
|
|
|
|
$this->json( $externals );
|
|
}
|
|
|
|
public function saveExternal()
|
|
{
|
|
$externalValidation = new ExternalValidation();
|
|
|
|
if ( ! $externalValidation->getValidationResult() )
|
|
return $this->json( [
|
|
'success' => FALSE, 'messages' => $externalValidation->getErrorMessages()] );
|
|
|
|
$external = $this->input->post();
|
|
|
|
$externalID = $external['id'];
|
|
unset( $external['id'] );
|
|
|
|
$externalID = External::saveExternal( $externalID, $external );
|
|
|
|
$this->json( ['success' => TRUE, 'externalID' => $externalID] );
|
|
}
|
|
|
|
public function archiveExternal( $externalID, $status )
|
|
{
|
|
External::whereId( $externalID )->update( ['archive' => $status] );
|
|
}
|
|
|
|
public function removeExternal( $externalID )
|
|
{
|
|
$removeExternal = new RemoveExternal( $externalID );
|
|
|
|
if ( $removeExternal->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
|
|
|
|
External::removeExternal( $externalID );
|
|
|
|
$this->json( ['result' => TRUE] );
|
|
}
|
|
} |