51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Created by Pensare Software.
|
|
* User: Theo Weijmer
|
|
* Date: 10/01/2018
|
|
* Time: 20:22
|
|
*/
|
|
|
|
class DocumentsController extends MY_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
|
|
|
$models = [];
|
|
$libraries = [];
|
|
|
|
$this->load->model( $models );
|
|
$this->load->library( $libraries );
|
|
}
|
|
|
|
public function getDocuments( $foreignID )
|
|
{
|
|
$documents = Document::getDocuments( $foreignID );
|
|
|
|
$this->json( $documents );
|
|
}
|
|
|
|
public function downloadDocument( $documentID )
|
|
{
|
|
$this->load->helper( 'download' );
|
|
|
|
$document = Document::find( $documentID );
|
|
|
|
$data = file_get_contents( MYROOTPATH . 'documents/' . $document->storagename );
|
|
|
|
force_download( $document->originalname, $data );
|
|
}
|
|
|
|
public function removeDocument( $documentID )
|
|
{
|
|
$document = Document::find( $documentID );
|
|
|
|
unlink( MYROOTPATH . 'documents/' . $document->storagename );
|
|
|
|
Document::whereId( $documentID )->delete();
|
|
}
|
|
|
|
} |