public function act_download()
 {
     //get file id
     //load document detaild
     $supporting_docs_meta = new SupportingDocsMeta();
     $supporting_docs_meta->LoadfromRecordNumber($_GET['doc_id']);
     $supporting_docs_meta->LoadRelationships();
     $supporting_docs = new SupportingDocs();
     $supporting_docs->LoadfromRecordNumber($_GET['doc_id']);
     //set headers
     if ($supporting_docs->uri != null) {
         //echo $supporting_docs->uri;
         $ext = shn_file_findexts($supporting_docs->uri);
         //fetch document
         //stream document
         $title = $supporting_docs_meta->title;
         $file_name = str_replace(" ", "_", $title);
         header("Content-Type: application/{$ext}");
         header("Content-Disposition: filename=" . urlencode("{$file_name}.{$ext}"));
         header("Content-Length: " . filesize($supporting_docs->uri));
         $fp = fopen($supporting_docs->uri, 'rb');
         fpassthru($fp);
         //inthis case we dont need to go to the templates so exit from the script
     } else {
         shnMessageQueue::addInformation('No attachment found to this document.');
         set_redirect_header('docu', 'view_document', null, null);
     }
     exit;
 }
 function act_supporting_doc()
 {
     include_once APPROOT . 'inc/lib_form_util.inc';
     include_once APPROOT . 'inc/lib_uuid.inc';
     $this->supporting_doc_form = $supporting_doc_form;
     $this->pid = isset($_GET['pid']) && $_GET['pid'] != null ? $_GET['pid'] : $_SESSION['pid'];
     if ($this->pid != null) {
         $person_form = person_form('new');
         $this->person_form = $person_form;
         $this->person = $this->person_information($this->pid, $this->person_form);
         $_SESSION['ppid'] = $this->pid;
     }
     if (isset($_POST['save'])) {
         $status = shn_form_validate($supporting_doc_form);
         if ($status) {
             $supporting_doc = new SupportingDocs();
             $supporting_doc->doc_id = shn_create_uuid('document');
             $supporting_doc->uri = 'www.respere.com';
             $supporting_doc->Save();
             $supporting_docmeta = new SupportingDocsMeta();
             $supporting_docmeta->doc_id = $supporting_doc->doc_id;
             form_objects($supporting_doc_form, $supporting_docmeta);
             $supporting_docmeta->format = $this->findexts($_FILES['document']['name']);
             $supporting_docmeta->Save();
         }
     }
 }