Highway to PSR2
[openemr.git] / interface / super / rules / library / RuleCriteriaDatabaseCustom.php
blob7af1b549411f63fb8d6b8e72462a1fd8298d3c10
1 <?php
2 // Copyright (C) 2010-2011 Aron Racho <aron@mi-squred.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 /**
10 * Description of RuleCriteriaDatabaseCustom
12 * @author aron
14 class RuleCriteriaDatabaseCustom extends RuleCriteria
17 var $table;
18 var $column;
19 var $valueComparator;
20 var $value;
21 var $frequencyComparator;
22 var $frequency;
24 function __construct(
25 $table,
26 $column,
27 $valueComparator,
28 $value,
29 $frequencyComparator,
30 $frequency
31 ) {
32 $this->table = $table;
33 $this->column = $column;
34 $this->valueComparator = $valueComparator;
35 $this->value = $value;
36 $this->frequencyComparator = $frequencyComparator;
37 $this->frequency = $frequency;
40 function getRequirements()
42 $requirements = "";
43 if ($this->value) {
44 $requirements .= xl("Value") . ": ";
45 $requirements .= $this->decodeComparator($this->valueComparator) . " " . $this->value;
46 $requirements .= " | ";
49 $requirements .= xl("Frequency") . ": ";
50 $requirements .= $this->decodeComparator($this->frequencyComparator) . " " . $this->frequency;
52 return $requirements;
55 function getTitle()
57 return xl($this->table) . "." . xl($this->column);
60 function getView()
62 return "custom.php";
65 function getTableNameOptions()
67 $options = array();
68 $stmts = sqlStatement("SHOW TABLES");
69 for ($iter=0; $row=sqlFetchArray($stmts); $iter++) {
70 foreach ($row as $key => $value) {
71 array_push($options, array( "id" => out($value), "label" => out(xl($value)) ));
75 return $options;
78 function getDbView()
80 $dbView = parent::getDbView();
82 $dbView->method = "database";
83 $dbView->methodDetail = "";
84 $dbView->value =
85 "::"
86 . $this->table . "::" . $this->column. "::"
87 . $this->valueComparator . "::" . $this->value . "::"
88 . $this->frequencyComparator . "::" . $this->frequency;
89 return $dbView;
92 function updateFromRequest()
94 parent::updateFromRequest();
96 $this->table = _post("fld_table");
97 $this->column = _post("fld_column");
98 $this->value = _post("fld_value");
99 $this->valueComparator = _post("fld_value_comparator");
100 $this->frequency = _post("fld_frequency");
101 $this->frequencyComparator = _post("fld_frequency_comparator");