示例#1
0
 /**
  * Assign a record array as the internal record of the {@link BizRecord}
  *
  * @param array $inpuArr
  * @return void
  */
 public final function setInputRecord(&$inputArr)
 {
     // unformat the inputs
     unset($this->m_InputFields);
     foreach ($inputArr as $key => $value) {
         // if allow changing key field, need to keep the old value which is also useful for audit trail
         // if (!$value)
         //    continue;
         $bizField = $this->m_var[$key];
         if (!$bizField) {
             continue;
         }
         $realVal = BizSystem::typeManager()->formattedStringToValue($bizField->m_Type, $bizField->m_Format, $value);
         if (strtoupper($bizField->m_Encrypted) == 'Y') {
             $svcobj = BizSystem::getService(CRYPT_SERVICE);
             $realVal = $svcobj->encrypt($realVal);
             $bizField->setValue($realVal);
         }
         // todo: need to optimize on lob column
         $bizField->setValue($realVal);
         $this->m_InputFields[] = $key;
     }
     //$this->m_var["Id"]->setValue($this->getKeyValue());
 }
示例#2
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 . "'";
}
示例#3
0
 /**
  * Get the value of the field.
  *
  * @param boolean $formatted true if want to get the formatted value
  * @return mixed string or number depending on the field type
  */
 public function getValue($formatted = true)
 {
     // need to ensure that value are retrieved from source/cache
     //if ($this->getDataObj()->CheckDataRetrieved() == false)
     //$this->getDataObj()->getActiveRecord();
     if ($this->_prevValue == $this->m_Value) {
         return $this->_getValueCache;
     }
     $value = stripcslashes($this->m_Value);
     $value = $this->m_Value;
     if ($this->m_ValueExpression && trim($this->m_Column) == "") {
         $value = Expression::evaluateExpression($this->m_ValueExpression, $this->getDataObj());
     }
     if ($this->m_Format && $formatted) {
         $value = BizSystem::typeManager()->valueToFormattedString($this->m_Type, $this->m_Format, $value);
     }
     $this->_prevValue = $this->m_Value;
     $this->_getValueCache = $value;
     return $value;
 }