CDR Module: Fixed broken headers in Admin GUI. No longer require output buffering.
[openemr.git] / interface / super / rules / library / RuleCriteriaDatabaseBucket.php
blobae5ddf5be85e685fe370cd156909da484000bc97
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 RuleCriteriaDatabaseBucketBuilder
12 * @author aron
14 class RuleCriteriaDatabaseBucket extends RuleCriteria {
15 var $category;
16 var $item;
17 var $categoryLbl;
18 var $itemLbl;
19 var $completed;
20 var $frequencyComparator;
21 var $frequency;
23 function __construct( $category, $item, $completed,
24 $frequencyComparator, $frequency ) {
25 $this->category = $category;
26 $this->categoryLbl = $this->getLabel($this->category, 'rule_action_category');
27 $this->item = $item;
28 $this->itemLbl = $this->getLabel($this->item, 'rule_action');
29 $this->completed = $completed;
30 $this->frequencyComparator = $frequencyComparator;
31 $this->frequency = $frequency;
34 function getRequirements() {
35 $requirements .= xl( "Completed" ) . ": ";
36 $requirements .= $this->completed ? xl( "Yes" ) : xl( "No" );
37 $requirements .= " | ";
38 $requirements .= xl( "Frequency" ) . ": ";
39 $requirements .= $this->decodeComparator( $this->frequencyComparator ) . " "
40 . $this->frequency . " ";
41 return $requirements;
44 function getTitle() {
45 return $this->getCategoryLabel() . " - " . $this->getItemLabel();
48 function getCategoryLabel() {
49 return $this->categoryLbl;
52 function getItemLabel() {
53 return $this->itemLbl;
56 function getView() {
57 return "bucket.php";
60 function getDbView() {
61 $dbView = parent::getDbView();
63 $dbView->method = "database";
64 $dbView->methodDetail = "";
65 $dbView->value =
66 "CUSTOM::"
67 . $this->category . "::" . $this->item . "::"
68 . ($this->completed ? "YES":"NO") . "::"
69 . $this->frequencyComparator . "::" . $this->frequency;
71 return $dbView;
74 function updateFromRequest() {
75 parent::updateFromRequest();
77 $category = _post("fld_category");
78 $categoryLbl = _post("fld_category_lbl");
79 $item = _post("fld_item");
80 $itemLbl = _post("fld_item_lbl");
81 $completed = _post("fld_completed");
82 $frequency = _post("fld_frequency");
83 $frequencyComparator = _post("fld_frequency_comparator");
85 $this->completed = $completed == 'yes';
86 $this->frequency = $frequency;
87 $this->frequencyComparator = $frequencyComparator;
89 // update labels
90 // xxx todo abstract this out to a manager (which may or may not defer to core options handling code)!
91 // xxx this belongs more in the rule manager
92 $dbLbl = getLabel($category, 'rule_action_category');
93 if ( $category && $dbLbl != $categoryLbl ) {
94 // update
95 sqlQuery(sqlStatement( "UPDATE list_options SET title = ? WHERE list_id = 'rule_action_category' AND option_id = ?", array(
96 $categoryLbl,
97 $category )
98 ));
101 $dbLbl = getLabel($item, 'rule_action');
102 if ( $item && $dbLbl != $itemLbl ) {
103 // update
104 sqlQuery(sqlStatement( "UPDATE list_options SET title = ? WHERE list_id = 'rule_action' AND option_id = ?", array(
105 $itemLbl,
106 $item )
110 $this->category = $category;
111 $this->item = $item;
112 $this->itemLbl = $itemLbl;
113 $this->categoryLbl = $categoryLbl;