5 * This is a class for storing document categories using the MPTT implementation
8 class CategoryTree
extends Tree
11 * This just sits on top of the parent constructor, only a shell so that the _table var gets set
13 function __construct($root, $root_type = ROOT_TYPE_ID
)
15 $this->_table
= "categories";
16 parent
::__construct($root, $root_type);
19 public function should_translate_name()
24 public function get_translated_name($name)
26 return xl_document_category($name);
29 function _get_categories_array($patient_id, $user = '')
31 $categories = array();
33 $sql = "SELECT c.id, c.name, c.aco_spec, d.id AS document_id, d.name AS document_name, d.type, d.url, d.docdate"
34 . " FROM categories AS c, documents AS d, categories_to_documents AS c2d"
35 . " WHERE c.id = c2d.category_id"
36 . " AND c2d.document_id = d.id AND d.deleted = 0";
38 if (is_numeric($patient_id)) {
39 if ($patient_id == "00") {
40 // Collect documents that are not assigned to a patient
41 $sql .= " AND (d.foreign_id = 0 OR d.foreign_id IS NULL) ";
43 // Collect documents for a specific patient
44 $sql .= " AND d.foreign_id = ? ";
45 array_push($sqlArray, $patient_id);
49 $sql .= " ORDER BY c.id ASC, d.docdate DESC, d.url ASC";
52 $result = $this->_db
->Execute($sql, $sqlArray);
54 while ($result && !$result->EOF
) {
55 $categories[$result->fields
['id']][$result->fields
['document_id']] = $result->fields
;