function get_single_with_documents($id, $return_type = "return_object")
 {
     $id = (int) $id;
     $counter = 0;
     $documents = null;
     $joins .= " {$this->left_join} controller_document ON (p.id = controller_document.procedure_id)";
     $sql = "SELECT p.*, controller_document.id AS document_id, controller_document.title AS document_title, controller_document.description as document_description FROM controller_procedure p {$joins} WHERE p.id = " . $id;
     //var_dump($sql);
     $this->db->query($sql, __LINE__, __FILE__);
     while ($this->db->next_record()) {
         if (!$counter) {
             $procedure = new controller_procedure($this->unmarshal($this->db->f('id'), 'int'));
             $procedure->set_title($this->unmarshal($this->db->f('title', true), 'string'));
             $procedure->set_purpose($this->unmarshal($this->db->f('purpose', true), 'string'));
             $procedure->set_responsibility($this->unmarshal($this->db->f('responsibility', true), 'string'));
             $procedure->set_description($this->unmarshal($this->db->f('description', true), 'string'));
             $procedure->set_reference($this->unmarshal($this->db->f('reference', true), 'string'));
             $procedure->set_attachment($this->unmarshal($this->db->f('attachment', true), 'string'));
             $procedure->set_start_date($this->unmarshal($this->db->f('start_date'), 'int'));
             $procedure->set_end_date($this->unmarshal($this->db->f('end_date'), 'int'));
             $procedure->set_procedure_id($this->unmarshal($this->db->f('procedure_id'), 'int'));
             $procedure->set_revision_no($this->unmarshal($this->db->f('revision_no'), 'int'));
             $procedure->set_revision_date($this->unmarshal($this->db->f('revision_date'), 'int'));
             $procedure->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 'int')));
             $category = execMethod('phpgwapi.categories.return_single', $this->unmarshal($this->db->f('control_area_id', 'int')));
             $procedure->set_control_area_name($category[0]['name']);
         }
         if ($this->db->f('document_id')) {
             $document = new controller_document($this->unmarshal($this->db->f('document_id'), 'int'));
             $document->set_procedure_id($procedure->get_id());
             $document->set_title($this->unmarshal($this->db->f('document_title', true), 'string'));
             $document->set_description($this->unmarshal($this->db->f('document_description', true), 'string'));
             if ($return_type == "return_array") {
                 $doc_as_array = $document->toArray();
                 $doc_as_array['document_link'] = controller_uidocument::link(array('menuaction' => 'controller.uidocument.view', 'id' => $document->get_id()));
                 //_debug_array($doc_as_array);
                 $documents_array[] = $doc_as_array;
             } else {
                 $documents_array[] = $document;
             }
         }
         $counter++;
     }
     if ($procedure != null) {
         $procedure->set_documents($documents_array);
         if ($return_type == "return_array") {
             return $procedure->toArray();
         } else {
             return $procedure;
         }
     } else {
         return null;
     }
 }