示例#1
0
 public function searchSipTrace($id = null)
 {
     include_once OPENBIZ_BIN . "/easy/SearchHelper.php";
     $searchRule = "";
     foreach ($this->m_DataPanel as $element) {
         if (!$element->m_FieldName) {
             continue;
         }
         $value = BizSystem::clientProxy()->getFormInputs($element->m_Name);
         if ($element->m_FuzzySearch == "Y") {
             $value = "*{$value}*";
         }
         if ($value) {
             $searchStr = inputValToRule($element->m_FieldName, $value, $this);
             if ($searchRule == "") {
                 $searchRule .= $searchStr;
             } else {
                 $searchRule .= " AND " . $searchStr;
             }
         }
     }
     $searchRuleBindValues = QueryStringParam::getBindValues();
     $listFormObj = BizSystem::getObject($this->localListForm);
     $listFormObj->setSearchRule($searchRule, $searchRuleBindValues);
     $listFormObj->rerender();
 }
示例#2
0
 public function SwitchSearchFieldForm($switchForm, $fieldName, $fieldValue)
 {
     include_once OPENBIZ_BIN . "/easy/SearchHelper.php";
     $this->switchForm($switchForm);
     $listFormObj = BizSystem::getObject($switchForm);
     QueryStringParam::reset();
     $searchRule = inputValToRule($fieldName, $fieldValue, $this);
     $searchRuleBindValues = QueryStringParam::getBindValues();
     $listFormObj->setSearchRule($searchRule, $searchRuleBindValues);
     $listFormObj->rerender();
 }
示例#3
0
 public function runSearch()
 {
     //include_once(OPENBIZ_BIN . "/easy/SearchHelper.php");
     $searchRule = "";
     foreach ($this->searchPanel as $element) {
         $searchStr = '';
         if (method_exists($element, "getSearchRule")) {
             $searchStr = $element->getSearchRule();
         } else {
             if (!$element->fieldName) {
                 continue;
             }
             $value = Openbiz::$app->getClientProxy()->getFormInputs($element->objectName);
             if ($element->fuzzySearch == "Y") {
                 $value = "*{$value}*";
             }
             if ($value != '') {
                 $searchStr = inputValToRule($element->fieldName, $value, $this);
                 $values[] = $value;
             }
         }
         if ($searchStr) {
             if ($searchRule == "") {
                 $searchRule .= $searchStr;
             } else {
                 $searchRule .= " AND " . $searchStr;
             }
         }
     }
     $this->searchRule = $searchRule;
     $this->searchRuleBindValues = $values;
     $this->isRefreshData = true;
     $this->currentPage = 1;
     Openbiz::$app->getLog()->log(LOG_DEBUG, "FORMOBJ", $this->objectName . "::runSearch(), SearchRule=" . $this->searchRule);
     $recArr = $this->readInputRecord();
     $this->searchPanelValues = $recArr;
     $this->runEventLog();
     $this->rerender();
 }
示例#4
0
/**
 * Convert the user input on a given fieldcontrol in query mode to search rule
 *
 * @param string $fieldName - fieldcontrol name
 * @param string $inputVal - use input text
 * @param EasyForm $formObj
 * @return string - searchRule
 */
function inputValToRule($fieldName, $inputVal, $formObj)
{
    // todo: should check single quote for nonoperators clauses
    // find locations for all sql key words
    // search for starting ' and closing ' pair, check if sql key word in the pair
    $val = strtoupper(trim($inputVal));
    // check " AND ", " OR "
    if (($pos = strpos($val, " AND ")) !== false) {
        $inputArr = explode(" AND ", $val);
        $retStr = null;
        foreach ($inputArr as $v) {
            $retStr .= $retStr ? " AND " . inputValToRule($fieldName, $v, $formObj) : inputValToRule($fieldName, $v, $formObj);
        }
        return $retStr;
    } else {
        if (($pos = strpos($val, " OR ")) !== false) {
            $inputArr = explode(" OR ", $val);
            $retStr = null;
            foreach ($inputArr as $v) {
                $retStr .= $retStr ? " OR " . inputValToRule($fieldName, $v, $formObj) : inputValToRule($fieldName, $v, $formObj);
            }
            return "(" . $retStr . ")";
        }
    }
    // check >=, >, <=, <, =
    if (($pos = strpos($val, "<>")) !== false || ($pos = strpos($val, "!=")) !== false) {
        $opr = "<>";
        $oprlen = 2;
    } else {
        if (($pos = strpos($val, ">=")) !== false) {
            $opr = ">=";
            $oprlen = 2;
        } else {
            if (($pos = strpos($val, ">")) !== false) {
                $opr = ">";
                $oprlen = 1;
            } else {
                if (($pos = strpos($val, "<=")) !== false) {
                    $opr = "<=";
                    $oprlen = 2;
                } else {
                    if (($pos = strpos($val, "<")) !== false) {
                        $opr = "<";
                        $oprlen = 1;
                    } else {
                        if (($pos = strpos($val, "=")) !== false) {
                            $opr = "=";
                            $oprlen = 1;
                        }
                    }
                }
            }
        }
    }
    if ($opr) {
        $val = trim(substr($val, $pos + $oprlen));
    }
    if (strpos($val, "*") !== false) {
        $opr = "LIKE";
        $val = str_replace("*", "%", $val);
    }
    //if (strpos($val, "'") !== false) {   // not needed since addslashes() is called before
    //   $val = str_replace("'", "\\'", $val);
    //}
    if (!$opr) {
        $opr = "=";
    }
    // unformat value to real value data
    if ($formObj->getDataObj()) {
        $bizField = $formObj->getDataObj()->getField($fieldName);
        $realValue = BizSystem::typeManager()->formattedStringToValue($bizField->m_Type, $bizField->m_Format, $val);
    } else {
        $realValue = $val;
    }
    // set the query param
    $queryString = QueryStringParam::formatQueryString("[{$fieldName}]", $opr, $realValue);
    return $queryString;
    //return "[" . $field . "] " . $opr . " '" . $realVal . "'";
}
示例#5
0
 /**
  * Run Search
  *
  * @return void
  */
 public function runSearch()
 {
     include_once OPENBIZ_BIN . "/easy/SearchHelper.php";
     $searchRule = "";
     foreach ($this->m_SearchPanel as $element) {
         if (!$element->m_FieldName) {
             continue;
         }
         $value = BizSystem::clientProxy()->getFormInputs($element->m_Name);
         if ($element->m_FuzzySearch == "Y") {
             $value = "*{$value}*";
         }
         if ($value) {
             $searchStr = inputValToRule($element->m_FieldName, $value, $this);
             if ($searchRule == "") {
                 $searchRule .= $searchStr;
             } else {
                 $searchRule .= " AND " . $searchStr;
             }
         }
     }
     $this->m_SearchRule = $searchRule;
     $this->m_SearchRuleBindValues = QueryStringParam::getBindValues();
     $this->m_RefreshData = true;
     $this->m_CurrentPage = 1;
     BizSystem::log(LOG_DEBUG, "FORMOBJ", $this->m_Name . "::runSearch(), SearchRule=" . $this->m_SearchRule);
     $this->runEventLog();
     $this->rerender();
 }