Example #1
0
function ew_CheckDateEx($value, $format, $sep)
{
    if (strval($value) == "") {
        return TRUE;
    }
    while (strpos($value, "  ") !== FALSE) {
        $value = str_replace("  ", " ", $value);
    }
    $value = trim($value);
    $arDT = explode(" ", $value);
    if (count($arDT) > 0) {
        if (preg_match('/^([0-9]{4})-([0][1-9]|[1][0-2])-([0][1-9]|[1|2][0-9]|[3][0|1])$/', $arDT[0], $matches)) {
            // accept yyyy-mm-dd
            $sYear = $matches[1];
            $sMonth = $matches[2];
            $sDay = $matches[3];
        } else {
            $wrksep = "\\{$sep}";
            switch ($format) {
                case "std":
                    $pattern = '/^([0-9]{4})' . $wrksep . '([0]?[1-9]|[1][0-2])' . $wrksep . '([0]?[1-9]|[1|2][0-9]|[3][0|1])$/';
                    break;
                case "stdshort":
                    $pattern = '/^([0-9]{2})' . $wrksep . '([0]?[1-9]|[1][0-2])' . $wrksep . '([0]?[1-9]|[1|2][0-9]|[3][0|1])$/';
                    break;
                case "us":
                    $pattern = '/^([0]?[1-9]|[1][0-2])' . $wrksep . '([0]?[1-9]|[1|2][0-9]|[3][0|1])' . $wrksep . '([0-9]{4})$/';
                    break;
                case "usshort":
                    $pattern = '/^([0]?[1-9]|[1][0-2])' . $wrksep . '([0]?[1-9]|[1|2][0-9]|[3][0|1])' . $wrksep . '([0-9]{2})$/';
                    break;
                case "euro":
                    $pattern = '/^([0]?[1-9]|[1|2][0-9]|[3][0|1])' . $wrksep . '([0]?[1-9]|[1][0-2])' . $wrksep . '([0-9]{4})$/';
                    break;
                case "euroshort":
                    $pattern = '/^([0]?[1-9]|[1|2][0-9]|[3][0|1])' . $wrksep . '([0]?[1-9]|[1][0-2])' . $wrksep . '([0-9]{2})$/';
                    break;
            }
            if (!preg_match($pattern, $arDT[0])) {
                return FALSE;
            }
            $arD = explode($sep, $arDT[0]);
            // change EW_DATE_SEPARATOR to $sep //***
            switch ($format) {
                case "std":
                case "stdshort":
                    $sYear = ew_UnformatYear($arD[0]);
                    $sMonth = $arD[1];
                    $sDay = $arD[2];
                    break;
                case "us":
                case "usshort":
                    $sYear = ew_UnformatYear($arD[2]);
                    $sMonth = $arD[0];
                    $sDay = $arD[1];
                    break;
                case "euro":
                case "euroshort":
                    $sYear = ew_UnformatYear($arD[2]);
                    $sMonth = $arD[1];
                    $sDay = $arD[0];
                    break;
            }
        }
        if (!ew_CheckDay($sYear, $sMonth, $sDay)) {
            return FALSE;
        }
    }
    if (count($arDT) > 1 && !ew_CheckTime($arDT[1])) {
        return FALSE;
    }
    return TRUE;
}
Example #2
0
 function ValidateForm()
 {
     global $gsFormError, $patient_detail;
     // Initialize
     $gsFormError = "";
     // Check if validation required
     if (!EW_SERVER_VALIDATE) {
         return $gsFormError == "";
     }
     if ($patient_detail->StudyID->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Study ID";
     }
     if ($patient_detail->PatientID->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Patient ID";
     }
     if (!ew_CheckDate($patient_detail->StudyDate->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect date, format = yyyy/mm/dd - Study Date";
     }
     if (!ew_CheckDate($patient_detail->ContentDate->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect date, format = yyyy/mm/dd - Content Date";
     }
     if (!ew_CheckTime($patient_detail->StudyTime->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect time (hh:mm:ss) - Study Time";
     }
     if (!ew_CheckTime($patient_detail->ContentTime->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect time (hh:mm:ss) - Content Time";
     }
     if (!ew_CheckInteger($patient_detail->InstanceNumber->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect integer - Instance Number";
     }
     if ($patient_detail->Status->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Status";
     }
     // Return validate result
     $ValidateForm = $gsFormError == "";
     // Call Form_CustomValidate event
     $sFormCustomError = "";
     $ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
     if ($sFormCustomError != "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $sFormCustomError;
     }
     return $ValidateForm;
 }
function ew_CheckDateEx($value, $format, $sep)
{
    if (strval($value) == "") {
        return TRUE;
    }
    while (strpos($value, "  ") !== FALSE) {
        $value = str_replace("  ", " ", $value);
    }
    $value = trim($value);
    $arDT = explode(" ", $value);
    if (count($arDT) > 0) {
        $sep = "\\{$sep}";
        switch ($format) {
            case "std":
                $pattern = '/^([0-9]{4})' . $sep . '([0]?[1-9]|[1][0-2])' . $sep . '([0]?[1-9]|[1|2][0-9]|[3][0|1])$/';
                break;
            case "us":
                $pattern = '/^([0]?[1-9]|[1][0-2])' . $sep . '([0]?[1-9]|[1|2][0-9]|[3][0|1])' . $sep . '([0-9]{4})$/';
                break;
            case "euro":
                $pattern = '/^([0]?[1-9]|[1|2][0-9]|[3][0|1])' . $sep . '([0]?[1-9]|[1][0-2])' . $sep . '([0-9]{4})$/';
                break;
        }
        if (!preg_match($pattern, $arDT[0])) {
            return FALSE;
        }
        $arD = explode(EW_DATE_SEPARATOR, $arDT[0]);
        switch ($format) {
            case "std":
                $sYear = $arD[0];
                $sMonth = $arD[1];
                $sDay = $arD[2];
                break;
            case "us":
                $sYear = $arD[2];
                $sMonth = $arD[0];
                $sDay = $arD[1];
                break;
            case "euro":
                $sYear = $arD[2];
                $sMonth = $arD[1];
                $sDay = $arD[0];
                break;
        }
        if (!ew_CheckDay($sYear, $sMonth, $sDay)) {
            return FALSE;
        }
    }
    if (count($arDT) > 1 && !ew_CheckTime($arDT[1])) {
        return FALSE;
    }
    return TRUE;
}
Example #4
0
 function ValidateForm()
 {
     global $Language, $gsFormError, $tbl_ga_stat;
     // Initialize form error message
     $gsFormError = "";
     // Check if validation required
     if (!EW_SERVER_VALIDATE) {
         return $gsFormError == "";
     }
     if (!is_null($tbl_ga_stat->id_profile->FormValue) && $tbl_ga_stat->id_profile->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_ga_stat->id_profile->FldCaption();
     }
     if (!is_null($tbl_ga_stat->stat_date->FormValue) && $tbl_ga_stat->stat_date->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_ga_stat->stat_date->FldCaption();
     }
     if (!ew_CheckDate($tbl_ga_stat->stat_date->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= $tbl_ga_stat->stat_date->FldErrMsg();
     }
     if (!is_null($tbl_ga_stat->year->FormValue) && $tbl_ga_stat->year->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_ga_stat->year->FldCaption();
     }
     if (!ew_CheckInteger($tbl_ga_stat->year->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= $tbl_ga_stat->year->FldErrMsg();
     }
     if (!is_null($tbl_ga_stat->month->FormValue) && $tbl_ga_stat->month->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_ga_stat->month->FldCaption();
     }
     if (!ew_CheckInteger($tbl_ga_stat->month->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= $tbl_ga_stat->month->FldErrMsg();
     }
     if (!is_null($tbl_ga_stat->week->FormValue) && $tbl_ga_stat->week->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_ga_stat->week->FldCaption();
     }
     if (!ew_CheckInteger($tbl_ga_stat->week->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= $tbl_ga_stat->week->FldErrMsg();
     }
     if (!is_null($tbl_ga_stat->hour->FormValue) && $tbl_ga_stat->hour->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_ga_stat->hour->FldCaption();
     }
     if (!ew_CheckTime($tbl_ga_stat->hour->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= $tbl_ga_stat->hour->FldErrMsg();
     }
     if (!is_null($tbl_ga_stat->pageview->FormValue) && $tbl_ga_stat->pageview->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_ga_stat->pageview->FldCaption();
     }
     if (!ew_CheckInteger($tbl_ga_stat->pageview->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= $tbl_ga_stat->pageview->FldErrMsg();
     }
     if (!is_null($tbl_ga_stat->visit->FormValue) && $tbl_ga_stat->visit->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $tbl_ga_stat->visit->FldCaption();
     }
     if (!ew_CheckInteger($tbl_ga_stat->visit->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= $tbl_ga_stat->visit->FldErrMsg();
     }
     // Return validate result
     $ValidateForm = $gsFormError == "";
     // Call Form_CustomValidate event
     $sFormCustomError = "";
     $ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
     if ($sFormCustomError != "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $sFormCustomError;
     }
     return $ValidateForm;
 }
 function ValidateSearch()
 {
     global $gsSearchError;
     // Initialize
     $gsSearchError = "";
     // Check if validation required
     if (!EW_SERVER_VALIDATE) {
         return TRUE;
     }
     if (!ew_CheckEuroDate($this->fecha->AdvancedSearch->SearchValue)) {
         ew_AddMessage($gsSearchError, $this->fecha->FldErrMsg());
     }
     if (!ew_CheckTime($this->hora->AdvancedSearch->SearchValue)) {
         ew_AddMessage($gsSearchError, $this->hora->FldErrMsg());
     }
     // Return validate result
     $ValidateSearch = $gsSearchError == "";
     // Call Form_CustomValidate event
     $sFormCustomError = "";
     $ValidateSearch = $ValidateSearch && $this->Form_CustomValidate($sFormCustomError);
     if ($sFormCustomError != "") {
         ew_AddMessage($gsSearchError, $sFormCustomError);
     }
     return $ValidateSearch;
 }
Example #6
0
 function ValidateSearch()
 {
     global $gsSearchError, $tbl_ga_stat;
     // Initialize
     $gsSearchError = "";
     // Check if validation required
     if (!EW_SERVER_VALIDATE) {
         return TRUE;
     }
     if (!ew_CheckDate($tbl_ga_stat->stat_date->AdvancedSearch->SearchValue)) {
         if ($gsSearchError != "") {
             $gsSearchError .= "<br>";
         }
         $gsSearchError .= $tbl_ga_stat->stat_date->FldErrMsg();
     }
     if (!ew_CheckInteger($tbl_ga_stat->year->AdvancedSearch->SearchValue)) {
         if ($gsSearchError != "") {
             $gsSearchError .= "<br>";
         }
         $gsSearchError .= $tbl_ga_stat->year->FldErrMsg();
     }
     if (!ew_CheckInteger($tbl_ga_stat->month->AdvancedSearch->SearchValue)) {
         if ($gsSearchError != "") {
             $gsSearchError .= "<br>";
         }
         $gsSearchError .= $tbl_ga_stat->month->FldErrMsg();
     }
     if (!ew_CheckInteger($tbl_ga_stat->week->AdvancedSearch->SearchValue)) {
         if ($gsSearchError != "") {
             $gsSearchError .= "<br>";
         }
         $gsSearchError .= $tbl_ga_stat->week->FldErrMsg();
     }
     if (!ew_CheckTime($tbl_ga_stat->hour->AdvancedSearch->SearchValue)) {
         if ($gsSearchError != "") {
             $gsSearchError .= "<br>";
         }
         $gsSearchError .= $tbl_ga_stat->hour->FldErrMsg();
     }
     if (!ew_CheckInteger($tbl_ga_stat->pageview->AdvancedSearch->SearchValue)) {
         if ($gsSearchError != "") {
             $gsSearchError .= "<br>";
         }
         $gsSearchError .= $tbl_ga_stat->pageview->FldErrMsg();
     }
     if (!ew_CheckInteger($tbl_ga_stat->visit->AdvancedSearch->SearchValue)) {
         if ($gsSearchError != "") {
             $gsSearchError .= "<br>";
         }
         $gsSearchError .= $tbl_ga_stat->visit->FldErrMsg();
     }
     // Return validate result
     $ValidateSearch = $gsSearchError == "";
     // Call Form_CustomValidate event
     $sFormCustomError = "";
     $ValidateSearch = $ValidateSearch && $this->Form_CustomValidate($sFormCustomError);
     if ($sFormCustomError != "") {
         if ($gsSearchError != "") {
             $gsSearchError .= "<br>";
         }
         $gsSearchError .= $sFormCustomError;
     }
     return $ValidateSearch;
 }
Example #7
0
 function ValidateForm()
 {
     global $gsFormError, $exam_data;
     // Initialize
     $gsFormError = "";
     if (!ew_CheckFileType($exam_data->Soap->Upload->FileName)) {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "File type is not allowed.";
     }
     if ($exam_data->Soap->Upload->FileSize > 0 && EW_MAX_FILE_SIZE > 0) {
         if ($exam_data->Soap->Upload->FileSize > EW_MAX_FILE_SIZE) {
             $gsFormError .= str_replace("%s", EW_MAX_FILE_SIZE, "Max. file size (%s bytes) exceeded.");
         }
     }
     // Check if validation required
     if (!EW_SERVER_VALIDATE) {
         return $gsFormError == "";
     }
     if ($exam_data->ExamDataNo->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Exam Data No";
     }
     if (!ew_CheckInteger($exam_data->ExamDataNo->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect integer - Exam Data No";
     }
     if ($exam_data->PatientMainNo->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Patient Main No";
     }
     if (!ew_CheckInteger($exam_data->PatientMainNo->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect integer - Patient Main No";
     }
     if ($exam_data->InstitutionNo->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Institution No";
     }
     if (!ew_CheckInteger($exam_data->InstitutionNo->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect integer - Institution No";
     }
     if (!ew_CheckInteger($exam_data->ImageDetailNo->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect integer - Image Detail No";
     }
     if (!ew_CheckInteger($exam_data->PatientKindNo->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect integer - Patient Kind No";
     }
     if ($exam_data->PatientSubKindNo->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Patient Sub Kind No";
     }
     if (!ew_CheckInteger($exam_data->PatientSubKindNo->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect integer - Patient Sub Kind No";
     }
     if (!ew_CheckInteger($exam_data->PatientTypeNo->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect integer - Patient Type No";
     }
     if (!ew_CheckInteger($exam_data->DepartmentNo->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect integer - Department No";
     }
     if (!ew_CheckDate($exam_data->SpecialExamDate->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect date, format = yyyy/mm/dd - Special Exam Date";
     }
     if ($exam_data->ExamDate->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Exam Date";
     }
     if (!ew_CheckDate($exam_data->ExamDate->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect date, format = yyyy/mm/dd - Exam Date";
     }
     if ($exam_data->ExamTime->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Exam Time";
     }
     if (!ew_CheckTime($exam_data->ExamTime->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect time (hh:mm:ss) - Exam Time";
     }
     if ($exam_data->LogDate->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Log Date";
     }
     if (!ew_CheckDate($exam_data->LogDate->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect date, format = yyyy/mm/dd - Log Date";
     }
     if (!ew_CheckDate($exam_data->ModifyDate->FormValue)) {
         if ($gsFormError != "") {
             $gsFormError .= "<br>";
         }
         $gsFormError .= "Incorrect date, format = yyyy/mm/dd - Modify Date";
     }
     if ($exam_data->CreatePart->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Create Part";
     }
     if ($exam_data->ModifyPart->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Modify Part";
     }
     if ($exam_data->Status->FormValue == "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= "Please enter required field - Status";
     }
     // Return validate result
     $ValidateForm = $gsFormError == "";
     // Call Form_CustomValidate event
     $sFormCustomError = "";
     $ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
     if ($sFormCustomError != "") {
         $gsFormError .= $gsFormError != "" ? "<br>" : "";
         $gsFormError .= $sFormCustomError;
     }
     return $ValidateForm;
 }