Fix to remove obsolete procedure_order.diagnoses.
[openemr.git] / gacl / admin / object_search.php
blobbec1d30dd37e7345e38eae8d8b0b16bb62152b0e
1 <?php
2 require_once('gacl_admin.inc.php');
4 switch (strtolower($_GET['object_type'])) {
5 case 'axo':
6 $object_type = 'axo';
7 break;
8 default:
9 $object_type = 'aro';
12 switch ($_GET['action']) {
13 case 'Search':
14 $gacl_api->debug_text('Submit!!');
16 //Function to pass array_walk to trim all entries in an array.
17 function array_walk_trim(&$array_field) {
18 $array_field = $db->qstr(strtolower(trim($array_field)));
21 $value_search_str = trim($_GET['value_search_str']);
22 $name_search_str = trim($_GET['name_search_str']);
24 $exploded_value_search_str = explode("\n", $value_search_str);
25 $exploded_name_search_str = explode("\n", $name_search_str);
27 if (count($exploded_value_search_str) > 1 OR count($exploded_name_search_str) > 1) {
28 //Given a list, lets try to match all lines in it.
29 array_walk($exploded_value_search_str, 'array_walk_trim');
30 array_walk($exploded_name_search_str, 'array_walk_trim');
31 } else {
32 if ($value_search_str != '') {
33 $value_search_str .= '%';
36 if ($name_search_str != '') {
37 $name_search_str .= '%';
41 //Search
42 $query = '
43 SELECT section_value,value,name
44 FROM '. $gacl_api->_db_table_prefix . $object_type .'
45 WHERE section_value='. $db->qstr($_GET['section_value']) .'
46 AND (';
48 if (count($exploded_value_search_str) > 1) {
49 $query .= 'lower(value) IN ('. implode(',', $exploded_value_search_str) .')';
50 } else {
51 $query .= 'lower(value) LIKE ' . $db->qstr($value_search_str);
54 $query .= ' OR ';
56 if (count($exploded_name_search_str) > 1) {
57 $query .= 'lower(name) IN ('. implode(',', $exploded_name_search_str) .')';
58 } else {
59 $query .= 'lower(name) LIKE ' . $db->qstr($name_search_str);
62 $query .= ')
63 ORDER BY section_value,order_value,name';
64 $rs = $db->SelectLimit($query, $gacl_api->_max_search_return_items);
66 $options_objects = array();
67 $total_rows = 0;
69 if (is_object($rs)) {
70 $total_rows = $rs->RecordCount();
72 while ($row = $rs->FetchRow()) {
73 list($section_value, $value, $name) = $row;
74 $options_objects[$value] = $name;
78 $smarty->assign('options_objects', $options_objects);
79 $smarty->assign('total_rows', $total_rows);
81 $smarty->assign('value_search_str', $_GET['value_search_str']);
82 $smarty->assign('name_search_str', $_GET['name_search_str']);
84 //break;
85 default:
86 $smarty->assign('src_form', $_GET['src_form']);
87 $smarty->assign('section_value', $_GET['section_value']);
88 $smarty->assign('section_value_name', ucfirst($_GET['section_value']));
89 $smarty->assign('object_type', $object_type);
90 $smarty->assign('object_type_name', strtoupper($object_type));
92 break;
95 $smarty->assign('current', $object_type .'_search');
96 $smarty->assign('page_title', strtoupper($object_type) .' Search');
98 $smarty->assign('phpgacl_version', $gacl_api->get_version());
99 $smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version());
101 $smarty->display('phpgacl/object_search.tpl');