docker dev update
[openemr.git] / library / classes / CategoryTree.class.php
blob6e84a66b3adf42b0ddac8a87be170db3b397e1e1
1 <?php
4 /**
5 * class CategoryTree
6 * This is a class for storing document categories using the MPTT implementation
7 */
9 class CategoryTree extends Tree
13 * This just sits on top of the parent constructor, only a shell so that the _table var gets set
15 function __construct($root, $root_type = ROOT_TYPE_ID)
17 $this->_table = "categories";
18 parent::__construct($root, $root_type);
21 function _get_categories_array($patient_id, $user = '')
23 $categories = array();
24 $sql = "SELECT c.id, c.name, c.aco_spec, d.id AS document_id, d.type, d.url, d.docdate"
25 . " FROM categories AS c, documents AS d, categories_to_documents AS c2d"
26 . " WHERE c.id = c2d.category_id"
27 . " AND c2d.document_id = d.id";
29 if (is_numeric($patient_id)) {
30 if ($patient_id == "00") {
31 // Collect documents that are not assigned to a patient
32 $sql .= " AND (d.foreign_id = 0 OR d.foreign_id IS NULL) ";
33 } else {
34 // Collect documents for a specific patient
35 $sql .= " AND d.foreign_id = '" . $patient_id . "'";
39 $sql .= " ORDER BY c.id ASC, d.docdate DESC, d.url ASC";
41 //echo $sql;
42 $result = $this->_db->Execute($sql);
44 while ($result && !$result->EOF) {
45 $categories[$result->fields['id']][$result->fields['document_id']] = $result->fields;
46 $result->MoveNext();
49 return $categories;