<?php 
//document moodule main file calling other objects and returning output or uploading files 

//upload a file and add to regisry 
header("Access-Control-Allow-Origin: https://www.khambers.com");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization");

// If you need to allow credentials:
// header("Access-Control-Allow-Credentials: true");
// header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
// header("Access-Control-Allow-Headers: Content-Type, X-Requested-With");
include 'database/dataslave.php';
include 'database/encrypt.php';
include 'elements/file-processor.php';
include 'elements/docs_view.php';

    if(isset($_POST['file_upload']) && $_POST['file_upload']==1)
    {
        $file_p = new file_processor();
        //upload file 
        $file_p->upload_file('doc_upload');
    }

    //return display docs view 
         //return display docs view 
 if(isset($_POST['docs_dashboard']) && $_POST['docs_dashboard']==1)
    {
        $docs_view = new docs_view();
        $docs_view->docs_dashboard($_POST['token']);
    }
       $docs_view = new docs_view();
      
        $docs_view->docs_dashboard($_POST['token']); 
        echo 234;
    
    if(isset($_POST['search']) && $_POST['search']==1)
    {
        //return doc search results
        $docs_view = new docs_view();
        $docs_view->search();
    }
    if(isset($_POST['download_doc'])&& $_POST['download_doc'])
    {
        $tk_data = base64_decode($_POST['token']);
        $tk_data = explode(';',$tk_data);
        $file_url =$tk_data[0].'_1.pdf';
        $file_prosessor = new file_processor();
        $file_prosessor->download_file($file_url);

    }
    if(isset($_POST['single_direct_upload']) && $_POST['single_direct_upload']==1)
    {
        $file_processor = new file_processor();
        $file_processor->single_direct_upload('doc_file');
    }
    
?>