function CCCompareValues($Value1, $Value2, $DataType = ccsText, $Format = "") { switch ($DataType) { case ccsInteger: case ccsFloat: if (strcmp(trim($Value1), "") == 0 || strcmp(trim($Value2), "") == 0) { return strcmp($Value1, $Value2); } else { if ($Value1 > $Value2) { return 1; } else { if ($Value1 < $Value2) { return -1; } else { return 0; } } } case ccsText: case ccsMemo: return strcmp($Value1, $Value2); case ccsBoolean: if (is_bool($Value1)) { $val1 = $Value1; } else { if (strlen($Value1) != 0 && CCValidateBoolean($Value1, $Format)) { $val1 = CCParseBoolean($Value1, $Format); } else { return 1; } } if (is_bool($Value2)) { $val2 = $Value2; } else { if (strlen($Value2) != 0 && CCValidateBoolean($Value2, $Format)) { $val2 = CCParseBoolean($Value2, $Format); } else { return 1; } } return $val1 xor $val2; case ccsDate: if (is_array($Value1) && is_array($Value2)) { $compare = array(ccsYear, ccsMonth, ccsDay, ccsHour, ccsMinute, ccsSecond); foreach ($compare as $ind => $val) { if ($Value1[$val] < $Value2[$val]) { return -1; } elseif ($Value1[$val] > $Value2[$val]) { return 1; } } return 0; } else { if (is_array($Value1)) { $FormattedValue = CCFormatValue($Value1, $Format, $DataType); return CCCompareValues($FormattedValue, $Value2); } else { if (is_array($Value2)) { $FormattedValue = CCFormatValue($Value2, $Format, $DataType); return CCCompareValues($Value1, $FormattedValue); } else { return CCCompareValues($Value1, $Value2); } } } } }
function GetParsedValue() { $varResult = ""; if (strlen($this->DBValue)) { switch ($this->DataType) { case ccsDate: if (CCValidateDate($this->DBValue, $this->DBFormat)) { $varResult = CCParseDate($this->DBValue, $this->DBFormat); } else { if (is_array($this->DBFormat)) { $this->Errors->addError("The value in field " . $this->Name . " is not valid. Use the following format: " . join("", $this->DBFormat) . ""); } else { $this->Errors->addError("The value in field " . $this->Name . " is not valid."); } } break; case ccsBoolean: if (CCValidateBoolean($this->DBValue, $this->DBFormat)) { $varResult = CCParseBoolean($this->DBValue, $this->DBFormat); } else { $this->Errors->addError("The value in field " . $this->Caption . " is not valid."); } break; case ccsInteger: if (CCValidateNumber($this->DBValue, $this->DBFormat)) { $varResult = CCParseInteger($this->DBValue, $this->DBFormat); } else { $this->Errors->addError("The value in field " . $this->Name . " is not valid."); } break; case ccsFloat: if (CCValidateNumber($this->DBValue, $this->DBFormat)) { $varResult = CCParseFloat($this->DBValue, $this->DBFormat); } else { $this->Errors->addError("The value in field " . $this->Name . " is not valid."); } break; case ccsText: case ccsMemo: $varResult = strval($this->DBValue); break; } } return $varResult; }
function GetParsedValue() { global $CCSLocales; $varResult = ""; if (strlen($this->DBValue)) { switch ($this->DataType) { case ccsDate: $DateValidation = true; if (CCValidateDateMask($this->DBValue, $this->DBFormat)) { $varResult = CCParseDate($this->DBValue, $this->DBFormat); if (!$varResult || !CCValidateDate($varResult)) { $DateValidation = false; $varResult = ""; } } else { $DateValidation = false; } if (!$DateValidation) { if (is_array($this->DBFormat)) { $FormatString = join("", $this->DBFormat); } else { $FormatString = $this->DBFormat; } $this->Errors->addError($CCSLocales->GetText('CCS_IncorrectFieldFormat', array($this->Name, $FormatString))); } break; case ccsBoolean: if (CCValidateBoolean($this->DBValue, $this->DBFormat)) { $varResult = CCParseBoolean($this->DBValue, $this->DBFormat); } else { if (is_array($this->DBFormat)) { $FormatString = CCGetBooleanFormat($this->DBFormat); } else { $FormatString = $this->DBFormat; } $this->Errors->addError($CCSLocales->GetText('CCS_IncorrectFieldFormat', array($this->Name, $FormatString))); } break; case ccsInteger: if (CCValidateNumber($this->DBValue, $this->DBFormat, true)) { $varResult = CCParseInteger($this->DBValue, $this->DBFormat, true); } else { $this->Errors->addError($CCSLocales->GetText('CCS_IncorrectFieldFormat', array($this->Name, $this->DBFormat))); } break; case ccsFloat: if (CCValidateNumber($this->DBValue, $this->DBFormat, true)) { $varResult = CCParseFloat($this->DBValue, $this->DBFormat, true); } else { $this->Errors->addError($CCSLocales->GetText('CCS_IncorrectFieldFormat', array($this->Name, $this->DBFormat))); } break; case ccsText: case ccsMemo: $varResult = strval($this->DBValue); break; } } return $varResult; }