Exemplo n.º 1
0
 function ValidateForm()
 {
     global $ReportLanguage, $gsFormError;
     // Initialize form error message
     $gsFormError = "";
     // Check if validation required
     if (!EWR_SERVER_VALIDATE) {
         return $gsFormError == "";
     }
     if (!ewr_CheckEuroDate($this->timeta->SearchValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= $this->timeta->FldErrMsg();
     }
     if (!ewr_CheckEuroDate($this->timeta->SearchValue2)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= $this->timeta->FldErrMsg();
     }
     // Return validate result
     $ValidateForm = $gsFormError == "";
     // Call Form_CustomValidate event
     $sFormCustomError = "";
     $ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
     if ($sFormCustomError != "") {
         $gsFormError .= $gsFormError != "" ? "<p>&nbsp;</p>" : "";
         $gsFormError .= $sFormCustomError;
     }
     return $ValidateForm;
 }
Exemplo n.º 2
0
function ewr_UnFormatDateTime($dt, $namedformat)
{
    $dt = trim($dt);
    while (strpos($dt, "  ") !== FALSE) {
        $dt = str_replace("  ", " ", $dt);
    }
    $arDateTime = explode(" ", $dt);
    if (count($arDateTime) == 0) {
        return $dt;
    }
    $arDatePt = explode(EWR_DATE_SEPARATOR, $arDateTime[0]);
    if ($namedformat == 0 || $namedformat == 1 || $namedformat == 2 || $namedformat == 8) {
        $arDefFmt = explode(EWR_DATE_SEPARATOR, EWR_DEFAULT_DATE_FORMAT);
        if ($arDefFmt[0] == "yyyy") {
            $namedformat = 9;
        } elseif ($arDefFmt[0] == "mm") {
            $namedformat = 10;
        } elseif ($arDefFmt[0] == "dd") {
            $namedformat = 11;
        }
    }
    if (count($arDatePt) == 3) {
        switch ($namedformat) {
            case 5:
            case 9:
                //yyyymmdd
                if (ewr_CheckDate($arDateTime[0])) {
                    list($year, $month, $day) = $arDatePt;
                    break;
                } else {
                    return $dt;
                }
            case 6:
            case 10:
                //mmddyyyy
                if (ewr_CheckUSDate($arDateTime[0])) {
                    list($month, $day, $year) = $arDatePt;
                    break;
                } else {
                    return $dt;
                }
            case 7:
            case 11:
                //ddmmyyyy
                if (ewr_CheckEuroDate($arDateTime[0])) {
                    list($day, $month, $year) = $arDatePt;
                    break;
                } else {
                    return $dt;
                }
            case 12:
            case 15:
                //yymmdd
                if (ewr_CheckShortDate($arDateTime[0])) {
                    list($year, $month, $day) = $arDatePt;
                    $year = ewr_UnformatYear($year);
                    break;
                } else {
                    return $dt;
                }
            case 13:
            case 16:
                //mmddyy
                if (ewr_CheckShortUSDate($arDateTime[0])) {
                    list($month, $day, $year) = $arDatePt;
                    $year = ewr_UnformatYear($year);
                    break;
                } else {
                    return $dt;
                }
            case 14:
            case 17:
                //ddmmyy
                if (ewr_CheckShortEuroDate($arDateTime[0])) {
                    list($day, $month, $year) = $arDatePt;
                    $year = ewr_UnformatYear($year);
                    break;
                } else {
                    return $dt;
                }
            default:
                return $dt;
        }
        if (strlen($year) <= 4 && strlen($month) <= 2 && strlen($day) <= 2) {
            return $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT) . (count($arDateTime) > 1 ? " " . $arDateTime[1] : "");
        } else {
            return $dt;
        }
    } else {
        return $dt;
    }
}